Skip to content

Commit b3792b9

Browse files
committed
fix(support): validate array lengths in combine()
1 parent dac877d commit b3792b9

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

packages/support/src/Arr/functions.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,12 @@ function combine(iterable $array, iterable $values): array
516516
$array = to_array($array);
517517
$values = to_array($values);
518518

519+
if (count($array) !== count($values)) {
520+
throw new InvalidArgumentException(
521+
sprintf('Cannot combine arrays of different lengths (%d keys vs %d values)', count($array), count($values))
522+
);
523+
}
524+
519525
return array_combine($array, $values);
520526
}
521527

0 commit comments

Comments
 (0)