Usually you it is possible to check whether a variable is an instance of a class by using:
$foo instanceof bar
But in the case of ArrayObjects (belonging to Symfony 2), this does not seem to work
get_class($foo) returns 'Doctrine\Common\Collections\ArrayCollection'
yet
$foo instanceof ArrayCollection
returns false
is_array($foo) returns false and $is_object($foo) returns true
but I would like to do a specific check on this type
To perform introspection of an object under a namespace, the class still needs to be included using the
usedirective.or
Regarding your attempt to determine the objects use as an array with
is_array($foo).The function will only work on the
arraytype. However to check if it can be used as an array, you can use:The
ArrayCollectionclass implements both of these interfaces.