Magic __callStatic catches parent::foo() calls before __call. This makes me angry
Rather than try to explain this in words, here is a code example. The issue I have is that really I want the parent::foo() method to be caught by the __call() and not the __callStatic(). It always struck me as a bit odd that you call a parent method using static looking syntax (and that any instance method can in fact be called like this) and now it seems it's more than just ugly but actually stopping me from getting at my __call(). Does anyone know of a solution for this? Obviously, in my example, I could explicitly define foo in the parent class but my actual use case is far more complicated and this is not practical. It seems that really we need a way to distinguish between calling static and instance methods on the parent.class A
{
public static function __callStatic($method, $args)
{
echo "Called a static method\n";
}
public function __call($method, $args)
{
echo "Called an instance method\n";
}
}
class B extends A
{
public function foo()
{
// extends the functionality of foo.
echo "Called new foo\n";
// and runs its parent's version too
parent::foo();
}
}
$b = new B();
$b->foo();
