psalm / phar

A place for Psalm's Phar to live in a composer-versioned setting
https://psalm.dev
25 stars 4 forks source link

Unexpected RedundantCondition #10

Open dzentota opened 2 years ago

dzentota commented 2 years ago

Consider the following code:

<?php
function check(string $filename): bool
{
    if (strpos($filename, ".suback.php") !== false || strpos($filename, "_backup") !== false) {
        // we'll ignore .suback files, they are old upgrade backups
        return false;
    }
    return true;
}

The latest psalm/phar 4.12.0 returns:

ERROR: RedundantCondition - t.php:4:9 - int can never contain false (see https://psalm.dev/122) if (strpos($filename, ".suback.php") !== false || strpos($filename, "_backup") !== false) { ERROR: RedundantCondition - t.php:4:55 - int can never contain false (see https://psalm.dev/122) if (strpos($filename, ".suback.php") !== false || strpos($filename, "_backup") !== false) {

While psalm.dev returns expected result

https://psalm.dev/r/0cc1635fe5

psalm-github-bot[bot] commented 2 years ago

I found these snippets:

https://psalm.dev/r/0cc1635fe5 ```php