You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/bundle/Core/Command/DebugConfigResolverCommand.php
+9-7Lines changed: 9 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -111,16 +111,18 @@ protected function execute(InputInterface $input, OutputInterface $output): int
111
111
112
112
if (null !== $sort && !empty($parameterData)) {
113
113
if (!is_array($parameterData)) {
114
-
thrownewInvalidArgumentException('--sort', "'$parameter' isn't a list. Sort can be used only on list.");
114
+
thrownewInvalidArgumentException('--sort', "'$parameter' isn't a list. Sort can be used only on a list.");
115
115
}
116
116
if (!array_is_list($parameterData)) {
117
-
thrownewInvalidArgumentException('--sort', "'$parameter' is a hash or an object. Sort can be used only on list.");
117
+
thrownewInvalidArgumentException('--sort', "'$parameter' is a hash but sort can be used only on a list (an array with numeral keys incremented from zero).");
118
118
}
119
-
if (!array_key_exists($sort, $parameterData[0])) {
120
-
thrownewInvalidArgumentException('--sort', "'$sort' property doesn't exist on '$parameter' list items.");
121
-
}
122
-
if (!is_scalar($parameterData[0][$sort])) {
123
-
thrownewInvalidArgumentException('--sort', "'{$parameter}[n][{$sort}]' properties aren't scalar and can't be sorted.");
119
+
for ($i=0, $count = count($parameterData); $i < $count; $i++) {
120
+
if (!array_key_exists($sort, $parameterData[$i])) {
121
+
thrownewInvalidArgumentException('--sort', "'$sort' property doesn't exist on each '$parameter' list item.");
122
+
}
123
+
if (!is_scalar($parameterData[$i][$sort])) {
124
+
thrownewInvalidArgumentException('--sort', "'$sort' properties aren't always scalar and can't be sorted.");
125
+
}
124
126
}
125
127
if ($input->getOption('reverse-sort')) {
126
128
usort($parameterData, staticfn (array$a, array$b): int => $b[$sort] <=> $a[$sort]);
0 commit comments