File tree Expand file tree Collapse file tree 2 files changed +6
-5
lines changed
src/Symfony/Component/Console Expand file tree Collapse file tree 2 files changed +6
-5
lines changed Original file line number Diff line number Diff line change 21
21
use Symfony \Component \Console \Event \ConsoleTerminateEvent ;
22
22
use Symfony \Component \Console \Exception \CommandNotFoundException ;
23
23
use Symfony \Component \Console \Exception \ExceptionInterface ;
24
+ use Symfony \Component \Console \Exception \LogicException ;
24
25
use Symfony \Component \Console \Formatter \OutputFormatter ;
25
26
use Symfony \Component \Console \Helper \DebugFormatterHelper ;
26
27
use Symfony \Component \Console \Helper \FormatterHelper ;
@@ -459,6 +460,10 @@ public function add(Command $command)
459
460
// Will throw if the command is not correctly initialized.
460
461
$ command ->getDefinition ();
461
462
463
+ if (!$ command ->getName ()) {
464
+ throw new LogicException (sprintf ('The command defined in "%s" cannot have an empty name. ' , \get_class ($ command )));
465
+ }
466
+
462
467
$ this ->commands [$ command ->getName ()] = $ command ;
463
468
464
469
foreach ($ command ->getAliases () as $ alias ) {
Original file line number Diff line number Diff line change @@ -453,14 +453,10 @@ public function setProcessTitle($title)
453
453
/**
454
454
* Returns the command name.
455
455
*
456
- * @return string The command name
456
+ * @return string|null
457
457
*/
458
458
public function getName ()
459
459
{
460
- if (!$ this ->name ) {
461
- throw new LogicException (sprintf ('The command defined in "%s" cannot have an empty name. ' , \get_class ($ this )));
462
- }
463
-
464
460
return $ this ->name ;
465
461
}
466
462
You can’t perform that action at this time.
0 commit comments