Skip to content

Commit e3a3419

Browse files
[Intl] fix
1 parent 8e9e087 commit e3a3419

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

Data/Util/RecursiveArrayAccess.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,23 @@
2020
*/
2121
class RecursiveArrayAccess
2222
{
23-
public static function get(array|\ArrayAccess $array, array $indices)
23+
public static function get(mixed $array, array $indices)
2424
{
2525
foreach ($indices as $index) {
26-
if (\is_array($array) ? !\array_key_exists($index, $array) : !isset($array[$index])) {
27-
throw new OutOfBoundsException(sprintf('The index "%s" does not exist.', $index));
26+
// Use array_key_exists() for arrays, isset() otherwise
27+
if (\is_array($array)) {
28+
if (\array_key_exists($index, $array)) {
29+
$array = $array[$index];
30+
continue;
31+
}
32+
} elseif ($array instanceof \ArrayAccess) {
33+
if (isset($array[$index])) {
34+
$array = $array[$index];
35+
continue;
36+
}
2837
}
2938

30-
$array = $array[$index];
39+
throw new OutOfBoundsException(sprintf('The index "%s" does not exist.', $index));
3140
}
3241

3342
return $array;

0 commit comments

Comments
 (0)