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
 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 27 15:01:29 2024 UTC