mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Previously, when an array was converted from packed to hashed, iterators would not be correctly reset to 0. Similarly, removing the last element from an array would decrease nNumUsed but not actually fix the iterator position, causing the element to be skipped in the next iteration. Some code was also removed that skips over IS_UNDEF elements for nInternalPointer and iterator positions. This is unnecessary, as this already happens during iteration. Closes GH-13178 Closes GH-13188
30 lines
372 B
PHP
30 lines
372 B
PHP
--TEST--
|
|
GH-13178: Packed to hash must reset nInternalPointer
|
|
--FILE--
|
|
<?php
|
|
$array = ['foo'];
|
|
reset($array);
|
|
while (true) {
|
|
$key = key($array);
|
|
next($array);
|
|
var_dump($key);
|
|
unset($array[$key]);
|
|
$array[] = 'foo';
|
|
if ($key === 10) {
|
|
break;
|
|
}
|
|
}
|
|
?>
|
|
--EXPECT--
|
|
int(0)
|
|
int(1)
|
|
int(2)
|
|
int(3)
|
|
int(4)
|
|
int(5)
|
|
int(6)
|
|
int(7)
|
|
int(8)
|
|
int(9)
|
|
int(10)
|