|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36132 CachingIterator do not work well
Submitted: 2006-01-23 09:51 UTC Modified: 2006-01-24 14:35 UTC
From: quick_defect at yahoo dot com Assigned: helly (profile)
Status: Not a bug Package: SPL related
PHP Version: 5.1.2 OS: *
Private report: No CVE-ID: None
 [2006-01-23 09:51 UTC] quick_defect at yahoo dot com
I know I did not use the rewind function as usual. But after I did so, the behavior of Iterator seemed went wrong.

Reproduce code:
$ary_obj=new ArrayObject($ary);
$c_ite=new CachingIterator($ite);


echo "*******\n";

Expected result:
string(1) "1"
string(1) "2"
string(1) "1"
string(1) "2"

Actual result:
string(1) "2"
string(1) "1"
string(1) "1"
string(1) "2"


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-01-23 10:00 UTC]
Assigned to the maintainer.
 [2006-01-23 10:08 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

Don't try to outsmart them and still expect them to work correct. The code you presented works exactly as you told it to.
 [2006-01-23 10:30 UTC] quick_defect at yahoo dot com
So you mean a CachingIterator can take more elements than the Iterator it cached? I can understand that the CachingIterator just caches Iterator for 1 element. As you know, there are not any documents for them. So would you PLS to illustrate this?
 [2006-01-23 10:51 UTC]
Just trust what the author of the code says.
 [2006-01-24 06:13 UTC] quick_defect at yahoo dot com
A tester will never trust a developer's words, we trust manuals and actual results:) I do that for the better of php. But I will not update the status of this defect again. Because there are no documents for SPL functions, it is really difficult to determain a defect. 
helly: From your website,CachingIterator "point" to exactly the next element of the Iterator being cached. So I still think it mis-behaved after two times of rewind.
 [2006-01-24 14:35 UTC]
SPL documentation is at 
(as linked from most classes are also 
avialable in form of an PHP implementation at 
php-src/ext/spl/internal/ in PHP Source distribution or 
CVS. And I trust the implementation only :-) 
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Thu Oct 18 12:01:25 2018 UTC