From 59ad6c29d104903e5bcba6c3cd7e20423a97d51b Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 29 Aug 2019 18:09:35 +0200 Subject: [PATCH] [Console] allow Command::getName() to return null --- src/Symfony/Component/Console/Application.php | 5 +++++ src/Symfony/Component/Console/Command/Command.php | 6 +----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Symfony/Component/Console/Application.php b/src/Symfony/Component/Console/Application.php index 9bb0746e404cf..fcdcd908a8981 100644 --- a/src/Symfony/Component/Console/Application.php +++ b/src/Symfony/Component/Console/Application.php @@ -21,6 +21,7 @@ use Symfony\Component\Console\Event\ConsoleTerminateEvent; use Symfony\Component\Console\Exception\CommandNotFoundException; use Symfony\Component\Console\Exception\ExceptionInterface; +use Symfony\Component\Console\Exception\LogicException; use Symfony\Component\Console\Formatter\OutputFormatter; use Symfony\Component\Console\Helper\DebugFormatterHelper; use Symfony\Component\Console\Helper\FormatterHelper; @@ -459,6 +460,10 @@ public function add(Command $command) // Will throw if the command is not correctly initialized. $command->getDefinition(); + if (!$command->getName()) { + throw new LogicException(sprintf('The command defined in "%s" cannot have an empty name.', \get_class($command))); + } + $this->commands[$command->getName()] = $command; foreach ($command->getAliases() as $alias) { diff --git a/src/Symfony/Component/Console/Command/Command.php b/src/Symfony/Component/Console/Command/Command.php index b68c05dedac85..493800b315d92 100644 --- a/src/Symfony/Component/Console/Command/Command.php +++ b/src/Symfony/Component/Console/Command/Command.php @@ -453,14 +453,10 @@ public function setProcessTitle($title) /** * Returns the command name. * - * @return string The command name + * @return string|null */ public function getName() { - if (!$this->name) { - throw new LogicException(sprintf('The command defined in "%s" cannot have an empty name.', \get_class($this))); - } - return $this->name; } pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy