Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 59ad6c2

Browse filesBrowse files
[Console] allow Command::getName() to return null
1 parent 593ec61 commit 59ad6c2
Copy full SHA for 59ad6c2

File tree

2 files changed

+6
-5
lines changed
Filter options

2 files changed

+6
-5
lines changed

‎src/Symfony/Component/Console/Application.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Application.php
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
use Symfony\Component\Console\Event\ConsoleTerminateEvent;
2222
use Symfony\Component\Console\Exception\CommandNotFoundException;
2323
use Symfony\Component\Console\Exception\ExceptionInterface;
24+
use Symfony\Component\Console\Exception\LogicException;
2425
use Symfony\Component\Console\Formatter\OutputFormatter;
2526
use Symfony\Component\Console\Helper\DebugFormatterHelper;
2627
use Symfony\Component\Console\Helper\FormatterHelper;
@@ -459,6 +460,10 @@ public function add(Command $command)
459460
// Will throw if the command is not correctly initialized.
460461
$command->getDefinition();
461462

463+
if (!$command->getName()) {
464+
throw new LogicException(sprintf('The command defined in "%s" cannot have an empty name.', \get_class($command)));
465+
}
466+
462467
$this->commands[$command->getName()] = $command;
463468

464469
foreach ($command->getAliases() as $alias) {

‎src/Symfony/Component/Console/Command/Command.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Command/Command.php
+1-5Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -453,14 +453,10 @@ public function setProcessTitle($title)
453453
/**
454454
* Returns the command name.
455455
*
456-
* @return string The command name
456+
* @return string|null
457457
*/
458458
public function getName()
459459
{
460-
if (!$this->name) {
461-
throw new LogicException(sprintf('The command defined in "%s" cannot have an empty name.', \get_class($this)));
462-
}
463-
464460
return $this->name;
465461
}
466462

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.