我有一个带有可调用参数的函数:
public static function setup(Router $router, Injector $injector, callable $toRouterCallable): void
我想从另一个类调用它并传递一个 protected 父函数作为可调用参数。我尝试了三种方法,但都失败了:
Routes::setup($router, $injector, $this->toRouterCallable); // Undefined property '$toRouterCallable'
Routes::setup($router, $injector, parent::toRouterCallable); // Undefined class constant 'toRouterCallable'
Routes::setup($router, $injector, [$this, 'toRouterCallable']); // Argument 3 passed setup() must be callable, array given
如何将父函数传递给此函数?