Sometimes I need to execute the grandparent method (that is, bypass the parent method), I know that this is the smell of the code, but sometimes I can not change other classes (frameworks, libraries, etc.).
In PHP, we can do something like:
call_user_func(array(get_parent_class(get_parent_class($childObject)), 'grandParentMethod'));
The problem is that if you have E_STRICT errors, you will receive an error message:
Strict standards: the non-static method GrandParent :: grandParentMethod () should not be called statically ...
I found only one solution for this (without removing E_STRICT), and it just adds @ to suppress the error.
But what is really ugly, does anyone know a better solution?
Thanks! PS: I cannot create an instance of a new object, for example:
$grandparent = get_parent_class(get_parent_class($son)); $gp= new $grandparent; $gp->grandParentMethod
because I need to call my grandparents method in the context of $ son.
inheritance php
Enrique
source share