-
-
Notifications
You must be signed in to change notification settings - Fork 887
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
Variable function support #2920
Variable function support #2920
Comments
@VincentLanglet PHPStan now reports different result with your code snippet: @@ @@
+PHP 8.0 (2 errors)
+==========
+
+10: Parameter #1 $callback of function call_user_func expects callable(): mixed, array($this(HelloWorld), 'a') given.
+20: Parameter #1 $callback of function call_user_func expects callable(): mixed, array($this(HelloWorld), 'foo') given.
+
+PHP 7.1 – 7.4 (2 errors)
+==========
+
10: Parameter #1 $function of function call_user_func expects callable(): mixed, array($this(HelloWorld), 'a') given.
20: Parameter #1 $function of function call_user_func expects callable(): mixed, array($this(HelloWorld), 'foo') given. Full reportPHP 8.0 (2 errors)
PHP 7.1 – 7.4 (2 errors)
|
@VincentLanglet After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
-10: Parameter #1 $function of function call_user_func expects callable(): mixed, array($this(HelloWorld), 'a') given.
-20: Parameter #1 $function of function call_user_func expects callable(): mixed, array($this(HelloWorld), 'foo') given.
+PHP 8.0 (2 errors)
+==========
+
+10: Parameter #1 $callback of function call_user_func expects callable(): mixed, array{$this(HelloWorld), 'a'} given.
+20: Parameter #1 $callback of function call_user_func expects callable(): mixed, array{$this(HelloWorld), 'foo'} given.
+
+PHP 7.1 – 7.4 (2 errors)
+==========
+
+10: Parameter #1 $function of function call_user_func expects callable(): mixed, array{$this(HelloWorld), 'a'} given.
+20: Parameter #1 $function of function call_user_func expects callable(): mixed, array{$this(HelloWorld), 'foo'} given. Full reportPHP 8.0 (2 errors)
PHP 7.1 – 7.4 (2 errors)
|
@VincentLanglet After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
-10: Parameter #1 $function of function call_user_func expects callable(): mixed, array($this(HelloWorld), 'a') given.
-20: Parameter #1 $function of function call_user_func expects callable(): mixed, array($this(HelloWorld), 'foo') given.
+PHP 8.0 – 8.1 (2 errors)
+==========
+
+10: Parameter #1 $callback of function call_user_func expects callable(): mixed, array{$this(HelloWorld), 'a'} given.
+20: Parameter #1 $callback of function call_user_func expects callable(): mixed, array{$this(HelloWorld), 'foo'} given.
+
+PHP 7.1 – 7.4 (2 errors)
+==========
+
+10: Parameter #1 $function of function call_user_func expects callable(): mixed, array{$this(HelloWorld), 'a'} given.
+20: Parameter #1 $function of function call_user_func expects callable(): mixed, array{$this(HelloWorld), 'foo'} given. Full reportPHP 8.0 – 8.1 (2 errors)
PHP 7.1 – 7.4 (2 errors)
|
@VincentLanglet After the latest push in 1.8.x, PHPStan now reports different result with your code snippet: @@ @@
-10: Parameter #1 $function of function call_user_func expects callable(): mixed, array($this(HelloWorld), 'a') given.
-20: Parameter #1 $function of function call_user_func expects callable(): mixed, array($this(HelloWorld), 'foo') given.
+PHP 8.0 – 8.2 (2 errors)
+==========
+
+10: Parameter #1 $callback of function call_user_func expects callable(): mixed, array{$this(HelloWorld), 'a'} given.
+20: Parameter #1 $callback of function call_user_func expects callable(): mixed, array{$this(HelloWorld), 'foo'} given.
+
+PHP 7.1 – 7.4 (2 errors)
+==========
+
+10: Parameter #1 $function of function call_user_func expects callable(): mixed, array{$this(HelloWorld), 'a'} given.
+20: Parameter #1 $function of function call_user_func expects callable(): mixed, array{$this(HelloWorld), 'foo'} given. Full reportPHP 8.0 – 8.2 (2 errors)
PHP 7.1 – 7.4 (2 errors)
|
@VincentLanglet After the latest push in 1.11.x, PHPStan now reports different result with your code snippet: @@ @@
-10: Parameter #1 $function of function call_user_func expects callable(): mixed, array($this(HelloWorld), 'a') given.
-20: Parameter #1 $function of function call_user_func expects callable(): mixed, array($this(HelloWorld), 'foo') given.
+PHP 8.0 – 8.3 (2 errors)
+==========
+
+10: Parameter #1 $callback of function call_user_func expects callable(): mixed, array{$this(HelloWorld), 'a'} given.
+20: Parameter #1 $callback of function call_user_func expects callable(): mixed, array{$this(HelloWorld), 'foo'} given.
+
+PHP 7.1 – 7.4 (2 errors)
+==========
+
+10: Parameter #1 $function of function call_user_func expects callable(): mixed, array{$this(HelloWorld), 'a'} given.
+20: Parameter #1 $function of function call_user_func expects callable(): mixed, array{$this(HelloWorld), 'foo'} given. Full reportPHP 8.0 – 8.3 (2 errors)
PHP 7.1 – 7.4 (2 errors)
|
@VincentLanglet After the latest push in 1.12.x, PHPStan now reports different result with your code snippet: @@ @@
-10: Parameter #1 $function of function call_user_func expects callable(): mixed, array($this(HelloWorld), 'a') given.
-20: Parameter #1 $function of function call_user_func expects callable(): mixed, array($this(HelloWorld), 'foo') given.
+PHP 8.0 – 8.4 (2 errors)
+==========
+
+10: Parameter #1 $callback of function call_user_func expects callable(): mixed, array{$this(HelloWorld), 'a'} given.
+20: Parameter #1 $callback of function call_user_func expects callable(): mixed, array{$this(HelloWorld), 'foo'} given.
+
+PHP 7.1 – 7.4 (2 errors)
+==========
+
+10: Parameter #1 $function of function call_user_func expects callable(): mixed, array{$this(HelloWorld), 'a'} given.
+20: Parameter #1 $function of function call_user_func expects callable(): mixed, array{$this(HelloWorld), 'foo'} given. Full reportPHP 8.0 – 8.4 (2 errors)
PHP 7.1 – 7.4 (2 errors)
|
This would be a nice feature, especially that it already works amazingly well when using |
will have a look |
This is a complex problem and we don't need to solve it now. Especially for dynamic code, which can often be rewritten not to be dynamic. @staabm You don't need to carry everything on your shoulders, especially with the number of open PRs you already have :) We solved a similar thing for properties, it can find errors with For example when Which means that before analysing the method call, we'd have to correctly filter all the argument types properly. |
Feature request
Variable function
Does not look to be actually checked.
You can see here
https://phpstan.org/r/ad9416aa-e138-4825-a3f4-2e064955547c
Return an error
But
Does not (and should).
The text was updated successfully, but these errors were encountered: