Skip to content

Commit

Permalink
[Console] Fix commands description with numeric namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
fancyweb committed Nov 7, 2019
1 parent 9151698 commit 2ef5028
Showing 1 changed file with 15 additions and 9 deletions.
Expand Up @@ -129,23 +129,29 @@ private function sortCommands(array $commands)
{
$namespacedCommands = [];
$globalCommands = [];
$sortedCommands = [];
foreach ($commands as $name => $command) {
$key = $this->application->extractNamespace($name, 1);
if (!$key) {
$globalCommands['_global'][$name] = $command;
if (\in_array($key, ['', self::GLOBAL_NAMESPACE], true)) {
$globalCommands[$name] = $command;
} else {
$namespacedCommands[$key][$name] = $command;
}
}
ksort($namespacedCommands);
$namespacedCommands = array_merge($globalCommands, $namespacedCommands);

foreach ($namespacedCommands as &$commandsSet) {
ksort($commandsSet);
if ($globalCommands) {
ksort($globalCommands);
$sortedCommands[self::GLOBAL_NAMESPACE] = $globalCommands;
}
// unset reference to keep scope clear
unset($commandsSet);

return $namespacedCommands;
if ($namespacedCommands) {
ksort($namespacedCommands);
foreach ($namespacedCommands as $key => $commandsSet) {
ksort($commandsSet);
$sortedCommands[$key] = $commandsSet;
}
}

return $sortedCommands;
}
}

0 comments on commit 2ef5028

Please sign in to comment.