-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Console] Commands with an alias should not be recognized as ambiguous #25407
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Console] Commands with an alias should not be recognized as ambiguous #25407
Conversation
|
||
return $commandName === $nameOrAlias || !in_array($commandName, $commands); | ||
}); | ||
} | ||
|
||
$exact = in_array($name, $commands, true); | ||
if (count($commands) > 1 && !$exact) { | ||
if (count($commands) > 1 && !$exact && !isset($aliases[$name])) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe move the isset to the beginning as it's faster then count? - Micro optimization.
1f1e54c
to
cb9f6ff
Compare
|
||
return $commandName === $nameOrAlias || !in_array($commandName, $commands); | ||
}); | ||
} | ||
|
||
$exact = in_array($name, $commands, true); | ||
if (count($commands) > 1 && !$exact) { | ||
if (!isset($aliases[$name]) && count($commands) > 1 && !$exact) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changing line 537 to $exact = \in_array($name, $commands, true) || isset($aliases[$name]);
would avoid the need for both this check and the condition added below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's better ike this ;). Thanks!
cb9f6ff
to
863f632
Compare
Thank you @Simperfit. |
…as ambiguous (Simperfit) This PR was merged into the 2.7 branch. Discussion ---------- [Console] Commands with an alias should not be recognized as ambiguous | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no <!-- don't forget to update src/**/CHANGELOG.md files --> | BC breaks? | no | Deprecations? | no <!-- don't forget to update UPGRADE-*.md files --> | Tests pass? | no | Fixed tickets | no <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | When having two commands with the same starting name and an alias equal to the starting name, we should not have an ambiguous error because we are setting the alias. Commits ------- 863f632 [Console] Commands with an alias should not be recognized as ambiguous
When having two commands with the same starting name and an alias equal to the starting name, we should not have an ambiguous error because we are setting the alias.