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

do while loop with bool variable incorrectly errored. #11195

Open
WyriHaximus opened this issue Jan 3, 2025 · 1 comment
Open

do while loop with bool variable incorrectly errored. #11195

WyriHaximus opened this issue Jan 3, 2025 · 1 comment

Comments

@WyriHaximus
Copy link

I have this loop in a project and I'm getting two errors, a [RedundantCondition and a UnusedVariable. https://psalm.dev/r/b420e29429 Both are wrong in this specific situation.

Copy link

I found these snippets:

https://psalm.dev/r/b420e29429
<?php

do {
    $run  = false;
    
    if (time() % 3 === 0) {
        continue;
    }
    
    $run        = true;
} while ($run);
Psalm output (using commit 765dcbf):

ERROR: RedundantCondition - 11:10 - Type true for $run is never falsy

INFO: UnusedVariable - 4:5 - $run is never referenced or the value is not used

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

No branches or pull requests

1 participant