-
-
Notifications
You must be signed in to change notification settings - Fork 915
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
First-class closure return type not resolved correctly #11056
Labels
Milestone
Comments
@uuf6429 After the latest push in 2.0.x, PHPStan now reports different result with your code snippet: @@ @@
32: Parameter #1 $values of function receive expects array<Item>, array<int, mixed> given.
39: Parameter #1 $values of function receive expects array<Item>, array<int, T> given.
-PHP 7.4 – 8.0 (4 errors)
+PHP 7.2 – 8.0 (4 errors)
==========
32: Parameter #1 $values of function receive expects array<Item>, array<int, mixed> given.
33: First-class callables are supported only on PHP 8.1 and later.
39: Parameter #1 $values of function receive expects array<Item>, array<int, T> given.
-40: First-class callables are supported only on PHP 8.1 and later.
-
-PHP 7.2 – 7.3 (8 errors)
-==========
-
-47: Syntax error, unexpected ',' on line 47
-47: Syntax error, unexpected T_DOUBLE_ARROW on line 47
-47: Syntax error, unexpected T_STRING, expecting T_PAAMAYIM_NEKUDOTAYIM on line 47
-49: Syntax error, unexpected ')' on line 49
-54: Syntax error, unexpected ',' on line 54
-54: Syntax error, unexpected T_DOUBLE_ARROW on line 54
-54: Syntax error, unexpected T_STRING, expecting T_PAAMAYIM_NEKUDOTAYIM on line 54
-56: Syntax error, unexpected ')' on line 56
+40: First-class callables are supported only on PHP 8.1 and later. Full reportPHP 8.1 – 8.3 (2 errors)
PHP 7.2 – 8.0 (4 errors)
|
@uuf6429 After the latest push in 2.0.x, PHPStan now reports different result with your code snippet: @@ @@
-PHP 8.1 – 8.3 (2 errors)
+PHP 8.1 – 8.3
==========
-32: Parameter #1 $values of function receive expects array<Item>, array<int, mixed> given.
-39: Parameter #1 $values of function receive expects array<Item>, array<int, T> given.
+No errors
-PHP 7.4 – 8.0 (4 errors)
+PHP 7.2 – 8.0 (2 errors)
==========
-32: Parameter #1 $values of function receive expects array<Item>, array<int, mixed> given.
33: First-class callables are supported only on PHP 8.1 and later.
-39: Parameter #1 $values of function receive expects array<Item>, array<int, T> given.
-40: First-class callables are supported only on PHP 8.1 and later.
-
-PHP 7.2 – 7.3 (8 errors)
-==========
-
-47: Syntax error, unexpected ',' on line 47
-47: Syntax error, unexpected T_DOUBLE_ARROW on line 47
-47: Syntax error, unexpected T_STRING, expecting T_PAAMAYIM_NEKUDOTAYIM on line 47
-49: Syntax error, unexpected ')' on line 49
-54: Syntax error, unexpected ',' on line 54
-54: Syntax error, unexpected T_DOUBLE_ARROW on line 54
-54: Syntax error, unexpected T_STRING, expecting T_PAAMAYIM_NEKUDOTAYIM on line 54
-56: Syntax error, unexpected ')' on line 56
+40: First-class callables are supported only on PHP 8.1 and later. Full reportPHP 8.1 – 8.3No errors PHP 7.2 – 8.0 (2 errors)
|
This was referenced Sep 9, 2024
Fixed by phpstan/phpstan-src#3425 |
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. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Bug report
The return type of generic first-class closures doesn't seem to resolve correctly.
Wrapping them in an arrow function or anonymous function seems to bypass the problem.
The type of closure (method, static method or function) doesn't seem to make a difference.
(discovered in #11055 (comment))
Code snippet that reproduces the problem
https://phpstan.org/r/3ac8de30-a9c4-4c59-b5eb-fe58291e30f5
Expected output
In the given example, no errors/warnings were expected to be reported in PHP 8.3.
Did PHPStan help you today? Did it make you happy in any way?
Yeah, managed to catch a couple of bugs that even testing didn't catch. 💪
The text was updated successfully, but these errors were encountered: