From 38692fbb8987de2af1a20157f946ef6a47cc93f8 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 2 Jun 2025 16:08:14 +0200 Subject: [PATCH 1/3] Allow Symfony ^8.0 --- composer.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index fa9c2cb..624f905 100644 --- a/composer.json +++ b/composer.json @@ -21,10 +21,10 @@ }, "require-dev": { "composer/composer": "^2.6", - "symfony/console": "^6.4|^7.0", - "symfony/dotenv": "^6.4|^7.0", - "symfony/http-foundation": "^6.4|^7.0", - "symfony/http-kernel": "^6.4|^7.0" + "symfony/console": "^6.4|^7.0|^8.0", + "symfony/dotenv": "^6.4|^7.0|^8.0", + "symfony/http-foundation": "^6.4|^7.0|^8.0", + "symfony/http-kernel": "^6.4|^7.0|^8.0" }, "conflict": { "symfony/dotenv": "<6.4" From 3c7162ec37f4f464b96655177a09ffccd79e7579 Mon Sep 17 00:00:00 2001 From: HypeMC Date: Mon, 9 Jun 2025 17:40:54 +0200 Subject: [PATCH 2/3] [Console] Simplify using invokable commands when the component is used standalone --- SymfonyRuntime.php | 6 +++++- Tests/phpt/application.php | 6 +++++- Tests/phpt/command_list.php | 6 +++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/SymfonyRuntime.php b/SymfonyRuntime.php index 4035f28..4667bbd 100644 --- a/SymfonyRuntime.php +++ b/SymfonyRuntime.php @@ -162,7 +162,11 @@ public function getRunner(?object $application): RunnerInterface if (!$application->getName() || !$console->has($application->getName())) { $application->setName($_SERVER['argv'][0]); - $console->add($application); + if (method_exists($console, 'addCommand')) { + $console->addCommand($application); + } else { + $console->add($application); + } } $console->setDefaultCommand($application->getName(), true); diff --git a/Tests/phpt/application.php b/Tests/phpt/application.php index ca2de55..b51947c 100644 --- a/Tests/phpt/application.php +++ b/Tests/phpt/application.php @@ -25,7 +25,11 @@ }); $app = new Application(); - $app->add($command); + if (method_exists($app, 'addCommand')) { + $app->addCommand($command); + } else { + $app->add($command); + } $app->setDefaultCommand('go', true); return $app; diff --git a/Tests/phpt/command_list.php b/Tests/phpt/command_list.php index 929b440..aa40eda 100644 --- a/Tests/phpt/command_list.php +++ b/Tests/phpt/command_list.php @@ -23,7 +23,11 @@ $command->setName('my_command'); [$cmd, $args] = $runtime->getResolver(require __DIR__.'/command.php')->resolve(); - $app->add($cmd(...$args)); + if (method_exists($app, 'addCommand')) { + $app->addCommand($cmd(...$args)); + } else { + $app->add($cmd(...$args)); + } return $app; }; From 86c48554f489c55353a128c62c5ae27025bac155 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Sun, 15 Jun 2025 21:39:02 +0200 Subject: [PATCH 3/3] fix backwards-compatibility with overridden add() methods --- SymfonyRuntime.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/SymfonyRuntime.php b/SymfonyRuntime.php index 4667bbd..7eff3f5 100644 --- a/SymfonyRuntime.php +++ b/SymfonyRuntime.php @@ -162,10 +162,11 @@ public function getRunner(?object $application): RunnerInterface if (!$application->getName() || !$console->has($application->getName())) { $application->setName($_SERVER['argv'][0]); - if (method_exists($console, 'addCommand')) { - $console->addCommand($application); - } else { + + if (!method_exists($console, 'addCommand') || (new \ReflectionMethod($console, 'add'))->getDeclaringClass()->getName() !== (new \ReflectionMethod($console, 'addCommand'))->getDeclaringClass()->getName()) { $console->add($application); + } else { + $console->addCommand($application); } }