xref: /PHP-7.3/Zend/tests/bug71154.phpt (revision 6a4c02e1)
1--TEST--
2Bug #71154: Incorrect HT iterator invalidation causes iterator reuse
3--FILE--
4<?php
5
6$array = [1, 2, 3];
7foreach ($array as &$ref) {
8    /* Free array, causing free of iterator */
9    $array = [];
10    /* Reuse the iterator.
11     * However it will also be reused on next foreach iteration */
12    $it = new ArrayIterator([1, 2, 3]);
13    $it->rewind();
14}
15var_dump($it->current());
16
17?>
18--EXPECT--
19int(1)
20