diff --git a/rules-tests/CodeQuality/Rector/MethodCall/AssertEqualsToSameRector/Fixture/skip_loose_compare_string.php.inc b/rules-tests/CodeQuality/Rector/MethodCall/AssertEqualsToSameRector/Fixture/skip_loose_compare_string.php.inc new file mode 100644 index 00000000..69587e89 --- /dev/null +++ b/rules-tests/CodeQuality/Rector/MethodCall/AssertEqualsToSameRector/Fixture/skip_loose_compare_string.php.inc @@ -0,0 +1,13 @@ +assertEquals(1, '1'); + } +} diff --git a/rules/CodeQuality/Rector/MethodCall/AssertEqualsToSameRector.php b/rules/CodeQuality/Rector/MethodCall/AssertEqualsToSameRector.php index a353eff6..0ea48257 100644 --- a/rules/CodeQuality/Rector/MethodCall/AssertEqualsToSameRector.php +++ b/rules/CodeQuality/Rector/MethodCall/AssertEqualsToSameRector.php @@ -108,11 +108,11 @@ public function refactor(Node $node): ?Node $secondArgType = TypeCombinator::removeNull($this->nodeTypeResolver->getNativeType($args[1]->value)); // loose comparison - if ($firstArgType instanceof IntegerType && $secondArgType instanceof FloatType) { + if ($firstArgType instanceof IntegerType && ($secondArgType instanceof FloatType || $secondArgType instanceof StringType)) { return null; } - if ($firstArgType instanceof FloatType && $secondArgType instanceof IntegerType) { + if ($firstArgType instanceof FloatType && ($secondArgType instanceof IntegerType || $secondArgType instanceof StringType)) { return null; }