Skip to content

Fix condition of fall-through case not used for exhaustive checks #3900

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

Merged
merged 1 commit into from
Mar 23, 2025

Conversation

rvanvelzen
Copy link
Contributor

Fix phpstan/phpstan#11064. Unfortunately this causes a regression elsewhere, which by the looks of it already didn't work completely.

The problem there is that the assignment is forgotten because of the $scopeForBranches = $scopeForBranches->filterByFalseyValue($fullCondExpr).

@rvanvelzen rvanvelzen changed the base branch from 2.1.x to 1.12.x March 23, 2025 12:29
116,
],
[
// could be Variable $variableInSecondCase in isset() always exists and is not nullable.
'Variable $variableInSecondCase in isset() is never defined.',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this error already was incorrect. The other one is now also broken, because its condition is also used

@ondrejmirtes
Copy link
Member

From the issue bot it looks like it fixed more issues: https://github.com/phpstan/phpstan-src/actions/runs/14018968530

Please add regression tests for them.

@rvanvelzen
Copy link
Contributor Author

Thanks, I added tests for the listed issues.

@ondrejmirtes ondrejmirtes merged commit ce0aaf2 into phpstan:1.12.x Mar 23, 2025
447 of 452 checks passed
@ondrejmirtes
Copy link
Member

Awesome, thank you!

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

Successfully merging this pull request may close these issues.

Switch branch with fall-through not narrowing values properly
2 participants