Skip to content

Commit

Permalink
SF7 compat & Some cleanings (#387)
Browse files Browse the repository at this point in the history
  • Loading branch information
webda2l authored Jan 3, 2024
1 parent ca3bf7b commit 44fbcae
Show file tree
Hide file tree
Showing 25 changed files with 295 additions and 362 deletions.
112 changes: 47 additions & 65 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,40 @@ on: ["push", "pull_request"]

env:
COMPOSER_ALLOW_SUPERUSER: '1'
SYMFONY_PHPUNIT_VERSION: 9.5
SYMFONY_PHPUNIT_REMOVE_RETURN_TYPEHINT: 1
SYMFONY_DEPRECATIONS_HELPER: max[self]=0

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
container:
image: php:7.4-alpine
image: php:8.3-alpine
options: >-
--tmpfs /tmp:exec
--tmpfs /var/tmp:exec
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Install Composer
run: wget -qO - https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer --quiet
- name: Cache Composer dependencies
uses: actions/cache@v1
- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
with:
path: ~/.composer/cache
key: composer-php${{ matrix.php }}-highest-
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-8.3-highest-${{ hashFiles('**/composer.json') }}
restore-keys: |
composer-php${{ matrix.php }}-highest-
composer-
${{ runner.os }}-composer-8.3-highest
- name: Validate Composer
run: composer validate
- name: Install xsl PHP extension
run: |
apk add $PHPIZE_DEPS libxslt-dev
docker-php-ext-install xsl
- name: Install highest dependencies with Composer
run: composer update --no-progress --ansi
run: composer update --no-progress --no-suggest --ansi
- name: Disable PHP memory limit
run: echo 'memory_limit=-1' >> /usr/local/etc/php/php.ini
- name: Analyze
run: vendor/bin/phpqa --execution no-parallel --progress-delay=-1 --ansi
- name: Run CS-Fixer
run: vendor/bin/php-cs-fixer fix --dry-run --diff --format=checkstyle

phpunit:
name: PHPUnit (PHP ${{ matrix.php }} Deps ${{ matrix.dependencies }})
Expand All @@ -54,93 +50,79 @@ jobs:
strategy:
matrix:
php:
- '7.2'
- '7.3'
- '7.4'
- '8.0'
- '8.1'
- '8.2'
- '8.3'
dependencies:
- lowest
- highest
- 'lowest'
- 'highest'
include:
- php: '7.2'
phpunit-version: 8.5
- php: '7.3'
phpunit-version: 9.5
- php: '7.4'
phpunit-version: 9.5
- php: '8.0'
phpunit-version: 9.5
- php: '8.1'
phpunit-version: 9.5
phpunit-version: 10
- php: '8.2'
phpunit-version: 10
- php: '8.3'
phpunit-version: 10
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Install Composer
run: wget -qO - https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer --quiet
- name: Cache Composer dependencies
uses: actions/cache@v1
- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
with:
path: ~/.composer/cache
key: composer-php${{ matrix.php }}-${{ matrix.dependencies }}-
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ matrix.php }}-${{ matrix.dependencies }}-${{ hashFiles('**/composer.json') }}
restore-keys: |
composer-php${{ matrix.php }}-${{ matrix.dependencies }}-
composer-
- name: Install xsl PHP extension
run: |
apk add $PHPIZE_DEPS libxslt-dev
docker-php-ext-install xsl
${{ runner.os }}-composer-${{ matrix.php }}-${{ matrix.dependencies }}
- name: Install lowest dependencies with Composer
if: matrix.dependencies == 'lowest'
run: composer update --no-progress --prefer-stable --prefer-lowest --ansi
run: composer update --no-progress --no-suggest --prefer-stable --prefer-lowest --ansi
- name: Install highest dependencies with Composer
if: matrix.dependencies == 'highest'
run: composer update --no-progress --ansi
run: composer update --no-progress --no-suggest --ansi
- name: Run tests with PHPUnit
env:
SYMFONY_PHPUNIT_VERSION: ${{ matrix.phpunit-version }}
SYMFONY_MAX_PHPUNIT_VERSION: ${{ matrix.phpunit-version }}
run: vendor/bin/simple-phpunit --colors=always

coverage:
name: Coverage (PHP ${{ matrix.php }})
name: Coverage (PHP 8.3)
runs-on: ubuntu-latest
container:
image: php:${{ matrix.php }}-alpine
image: php:8.3-alpine
options: >-
--tmpfs /tmp:exec
--tmpfs /var/tmp:exec
strategy:
matrix:
php:
- '7.4'
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Install pcov PHP extension
run: |
apk add $PHPIZE_DEPS
pecl install pcov
docker-php-ext-enable pcov
- name: Install Composer
run: wget -qO - https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer --quiet
- name: Cache Composer dependencies
uses: actions/cache@v1
- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
with:
path: ~/.composer/cache
key: composer-php${{ matrix.php }}-highest-
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-8.3-highest-${{ hashFiles('**/composer.json') }}
restore-keys: |
composer-php${{ matrix.php }}-highest-
composer-
- name: Install xsl PHP extension
run: |
apk add $PHPIZE_DEPS libxslt-dev
docker-php-ext-install xsl
${{ runner.os }}-composer-8.3-highest
- name: Install highest dependencies with Composer
run: composer update --no-progress --ansi
run: composer update --no-progress --no-suggest --ansi
- name: Run coverage with PHPUnit
run: vendor/bin/simple-phpunit --coverage-clover ./coverage.xml --colors=always
- name: Send code coverage report to Codecov.io
uses: codecov/codecov-action@v1.0.3 # 1.0.4+ uncompatible alpine :/
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
50 changes: 30 additions & 20 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,43 @@
file that was distributed with this source code.
HEADER;


$finder = (new PhpCsFixer\Finder())
->in(['src', 'tests'])
;

return (new PhpCsFixer\Config())
->setRiskyAllowed(true)
->registerCustomFixers(new PhpCsFixerCustomFixers\Fixers())
->setRules([
'@DoctrineAnnotation' => true,
'@PHP70Migration' => true,
'@PHP70Migration:risky' => true,
'@PHP71Migration' => true,
'@PHP71Migration:risky' => true,
'@PHP73Migration' => true,
'@PHPUnit75Migration:risky' => true,
'@PHP82Migration' => true,
'@PhpCsFixer' => true,
'@PhpCsFixer:risky' => true,
'@Symfony' => true,
'@Symfony:risky' => true,
'array_syntax' => ['syntax' => 'short'],
'date_time_immutable' => true,
'header_comment' => ['header' => $header],
'general_phpdoc_annotation_remove' => true,

// From https://github.com/symfony/demo/blob/main/.php-cs-fixer.dist.php
'linebreak_after_opening_tag' => true,
'list_syntax' => ['syntax' => 'short'],
'no_superfluous_phpdoc_tags' => true,
// 'mb_str_functions' => true,
'no_php4_constructor' => true,
'no_unreachable_default_argument_value' => true,
'no_useless_else' => true,
'no_useless_return' => true,
'php_unit_strict' => false,
'php_unit_internal_class' => false,
'php_unit_test_class_requires_covers' => false,
'phpdoc_order' => true,
'strict_comparison' => true,
'strict_param' => true,
'trailing_comma_in_multiline' => ['after_heredoc' => true, 'elements' => ['arrays', 'parameters']],
'statement_indentation' => true,
'method_chaining_indentation' => true,
'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline', 'attribute_placement' => 'ignore'],

PhpCsFixerCustomFixers\Fixer\ConstructorEmptyBracesFixer::name() => true,
PhpCsFixerCustomFixers\Fixer\MultilineCommentOpeningClosingAloneFixer::name() => true,
PhpCsFixerCustomFixers\Fixer\MultilinePromotedPropertiesFixer::name() => true,
PhpCsFixerCustomFixers\Fixer\NoDuplicatedImportsFixer::name() => true,
PhpCsFixerCustomFixers\Fixer\NoImportFromGlobalNamespaceFixer::name() => true,
PhpCsFixerCustomFixers\Fixer\PhpdocSingleLineVarFixer::name() => true,
])
->setFinder(
(new PhpCsFixer\Finder())
->exclude(['vendor'])
->in(['src', 'tests'])
)
->setFinder($finder)
;
15 changes: 0 additions & 15 deletions .phpqa.yml

This file was deleted.

43 changes: 22 additions & 21 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,28 +26,29 @@
}
],
"require": {
"php": ">=7.2",
"a2lix/auto-form-bundle": "^0.2|^0.3|^0.4",
"symfony/config": "^3.4.30|^4.3|^5.0|^6.0",
"symfony/dependency-injection": "^3.4.30|^4.3|^5.0|^6.0",
"symfony/doctrine-bridge": "^3.4.30|^4.3|^5.0|^6.0",
"symfony/event-dispatcher": "^3.4.30|^4.3|^5.0|^6.0",
"symfony/form": "^3.4.30|^4.3|^5.0|^6.0",
"symfony/http-foundation": "^3.4.30|^4.3|^5.0|^6.0",
"symfony/http-kernel": "^3.4.30|^4.3|^5.0|^6.0",
"symfony/options-resolver": "^3.4.30|^4.3|^5.0|^6.0"
"php": "^8.1",
"a2lix/auto-form-bundle": "^0.4",
"symfony/config": "^5.4.30|^6.3.10|^7.0",
"symfony/dependency-injection": "^5.4.30|^6.3.10|^7.0",
"symfony/doctrine-bridge": "^5.4.30|^6.3.10|^7.0",
"symfony/event-dispatcher": "^5.4.30|^6.3.10|^7.0",
"symfony/form": "^5.4.30|^6.3.10|^7.0",
"symfony/http-foundation": "^5.4.30|^6.3.10|^7.0",
"symfony/http-kernel": "^5.4.30|^6.3.10|^7.0",
"symfony/options-resolver": "^5.4.30|^6.3.10|^7.0"
},
"require-dev": {
"doctrine/orm": "^2.7",
"edgedesign/phpqa": "^1.25",
"friendsofphp/php-cs-fixer": "^3.4.0",
"knplabs/doctrine-behaviors": "^2.0",
"matthiasnoback/symfony-dependency-injection-test": "^4.3",
"phpstan/phpstan": "^1.2.0",
"symfony/cache": "^5.4",
"symfony/phpunit-bridge": "^6.0",
"symfony/validator": "^3.4.30|^4.3|^5.0|^6.0",
"vimeo/psalm": "^4.15"
"doctrine/orm": "^2.15",
"friendsofphp/php-cs-fixer": "^3.45",
"knplabs/doctrine-behaviors": "^2.3",
"kubawerlos/php-cs-fixer-custom-fixers": "^3.18",
"matthiasnoback/symfony-dependency-injection-test": "^5.0",
"phpstan/phpstan": "^1.10",
"rector/rector": "^0.18",
"symfony/cache": "^5.4.30|^6.3.10|^7.0",
"symfony/phpunit-bridge": "^5.4.30|^6.3.10|^7.0",
"symfony/validator": "^5.4.30|^6.3.10|^7.0",
"vimeo/psalm": "^5.18"
},
"suggest": {
"knplabs/doctrine-behaviors": "For Knp strategy",
Expand All @@ -61,7 +62,7 @@
"psalm"
],
"phpunit": [
"SYMFONY_DEPRECATIONS_HELPER=max[self]=0 SYMFONY_PHPUNIT_VERSION=9.5 SYMFONY_PHPUNIT_REMOVE_RETURN_TYPEHINT=1 simple-phpunit"
"SYMFONY_DEPRECATIONS_HELPER=max[self]=0 simple-phpunit"
]
},
"config": {
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<!-- https://phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/6.1/phpunit.xsd"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/9.6/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="vendor/autoload.php"
Expand Down
37 changes: 37 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\Core\ValueObject\PhpVersion;
use Rector\Doctrine\Set\DoctrineSetList;
use Rector\PHPUnit\Set\PHPUnitLevelSetList;
use Rector\PHPUnit\Set\PHPUnitSetList;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Symfony\Set\SymfonyLevelSetList;
use Rector\Symfony\Set\SymfonySetList;
use Rector\Symfony\Set\TwigSetList;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->parallel();
$rectorConfig->paths([
__DIR__.'/src',
__DIR__.'/tests',
]);
$rectorConfig->importNames();
$rectorConfig->importShortClasses(false);

$rectorConfig->phpVersion(PhpVersion::PHP_82);
$rectorConfig->sets([
LevelSetList::UP_TO_PHP_82,

DoctrineSetList::ANNOTATIONS_TO_ATTRIBUTES,
// DoctrineSetList::DOCTRINE_CODE_QUALITY,
DoctrineSetList::DOCTRINE_ORM_214,
DoctrineSetList::DOCTRINE_DBAL_30,

PHPUnitLevelSetList::UP_TO_PHPUNIT_91,
// PHPUnitSetList::PHPUNIT_CODE_QUALITY,
// PHPUnitSetList::PHPUNIT_YIELD_DATA_PROVIDER,
]);
};
4 changes: 2 additions & 2 deletions src/DependencyInjection/A2lixTranslationFormExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use Symfony\Component\Config\Definition\Processor;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;

class A2lixTranslationFormExtension extends Extension
Expand All @@ -26,7 +26,7 @@ public function load(array $configs, ContainerBuilder $container): void
$processor = new Processor();
$config = $processor->processConfiguration(new Configuration(), $configs);

$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('a2lix_form.xml');

$container->setParameter('a2lix_translation_form.locale_provider', $config['locale_provider']);
Expand Down
2 changes: 1 addition & 1 deletion src/DependencyInjection/Compiler/LocaleProviderPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

class LocaleProviderPass implements CompilerPassInterface
{
public const DEFAULT_LOCALE_PROVIDER_KEY = 'default';
final public const DEFAULT_LOCALE_PROVIDER_KEY = 'default';

public function process(ContainerBuilder $container): void
{
Expand Down
Loading

0 comments on commit 44fbcae

Please sign in to comment.