Sometimes I need to execute grandparent method (that is, bypass the parent method), I know this is code smell, but sometimes I can't change the other classes (frameworks, libraries, etc).
In PHP we can do that with something like:
call_user_func(array(get_parent_class(get_parent_class($childObject)), 'grandParentMethod'));
The problem is that if you have E_STRICT errors enabled you will get an error like:
Strict standards: non-static method GrandParent::grandParentMethod() should not be called statically in ...
I've found only one solution for this (without removing E_STRICT), and it's just adding the @
to supress the error.
But that's really ugly, does somebody know a better solution?
Thanks ! PS: I can't instantiate a new object like:
$grandparent = get_parent_class(get_parent_class($son));
$gp= new $grandparent;
$gp->grandParentMethod
because I need to call my grandparent method in the context of $son.