Bug #80917 [NEW]: LimitIterator does not end at count
From: alexandreparent_dev at outlook dot com
Operating system: All
PHP version: Irrelevant
Package: SPL related
Bug Type: Bug
Bug description:LimitIterator does not end at count
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
--
Edit bug report at https://bugs.php.net/bug.php?id=80917&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=80917&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=80917&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=80917&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=80917&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=80917&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=80917&r=support
Expected behavior: https://bugs.php.net/fix.php?id=80917&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=80917&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=80917&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=80917&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=80917&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=80917&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=80917&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=80917&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=80917&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=80917&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=80917&r=mysqlcfg
Thread (6 messages)
- alexandreparent_dev at outlook dot com