8000 [Console] Fix commands description with numeric namespaces · symfony/symfony@2ef5028 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2ef5028

Browse files
committed
[Console] Fix commands description with numeric namespaces
1 parent 9151698 commit 2ef5028

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

src/Symfony/Component/Console/Descriptor/ApplicationDescription.php

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -129,23 +129,29 @@ private function sortCommands(array $commands)
129129
{
130130
$namespacedCommands = [];
131131
$globalCommands = [];
132+
$sortedCommands = [];
132133
foreach ($commands as $name => $command) {
133134
$key = $this->application->extractNamespace($name, 1);
134-
if (!$key) {
135-
$globalCommands['_global'][$name] = $command;
135+
if (\in_array($key, ['', self::GLOBAL_NAMESPACE], true)) {
136+
$globalCommands[$name] = $command;
136137
} else {
137138
$namespacedCommands[$key][$name] = $command;
138139
}
139140
}
140-
ksort($namespacedCommands);
141-
$namespacedCommands = array_merge($globalCommands, $namespacedCommands);
142141

143-
foreach ($namespacedCommands as &$commandsSet) {
144-
ksort($commandsSet);
142+
if ($globalCommands) {
143+
ksort($globalCommands);
144+
$sortedCommands[self::GLOBAL_NAMESPACE] = $globalCommands;
145145
}
146-
// unset reference to keep scope clear
147-
unset($commandsSet);
148146

149-
return $namespacedCommands;
147+
if ($namespacedCommands) {
148+
ksort($namespacedCommands);
149+
foreach ($namespacedCommands as $key => $commandsSet) {
150+
ksort($commandsSet);
151+
$sortedCommands[$key] = $commandsSet;
152+
}
153+
}
154+
155+
return $sortedCommands;
150156
}
151157
}

0 commit comments

Comments
 (0)
0