I am trying to figure out how to catch any method called on an object in PHP. I know about the magic function __call, but it is triggered only for methods that
You can wrap an object around the object, intercepting any calls then forwarding them on the original object and returning the result.
Just store the object as a variable in your wrapper class and use overloading methods in your wrapper class to call/set/get/check on the object.
$object = new AnyObject;
$object = new Wrapper($object);
$object->anyMethod();
$object->anyVar = 'test';
echo $object->anyVar;
echo $object['array form'];
Looping the wrapper class in foreach is probably harder. Havent tried that.