Search code examples
phpsymfonycallbackmagic-methods

Symfony goes down after call call_user_func_array() in __call() method


I have two simple classes

Parent

class Parent {
    public function __call($name, $args)
    {
        return call_user_func_array([$this, $name], $args);
    }
}

and Child

class Child extends Parent {
    private function test()
    {
        return 1;
    }
}

When I execute Child object $child->test() my Symfony server (runned by php bin/console server:run) goes down. Only message is [ERROR] Built-in server terminated unexpectedly..


Solution

  • The method test() is private and can't be executed from the Parent scope. Make the method protected.