Skip to content

Commit cf17bbf

Browse files
committed
Allow Symfony 8
1 parent 46a1688 commit cf17bbf

File tree

8 files changed

+59
-5
lines changed

8 files changed

+59
-5
lines changed

composer-diff

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,13 @@ if (!class_exists('Composer\Package\CompletePackage')) {
2424
exit(1);
2525
}
2626

27+
$command = new DiffCommand(new PackageDiff());
2728
$application = new Application();
28-
$application->add(new DiffCommand(new PackageDiff()));
29+
30+
if (method_exists('Symfony\Component\Console\Application', 'addCommand')) {
31+
$application->addCommand($command);
32+
} else {
33+
$application->add($command);
34+
}
2935
$application->setDefaultCommand('diff', true);
3036
$application->run();

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
},
2727
"require-dev": {
2828
"composer/composer": "^1.1 || ^2.0",
29-
"symfony/console": "^2.3 || ^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0",
30-
"symfony/phpunit-bridge": "^4.2 || ^5.0 || ^6.0 || ^7.0"
29+
"symfony/console": "^2.3 || ^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0",
30+
"symfony/phpunit-bridge": "^4.2 || ^5.0 || ^6.0 || ^7.0 || ^8.0"
3131
},
3232
"suggest": {
3333
"composer/composer": "To use the binary without composer runtime",

infection.json.dist

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"src"
55
],
66
"excludes": [
7-
"src/Command/BaseNotTypedCommand.php"
7+
"src/Command/BaseNotTypedCommand.php",
8+
"src/Command/NotTypedConfigureTrait.php",
89
]
910
},
1011
"logs": {

src/Command/BaseNotTypedCommand.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,18 @@ protected function execute(InputInterface $input, OutputInterface $output)
1818
return $this->handle($input, $output);
1919
}
2020

21+
protected function configure()
22+
{
23+
parent::configure();
24+
25+
$this->doConfigure();
26+
}
27+
28+
/**
29+
* @return void
30+
*/
31+
abstract protected function doConfigure();
32+
2133
/**
2234
* @return int
2335
*/

src/Command/BaseTypedCommand.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,23 @@
66
use Symfony\Component\Console\Input\InputInterface;
77
use Symfony\Component\Console\Output\OutputInterface;
88

9+
10+
class_alias(
11+
PHP_VERSION_ID >= 70200
12+
? 'IonBazan\ComposerDiff\Command\TypedConfigureTrait'
13+
: 'IonBazan\ComposerDiff\Command\NotTypedConfigureTrait',
14+
'IonBazan\ComposerDiff\Command\ConfigureTrait'
15+
);
16+
917
/**
1018
* @codeCoverageIgnore
1119
*
1220
* This class contains a typed version of execute() method (PHP 7+).
1321
*/
1422
abstract class BaseTypedCommand extends BaseCommand
1523
{
24+
use ConfigureTrait;
25+
1626
protected function execute(InputInterface $input, OutputInterface $output): int
1727
{
1828
return $this->handle($input, $output);

src/Command/DiffCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function __construct(PackageDiff $packageDiff, array $gitlabDomains = arr
5353
/**
5454
* @return void
5555
*/
56-
protected function configure()
56+
protected function doConfigure()
5757
{
5858
$this->setName('diff')
5959
->setDescription('Compares composer.lock files and shows package changes')
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
namespace IonBazan\ComposerDiff\Command;
4+
5+
trait NotTypedConfigureTrait
6+
{
7+
/**
8+
* @return void
9+
*/
10+
protected function configure()
11+
{
12+
$this->doConfigure();
13+
}
14+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
namespace IonBazan\ComposerDiff\Command;
4+
5+
trait TypedConfigureTrait
6+
{
7+
protected function configure(): void
8+
{
9+
$this->doConfigure();
10+
}
11+
}

0 commit comments

Comments
 (0)