#46227 [Opn]: wrong initial pointer for CachingIterator and RecursiveCachingIterator
ID: 46227
Updated by: felipe@php.net
Reported By: exceptione at hotmail dot com
Status: Open
Bug Type: SPL related
Operating System: windos XP sp3
PHP Version: 5.2.6
New Comment:
That looks like #44063
Previous Comments:
------------------------------------------------------------------------
[2008-10-04 14:57:34] exceptione at hotmail dot com
Note that one get get the expected behaviour from the implementation in
ext\spl\internal\cachingiterator.inc after correcting the following bugs
in that file:
add private $flags as class member
on line 50 change flags into $flags
on line 50 delete CIT_ prefix
------------------------------------------------------------------------
[2008-10-04 14:52:05] exceptione at hotmail dot com
Description:
------------
In order to use a new CachingIterator of RecursiveCachingIterator, one
needs to do a rewind() or next() to get current() pointing to the first
element. This is unlike the other Iterators.
Reproduce code:
---------------
$arr = array(1,2,3,4,5);
$it = new CachingIterator(new ArrayIterator($arr));
var_dump($it->current()); echo PHP_EOL;
$it->next();
var_dump($it->current()); echo PHP_EOL;
Expected result:
----------------
int 1
int 2
Actual result:
--------------
null
int 1
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=46227&edit=1
Thread (9 messages)