From: sixd Operating system: Linux PHP version: 5.4Git-2012-12-21 (Git) Package: SPL related Bug Type: Bug Bug description:SPL InfiniteIterator needs explicit rewind to be usable in a closure
Description: ------------ SPL's InfiniteIterator returns NULL for the first access, unless used in a 'foreach' loop, or a rewind is done. This means that an explicit rewind is needed before an InfiniteIterator can be safely be used in an application. Test script: --------------- <?php $b = array('one', 'two', 'three'); $b_it = new InfiniteIterator(new ArrayIterator($b)); for ($i = 0; $i < 7; $i++) { var_dump($b_it->current()); $b_it->next(); } ?> Expected result: ---------------- string(3) "one" string(3) "two" string(5) "three" string(3) "one" string(3) "two" string(5) "three" string(3) "one" Actual result: -------------- NULL string(3) "two" string(5) "three" string(3) "one" string(3) "two" string(5) "three" string(3) "one" -- Edit bug report at https://bugs.php.net/bug.php?id=63823&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=63823&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=63823&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=63823&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=63823&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=63823&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=63823&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=63823&r=needscript Try newer version: https://bugs.php.net/fix.php?id=63823&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=63823&r=support Expected behavior: https://bugs.php.net/fix.php?id=63823&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=63823&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=63823&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=63823&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=63823&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=63823&r=dst IIS Stability: https://bugs.php.net/fix.php?id=63823&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=63823&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=63823&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=63823&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=63823&r=mysqlcfg