Skip to content

Commit

Permalink
loose comparisons of int with string shouldn't change change the int …
Browse files Browse the repository at this point in the history
…to empty-mixed
  • Loading branch information
kkmuffme committed Nov 21, 2023
1 parent 5f0332b commit d94f7bd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/Psalm/Internal/Type/SimpleAssertionReconciler.php
Original file line number Diff line number Diff line change
Expand Up @@ -1040,6 +1040,10 @@ private static function reconcileString(
$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;
Expand Down
1 change: 0 additions & 1 deletion tests/TypeReconciliation/ConditionalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1350,7 +1350,6 @@ function takes_string(string $string) : void {}
function takes_int(int $int) : void {}
if ($int == $string) {
/** @psalm-suppress MixedArgument */
takes_int($int);
}',
],
Expand Down

0 comments on commit d94f7bd

Please sign in to comment.