Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit59ad6c2

Browse files
[Console] allow Command::getName() to return null
1 parent593ec61 commit59ad6c2

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
useSymfony\Component\Console\Event\ConsoleTerminateEvent;
2222
useSymfony\Component\Console\Exception\CommandNotFoundException;
2323
useSymfony\Component\Console\Exception\ExceptionInterface;
24+
useSymfony\Component\Console\Exception\LogicException;
2425
useSymfony\Component\Console\Formatter\OutputFormatter;
2526
useSymfony\Component\Console\Helper\DebugFormatterHelper;
2627
useSymfony\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+
thrownewLogicException(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‎

Lines 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
publicfunctiongetName()
459459
{
460-
if (!$this->name) {
461-
thrownewLogicException(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)

[8]ページ先頭

©2009-2025 Movatter.jp