You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
bug #38024 [Console] Fix undefined index for inconsistent command name definition (chalasr)
This PR was merged into the 3.4 branch.
Discussion
----------
[Console] Fix undefined index for inconsistent command name definition
| Q | A
| ------------- | ---
| Branch? | 3.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | Fixes#38015
| License | MIT
| Doc PR | -
The issue happens when the command name is set via construct/setName() and is routed via a command loader under a different name, which causes `Application::get(): Command` to return null (return type violation) with a notice. This makes it throws a proper CommandNotFoundException as expected.
Commits
-------
d59140e Fix undefined index for inconsistent command name definition
Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Application.php
+5Lines changed: 5 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -490,6 +490,11 @@ public function get($name)
490
490
thrownewCommandNotFoundException(sprintf('The command "%s" does not exist.', $name));
491
491
}
492
492
493
+
// When the command has a different name than the one used at the command loader level
494
+
if (!isset($this->commands[$name])) {
495
+
thrownewCommandNotFoundException(sprintf('The "%s" command cannot be found because it is registered under multiple names. Make sure you don\'t set a different name via constructor or "setName()".', $name));
$this->expectExceptionMessage('The "test" command cannot be found because it is registered under multiple names. Make sure you don\'t set a different name via constructor or "setName()".');
0 commit comments