1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 20:34:47 +01:00

loose comparisons of int with string shouldn't change change the int to empty-mixed

This commit is contained in:
kkmuffme 2023-11-18 15:21:01 +01:00
parent 5f0332b678
commit d94f7bd553
2 changed files with 4 additions and 1 deletions

View File

@ -1040,6 +1040,10 @@ final class SimpleAssertionReconciler extends Reconciler
$string_types[] = $type;
}
$redundant = false;
} elseif ($type instanceof TInt && $assertion instanceof IsLooselyEqual) {
// don't change the type of an int for non-strict comparisons
$string_types[] = $type;
$redundant = false;
} else {
$redundant = false;

View File

@ -1350,7 +1350,6 @@ class ConditionalTest extends TestCase
function takes_int(int $int) : void {}
if ($int == $string) {
/** @psalm-suppress MixedArgument */
takes_int($int);
}',
],