PHP :: Bug #28099 :: ArrayObject doesn't implement ArrayAccess
| Bug #28099 | ArrayObject doesn't implement ArrayAccess | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Submitted: | 2004-04-21 21:38 UTC | Modified: | 2004-04-25 13:14 UTC |
|
||||||||||
| From: | wast33d at hotmail dot com | Assigned: | helly (profile) | |||||||||||
| Status: | Closed | Package: | Class/Object related | |||||||||||
| PHP Version: | 5.0.0RC2 | OS: | * | |||||||||||
| Private report: | No | CVE-ID: | None | |||||||||||
[2004-04-21 21:38 UTC] wast33d at hotmail dot com
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
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2004-04-25 13:14 UTC] helly@php.net