1
class Foo
{
    public function bar(){
        echo "Non-static\n";
    }

    public static function __callStatic($name, $arguments)
    {
        if ($name === 'bar') {
            echo "Static\n";
        }
    }
}

Foo::bar();

Class Foo does not have a static bar method. That is why I was expecting the Foo::bar() to be handled by the __callStatic method. Unfortunately for me that's not happening for some reason.

The non-static method is being called on null instead.

Is it a bug or a feature? How can I make the __callStatic to handle that call of a missing static method?

Kolyunya
  • 5,973
  • 7
  • 46
  • 81
  • You have method bar. And can not call this method as static. Thi is logicaly because. You can not have 2 methods in 1 name. – Naumov Apr 03 '16 at 16:49
  • @Naumov no, the class has no *static* `bar` method. I don't find it logical personally. – Kolyunya Apr 03 '16 at 16:50
  • But when you call bar you got call non static method as static error. Becouse bar exist. You can't have in class 2 methods bar. For example `function bar(){} static function bar(){}` this is erro. – Naumov Apr 03 '16 at 16:58

0 Answers0