|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2004-04-22 22:15 UTC] helly@php.net
[2004-04-25 13:14 UTC] helly@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 13 08:00:02 2025 UTC |
Description: ------------ It seems that ArrayObject should implement ArrayAccess given that it already implements Traversable. For me to know if a given variable can be accessed with the [] operator, I need to do: if (is_array($obj) || $obj instanceof ArrayAccess || $obj instanceof ArrayObject) { } Reproduce code: --------------- function array_check($obj) { if (is_array($obj)) { print "Is an array()<br />\n"; } if ($obj instanceof ArrayAccess) { print "Implements ArrayAccess<br />\n"; } if ($obj instanceof ArrayObject) { print "Is an instance of ArrayObject<br />\n"; } } array_check(new ArrayObject(array())); Expected result: ---------------- Implements ArrayAccess Is an instance of ArrayObject Actual result: -------------- Is an instance of ArrayObject