File tree
2 files changed
+68
-9
lines changed- src/Symfony/Component/Console
- Descriptor
- Tests/Descriptor
2 files changed
+68
-9
lines changedLines changed: 15 additions & 9 deletions
@@ -129,23 +129,29 @@ private function sortCommands(array $commands)
129
129
{
130
130
$namespacedCommands = [];
131
131
$globalCommands = [];
132
+ $sortedCommands = [];
132
133
foreach ($commands as $name => $command) {
133
134
$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;
136
137
} else {
137
138
$namespacedCommands[$key][$name] = $command;
138
139
}
139
140
}
140
- ksort($namespacedCommands);
141
- $namespacedCommands = array_merge($globalCommands, $namespacedCommands);
142
141
143
- foreach ($namespacedCommands as &$commandsSet) {
144
- ksort($commandsSet);
142
+ if ($globalCommands) {
143
+ ksort($globalCommands);
144
+ $sortedCommands[self::GLOBAL_NAMESPACE] = $globalCommands;
145
145
}
146
- // unset reference to keep scope clear
147
- unset($commandsSet);
148
146
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;
150
156
}
151
157
}
Lines changed: 53 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
| 1 | + | |
| 2 |
10000
+ | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + |
0 commit comments