Skip to content

Commit 44fbcae

Browse files
authored
SF7 compat & Some cleanings (#387)
1 parent ca3bf7b commit 44fbcae

25 files changed

+295
-362
lines changed

.github/workflows/ci.yml

+47-65
Original file line numberDiff line numberDiff line change
@@ -4,44 +4,40 @@ on: ["push", "pull_request"]
44

55
env:
66
COMPOSER_ALLOW_SUPERUSER: '1'
7-
SYMFONY_PHPUNIT_VERSION: 9.5
8-
SYMFONY_PHPUNIT_REMOVE_RETURN_TYPEHINT: 1
97
SYMFONY_DEPRECATIONS_HELPER: max[self]=0
108

119
jobs:
1210
analyze:
1311
name: Analyze
1412
runs-on: ubuntu-latest
1513
container:
16-
image: php:7.4-alpine
14+
image: php:8.3-alpine
1715
options: >-
1816
--tmpfs /tmp:exec
1917
--tmpfs /var/tmp:exec
2018
steps:
2119
- name: Checkout
22-
uses: actions/checkout@v2
20+
uses: actions/checkout@v4
2321
- name: Install Composer
2422
run: wget -qO - https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer --quiet
25-
- name: Cache Composer dependencies
26-
uses: actions/cache@v1
23+
- name: Get Composer Cache Directory
24+
id: composer-cache
25+
run: |
26+
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
27+
- uses: actions/cache@v3
2728
with:
28-
path: ~/.composer/cache
29-
key: composer-php${{ matrix.php }}-highest-
29+
path: ${{ steps.composer-cache.outputs.dir }}
30+
key: ${{ runner.os }}-composer-8.3-highest-${{ hashFiles('**/composer.json') }}
3031
restore-keys: |
31-
composer-php${{ matrix.php }}-highest-
32-
composer-
32+
${{ runner.os }}-composer-8.3-highest
3333
- name: Validate Composer
3434
run: composer validate
35-
- name: Install xsl PHP extension
36-
run: |
37-
apk add $PHPIZE_DEPS libxslt-dev
38-
docker-php-ext-install xsl
3935
- name: Install highest dependencies with Composer
40-
run: composer update --no-progress --ansi
36+
run: composer update --no-progress --no-suggest --ansi
4137
- name: Disable PHP memory limit
4238
run: echo 'memory_limit=-1' >> /usr/local/etc/php/php.ini
43-
- name: Analyze
44-
run: vendor/bin/phpqa --execution no-parallel --progress-delay=-1 --ansi
39+
- name: Run CS-Fixer
40+
run: vendor/bin/php-cs-fixer fix --dry-run --diff --format=checkstyle
4541

4642
phpunit:
4743
name: PHPUnit (PHP ${{ matrix.php }} Deps ${{ matrix.dependencies }})
@@ -54,93 +50,79 @@ jobs:
5450
strategy:
5551
matrix:
5652
php:
57-
- '7.2'
58-
- '7.3'
59-
- '7.4'
60-
- '8.0'
6153
- '8.1'
54+
- '8.2'
55+
- '8.3'
6256
dependencies:
63-
- lowest
64-
- highest
57+
- 'lowest'
58+
- 'highest'
6559
include:
66-
- php: '7.2'
67-
phpunit-version: 8.5
68-
- php: '7.3'
69-
phpunit-version: 9.5
70-
- php: '7.4'
71-
phpunit-version: 9.5
72-
- php: '8.0'
73-
phpunit-version: 9.5
7460
- php: '8.1'
75-
phpunit-version: 9.5
61+
phpunit-version: 10
62+
- php: '8.2'
63+
phpunit-version: 10
64+
- php: '8.3'
65+
phpunit-version: 10
7666
fail-fast: false
7767
steps:
7868
- name: Checkout
79-
uses: actions/checkout@v2
69+
uses: actions/checkout@v4
8070
- name: Install Composer
8171
run: wget -qO - https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer --quiet
82-
- name: Cache Composer dependencies
83-
uses: actions/cache@v1
72+
- name: Get Composer Cache Directory
73+
id: composer-cache
74+
run: |
75+
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
76+
- uses: actions/cache@v3
8477
with:
85-
path: ~/.composer/cache
86-
key: composer-php${{ matrix.php }}-${{ matrix.dependencies }}-
78+
path: ${{ steps.composer-cache.outputs.dir }}
79+
key: ${{ runner.os }}-composer-${{ matrix.php }}-${{ matrix.dependencies }}-${{ hashFiles('**/composer.json') }}
8780
restore-keys: |
88-
composer-php${{ matrix.php }}-${{ matrix.dependencies }}-
89-
composer-
90-
- name: Install xsl PHP extension
91-
run: |
92-
apk add $PHPIZE_DEPS libxslt-dev
93-
docker-php-ext-install xsl
81+
${{ runner.os }}-composer-${{ matrix.php }}-${{ matrix.dependencies }}
9482
- name: Install lowest dependencies with Composer
9583
if: matrix.dependencies == 'lowest'
96-
run: composer update --no-progress --prefer-stable --prefer-lowest --ansi
84+
run: composer update --no-progress --no-suggest --prefer-stable --prefer-lowest --ansi
9785
- name: Install highest dependencies with Composer
9886
if: matrix.dependencies == 'highest'
99-
run: composer update --no-progress --ansi
87+
run: composer update --no-progress --no-suggest --ansi
10088
- name: Run tests with PHPUnit
10189
env:
102-
SYMFONY_PHPUNIT_VERSION: ${{ matrix.phpunit-version }}
90+
SYMFONY_MAX_PHPUNIT_VERSION: ${{ matrix.phpunit-version }}
10391
run: vendor/bin/simple-phpunit --colors=always
10492

10593
coverage:
106-
name: Coverage (PHP ${{ matrix.php }})
94+
name: Coverage (PHP 8.3)
10795
runs-on: ubuntu-latest
10896
container:
109-
image: php:${{ matrix.php }}-alpine
97+
image: php:8.3-alpine
11098
options: >-
11199
--tmpfs /tmp:exec
112100
--tmpfs /var/tmp:exec
113-
strategy:
114-
matrix:
115-
php:
116-
- '7.4'
117101
steps:
118102
- name: Checkout
119-
uses: actions/checkout@v2
103+
uses: actions/checkout@v4
120104
- name: Install pcov PHP extension
121105
run: |
122106
apk add $PHPIZE_DEPS
123107
pecl install pcov
124108
docker-php-ext-enable pcov
125109
- name: Install Composer
126110
run: wget -qO - https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer --quiet
127-
- name: Cache Composer dependencies
128-
uses: actions/cache@v1
111+
- name: Get Composer Cache Directory
112+
id: composer-cache
113+
run: |
114+
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
115+
- uses: actions/cache@v3
129116
with:
130-
path: ~/.composer/cache
131-
key: composer-php${{ matrix.php }}-highest-
117+
path: ${{ steps.composer-cache.outputs.dir }}
118+
key: ${{ runner.os }}-composer-8.3-highest-${{ hashFiles('**/composer.json') }}
132119
restore-keys: |
133-
composer-php${{ matrix.php }}-highest-
134-
composer-
135-
- name: Install xsl PHP extension
136-
run: |
137-
apk add $PHPIZE_DEPS libxslt-dev
138-
docker-php-ext-install xsl
120+
${{ runner.os }}-composer-8.3-highest
139121
- name: Install highest dependencies with Composer
140-
run: composer update --no-progress --ansi
122+
run: composer update --no-progress --no-suggest --ansi
141123
- name: Run coverage with PHPUnit
142124
run: vendor/bin/simple-phpunit --coverage-clover ./coverage.xml --colors=always
143125
- name: Send code coverage report to Codecov.io
144-
uses: codecov/codecov-action@v1.0.3 # 1.0.4+ uncompatible alpine :/
126+
uses: codecov/codecov-action@v3
145127
with:
146128
token: ${{ secrets.CODECOV_TOKEN }}

.php-cs-fixer.dist.php

+30-20
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,43 @@
99
file that was distributed with this source code.
1010
HEADER;
1111

12+
13+
$finder = (new PhpCsFixer\Finder())
14+
->in(['src', 'tests'])
15+
;
16+
1217
return (new PhpCsFixer\Config())
1318
->setRiskyAllowed(true)
19+
->registerCustomFixers(new PhpCsFixerCustomFixers\Fixers())
1420
->setRules([
15-
'@DoctrineAnnotation' => true,
16-
'@PHP70Migration' => true,
17-
'@PHP70Migration:risky' => true,
18-
'@PHP71Migration' => true,
19-
'@PHP71Migration:risky' => true,
20-
'@PHP73Migration' => true,
21-
'@PHPUnit75Migration:risky' => true,
21+
'@PHP82Migration' => true,
2222
'@PhpCsFixer' => true,
2323
'@PhpCsFixer:risky' => true,
24-
'@Symfony' => true,
25-
'@Symfony:risky' => true,
26-
'array_syntax' => ['syntax' => 'short'],
27-
'date_time_immutable' => true,
28-
'header_comment' => ['header' => $header],
29-
'general_phpdoc_annotation_remove' => true,
24+
25+
// From https://github.com/symfony/demo/blob/main/.php-cs-fixer.dist.php
3026
'linebreak_after_opening_tag' => true,
31-
'list_syntax' => ['syntax' => 'short'],
32-
'no_superfluous_phpdoc_tags' => true,
27+
// 'mb_str_functions' => true,
28+
'no_php4_constructor' => true,
29+
'no_unreachable_default_argument_value' => true,
30+
'no_useless_else' => true,
31+
'no_useless_return' => true,
3332
'php_unit_strict' => false,
33+
'php_unit_internal_class' => false,
3434
'php_unit_test_class_requires_covers' => false,
35+
'phpdoc_order' => true,
36+
'strict_comparison' => true,
37+
'strict_param' => true,
38+
'trailing_comma_in_multiline' => ['after_heredoc' => true, 'elements' => ['arrays', 'parameters']],
39+
'statement_indentation' => true,
40+
'method_chaining_indentation' => true,
41+
'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline', 'attribute_placement' => 'ignore'],
42+
43+
PhpCsFixerCustomFixers\Fixer\ConstructorEmptyBracesFixer::name() => true,
44+
PhpCsFixerCustomFixers\Fixer\MultilineCommentOpeningClosingAloneFixer::name() => true,
45+
PhpCsFixerCustomFixers\Fixer\MultilinePromotedPropertiesFixer::name() => true,
46+
PhpCsFixerCustomFixers\Fixer\NoDuplicatedImportsFixer::name() => true,
47+
PhpCsFixerCustomFixers\Fixer\NoImportFromGlobalNamespaceFixer::name() => true,
48+
PhpCsFixerCustomFixers\Fixer\PhpdocSingleLineVarFixer::name() => true,
3549
])
36-
->setFinder(
37-
(new PhpCsFixer\Finder())
38-
->exclude(['vendor'])
39-
->in(['src', 'tests'])
40-
)
50+
->setFinder($finder)
4151
;

.phpqa.yml

-15
This file was deleted.

composer.json

+22-21
Original file line numberDiff line numberDiff line change
@@ -26,28 +26,29 @@
2626
}
2727
],
2828
"require": {
29-
"php": ">=7.2",
30-
"a2lix/auto-form-bundle": "^0.2|^0.3|^0.4",
31-
"symfony/config": "^3.4.30|^4.3|^5.0|^6.0",
32-
"symfony/dependency-injection": "^3.4.30|^4.3|^5.0|^6.0",
33-
"symfony/doctrine-bridge": "^3.4.30|^4.3|^5.0|^6.0",
34-
"symfony/event-dispatcher": "^3.4.30|^4.3|^5.0|^6.0",
35-
"symfony/form": "^3.4.30|^4.3|^5.0|^6.0",
36-
"symfony/http-foundation": "^3.4.30|^4.3|^5.0|^6.0",
37-
"symfony/http-kernel": "^3.4.30|^4.3|^5.0|^6.0",
38-
"symfony/options-resolver": "^3.4.30|^4.3|^5.0|^6.0"
29+
"php": "^8.1",
30+
"a2lix/auto-form-bundle": "^0.4",
31+
"symfony/config": "^5.4.30|^6.3.10|^7.0",
32+
"symfony/dependency-injection": "^5.4.30|^6.3.10|^7.0",
33+
"symfony/doctrine-bridge": "^5.4.30|^6.3.10|^7.0",
34+
"symfony/event-dispatcher": "^5.4.30|^6.3.10|^7.0",
35+
"symfony/form": "^5.4.30|^6.3.10|^7.0",
36+
"symfony/http-foundation": "^5.4.30|^6.3.10|^7.0",
37+
"symfony/http-kernel": "^5.4.30|^6.3.10|^7.0",
38+
"symfony/options-resolver": "^5.4.30|^6.3.10|^7.0"
3939
},
4040
"require-dev": {
41-
"doctrine/orm": "^2.7",
42-
"edgedesign/phpqa": "^1.25",
43-
"friendsofphp/php-cs-fixer": "^3.4.0",
44-
"knplabs/doctrine-behaviors": "^2.0",
45-
"matthiasnoback/symfony-dependency-injection-test": "^4.3",
46-
"phpstan/phpstan": "^1.2.0",
47-
"symfony/cache": "^5.4",
48-
"symfony/phpunit-bridge": "^6.0",
49-
"symfony/validator": "^3.4.30|^4.3|^5.0|^6.0",
50-
"vimeo/psalm": "^4.15"
41+
"doctrine/orm": "^2.15",
42+
"friendsofphp/php-cs-fixer": "^3.45",
43+
"knplabs/doctrine-behaviors": "^2.3",
44+
"kubawerlos/php-cs-fixer-custom-fixers": "^3.18",
45+
"matthiasnoback/symfony-dependency-injection-test": "^5.0",
46+
"phpstan/phpstan": "^1.10",
47+
"rector/rector": "^0.18",
48+
"symfony/cache": "^5.4.30|^6.3.10|^7.0",
49+
"symfony/phpunit-bridge": "^5.4.30|^6.3.10|^7.0",
50+
"symfony/validator": "^5.4.30|^6.3.10|^7.0",
51+
"vimeo/psalm": "^5.18"
5152
},
5253
"suggest": {
5354
"knplabs/doctrine-behaviors": "For Knp strategy",
@@ -61,7 +62,7 @@
6162
"psalm"
6263
],
6364
"phpunit": [
64-
"SYMFONY_DEPRECATIONS_HELPER=max[self]=0 SYMFONY_PHPUNIT_VERSION=9.5 SYMFONY_PHPUNIT_REMOVE_RETURN_TYPEHINT=1 simple-phpunit"
65+
"SYMFONY_DEPRECATIONS_HELPER=max[self]=0 simple-phpunit"
6566
]
6667
},
6768
"config": {

phpunit.xml.dist

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<!-- https://phpunit.de/manual/current/en/appendixes.configuration.html -->
44
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5-
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/6.1/phpunit.xsd"
5+
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/9.6/phpunit.xsd"
66
backupGlobals="false"
77
colors="true"
88
bootstrap="vendor/autoload.php"

rector.php

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Rector\Config\RectorConfig;
6+
use Rector\Core\ValueObject\PhpVersion;
7+
use Rector\Doctrine\Set\DoctrineSetList;
8+
use Rector\PHPUnit\Set\PHPUnitLevelSetList;
9+
use Rector\PHPUnit\Set\PHPUnitSetList;
10+
use Rector\Set\ValueObject\LevelSetList;
11+
use Rector\Symfony\Set\SymfonyLevelSetList;
12+
use Rector\Symfony\Set\SymfonySetList;
13+
use Rector\Symfony\Set\TwigSetList;
14+
15+
return static function (RectorConfig $rectorConfig): void {
16+
$rectorConfig->parallel();
17+
$rectorConfig->paths([
18+
__DIR__.'/src',
19+
__DIR__.'/tests',
20+
]);
21+
$rectorConfig->importNames();
22+
$rectorConfig->importShortClasses(false);
23+
24+
$rectorConfig->phpVersion(PhpVersion::PHP_82);
25+
$rectorConfig->sets([
26+
LevelSetList::UP_TO_PHP_82,
27+
28+
DoctrineSetList::ANNOTATIONS_TO_ATTRIBUTES,
29+
// DoctrineSetList::DOCTRINE_CODE_QUALITY,
30+
DoctrineSetList::DOCTRINE_ORM_214,
31+
DoctrineSetList::DOCTRINE_DBAL_30,
32+
33+
PHPUnitLevelSetList::UP_TO_PHPUNIT_91,
34+
// PHPUnitSetList::PHPUNIT_CODE_QUALITY,
35+
// PHPUnitSetList::PHPUNIT_YIELD_DATA_PROVIDER,
36+
]);
37+
};

src/DependencyInjection/A2lixTranslationFormExtension.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
use Symfony\Component\Config\Definition\Processor;
1717
use Symfony\Component\Config\FileLocator;
1818
use Symfony\Component\DependencyInjection\ContainerBuilder;
19-
use Symfony\Component\DependencyInjection\Loader;
19+
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
2020
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
2121

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

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

3232
$container->setParameter('a2lix_translation_form.locale_provider', $config['locale_provider']);

src/DependencyInjection/Compiler/LocaleProviderPass.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
class LocaleProviderPass implements CompilerPassInterface
2020
{
21-
public const DEFAULT_LOCALE_PROVIDER_KEY = 'default';
21+
final public const DEFAULT_LOCALE_PROVIDER_KEY = 'default';
2222

2323
public function process(ContainerBuilder $container): void
2424
{

0 commit comments

Comments
 (0)