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

Detecting more complex dead code which does not do anything #10267

Closed
VladaHejda opened this issue Dec 7, 2023 · 2 comments
Closed

Detecting more complex dead code which does not do anything #10267

VladaHejda opened this issue Dec 7, 2023 · 2 comments

Comments

@VladaHejda
Copy link

Feature request

Phpstan detects only simple expressions ($a;) which does not do anything, but not more complex ones ($a || $b): https://phpstan.org/r/27c2d921-4ecd-4d4d-a11f-984b4f05a81a

However, I had an issue with an expression $r = $a xor $b; which looks pretty obvious what is intended, despite it does not work as that. The precedence of = over xor makes a dead code from xor $b. (Same applies also for or / and, however they are less common used.)
https://phpstan.org/r/29428d5b-5f46-4827-8b64-e54000821c9d

I believe it could be detected by Phpstan.

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

No response

@ondrejmirtes
Copy link
Member

I could not resist and had to implement this awesome suggestion immediately :)

See: phpstan/phpstan-src@a1fffb3

Thank you friend :)

Copy link

github-actions bot commented Jan 8, 2024

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 Jan 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants