From 596312a800860cd5d7b83fcd93fd5b65d95c9451 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Sat, 4 Oct 2025 07:18:41 +0700 Subject: [PATCH 1/3] [CodeQuality] Skip bool equal float on UseIdenticalOverEqualWithSameTypeRector --- .../Fixture/skip_bool_equal_float.php.inc | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 rules-tests/CodeQuality/Rector/Equal/UseIdenticalOverEqualWithSameTypeRector/Fixture/skip_bool_equal_float.php.inc 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 @@ + Date: Sat, 4 Oct 2025 07:20:53 +0700 Subject: [PATCH 2/3] Fix --- .../UseIdenticalOverEqualWithSameTypeRector.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/rules/CodeQuality/Rector/Equal/UseIdenticalOverEqualWithSameTypeRector.php b/rules/CodeQuality/Rector/Equal/UseIdenticalOverEqualWithSameTypeRector.php index cfee206643d..8e939abe8a6 100644 --- a/rules/CodeQuality/Rector/Equal/UseIdenticalOverEqualWithSameTypeRector.php +++ b/rules/CodeQuality/Rector/Equal/UseIdenticalOverEqualWithSameTypeRector.php @@ -109,7 +109,12 @@ private function shouldSkipCompareBoolToNumeric(Type $leftStaticType, Type $righ return true; } - return ! $rightStaticType->isInteger() + if (! $rightStaticType->isInteger() + ->no()) { + return true; + } + + return ! $rightStaticType->isFloat() ->no(); } @@ -118,7 +123,12 @@ private function shouldSkipCompareBoolToNumeric(Type $leftStaticType, Type $righ return true; } - return ! $leftStaticType->isInteger() + if (! $leftStaticType->isInteger() + ->no()) { + return true; + } + + return ! $leftStaticType->isFloat() ->no(); } From f47ea39adfc4b2d10d4a227190020204609c2623 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Sat, 4 Oct 2025 07:22:53 +0700 Subject: [PATCH 3/3] fix --- ...seIdenticalOverEqualWithSameTypeRector.php | 39 ++++++++----------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/rules/CodeQuality/Rector/Equal/UseIdenticalOverEqualWithSameTypeRector.php b/rules/CodeQuality/Rector/Equal/UseIdenticalOverEqualWithSameTypeRector.php index 8e939abe8a6..e3cb73cd75d 100644 --- a/rules/CodeQuality/Rector/Equal/UseIdenticalOverEqualWithSameTypeRector.php +++ b/rules/CodeQuality/Rector/Equal/UseIdenticalOverEqualWithSameTypeRector.php @@ -103,36 +103,31 @@ public function refactor(Node $node): ?Node private function shouldSkipCompareBoolToNumeric(Type $leftStaticType, Type $rightStaticType): bool { - // use ! ->no() as to verify both yes and maybe if ($leftStaticType instanceof BooleanType) { - if (! $rightStaticType->isNumericString()->no()) { - return true; - } - - if (! $rightStaticType->isInteger() - ->no()) { - return true; - } - - return ! $rightStaticType->isFloat() - ->no(); + return $this->shouldSkipNumericType($rightStaticType); } if ($rightStaticType instanceof BooleanType) { - if (! $leftStaticType->isNumericString()->no()) { - return true; - } + return $this->shouldSkipNumericType($leftStaticType); + } - if (! $leftStaticType->isInteger() - ->no()) { - return true; - } + return false; + } - return ! $leftStaticType->isFloat() - ->no(); + private function shouldSkipNumericType(Type $type): bool + { + // use ! ->no() as to verify both yes and maybe + if (! $type->isNumericString()->no()) { + return true; } - return false; + if (! $type->isInteger() + ->no()) { + return true; + } + + return ! $type->isFloat() + ->no(); } private function processIdenticalOrNotIdentical(Equal|NotEqual $node): Identical|NotIdentical