ID:               44793
 Updated by:       [EMAIL PROTECTED]
 Reported By:      matthew at zend dot com
 Status:           Bogus
 Bug Type:         SPL related
-Operating System: Linux (Ubuntu)
+Operating System: *
-PHP Version:      5.2.5
+PHP Version:      5+
 New Comment:

For you rand everybodies education, there are two very useful commands
as shown below. The second shows that ArrayAccess does not implement any
Interface at all. The first shows that ArrayObject and ArrayIterator are
on the same level. Doing 'php --rc ArrayIterator' and 'php --rc
ArrayObject' you will find that the former implement Iterator while as
the second implements IteratorAggregate which in turn does not inherit
Iterator.

[EMAIL PROTECTED] php-cvs]$ php ext/spl/examples/class_tree.php
ArrayAccess
make: `sapi/cli/php' is up to date.
ArrayAccess
|-ArrayIterator
| \-RecursiveArrayIterator (RecursiveIterator)
|   \-SubClasses
|-ArrayObject
|-CachingIterator (ArrayAccess, Countable)
| \-RecursiveCachingIterator (RecursiveIterator)
|-SplDoublyLinkedList
| |-SplQueue
| \-SplStack
\-SplObjectStorage
[EMAIL PROTECTED] php-cvs]$ php --rc ArrayAccess
make: `sapi/cli/php' is up to date.
Interface [ <internal> interface ArrayAccess ] {

....


Previous Comments:
------------------------------------------------------------------------

[2008-04-21 16:12:36] [EMAIL PROTECTED]

Actually, ArrayAccess does not implment ArrayIterator, but vice versa.
ArrayObject therefor does not implement Iterator.

------------------------------------------------------------------------

[2008-04-21 16:07:34] [EMAIL PROTECTED]

Re-opening

------------------------------------------------------------------------

[2008-04-21 16:03:38] matthew at zend dot com

This is a bug in SPL, which is bundled in PHP core; additionally, it
exposes a potential issue with how inheritence is resolved in the
language. Please re-open.

------------------------------------------------------------------------

[2008-04-21 15:51:24] [EMAIL PROTECTED]

Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

class ArrayObject implements IteratorAggregate, Traversable,
ArrayAccess, Serializable, Countable.

Traversable is not the same as Iterator: Traversable allows an object
to be magically iterated by, i.e foreach, while Iterator explicitly
provides userland iteration interface through
next/valid/current/key/rewind.

------------------------------------------------------------------------

[2008-04-21 12:52:27] matthew at zend dot com

Description:
------------
ArrayObject extends ArrayAccess, which implements ArrayIterator and in
turn Iterator. However, when checking to see if a concrete instance of
ArrayObject implements Iterator, the return is false.

Reproduce code:
---------------
$o = new ArrayObject(array());
if ($o instanceof Iterator) {
    echo "Instance of Iterator";
} else {
    echo "Failed";
}

Expected result:
----------------
Instance of Iterator

Actual result:
--------------
Failed


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=44793&edit=1

Reply via email to