File tree 3 files changed +17
-6
lines changed
3 files changed +17
-6
lines changed Original file line number Diff line number Diff line change @@ -739,7 +739,11 @@ impl<'a> Iter<'a> {
739
739
)
740
740
} ;
741
741
742
- if key_type == -1 {
742
+ // Key type `-1` is ???
743
+ // Key type `1` is string
744
+ // Key type `2` is long
745
+ // Key type `3` is null meaning the end of the array
746
+ if key_type == -1 || key_type == 3 {
743
747
return None ;
744
748
}
745
749
@@ -753,10 +757,16 @@ impl<'a> Iter<'a> {
753
757
) ;
754
758
}
755
759
let value = unsafe {
756
- & * zend_hash_get_current_data_ex (
760
+ let val_ptr = zend_hash_get_current_data_ex (
757
761
self . ht as * const ZendHashTable as * mut ZendHashTable ,
758
762
& mut self . pos as * mut HashPosition ,
759
- )
763
+ ) ;
764
+
765
+ if val_ptr. is_null ( ) {
766
+ return None ;
767
+ }
768
+
769
+ & * val_ptr
760
770
} ;
761
771
762
772
if !key. is_long ( ) && !key. is_string ( ) {
Original file line number Diff line number Diff line change 3
3
require ('_utils.php ' );
4
4
5
5
// Tests sequential arrays
6
- $ array = test_array (['a ' , 'b ' , 'c ' ]);
6
+ $ array = test_array (['a ' , 'b ' , 'c ' , 'd ' ]);
7
+ unset($ array [2 ]);
7
8
8
9
assert (is_array ($ array ));
9
10
assert (count ($ array ) === 3 );
10
11
assert (in_array ('a ' , $ array ));
11
12
assert (in_array ('b ' , $ array ));
12
- assert (in_array ('c ' , $ array ));
13
+ assert (in_array ('d ' , $ array ));
13
14
14
15
// Tests associative arrays
15
16
$ assoc = test_array_assoc ([
Original file line number Diff line number Diff line change 1
1
#[ test]
2
- fn binary_works ( ) {
2
+ fn array_works ( ) {
3
3
assert ! ( crate :: integration:: run_php( "array.php" ) ) ;
4
4
}
You can’t perform that action at this time.
0 commit comments