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 UnusedVariable when casting #4956

Closed
AndrolGenhald opened this issue Jan 8, 2021 · 2 comments · Fixed by #5349
Closed

False positive UnusedVariable when casting #4956

AndrolGenhald opened this issue Jan 8, 2021 · 2 comments · Fixed by #5349
Labels

Comments

@AndrolGenhald
Copy link
Collaborator

https://psalm.dev/r/29407446ea

The (int) cast appears to cause the false positive.

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/29407446ea
<?php

$a = random_int(0, 10) >= 5 ? true : false;

$b = (int) $a;

// This part isn't important, just using $b so there aren't more issues.
if ($b > 0) {
}
Psalm output (using commit d1398f2):

INFO: UnusedVariable - 3:1 - $a is never referenced or the value is not used

@weirdan weirdan added the bug label Jan 8, 2021
@weirdan
Copy link
Collaborator

weirdan commented Mar 8, 2021

Only bool to int casts are affected.

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