Skip to content

Commit e1bb8b3

Browse files
Merge branch '4.4' into 5.0
* 4.4: 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 add note about HTTP status code change Migrate server:log command away from WebServerBundle [DependencyInjection][CheckTypeDeclarationsPass] Handle \Closure for callable [Security] Fix missing defaults for auto-migrating encoders bumped Symfony version to 4.4.3 updated VERSION for 4.4.2 updated CHANGELOG for 4.4.2
2 parents fe6e3cd + 77ebcb5 commit e1bb8b3

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
@@ -648,8 +648,13 @@ public function find(string $name)
648648
// filter out aliases for commands which are already on the list
649649
if (\count($commands) > 1) {
650650
$commandList = $this->commandLoader ? array_merge(array_flip($this->commandLoader->getNames()), $this->commands) : $this->commands;
651-
$commands = array_unique(array_filter($commands, function ($nameOrAlias) use ($commandList, $commands, &$aliases) {
652-
$commandName = $commandList[$nameOrAlias] instanceof Command ? $commandList[$nameOrAlias]->getName() : $nameOrAlias;
651+
$commands = array_unique(array_filter($commands, function ($nameOrAlias) use (&$commandList, $commands, &$aliases) {
652+
if (!$commandList[$nameOrAlias] instanceof Command) {
653+
$commandList[$nameOrAlias] = $this->commandLoader->get($nameOrAlias);
654+
}
655+
656+
$commandName = $commandList[$nameOrAlias]->getName();
657+
653658
$aliases[$nameOrAlias] = $commandName;
654659

655660
return $commandName === $nameOrAlias || !\in_array($commandName, $commands);
@@ -664,10 +669,6 @@ public function find(string $name)
664669
$maxLen = max(Helper::strlen($abbrev), $maxLen);
665670
}
666671
$abbrevs = array_map(function ($cmd) use ($commandList, $usableWidth, $maxLen, &$commands) {
667-
if (!$commandList[$cmd] instanceof Command) {
668-
$commandList[$cmd] = $this->commandLoader->get($cmd);
669-
}
670-
671672
if ($commandList[$cmd]->isHidden()) {
672673
unset($commands[array_search($cmd, $commands)]);
673674

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)