|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2015-12-17 21:21 UTC] nikic@php.net
[2015-12-17 21:21 UTC] nikic@php.net
-Status: Open
+Status: Closed
[2016-07-20 11:34 UTC] davey@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 19:00:01 2025 UTC |
Description: ------------ When iterators are removed on HT destruction we NULL out iter->ht entries. This will allow the iter to be reused. However it may still be in use by the foreach loop. In this case one iter will be shared between two loops/iterators. Test script: --------------- <?php $array = [1, 2, 3]; foreach ($array as &$ref) { /* Free array, causing free of iterator */ $array = []; /* Reuse the iterator. * However it will also be reused on next foreach iteration */ $it = new ArrayIterator([1, 2, 3]); $it->rewind(); } var_dump($it->current()); Expected result: ---------------- int(1) Actual result: -------------- NULL