From 38692fbb8987de2af1a20157f946ef6a47cc93f8 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 2 Jun 2025 16:08:14 +0200 Subject: [PATCH 1/6] 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 77c754703be5e6a347c72c2b81ec6b9da9894749 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 2 Jun 2025 17:50:55 +0200 Subject: [PATCH 2/6] Bump Symfony 8 to PHP >= 8.4 --- composer.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index 624f905..b25fa84 100644 --- a/composer.json +++ b/composer.json @@ -16,18 +16,18 @@ } ], "require": { - "php": ">=8.2", + "php": ">=8.4", "composer-plugin-api": "^1.0|^2.0" }, "require-dev": { "composer/composer": "^2.6", - "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" + "symfony/console": "^7.4|^8.0", + "symfony/dotenv": "^7.4|^8.0", + "symfony/http-foundation": "^7.4|^8.0", + "symfony/http-kernel": "^7.4|^8.0" }, "conflict": { - "symfony/dotenv": "<6.4" + "symfony/error-handler": "<7.4" }, "autoload": { "psr-4": { From 3c7162ec37f4f464b96655177a09ffccd79e7579 Mon Sep 17 00:00:00 2001 From: HypeMC Date: Mon, 9 Jun 2025 17:40:54 +0200 Subject: [PATCH 3/6] [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 e0c2024db138439e8ed7ff418a55dc1b9582308b Mon Sep 17 00:00:00 2001 From: HypeMC Date: Fri, 13 Jun 2025 02:20:31 +0200 Subject: [PATCH 4/6] [Console][FrameworkBundle] Remove deprecated `Application::add()` methods --- SymfonyRuntime.php | 6 +----- Tests/phpt/application.php | 6 +----- Tests/phpt/command_list.php | 6 +----- composer.json | 1 + 4 files changed, 4 insertions(+), 15 deletions(-) diff --git a/SymfonyRuntime.php b/SymfonyRuntime.php index 4667bbd..45500cd 100644 --- a/SymfonyRuntime.php +++ b/SymfonyRuntime.php @@ -162,11 +162,7 @@ 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 { - $console->add($application); - } + $console->addCommand($application); } $console->setDefaultCommand($application->getName(), true); diff --git a/Tests/phpt/application.php b/Tests/phpt/application.php index b51947c..c0e37d6 100644 --- a/Tests/phpt/application.php +++ b/Tests/phpt/application.php @@ -25,11 +25,7 @@ }); $app = new Application(); - if (method_exists($app, 'addCommand')) { - $app->addCommand($command); - } else { - $app->add($command); - } + $app->addCommand($command); $app->setDefaultCommand('go', true); return $app; diff --git a/Tests/phpt/command_list.php b/Tests/phpt/command_list.php index aa40eda..805a417 100644 --- a/Tests/phpt/command_list.php +++ b/Tests/phpt/command_list.php @@ -23,11 +23,7 @@ $command->setName('my_command'); [$cmd, $args] = $runtime->getResolver(require __DIR__.'/command.php')->resolve(); - if (method_exists($app, 'addCommand')) { - $app->addCommand($cmd(...$args)); - } else { - $app->add($cmd(...$args)); - } + $app->addCommand($cmd(...$args)); return $app; }; diff --git a/composer.json b/composer.json index b25fa84..465df72 100644 --- a/composer.json +++ b/composer.json @@ -27,6 +27,7 @@ "symfony/http-kernel": "^7.4|^8.0" }, "conflict": { + "symfony/console": "<7.4", "symfony/error-handler": "<7.4" }, "autoload": { From 86c48554f489c55353a128c62c5ae27025bac155 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Sun, 15 Jun 2025 21:39:02 +0200 Subject: [PATCH 5/6] 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); } } From b814dd0f7f86203e7730bbe253e759b1410fa8de Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Wed, 18 Jun 2025 12:21:51 +0200 Subject: [PATCH 6/6] fix forward-compatibility with Symfony 8 --- SymfonyRuntime.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SymfonyRuntime.php b/SymfonyRuntime.php index 7eff3f5..aae1fb1 100644 --- a/SymfonyRuntime.php +++ b/SymfonyRuntime.php @@ -163,7 +163,7 @@ public function getRunner(?object $application): RunnerInterface if (!$application->getName() || !$console->has($application->getName())) { $application->setName($_SERVER['argv'][0]); - if (!method_exists($console, 'addCommand') || (new \ReflectionMethod($console, 'add'))->getDeclaringClass()->getName() !== (new \ReflectionMethod($console, 'addCommand'))->getDeclaringClass()->getName()) { + if (!method_exists($console, 'addCommand') || method_exists($console, 'add') && (new \ReflectionMethod($console, 'add'))->getDeclaringClass()->getName() !== (new \ReflectionMethod($console, 'addCommand'))->getDeclaringClass()->getName()) { $console->add($application); } else { $console->addCommand($application);