I suggest just making sure that this is an object. Using methods / functions, you can use type hints
public function x (myClass $object) { $object->foo(); }
otherwise you can use is_object()
. At the end, such a message sounds as if your application has a bug that should be fixed before release, or - if such a situation may arise by design - check the type ( is_object()
(see above) or !is_null($obj)
or something like that) before trying to call something that does not exist.
source share