I have some legacy code and refactored an array to an ArrayObject. Now I have problems checking, if a variable is an array:
if (is_array($entity) && $otherCondition) {
// do something
}
The function is_array() returns false on an ArrayObject. See this report.
Simplest solution would be to use something like this:
function is_traversable($var) {
return is_array($var) || $var instanceof Traversable;
}
Is there some native way for PHP to do a check like this?