-
-
Notifications
You must be signed in to change notification settings - Fork 864
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
Errors missed on arrow functions #3660
Comments
The ArrowFunction needs similar handling as the Closure node has here: https://github.com/phpstan/phpstan-src/blob/a23f80828620e663c67bbacdcb246b888db158a4/src/Analyser/NodeScopeResolver.php#L2093-L2101 (+ where the $callableParameters are used: https://github.com/phpstan/phpstan-src/blob/a23f80828620e663c67bbacdcb246b888db158a4/src/Analyser/NodeScopeResolver.php#L2140 |
@nicofff PHPStan now reports different result with your code snippet: @@ @@
-5: Parameter #1 $string of function strlen expects string, int given.
+PHP 7.4 – 8.0 (1 error)
+==========
+
+5: Parameter #1 $string of function strlen expects string, int given.
+
+PHP 7.1 – 7.3 (2 errors)
+==========
+
+4: Syntax error, unexpected ',' on line 4
+4: Syntax error, unexpected T_DOUBLE_ARROW, expecting ')' on line 4 Full reportPHP 7.4 – 8.0 (1 error)
PHP 7.1 – 7.3 (2 errors)
|
@nicofff After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
-5: Parameter #1 $string of function strlen expects string, int given.
+PHP 7.4 – 8.0 (2 errors)
+==========
+
+4: Parameter #1 $string of function strlen expects string, int given.
+5: Parameter #1 $string of function strlen expects string, int given.
+
+PHP 7.1 – 7.3 (2 errors)
+==========
+
+4: Syntax error, unexpected ',' on line 4
+4: Syntax error, unexpected T_DOUBLE_ARROW, expecting ')' on line 4 Full reportPHP 7.4 – 8.0 (2 errors)
PHP 7.1 – 7.3 (2 errors)
|
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Bug report
Under some circumstances, the same implementation using anonymous functions will detect an issue, but if arrow functions are used, it won't.
Code snippet that reproduces the problem
https://phpstan.org/r/8dd5b2a8-e742-4577-b00a-b2bfc72184d5
Expected output
I'd expect both array_map's to raise the same issue, since the code is equivalent.
The text was updated successfully, but these errors were encountered: