|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits              [2021-03-29 20:11 UTC] alexandreparent_dev at outlook dot com
  [2021-03-29 20:19 UTC] levim@php.net
  [2021-03-29 20:20 UTC] levim@php.net
 
-Status: Open
+Status: Feedback
  [2021-03-29 20:36 UTC] levim@php.net
 
-Status: Feedback
+Status: Open
  [2021-03-29 20:36 UTC] levim@php.net
  [2021-03-30 10:18 UTC] rowan dot collins at gmail dot com
 | |||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 04:00:01 2025 UTC | 
Description: ------------ LimitIterator will try to iterate beyond $count. If its inner iterator never yield another item nor return, the LimitIterator will not limit at the expected count. Test script: --------------- <?php function generator(): iterable { $count = 0; while (true) { yield $count++; echo 'Yielded: ', $count - 1, \PHP_EOL; if ($count > 2) { while(true); } } } foreach (new \LimitIterator($generator(), 0, 3) as $count) { echo 'Iterating: ', $count, \PHP_EOL; } Expected result: ---------------- Iterating: 0 Yielded: 0 Iterating: 1 Yielded: 1 Iterating: 2 Yielded: 2 // Hanging here Actual result: -------------- Iterating: 0 Yielded: 0 Iterating: 1 Yielded: 1 Iterating: 2 // Exiting here