From bba7e9d70a166889fbf618779b0eb66f7c694b96 Mon Sep 17 00:00:00 2001 From: Andy Thompson Date: Thu, 16 Nov 2017 11:38:13 +0000 Subject: [PATCH] [Console] Allow a command iterator to be added to console app Symfony 3.4/4.0 brings in the ability to use !tagged in service definitions to pass tagged services as a argument. It uses a RewindableGenerator class, so the typehint here doesn't accept it even though it just iterates over the commands. This change will allow a custom console app to be created with a service method call in the definition. The typehint is only available in PHP 7.1+ though, so isn't compatible with Symfony 3.4's targeted PHP versions, but is for 4.0. --- src/Symfony/Component/Console/Application.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Console/Application.php b/src/Symfony/Component/Console/Application.php index 6fe7692d3eed7..8888378e3fc30 100644 --- a/src/Symfony/Component/Console/Application.php +++ b/src/Symfony/Component/Console/Application.php @@ -390,9 +390,9 @@ public function register($name) * * If a Command is not enabled it will not be added. * - * @param Command[] $commands An array of commands + * @param Command[] $commands An array or iterator of commands */ - public function addCommands(array $commands) + public function addCommands(iterable $commands) { foreach ($commands as $command) { $this->add($command);