if (is_object($object) && $object instanceof xPDOObject) {
No, it’s an error thing, you can’t check a non-object with instanceof or it throws a PHP error; both checks are necessary. The first says, is this in object, the next says is it an instance of the class I want.
I’ve been trying hard, but I can’t see why this common code in MODx uses both tests:
if (is_object($object) && $object instanceof xPDOObject) {
It would seem that an instance of an object class would have to be an object so the is_object() test seems unnecessary.
Does this code work in PHP4?
Is it a speed thing? I imagine that most of the time the object passes the test so you’d have a net loss in speed by using both tests.
if ($object instanceof xPDOObject) {
case 'OnLoadWebDocument': if ($modx->resource instanceof modStaticResource){ ... } ...