php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #28813 ArrayObject should implement IteratorAggregate
Submitted: 2004-06-17 05:39 UTC Modified: 2004-06-17 21:04 UTC
From: nospam0 at malkusch dot de Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 5.0.0RC3 OS: *
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: nospam0 at malkusch dot de
New email:
PHP Version: OS:

 

 [2004-06-17 05:39 UTC] nospam0 at malkusch dot de
Description:
------------
It would be very nice, if the ArrayObject would implement 
IteratorAggregate. The only thing, which must be done, is 
ArrayIterator should implement Iterator, by aliasing 
valid() with hasMore(). 
 
I think it's to confusing to use so many different 
Iterators wich all provides the same functionallity of 
Iterator. So why don't they all extend Iterator? 


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-06-17 09:37 UTC] helly@php.net
1) It does:

php -r 'ReflectionClass::export("ArrayObject");'
Class [ <internal:SPL> <iterateable> class ArrayObject implements IteratorAggregate, Traversable, ArrayAccess ] {
......

2) The base interface for ALL Iterators is Traversable

3) The iterators all serve different purposes.

4) ArrayIterator has a method valid(), otherwise it couldn't implement Iterator:
php -r 'ReflectionClass::export("ArrayIterator");'
Class [ <internal:SPL> <iterateable> class ArrayIterator implements Iterator, Traversable, ArrayAccess, SeekableIterator ] {
.....
    Method [ <internal> public method valid ] {
    }
.....

=> There is obviously nothing to change.
   Next time you file a bug report verify what you propose.
 [2004-06-17 15:15 UTC] nospam0 at malkusch dot de
Yes, when I'm using ReflectionAPI I see that I'm wrong.  
I thaught, that an Iterator must have a hasMore()  
method...But it is the valid() method. I don't know where  
I have that wrong information from.
 [2004-06-17 21:04 UTC] helly@php.net
Most probably from older beta versions where we had
hasMore() instead of valid().
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 15:01:34 2025 UTC