Skip to content

Commit f1cae5e

Browse files
Merge branch '3.4' into 4.3
* 3.4: Add missing use statement [Profiler] wording 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 354a2f2 + 62c4b96 commit f1cae5e

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
@@ -663,8 +663,13 @@ public function find($name)
663663
// filter out aliases for commands which are already on the list
664664
if (\count($commands) > 1) {
665665
$commandList = $this->commandLoader ? array_merge(array_flip($this->commandLoader->getNames()), $this->commands) : $this->commands;
666-
$commands = array_unique(array_filter($commands, function ($nameOrAlias) use ($commandList, $commands, &$aliases) {
667-
$commandName = $commandList[$nameOrAlias] instanceof Command ? $commandList[$nameOrAlias]->getName() : $nameOrAlias;
666+
$commands = array_unique(array_filter($commands, function ($nameOrAlias) use (&$commandList, $commands, &$aliases) {
667+
if (!$commandList[$nameOrAlias] instanceof Command) {
668+
$commandList[$nameOrAlias] = $this->commandLoader->get($nameOrAlias);
669+
}
670+
671+
$commandName = $commandList[$nameOrAlias]->getName();
672+
668673
$aliases[$nameOrAlias] = $commandName;
669674

670675
return $commandName === $nameOrAlias || !\in_array($commandName, $commands);
@@ -680,10 +685,6 @@ public function find($name)
680685
$maxLen = max(Helper::strlen($abbrev), $maxLen);
681686
}
682687
$abbrevs = array_map(function ($cmd) use ($commandList, $usableWidth, $maxLen) {
683-
if (!$commandList[$cmd] instanceof Command) {
684-
$commandList[$cmd] = $this->commandLoader->get($cmd);
685-
}
686-
687688
if ($commandList[$cmd]->isHidden()) {
688689
return false;
689690
}

Tests/ApplicationTest.php

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

617617
$application = new Application();
618+
$application->setCommandLoader(new FactoryCommandLoader([
619+
'foo3' => static function () use ($fooCommand) { return $fooCommand; },
620+
]));
618621
$application->add($fooCommand);
619622

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

0 commit comments

Comments
 (0)