|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2008-04-21 12:52 UTC] 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
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 22:00:01 2025 UTC |
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. [marcus@zaphod 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 [marcus@zaphod php-cvs]$ php --rc ArrayAccess make: `sapi/cli/php' is up to date. Interface [ <internal> interface ArrayAccess ] { ....