Skip to content

Commit 48985d1

Browse files
committed
Match expected functionality
1 parent bfb2740 commit 48985d1

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/Arrays/Arr.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -1438,11 +1438,15 @@ public static function intersect_key_recursive( array $array, array ...$arrays )
14381438

14391439
$arrays_to_intersect = [];
14401440
foreach ( $arrays as $intersect_array ) {
1441-
if ( ! isset( $intersect_array[ $key ] ) || ! is_array( $intersect_array[ $key ] ) ) {
1441+
if ( ! isset( $intersect_array[ $key ] ) ) {
14421442
unset( $array[ $key ] );
14431443
continue 2;
14441444
}
14451445

1446+
if ( ! is_array( $intersect_array[ $key ] ) ) {
1447+
continue;
1448+
}
1449+
14461450
$arrays_to_intersect[] = $intersect_array[ $key ];
14471451
}
14481452

tests/wpunit/IntersectKeyRecursiveTest.php

+4
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,10 @@ public function test_with_multiple_arrays(): void {
248248
'a' => 1,
249249
'b' => 2,
250250
],
251+
'z' => [
252+
'a' => 1,
253+
'b' => 2,
254+
],
251255
],
252256
], $result );
253257
}

0 commit comments

Comments
 (0)