Well, there is no easy way to do this, but it is possible. However, the way you need to achieve this is not recommended, as this will lead to slow code. However, here is an easy way to do this:
class Foo
{
protected static function bar ()
{
}
protected function nonStaticBar()
{
}
public function __call($method, array $args)
{
printf('You called %s::%s', get_class($this), $method);
return call_user_func_array([$this, $method], $args);
}
public static function __callStatic($method, array $args)
{
$calledClass = get_called_class();
printf('You called %s::%s statically', $calledClass, $method);
return call_user_func_array($calledClass . '::' . $method, $args);
}
}
$foo = new Foo;
$foo->nonStaticBar();
Foo::bar();
__callStatic get_called_class, get_class(self); , final - :
class Foobar extends Foo
{}
Foobar::bar();
: