diff --git a/rules-tests/CodeQuality/Rector/Equal/UseIdenticalOverEqualWithSameTypeRector/Fixture/identical_integer.php.inc b/rules-tests/CodeQuality/Rector/Equal/UseIdenticalOverEqualWithSameTypeRector/Fixture/identical_integer.php.inc new file mode 100644 index 00000000000..c2762c2c0a8 --- /dev/null +++ b/rules-tests/CodeQuality/Rector/Equal/UseIdenticalOverEqualWithSameTypeRector/Fixture/identical_integer.php.inc @@ -0,0 +1,51 @@ +getValue() == 1) { + return 'yes'; + } + + return 'no'; + } + + /** + * @return int<0, max> + */ + private function getValue(): int + { + return 1; + } +} + +?> +----- +getValue() === 1) { + return 'yes'; + } + + return 'no'; + } + + /** + * @return int<0, max> + */ + private function getValue(): int + { + return 1; + } +} + +?> diff --git a/rules/CodeQuality/Rector/Equal/UseIdenticalOverEqualWithSameTypeRector.php b/rules/CodeQuality/Rector/Equal/UseIdenticalOverEqualWithSameTypeRector.php index 2ec3520d03c..cee3f4f3b05 100644 --- a/rules/CodeQuality/Rector/Equal/UseIdenticalOverEqualWithSameTypeRector.php +++ b/rules/CodeQuality/Rector/Equal/UseIdenticalOverEqualWithSameTypeRector.php @@ -89,6 +89,10 @@ public function refactor(Node $node): ?Node return $this->processIdenticalOrNotIdentical($node); } + if ($leftStaticType->isInteger()->yes() && $rightStaticType->isInteger()->yes()) { + return $this->processIdenticalOrNotIdentical($node); + } + // different types if (! $leftStaticType->equals($rightStaticType)) { return null; diff --git a/rules/TypeDeclaration/PhpDocParser/TypeExpressionFromVarTagResolver.php b/rules/TypeDeclaration/PhpDocParser/TypeExpressionFromVarTagResolver.php index b0e8156881c..34760ba403e 100644 --- a/rules/TypeDeclaration/PhpDocParser/TypeExpressionFromVarTagResolver.php +++ b/rules/TypeDeclaration/PhpDocParser/TypeExpressionFromVarTagResolver.php @@ -110,7 +110,7 @@ public function resolveTypeExpressionFromVarTag(TypeNode $typeNode, Variable $va private function generateOrExpression(array $unionExpressions) { $booleanOr = new BooleanOr($unionExpressions[0], $unionExpressions[1]); - if (count($unionExpressions) == 2) { + if (count($unionExpressions) === 2) { return $booleanOr; } @@ -125,7 +125,7 @@ private function generateOrExpression(array $unionExpressions) private function generateAndExpression(array $intersectionExpressions) { $booleanAnd = new BooleanAnd($intersectionExpressions[0], $intersectionExpressions[1]); - if (count($intersectionExpressions) == 2) { + if (count($intersectionExpressions) === 2) { return $booleanAnd; } diff --git a/src/Configuration/OnlyRuleResolver.php b/src/Configuration/OnlyRuleResolver.php index 896e3dcee69..e4f3ad52c1f 100644 --- a/src/Configuration/OnlyRuleResolver.php +++ b/src/Configuration/OnlyRuleResolver.php @@ -48,7 +48,7 @@ public function resolve(string $rule): string } $matching = array_unique($matching); - if (count($matching) == 1) { + if (count($matching) === 1) { return $matching[0]; }