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

when 'Else branch is unreachable because previous condition is always true' is not true #4887

Closed
yphoenix opened this issue Apr 22, 2021 · 5 comments
Labels
Milestone

Comments

@yphoenix
Copy link

Bug report

PHPStan - PHP Static Analysis Tool 0.12.84

PHPStan says that the else is unreachable, I say it is.

Code snippet that reproduces the problem

https://phpstan.org/r/adffe5b9-8174-41b6-a774-b988dbfd0165

Expected output

No warnings

@ondrejmirtes
Copy link
Member

The root issue here is that isset($_SESSION) should be bool and not true: https://phpstan.org/r/905e0f11-19d7-42d9-b3c4-b176c21d0aaa

@ondrejmirtes ondrejmirtes added this to the Easy fixes milestone Apr 22, 2021
@phpstan-bot
Copy link
Contributor

@yphoenix After the latest commit in dev-master, PHPStan now reports different result with your code snippet:

@@ @@
-15: Else branch is unreachable because previous condition is always true.
+No errors

@phpstan-bot
Copy link
Contributor

@ondrejmirtes After the latest commit in dev-master, PHPStan now reports different result with your code snippet:

@@ @@
- 9: Dumped type: true
-17: Else branch is unreachable because previous condition is always true.
+ 9: Dumped type: bool
Full report
Line Error
9 Dumped type: bool

@yphoenix
Copy link
Author

Thank you.

@github-actions
Copy link

github-actions bot commented Mar 4, 2022

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 4, 2022
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

3 participants