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

False positive when using match expression to narrow types #9694

Closed
axlon opened this issue Jul 28, 2023 · 0 comments · Fixed by phpstan/phpstan-src#3053
Closed

False positive when using match expression to narrow types #9694

axlon opened this issue Jul 28, 2023 · 0 comments · Fixed by phpstan/phpstan-src#3053
Labels
Milestone

Comments

@axlon
Copy link
Contributor

axlon commented Jul 28, 2023

Bug report

It appears that PHPStan doesn't narrow types that are part of a match expression's condition, which leads to false positives when a match expression is used to eliminate certain types from a union.

Code snippet that reproduces the problem

https://phpstan.org/r/1b12aa5c-1398-4065-a014-80cfe3c45916

Expected output

No errors. We already know that the object cannot be null because we ended up in the false match arm.

Did PHPStan help you today? Did it make you happy in any way?

No response

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

Successfully merging a pull request may close this issue.

2 participants