From d0fa4bbac710ae124ee15e73d7f262ecb106aa78 Mon Sep 17 00:00:00 2001 From: Martin Herndl Date: Fri, 4 Mar 2022 12:57:42 +0100 Subject: [PATCH] Fix IntegerRange-FloatType subtype detection --- src/Type/IntegerRangeType.php | 2 +- .../StrictComparisonOfDifferentTypesRuleTest.php | 8 -------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/src/Type/IntegerRangeType.php b/src/Type/IntegerRangeType.php index cc1e2035fd..42419099d2 100644 --- a/src/Type/IntegerRangeType.php +++ b/src/Type/IntegerRangeType.php @@ -233,7 +233,7 @@ public function isSuperTypeOf(Type $type): TrinaryLogic return TrinaryLogic::createMaybe(); } - if ($type instanceof parent) { + if ($type instanceof parent || $type instanceof FloatType) { return TrinaryLogic::createMaybe(); } diff --git a/tests/PHPStan/Rules/Comparison/StrictComparisonOfDifferentTypesRuleTest.php b/tests/PHPStan/Rules/Comparison/StrictComparisonOfDifferentTypesRuleTest.php index ee5d2dcc42..cf469f8082 100644 --- a/tests/PHPStan/Rules/Comparison/StrictComparisonOfDifferentTypesRuleTest.php +++ b/tests/PHPStan/Rules/Comparison/StrictComparisonOfDifferentTypesRuleTest.php @@ -158,10 +158,6 @@ public function testStrictComparison(): void 'Strict comparison using === between 0 and 0 will always evaluate to true.', 426, ], - [ - 'Strict comparison using === between (int|int<2, max>|string) and 1.0 will always evaluate to false.', - 464, - ], [ 'Strict comparison using === between (int|int<2, max>|string) and stdClass will always evaluate to false.', 466, @@ -332,10 +328,6 @@ public function testStrictComparisonWithoutAlwaysTrue(): void 'Strict comparison using !== between null and null will always evaluate to false.', 408, ], - [ - 'Strict comparison using === between (int|int<2, max>|string) and 1.0 will always evaluate to false.', - 464, - ], [ 'Strict comparison using === between (int|int<2, max>|string) and stdClass will always evaluate to false.', 466,