Hello, On Tue, Dec 29, 2009 at 12:04 AM, Clint Priest <cpri...@warpmail.net> wrote: > Unfortunately $x instanceOf ArrayAccess doesn't return true when $x is > indeed an array.
Making is_array return true for objects implementing ArrayAccess is a bad idea, for two main reasons: 1) is_array is a type check, and we should still be able to distinguish real arrays from objects 2) ArrayAccess does not guarantee that an object will behave like an array, (e.g. you won't be able to use sort() on an object implementing ArrayAccess. If, in your case, you want to accept both arrays and ArrayAccess objects, I guess if (is_array($v) || $v instanceof ArrayAccess) is a sufficiently good way to check. Best, > > Jille Timmermans wrote: >> >> Op 28-12-2009 17:30, Clint Priest schreef: >>> >>> Has there been any discussion or decision about whether is_array() >>> should return true for objects which implement ArrayAccess or is there >>> another function already available which checks for either being the >>> case? >>> >> How about $x instanceOf ArrayAccess ? >> >> -- Jille > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Etienne Kneuss http://www.colder.ch -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php