Skip to content

Commit 77ebcb5

Browse files
Merge branch '4.3' into 4.4
* 4.3: Fixed #35084 Add missing use statement [HttpClient] fix scheduling pending NativeResponse do not overwrite variable value [Profiler] wording Use spaces correctly to display options in DebugCommand X-Accel Nginx URL updated ticket-30197 [Validator] Add the missing translations for the Chinese (Taiwan) ("zh_TW") locale Fixed test added in #35022 Use locale_parse for computing fallback locales [Console] Fix filtering out identical alternatives when there is a command loader
2 parents 8243771 + f1cae5e commit 77ebcb5

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

Application.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -673,8 +673,13 @@ public function find($name)
673673
// filter out aliases for commands which are already on the list
674674
if (\count($commands) > 1) {
675675
$commandList = $this->commandLoader ? array_merge(array_flip($this->commandLoader->getNames()), $this->commands) : $this->commands;
676-
$commands = array_unique(array_filter($commands, function ($nameOrAlias) use ($commandList, $commands, &$aliases) {
677-
$commandName = $commandList[$nameOrAlias] instanceof Command ? $commandList[$nameOrAlias]->getName() : $nameOrAlias;
676+
$commands = array_unique(array_filter($commands, function ($nameOrAlias) use (&$commandList, $commands, &$aliases) {
677+
if (!$commandList[$nameOrAlias] instanceof Command) {
678+
$commandList[$nameOrAlias] = $this->commandLoader->get($nameOrAlias);
679+
}
680+
681+
$commandName = $commandList[$nameOrAlias]->getName();
682+
678683
$aliases[$nameOrAlias] = $commandName;
679684

680685
return $commandName === $nameOrAlias || !\in_array($commandName, $commands);
@@ -689,10 +694,6 @@ public function find($name)
689694
$maxLen = max(Helper::strlen($abbrev), $maxLen);
690695
}
691696
$abbrevs = array_map(function ($cmd) use ($commandList, $usableWidth, $maxLen, &$commands) {
692-
if (!$commandList[$cmd] instanceof Command) {
693-
$commandList[$cmd] = $this->commandLoader->get($cmd);
694-
}
695-
696697
if ($commandList[$cmd]->isHidden()) {
697698
unset($commands[array_search($cmd, $commands)]);
698699

Tests/ApplicationTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,9 @@ public function testFindAlternativeCommandsWithAnAlias()
626626
$fooCommand->setAliases(['foo2']);
627627

628628
$application = new Application();
629+
$application->setCommandLoader(new FactoryCommandLoader([
630+
'foo3' => static function () use ($fooCommand) { return $fooCommand; },
631+
]));
629632
$application->add($fooCommand);
630633

631634
$result = $application->find('foo');

0 commit comments

Comments
 (0)