Skip to content

Commit 1c364a7

Browse files
committed
fix(support): validate intermediate types in get_by_key()
1 parent b3792b9 commit 1c364a7

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

packages/support/src/Arr/functions.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ function combine(iterable $array, iterable $values): array
518518

519519
if (count($array) !== count($values)) {
520520
throw new InvalidArgumentException(
521-
sprintf('Cannot combine arrays of different lengths (%d keys vs %d values)', count($array), count($values))
521+
sprintf('Cannot combine arrays of different lengths (%d keys vs %d values)', count($array), count($values)),
522522
);
523523
}
524524

@@ -798,6 +798,10 @@ function get_by_key(iterable $array, int|string $key, mixed $default = null): mi
798798
: explode('.', $key);
799799

800800
foreach ($keys as $key) {
801+
if (! is_array($value) && ! $value instanceof \ArrayAccess) {
802+
return $default;
803+
}
804+
801805
if (! isset($value[$key])) {
802806
return $default;
803807
}

0 commit comments

Comments
 (0)