返回对PHP中静态函数的直接引用

返回对PHP中静态函数的直接引用,php,function,reference,Php,Function,Reference,现在要返回对静态函数的引用,我要返回对闭包的引用(在启动函数内部)。闭包只调用静态函数 class AuthServiceProvider extends ServiceProvider { private static function createEloquentLdapProvider($app) {...} public function boot() { Auth::extend('databaseLdapCredentials', funct

现在要返回对静态函数的引用,我要返回对闭包的引用(在启动函数内部)。闭包只调用静态函数

class AuthServiceProvider extends ServiceProvider
{
    private static function createEloquentLdapProvider($app) {...}

    public function boot()
    {
        Auth::extend('databaseLdapCredentials', function($app) {
            return self::createDatabaseLdapProvider($app);
        });
    });
}
在C#中,我可以通过名称返回对静态函数的直接引用。我还尝试在PHP中使用函数名:

    public function boot()
    {
        Auth::extend('databaseLdapCredentials', self::createDatabaseLdapProvider);
    });
但它不起作用。PHP认为
self::CreateDatabaselApprovider
是静态变量(不引用静态函数)


那么,我如何在PHP中返回对静态函数的直接引用而不使用闭包,这是本例的关键?

我认为您犯了一个错误,您必须使用$this作为:

return this->createDatabaseLdapProvider($app);

CreateDatabaselApprovider
是静态函数!您可以尝试以下操作:公共静态函数example2(){echo'hello';}公共函数example1(){$this->example2();}