diff --git a/rules-tests/CodeQuality/Rector/Equal/UseIdenticalOverEqualWithSameTypeRector/Fixture/skip_bool_equal_float.php.inc b/rules-tests/CodeQuality/Rector/Equal/UseIdenticalOverEqualWithSameTypeRector/Fixture/skip_bool_equal_float.php.inc new file mode 100644 index 00000000000..1978d9a67a4 --- /dev/null +++ b/rules-tests/CodeQuality/Rector/Equal/UseIdenticalOverEqualWithSameTypeRector/Fixture/skip_bool_equal_float.php.inc @@ -0,0 +1,18 @@ +no() as to verify both yes and maybe if ($leftStaticType instanceof BooleanType) { - if (! $rightStaticType->isNumericString()->no()) { - return true; - } - - return ! $rightStaticType->isInteger() - ->no(); + return $this->shouldSkipNumericType($rightStaticType); } if ($rightStaticType instanceof BooleanType) { - if (! $leftStaticType->isNumericString()->no()) { - return true; - } - - return ! $leftStaticType->isInteger() - ->no(); + return $this->shouldSkipNumericType($leftStaticType); } return false; } + private function shouldSkipNumericType(Type $type): bool + { + // use ! ->no() as to verify both yes and maybe + if (! $type->isNumericString()->no()) { + return true; + } + + if (! $type->isInteger() + ->no()) { + return true; + } + + return ! $type->isFloat() + ->no(); + } + private function processIdenticalOrNotIdentical(Equal|NotEqual $node): Identical|NotIdentical { if ($node instanceof Equal) {