Skip to content

Commit d6c26f6

Browse files
ngriekochen
authored andcommitted
Add support for Symfony 8
1 parent 3d9b69a commit d6c26f6

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@
4545
"phpunit/php-timer": "^7.0.1",
4646
"phpunit/phpunit": "^11.5.24",
4747
"sebastian/environment": "^7.2.1",
48-
"symfony/console": "^6.4.22 || ^7.3.0",
49-
"symfony/process": "^6.4.20 || ^7.3.0"
48+
"symfony/console": "^6.4.22 || ^7.3.4 || ^8.0.0",
49+
"symfony/process": "^6.4.20 || ^7.3.4 || ^8.0.0"
5050
},
5151
"require-dev": {
5252
"ext-pcov": "*",
@@ -57,7 +57,7 @@
5757
"phpstan/phpstan-phpunit": "^2.0.6",
5858
"phpstan/phpstan-strict-rules": "^2.0.4",
5959
"squizlabs/php_codesniffer": "^3.13.2",
60-
"symfony/filesystem": "^6.4.13 || ^7.3.0"
60+
"symfony/filesystem": "^6.4.13 || ^7.3.2 || ^8.0.0"
6161
},
6262
"autoload": {
6363
"psr-4": {

src/ParaTestCommand.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use function class_exists;
1919
use function is_string;
2020
use function is_subclass_of;
21+
use function method_exists;
2122
use function sprintf;
2223

2324
/** @internal */
@@ -45,7 +46,14 @@ public static function applicationFactory(string $cwd): Application
4546

4647
$application->setName('ParaTest');
4748
$application->setVersion(PrettyVersions::getVersion('brianium/paratest')->getPrettyVersion());
48-
$application->add($command);
49+
// @phpstan-ignore function.alreadyNarrowedType (can be removed when dropping support for Symfony 7.3)
50+
if (method_exists($application, 'addCommand')) {
51+
$application->addCommand($command);
52+
} else {
53+
// @phpstan-ignore method.deprecated (can be removed when dropping support for Symfony 7.3)
54+
$application->add($command);
55+
}
56+
4957
$commandName = $command->getName();
5058
assert($commandName !== null);
5159
$application->setDefaultCommand($commandName, true);

test/Unit/ParaTestCommandTest.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use function assert;
1717
use function chdir;
1818
use function getcwd;
19+
use function method_exists;
1920
use function uniqid;
2021

2122
/** @internal */
@@ -36,7 +37,13 @@ protected function setUp(): void
3637
$this->tmpDir = (new TmpDirCreator())->create();
3738
chdir($this->tmpDir);
3839
$application = ParaTestCommand::applicationFactory($this->tmpDir);
39-
$application->add(new HelpCommand());
40+
// @phpstan-ignore function.alreadyNarrowedType (can be removed when dropping support for Symfony 7.3)
41+
if (method_exists($application, 'addCommand')) {
42+
$application->addCommand(new HelpCommand());
43+
} else {
44+
// @phpstan-ignore method.deprecated (can be removed when dropping support for Symfony 7.3)
45+
$application->add(new HelpCommand());
46+
}
4047

4148
$this->commandTester = new CommandTester($application->find(ParaTestCommand::COMMAND_NAME));
4249
}

0 commit comments

Comments
 (0)