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

Type from multiple Closures is not unioned #10283

Closed
mvorisek opened this issue Dec 11, 2023 · 5 comments
Closed

Type from multiple Closures is not unioned #10283

mvorisek opened this issue Dec 11, 2023 · 5 comments
Labels
Milestone

Comments

@mvorisek
Copy link
Contributor

mvorisek commented Dec 11, 2023

Bug report

Currently, only the first Closure is analysed.

Code snippet that reproduces the problem

https://phpstan.org/r/06a4c6f9-99ec-4f9c-a8ca-d4a14633b153

once fixed, check https://phpstan.org/r/d77648c1-796f-41b3-abc0-a548b71ff927

Expected output

no phpstan error

@ondrejmirtes ondrejmirtes added this to the Easy fixes milestone Dec 11, 2023
@bendavies
Copy link

bendavies commented Dec 11, 2023

@mvorisek
Copy link
Contributor Author

@phpstan-bot
Copy link
Contributor

@mvorisek After the latest push in 1.11.x, PHPStan now reports different result with your code snippet:

@@ @@
-PHP 7.4 – 8.3 (7 errors)
+PHP 7.4 – 8.3 (5 errors)
 ==========
 
 13: Strict comparison using !== between JsExpressionable and null will always evaluate to true.
@@ @@
 26: Strict comparison using !== between JsExpressionable|void and null will always evaluate to true.
 27: Method Cl::test2() should return JsExpressionable|null but returns JsExpressionable|void.
 30: Unreachable statement - code above always terminates.
-38: Parameter #1 $fx of method Cl::test() expects (Closure(): JsExpressionable)|(Closure(): void), Closure(): null given.
-39: Parameter #1 $fx of method Cl::test2() expects Closure(): (JsExpressionable|void), Closure(): null given.
 
 PHP 7.2 – 7.3 (6 errors)
 ==========
Full report

PHP 7.4 – 8.3 (5 errors)

Line Error
13 Strict comparison using !== between JsExpressionable and null will always evaluate to true.
17 Unreachable statement - code above always terminates.
26 `Strict comparison using !== between JsExpressionable
27 `Method Cl::test2() should return JsExpressionable
30 Unreachable statement - code above always terminates.

PHP 7.2 – 7.3 (6 errors)

Line Error
34 Syntax error, unexpected ')' on line 34
34 Syntax error, unexpected T_DOUBLE_ARROW, expecting ')' on line 34
35 Syntax error, unexpected ')' on line 35
35 Syntax error, unexpected T_DOUBLE_ARROW, expecting ')' on line 35
38 Syntax error, unexpected T_DOUBLE_ARROW, expecting ')' on line 38
39 Syntax error, unexpected T_DOUBLE_ARROW, expecting ')' on line 39

@ondrejmirtes
Copy link
Member

Fixed: phpstan/phpstan-src#2902

Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants