File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -91,6 +91,8 @@ PHP NEWS
9191 INT_MAX instead of truncating it. (marc-mabe)
9292 . Fixed GH-23338 (fsockopen()/pfsockopen() ValueError reported wrong
9393 argument number for $timeout). (lacatoire)
94+ . Fixed bug GH-23576 (Next index for array returned from array_keys() is
95+ wrong). (Lazizbek Ergashev)
9496
9597- SimpleXML:
9698 . Fixed writing to a dimension of the object returned by attributes() not
Original file line number Diff line number Diff line change @@ -4406,7 +4406,7 @@ PHP_FUNCTION(array_keys)
44064406
44074407 /* Base case: empty input */
44084408 if (!elem_count ) {
4409- RETURN_COPY ( input );
4409+ RETURN_EMPTY_ARRAY ( );
44104410 }
44114411
44124412 /* Initialize return array */
Original file line number Diff line number Diff line change 1+ --TEST--
2+ GH-23576 (Next index for array returned from array_keys() is wrong)
3+ --FILE--
4+ <?php
5+ $ a = [123 => 123 ];
6+ unset($ a [123 ]);
7+
8+ $ b = array_keys ($ a );
9+ $ b [] = 42 ;
10+ var_dump ($ b );
11+
12+ $ c = array_keys ($ a , 123 );
13+ $ c [] = 42 ;
14+ var_dump ($ c );
15+
16+ $ d = array_keys ($ a , 123 , true );
17+ $ d [] = 42 ;
18+ var_dump ($ d );
19+
20+ $ e = [];
21+
22+ $ f = array_keys ($ e );
23+ $ f [] = 42 ;
24+ var_dump ($ f );
25+
26+ $ g = array_keys ($ e , 123 );
27+ $ g [] = 42 ;
28+ var_dump ($ g );
29+
30+ $ h = array_keys ($ e , 123 , true );
31+ $ h [] = 42 ;
32+ var_dump ($ h );
33+ ?>
34+ --EXPECT--
35+ array(1) {
36+ [0]=>
37+ int(42)
38+ }
39+ array(1) {
40+ [0]=>
41+ int(42)
42+ }
43+ array(1) {
44+ [0]=>
45+ int(42)
46+ }
47+ array(1) {
48+ [0]=>
49+ int(42)
50+ }
51+ array(1) {
52+ [0]=>
53+ int(42)
54+ }
55+ array(1) {
56+ [0]=>
57+ int(42)
58+ }
You can’t perform that action at this time.
0 commit comments