Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/workflows/cs-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
on:
- push

name: Run phpcs checks

jobs:
mutation:
name: PHP ${{ matrix.php }}-${{ matrix.os }}

runs-on: ${{ matrix.os }}

strategy:
matrix:
os:
- ubuntu-latest

php:
- "8.1"
- "8.2"

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: "${{ matrix.php }}"
tools: composer:v2, cs2pr
coverage: none

- name: Determine composer cache directory
run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV

- name: Cache dependencies installed with composer
uses: actions/cache@v3
with:
path: ${{ env.COMPOSER_CACHE_DIR }}
key: php${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: |
php${{ matrix.php }}-composer-
- name: Install dependencies with composer
run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi

- name: Run phpcs checks
run: vendor/bin/phpcs
46 changes: 46 additions & 0 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
on:
- push

name: Run static analysis

jobs:
mutation:
name: PHP ${{ matrix.php }}-${{ matrix.os }}

runs-on: ${{ matrix.os }}

strategy:
matrix:
os:
- ubuntu-latest

php:
- "8.1"
- "8.2"

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: "${{ matrix.php }}"
tools: composer:v2, cs2pr
coverage: none

- name: Determine composer cache directory
run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV

- name: Cache dependencies installed with composer
uses: actions/cache@v3
with:
path: ${{ env.COMPOSER_CACHE_DIR }}
key: php${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: |
php${{ matrix.php }}-composer-
- name: Install dependencies with composer
run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi

- name: Run static analysis
run: vendor/bin/psalm --no-cache --output-format=github --show-info=false --threads=4
46 changes: 46 additions & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
on:
- push

name: Run PHPUnit tests

jobs:
mutation:
name: PHP ${{ matrix.php }}-${{ matrix.os }}

runs-on: ${{ matrix.os }}

strategy:
matrix:
os:
- ubuntu-latest

php:
- "8.1"
- "8.2"

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: "${{ matrix.php }}"
tools: composer:v2, cs2pr
coverage: none

- name: Determine composer cache directory
run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV

- name: Cache dependencies installed with composer
uses: actions/cache@v3
with:
path: ${{ env.COMPOSER_CACHE_DIR }}
key: php${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: |
php${{ matrix.php }}-composer-
- name: Install dependencies with composer
run: composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi

- name: Run PHPUnit tests
run: vendor/bin/phpunit --colors=always
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
clover.xml
coveralls-upload.json
phpunit.xml
.phpcs-cache
.phpunit.result.cache

Comment thread
alexmerlin marked this conversation as resolved.
# Created by .ignore support plugin (hsz.mobi)
### JetBrains template
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
DotKernel component providing twig extensions and customizations

![OSS Lifecycle](https://img.shields.io/osslifecycle/dotkernel/dot-twigrenderer)
![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-twigrenderer/3.2.0)
![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-twigrenderer/3.4.0)

[![GitHub issues](https://img.shields.io/github/issues/dotkernel/dot-form)](https://github.com/dotkernel/dot-twigrenderer/issues)
[![GitHub forks](https://img.shields.io/github/forks/dotkernel/dot-form)](https://github.com/dotkernel/dot-twigrenderer/network)
[![GitHub stars](https://img.shields.io/github/stars/dotkernel/dot-form)](https://github.com/dotkernel/dot-twigrenderer/stargazers)
[![GitHub license](https://img.shields.io/github/license/dotkernel/dot-form)](https://github.com/dotkernel/dot-twigrenderer/blob/3.2.0/LICENSE.md)
[![GitHub license](https://img.shields.io/github/license/dotkernel/dot-form)](https://github.com/dotkernel/dot-twigrenderer/blob/3.0/LICENSE.md)

[![SymfonyInsight](https://insight.symfony.com/projects/b9a7d75d-d00a-44a9-b1c0-aea8670681cc/big.svg)](https://insight.symfony.com/projects/b9a7d75d-d00a-44a9-b1c0-aea8670681cc)
32 changes: 25 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,21 @@
}
],
"require": {
"php": "~7.4.0 || ~8.0.0 || ~8.1.0",
"php": "~8.1.0 || ~8.2.0",
"laminas/laminas-servicemanager": "^3.11",
"mezzio/mezzio-twigrenderer": "^2.9",
"laminas/laminas-view": "^2.20",
"laminas/laminas-authentication": "^2.10"
},
"require-dev": {
"phpunit/phpunit": "^9.5",
"squizlabs/php_codesniffer": "^3.6",
"laminas/laminas-authentication": "^2.10",
"dotkernel/dot-navigation": "^3.1",
"dotkernel/dot-flashmessenger": "^3.1.1",
"laminas/laminas-form": "^3.1.1",
"doctrine/doctrine-module": "^5.1",
"mezzio/mezzio-authorization": "^1.4"
"dotkernel/dot-authorization": "^3.3"
},
"require-dev": {
"phpunit/phpunit": "^10.2",
"laminas/laminas-coding-standard": "^2.5",
"vimeo/psalm": "^5.13"
},
"autoload": {
"psr-4": {
Expand All @@ -40,5 +41,22 @@
"psr-4": {
"DotTest\\Twig\\": "test/"
}
},
"config": {
Comment thread
alexmerlin marked this conversation as resolved.
"sort-packages": true,
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
},
"scripts": {
Comment thread
alexmerlin marked this conversation as resolved.
"check": [
"@cs-check",
"@test"
],
"cs-check": "phpcs",
"cs-fix": "phpcbf",
"test": "phpunit --colors=always",
"test-coverage": "phpunit --colors=always --coverage-clover clover.xml",
"static-analysis": "psalm --shepherd --stats"
}
}
20 changes: 20 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd">

<arg name="basepath" value="."/>
<arg name="cache" value=".phpcs-cache"/>
<arg name="colors"/>
<arg name="extensions" value="php"/>
<arg name="parallel" value="80"/>

<!-- Show progress -->
<arg value="p"/>

<!-- Paths to check -->
<file>src</file>
<file>test</file>

<!-- Include all rules from the Laminas Coding Standard -->
<rule ref="LaminasCodingStandard"/>
</ruleset>
12 changes: 12 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/|version|/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
>
<testsuites>
<testsuite name="Dot Twig Renderer Test Suite">
<directory>./test</directory>
</testsuite>
</testsuites>
</phpunit>
9 changes: 9 additions & 0 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="5.13.1@086b94371304750d1c673315321a55d15fc59015">
<file src="src/Extension/DateExtension.php">
<UndefinedFunction>
<code>twig_date_converter($env, $date)</code>
<code>twig_date_converter($env, $now)</code>
</UndefinedFunction>
</file>
</files>
18 changes: 18 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0"?>
<psalm
errorLevel="4"
resolveFromConfigFile="true"
findUnusedCode="false"
findUnusedBaselineEntry="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
errorBaseline="psalm-baseline.xml"
>
<projectFiles>
<directory name="src" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
</psalm>
54 changes: 19 additions & 35 deletions src/ConfigProvider.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
<?php
/**
* @see https://github.com/dotkernel/dot-twigrenderer/ for the canonical source repository
* @copyright Copyright (c) 2017 Apidemia (https://www.apidemia.com)
* @license https://github.com/dotkernel/dot-twigrenderer/blob/master/LICENSE.md MIT License
*/

declare(strict_types = 1);
declare(strict_types=1);

namespace Dot\Twig;

Expand All @@ -29,61 +24,50 @@
use Laminas\View\HelperPluginManager;
use Twig\Environment;

/**
* Class ConfigProvider
* @package Dot\Twig
*/
class ConfigProvider
{
public function __invoke(): array
{
return [
'dependencies' => $this->getDependencyConfig(),

'view_helpers' => [],
];
}

public function getDependencyConfig(): array
{
return [
'factories' => [
HelperPluginManager::class => HelperPluginManagerFactory::class,

'factories' => [
HelperPluginManager::class => HelperPluginManagerFactory::class,
AuthenticationExtension::class => AuthenticationExtensionFactory::class,
AuthorizationExtension::class => AuthorizationExtensionFactory::class,
NavigationExtension::class => NavigationExtensionFactory::class,
AuthorizationExtension::class => AuthorizationExtensionFactory::class,
NavigationExtension::class => NavigationExtensionFactory::class,
FlashMessengerExtension::class => FlashMessengerExtensionFactory::class,
FormElementsExtension::class => InvokableFactory::class,
AuthenticationService::class => AuthenticationServiceFactory::class
FormElementsExtension::class => InvokableFactory::class,
AuthenticationService::class => AuthenticationServiceFactory::class,
],

'delegators' => [
Environment::class => [
'delegators' => [
Environment::class => [
TwigEnvironmentDelegator::class,
],

FlashMessengerRenderer::class => [
LazyServiceFactory::class,
],
NavigationRenderer::class => [
NavigationRenderer::class => [
LazyServiceFactory::class,
]
],
],

'lazy_services' => [
'class_map' => [
NavigationRenderer::class =>
NavigationRenderer::class,

FlashMessengerRenderer::class =>
FlashMessengerRenderer::class,
]
NavigationRenderer::class
=> NavigationRenderer::class,
FlashMessengerRenderer::class
=> FlashMessengerRenderer::class,
],
],

'aliases' => [
'ViewHelperManager' => HelperPluginManager::class,
AuthenticationServiceInterface::class => AuthenticationService::class
'aliases' => [
'ViewHelperManager' => HelperPluginManager::class,
AuthenticationServiceInterface::class => AuthenticationService::class,
],
];
}
Expand Down
Loading