Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot call closure returned by bindTo #392

Open
danog opened this issue Mar 9, 2020 · 1 comment
Open

Cannot call closure returned by bindTo #392

danog opened this issue Mar 9, 2020 · 1 comment
Labels

Comments

@danog
Copy link

danog commented Mar 9, 2020

Closures returned by bindTo cannot be directly called.

Source:

class a {
    public static function init() { var_dump("test"); }
}

(function () {
    static::init();
})->bindTo(null, a::class)();

Result:

[daniil@daniil-arch jav]$ php src/q.php 
string(4) "test"

[daniil@daniil-arch jav]$ jppm start
-> linux
-> app:run 
-> install 

Fatal error: Uncaught ParseError: Syntax error, unexpected 'function' in res://q.php on line 6, position 2
Stack Trace:
#0 {main}
  thrown in res://q.php on line 6

Storing the return value of bindTo in a variable and calling that works just fine

@dim-s dim-s added the bug label Mar 9, 2020
@dim-s
Copy link
Member

dim-s commented Mar 10, 2020

Workaround:

class a {
    public static function init() { var_dump("test"); }
}

((function () {
    static::init();
})->bindTo(null, a::class))();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants