__callStatic doesn't handle missing static calls

∥☆過路亽.° 提交于 2019-12-24 13:06:15

问题


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?

来源:https://stackoverflow.com/questions/36388152/callstatic-doesnt-handle-missing-static-calls

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!