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
Description
Console Application::get() method could return null with undefined index notice when command loader is used but command name key does not match name or aliases from command object.
Possible Solution
After command is obtained from command loader in Application::has(), assert that command is actually present in $this->commands.
I believe proper approach would be to raise an error when this occurs.
Ideally, application would transparently decorate command loader and decorator will then handle assertions that command object has matching name or alias:
…e 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
Symfony version(s) affected: 5.1.4
Description
Console
Application::get()
method could return null with undefined index notice when command loader is used but command name key does not match name or aliases from command object.Application::find()
is affected too because ofsymfony/src/Symfony/Component/Console/Application.php
Lines 645 to 647 in d6468a9
How to reproduce
Possible Solution
After command is obtained from command loader in
Application::has()
, assert that command is actually present in$this->commands
.I believe proper approach would be to raise an error when this occurs.
Ideally, application would transparently decorate command loader and decorator will then handle assertions that command object has matching name or alias:
Additional context
Command is loaded in
has()
symfony/src/Symfony/Component/Console/Application.php
Lines 552 to 556 in d6468a9
The text was updated successfully, but these errors were encountered: