mirror of
https://github.com/php/php-src.git
synced 2024-09-21 18:07:23 +00:00
d653646841
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
27 lines
375 B
PHP
27 lines
375 B
PHP
--TEST--
|
|
GH-13178: Unsetting last offset must floor iterator position
|
|
--FILE--
|
|
<?php
|
|
$array = [100 => 'foo'];
|
|
foreach ($array as $key => &$value) {
|
|
var_dump($key);
|
|
unset($array[$key]);
|
|
$array[] = 'foo';
|
|
if ($key === 110) {
|
|
break;
|
|
}
|
|
}
|
|
?>
|
|
--EXPECT--
|
|
int(100)
|
|
int(101)
|
|
int(102)
|
|
int(103)
|
|
int(104)
|
|
int(105)
|
|
int(106)
|
|
int(107)
|
|
int(108)
|
|
int(109)
|
|
int(110)
|