1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +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; $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; $redundant = false;
} else { } else {
$redundant = false; $redundant = false;

View File

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