php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #49556 OuterIterator(s) don't point to the first element
Submitted: 2009-09-14 22:26 UTC Modified: 2009-09-15 06:12 UTC
From: adrien dot gibrat at gmail dot com Assigned:
Status: Not a bug Package: SPL related
PHP Version: 5.2.10 OS: *
Private report: No CVE-ID: None
 [2009-09-14 22:26 UTC] adrien dot gibrat at gmail dot com
Description:
------------
Classes implementig OuterIterator don't point to the first
element just after instanciation, unlike the other Iterators.

I'm sure this is the same problem that authors of the following bug reports are talking about 
http://bugs.php.net/bug.php?id=36132 (bogus)
http://bugs.php.net/bug.php?id=44063 (bogus)
http://bugs.php.net/bug.php?id=47497 (bogus)
http://bugs.php.net/bug.php?id=46227 (assigned but nothing appends)

The implementations in .inc from ext\spl\internal works as expected... but not the actual C code!

Reproduce code:
---------------
$a = new ArrayIterator(range('a','z'));
var_dump($a->current());
$ii = new IteratorIterator($a);
var_dump($ii->current());
$ca = new CachingIterator($a);
var_dump($ca->current());
$ai = new AppendIterator($a);
var_dump($ai->current());
$ni = new InfiniteIterator($a);
var_dump($ni->current());
$li = new LimitIterator($a);
var_dump($li->current());

Expected result:
----------------
string(1) "a"
string(1) "a"
string(1) "a"
string(1) "a"
string(1) "a"
string(1) "a"


Actual result:
--------------
string(1) "a"
NULL
NULL
NULL
NULL
NULL


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-09-15 06:12 UTC] jani@php.net
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. 

Thank you for your interest in PHP.

Just add comments to bug #46227 since it's the same issue.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 02 22:01:30 2024 UTC