Skip to content

Commit 8d002d2

Browse files
authored
Compatibility with Symfony 8.0 (#182)
* Rewrite test scripts to use symfony/console * Add Symfony 8.0 to testing matrix * Allow Symfony 8.0 & Remove Doctrine <3 * Convert Bundle XML configuration to PHP * Fixed Doctrine compatibility * Fixed usage of validator constraints options * Lock more Symfony component versions to avoid incompatibility issues * Update PHPUnit version * Fixed PHPUnit warnings, deprecations and notices * Drop PHP 8.1 & Symfony 6.4 support * Ignore deprecated parts of DoctrineDBALJobExecutionStorage from coverage
1 parent 96533f2 commit 8d002d2

99 files changed

Lines changed: 779 additions & 803 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/actions/install/action.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,6 @@ runs:
4141
composer require --quiet --no-update "symfony/process:${{ inputs.symfony-version }}" --dev
4242
composer require --quiet --no-update "symfony/yaml:${{ inputs.symfony-version }}" --dev
4343
composer require --quiet --no-update "symfony/http-client:${{ inputs.symfony-version }}" --dev
44+
composer require --quiet --no-update "symfony/browser-kit:${{ inputs.symfony-version }}" --dev
45+
composer require --quiet --no-update "symfony/translation:${{ inputs.symfony-version }}" --dev
4446
composer update --no-interaction --no-progress

.github/workflows/tests.yml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,12 @@ jobs:
1313
strategy:
1414
matrix:
1515
include:
16-
- php-version: '8.1'
17-
symfony-version: '6.4.*'
18-
- php-version: '8.4'
19-
symfony-version: '6.4.*'
2016
- php-version: '8.2'
2117
symfony-version: '7.4.*'
2218
- php-version: '8.4'
2319
symfony-version: '7.4.*'
20+
- php-version: '8.4'
21+
symfony-version: '8.0.*'
2422
steps:
2523
- name: "Checkout"
2624
uses: actions/checkout@v2
@@ -42,7 +40,7 @@ jobs:
4240
uses: ./.github/actions/install
4341
with:
4442
php-version: '8.4'
45-
symfony-version: '7.4.*'
43+
symfony-version: '8.0.*'
4644
- name: "Run static analyzis with phpstan/phpstan"
4745
run: vendor/bin/phpstan analyze
4846

@@ -56,7 +54,7 @@ jobs:
5654
uses: ./.github/actions/install
5755
with:
5856
php-version: '8.4'
59-
symfony-version: '7.4.*'
57+
symfony-version: '8.0.*'
6058
- name: "Run checkstyle with symplify/easy-coding-standard"
6159
run: vendor/bin/ecs
6260

@@ -70,7 +68,7 @@ jobs:
7068
uses: ./.github/actions/install
7169
with:
7270
php-version: '8.4'
73-
symfony-version: '7.4.*'
71+
symfony-version: '8.0.*'
7472
- name: "Run tests with phpunit/phpunit"
7573
run: vendor/bin/phpunit --testsuite=Convention
7674

@@ -85,7 +83,7 @@ jobs:
8583
uses: ./.github/actions/install
8684
with:
8785
php-version: '8.4'
88-
symfony-version: '7.4.*'
86+
symfony-version: '8.0.*'
8987
coverage-mode: 'xdebug'
9088
- name: "Run tests with phpunit/phpunit"
9189
run: |

.led/config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[service]
22
project-name = yokai-batch
33
[default]
4-
container = php83
4+
container = php84

.led/scripts/tests

Lines changed: 60 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,77 @@
11
#!/usr/bin/env php
22
<?php
33

4-
use Symfony\Component\Console\Input\ArrayInput;
5-
use Symfony\Component\Console\Output\ConsoleOutput;
4+
use Symfony\Component\Console\Input\InputInterface;
5+
use Symfony\Component\Console\Output\OutputInterface;
6+
use Symfony\Component\Console\SingleCommandApplication;
67
use Symfony\Component\Console\Style\SymfonyStyle;
78
use Symfony\Component\Process\Process;
89
use Symfony\Component\Yaml\Yaml;
910

1011
require_once __DIR__ . '/../../vendor/autoload.php';
1112

12-
$action = Yaml::parseFile(__DIR__ . '/../../.github/actions/install/action.yml');
13-
$composer = \array_filter(\explode(\PHP_EOL, $action['runs']['steps'][1]['run']));
13+
(new SingleCommandApplication())
14+
->setCode(function (InputInterface $input, OutputInterface $output) {
15+
$return = 0;
1416

15-
$io = new SymfonyStyle(new ArrayInput([]), new ConsoleOutput());
17+
$action = Yaml::parseFile(__DIR__ . '/../../.github/actions/install/action.yml');
18+
$composer = \array_filter(\explode(\PHP_EOL, $action['runs']['steps'][1]['run']));
1619

17-
$execute = function (array $job, string|null $php = null, string|null $symfony = null) use ($io, $composer) {
18-
$io->section($job['name']);
20+
$io = new SymfonyStyle($input, $output);
1921

20-
if ($php === null && $symfony === null) {
21-
['php-version' => $php, 'symfony-version' => $symfony] = $job['steps'][1]['with'];
22-
} else {
23-
$io->definitionList(
24-
['PHP' => $php],
25-
['Symfony' => $symfony],
26-
);
27-
}
22+
$execute = function (array $job, string|null $php = null, string|null $symfony = null) use ($io, $composer) {
23+
$io->section($job['name']);
2824

29-
$process = function (string $command, bool $output) use ($io, $php) {
30-
$container = 'php' . \str_replace('.', '', $php);
31-
$command = "led in -s {$container} -- {$command}";
25+
if ($php === null && $symfony === null) {
26+
['php-version' => $php, 'symfony-version' => $symfony] = $job['steps'][1]['with'];
27+
} else {
28+
$io->definitionList(
29+
['PHP' => $php],
30+
['Symfony' => $symfony],
31+
);
32+
}
3233

33-
$callback = null;
34-
if ($output) {
35-
$io->writeln($command);
36-
$callback = function ($type, $buffer) {
37-
echo $buffer;
34+
$process = function (string $command, bool $output) use ($io, $php) {
35+
$container = 'php' . \str_replace('.', '', $php);
36+
$command = "led in -s {$container} -- {$command}";
37+
38+
$callback = null;
39+
if ($output) {
40+
$io->writeln($command);
41+
$callback = function ($type, $buffer) {
42+
echo $buffer;
43+
};
44+
}
45+
46+
Process::fromShellCommandline($command)->mustRun($callback);
3847
};
48+
49+
foreach ($composer as $command) {
50+
$process(\str_replace('${{ inputs.symfony-version }}', $symfony, $command), false);
51+
}
52+
$process($job['steps'][2]['run'], true);
53+
};
54+
55+
$tests = Yaml::parseFile(__DIR__ . '/../../.github/workflows/tests.yml');
56+
57+
try {
58+
$execute($tests['jobs']['checkstyke']);
59+
$execute($tests['jobs']['phpstan']);
60+
$execute($tests['jobs']['conventions']);
61+
62+
$phpunitTestingMatrix = $tests['jobs']['phpunit']['strategy']['matrix']['include'];
63+
foreach ($phpunitTestingMatrix as ['php-version' => $php, 'symfony-version' => $symfony]) {
64+
$execute($tests['jobs']['phpunit'], $php, $symfony);
65+
}
66+
} catch (\Throwable) {
67+
$return = 1;
68+
$io->error('An error occurred, abort tests.');
3969
}
4070

41-
Process::fromShellCommandline($command)->mustRun($callback);
42-
};
43-
44-
foreach ($composer as $command) {
45-
$process(\str_replace('${{ inputs.symfony-version }}', $symfony, $command), false);
46-
}
47-
$process($job['steps'][2]['run'], true);
48-
};
49-
50-
$tests = Yaml::parseFile(__DIR__ . '/../../.github/workflows/tests.yml');
51-
52-
try {
53-
$execute($tests['jobs']['checkstyke']);
54-
$execute($tests['jobs']['phpstan']);
55-
$execute($tests['jobs']['conventions']);
56-
57-
$phpunitTestingMatrix = $tests['jobs']['phpunit']['strategy']['matrix']['include'];
58-
foreach ($phpunitTestingMatrix as ['php-version' => $php, 'symfony-version' => $symfony]) {
59-
$execute($tests['jobs']['phpunit'], $php, $symfony);
60-
}
61-
} catch (\Throwable) {
62-
$io->error('An error occurred, abort tests.');
63-
}
64-
65-
$io->success('Revert changes made to composer.json');
66-
Process::fromShellCommandline('git restore composer.json')->mustRun();
67-
Process::fromShellCommandline('led in -- composer update')->mustRun();
71+
$io->success('Revert changes made to composer.json');
72+
Process::fromShellCommandline('git restore composer.json')->mustRun();
73+
Process::fromShellCommandline('led in -- composer update')->mustRun();
74+
75+
return $return;
76+
})
77+
->run();

composer.json

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -11,47 +11,46 @@
1111
"minimum-stability": "dev",
1212
"prefer-stable": true,
1313
"require": {
14-
"php": "^8.1",
14+
"php": "^8.2",
1515
"ext-json": "*",
1616
"composer-runtime-api": "^2.0",
17-
"doctrine/dbal": "^2.11|^3.0",
18-
"doctrine/orm": "^2.8",
19-
"doctrine/persistence": "^2.0|^3.0",
17+
"doctrine/dbal": "^4.0",
18+
"doctrine/orm": "^3.0",
19+
"doctrine/persistence": "^4.0",
2020
"league/flysystem": "^3.0",
2121
"openspout/openspout": "^4.0",
2222
"psr/container": "^1.0",
2323
"psr/event-dispatcher": "^1.0",
24-
"psr/log": "^1.0|^2.0|^3.0",
25-
"symfony/config": "^6.4|^7.0",
26-
"symfony/console": "^6.4|^7.0",
27-
"symfony/dependency-injection": "^6.4|^7.0",
28-
"symfony/form": "^6.4|^7.0",
29-
"symfony/http-kernel": "^6.4|^7.0",
30-
"symfony/framework-bundle": "^6.4|^7.0",
31-
"symfony/messenger": "^6.4|^7.0",
32-
"symfony/serializer": "^6.4|^7.0",
33-
"symfony/uid": "^6.4|^7.0",
34-
"symfony/validator": "^6.4|^7.0"
24+
"psr/log": "^3.0",
25+
"symfony/config": "^7.4|^8.0",
26+
"symfony/console": "^7.4|^8.0",
27+
"symfony/dependency-injection": "^7.4|^8.0",
28+
"symfony/form": "^7.4|^8.0",
29+
"symfony/http-kernel": "^7.4|^8.0",
30+
"symfony/framework-bundle": "^7.4|^8.0",
31+
"symfony/messenger": "^7.4|^8.0",
32+
"symfony/serializer": "^7.4|^8.0",
33+
"symfony/uid": "^7.4|^8.0",
34+
"symfony/validator": "^7.4|^8.0"
3535
},
3636
"require-dev": {
37-
"doctrine/annotations": "^1.14",
38-
"doctrine/doctrine-bundle": "^2.5",
37+
"doctrine/doctrine-bundle": "^2.0|^3.0",
3938
"league/flysystem-memory": "^3.0",
4039
"phpspec/prophecy-phpunit": "^2.0",
4140
"phpstan/phpstan": "^1.4",
42-
"phpunit/phpunit": "^9.5",
41+
"phpunit/phpunit": "^11.0|^12.0",
4342
"sonata-project/admin-bundle": "^4.0",
44-
"symfony/browser-kit": "^6.4|^7.0",
45-
"symfony/css-selector": "^6.4|^7.0",
46-
"symfony/filesystem": "^6.4|^7.0",
47-
"symfony/finder": "^6.4|^7.0",
48-
"symfony/process": "^6.4|^7.0",
49-
"symfony/security-bundle": "^6.4|^7.0",
50-
"symfony/translation": "^6.4|^7.0",
51-
"symfony/twig-bundle": "^6.4|^7.0",
52-
"symfony/yaml": "^6.4|^7.0",
43+
"symfony/browser-kit": "^7.4|^8.0",
44+
"symfony/css-selector": "^7.4|^8.0",
45+
"symfony/filesystem": "^7.4|^8.0",
46+
"symfony/finder": "^7.4|^8.0",
47+
"symfony/process": "^7.4|^8.0",
48+
"symfony/security-bundle": "^7.4|^8.0",
49+
"symfony/translation": "^7.4|^8.0",
50+
"symfony/twig-bundle": "^7.4|^8.0",
51+
"symfony/yaml": "^7.4|^8.0",
5352
"symplify/easy-coding-standard": "^12.5",
54-
"symfony/http-client": "^6.4|^7.0"
53+
"symfony/http-client": "^7.4|^8.0"
5554
},
5655
"replace": {
5756
"yokai/batch": "self.version",

ecs.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,5 +77,8 @@
7777
ArrayOpenerAndCloserNewlineFixer::class,
7878
ExplicitStringVariableFixer::class,
7979
StandaloneLineInMultilineArrayFixer::class,
80+
NativeFunctionInvocationFixer::class => [
81+
'src/batch-symfony-framework/src/Resources/*',
82+
],
8083
])
8184
;

phpunit.xml

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,18 @@
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="https://schema.phpunit.de/9.3/phpunit.xsd"
5+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
66
backupGlobals="false"
77
colors="true"
88
bootstrap="tests/bootstrap.php"
99
>
1010
<php>
1111
<env name="ARTIFACT_DIR" value="tests/.artifacts"/>
12-
<env name="DATABASE_URL" value="sqlite:///:memory:"/>
12+
<env name="DATABASE_URL" value="pdo-sqlite:///:memory:"/>
1313
<env name="KERNEL_CLASS" value="Yokai\Batch\Sources\Tests\Symfony\App\Kernel"/>
1414
</php>
1515

1616
<testsuites>
17-
<testsuite name="Package">
18-
<directory>./src/*/tests</directory>
19-
</testsuite>
20-
<testsuite name="Integration">
21-
<directory>./tests/integration</directory>
22-
</testsuite>
23-
<testsuite name="Symfony">
24-
<directory>./tests/symfony/tests</directory>
25-
</testsuite>
26-
2717
<testsuite name="Code">
2818
<directory>./src/*/tests</directory>
2919
<directory>./tests/integration</directory>
@@ -34,9 +24,9 @@
3424
</testsuite>
3525
</testsuites>
3626

37-
<coverage>
27+
<source>
3828
<include>
3929
<directory>./src/*/src</directory>
4030
</include>
41-
</coverage>
31+
</source>
4232
</phpunit>

src/batch-doctrine-dbal/composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
}
1212
],
1313
"require": {
14-
"php": "^8.1",
14+
"php": "^8.2",
1515
"ext-json": "*",
16-
"doctrine/dbal": "^2.11|^3.0",
17-
"doctrine/persistence": "^2.0|^3.0",
16+
"doctrine/dbal": "^4.0",
17+
"doctrine/persistence": "^4.0",
1818
"yokai/batch": "^0.7.0"
1919
},
2020
"autoload": {

0 commit comments

Comments
 (0)