From d94f7bd5536d8d3ce93f6bdf65e487caeca0d1bf Mon Sep 17 00:00:00 2001 From: kkmuffme <11071985+kkmuffme@users.noreply.github.com> Date: Sat, 18 Nov 2023 15:21:01 +0100 Subject: [PATCH] loose comparisons of int with string shouldn't change change the int to empty-mixed --- src/Psalm/Internal/Type/SimpleAssertionReconciler.php | 4 ++++ tests/TypeReconciliation/ConditionalTest.php | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Psalm/Internal/Type/SimpleAssertionReconciler.php b/src/Psalm/Internal/Type/SimpleAssertionReconciler.php index f63100c49..24041dfac 100644 --- a/src/Psalm/Internal/Type/SimpleAssertionReconciler.php +++ b/src/Psalm/Internal/Type/SimpleAssertionReconciler.php @@ -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; diff --git a/tests/TypeReconciliation/ConditionalTest.php b/tests/TypeReconciliation/ConditionalTest.php index 6b246d276..926e2866b 100644 --- a/tests/TypeReconciliation/ConditionalTest.php +++ b/tests/TypeReconciliation/ConditionalTest.php @@ -1350,7 +1350,6 @@ class ConditionalTest extends TestCase function takes_int(int $int) : void {} if ($int == $string) { - /** @psalm-suppress MixedArgument */ takes_int($int); }', ],