ID: 47497 Updated by: johan...@php.net Reported By: doctorrock83 at gmail dot com -Status: Verified +Status: Bogus Bug Type: SPL related Operating System: * PHP Version: 5.*, 6CVS (2009-04-30) New Comment:
You have to call $cache->rewind(); first else the iterator in in a not defined state. Previous Comments: ------------------------------------------------------------------------ [2009-02-24 16:34:31] doctorrock83 at gmail dot com "Expected result" is 'a' and TRUE and not 1 and TRUE as you might have guessed ------------------------------------------------------------------------ [2009-02-24 16:31:36] doctorrock83 at gmail dot com Description: ------------ CachingIterator doesn't work if its innerIterator is an instance of IteratorIterator. The use-case provided here might seem strange as the IteratorIterator is not necessary. However, it would become necessary for a use case dealing with a Traversable class such as PDOStatement, and the bug stays the same. Additionnaly, we actually have to call next() manually but it should be called internaly. This leads to another bug which has already been reported at #46227 Reproduce code: --------------- $it = new ArrayIterator(range('a','z'); $cache = new CachingIterator(new IteratorIterator($it)); $cache->next(); var_dump($cache->current()); var_dump($cache->hasNext()); Expected result: ---------------- 1 and TRUE Actual result: -------------- NULL and FALSE ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=47497&edit=1