From 7e6c39d7cabad05ab4bd1cf2f995e62eec092ea5 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sat, 16 Sep 2023 13:41:27 +0200 Subject: [PATCH 1/2] Simplify UseIdenticalOverEqualWithSameTypeRector --- .../UseIdenticalOverEqualWithSameTypeRector.php | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/rules/CodeQuality/Rector/Equal/UseIdenticalOverEqualWithSameTypeRector.php b/rules/CodeQuality/Rector/Equal/UseIdenticalOverEqualWithSameTypeRector.php index 7ac0b732a5e..09032e5878c 100644 --- a/rules/CodeQuality/Rector/Equal/UseIdenticalOverEqualWithSameTypeRector.php +++ b/rules/CodeQuality/Rector/Equal/UseIdenticalOverEqualWithSameTypeRector.php @@ -72,7 +72,7 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - $leftStaticType = $this->getType($node->left); + $leftStaticType = $this->nodeTypeResolver->getNativeType($node->left); // objects can be different by content if ($leftStaticType instanceof ObjectType) { @@ -83,7 +83,7 @@ public function refactor(Node $node): ?Node return null; } - $rightStaticType = $this->getType($node->right); + $rightStaticType = $this->nodeTypeResolver->getNativeType($node->right); if ($rightStaticType instanceof MixedType) { return null; } @@ -93,23 +93,10 @@ public function refactor(Node $node): ?Node return null; } - if ($this->areNonTypedFromParam($node->left, $node->right)) { - return null; - } - if ($node instanceof Equal) { return new Identical($node->left, $node->right); } return new NotIdentical($node->left, $node->right); } - - private function areNonTypedFromParam(Expr $left, Expr $right): bool - { - if ($this->exprAnalyzer->isNonTypedFromParam($left)) { - return true; - } - - return $this->exprAnalyzer->isNonTypedFromParam($right); - } } From 5ff4880c09b5cd084bd79c645cd75e792f6cb82f Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sat, 16 Sep 2023 13:43:35 +0200 Subject: [PATCH 2/2] Update UseIdenticalOverEqualWithSameTypeRector.php --- .../Rector/Equal/UseIdenticalOverEqualWithSameTypeRector.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/rules/CodeQuality/Rector/Equal/UseIdenticalOverEqualWithSameTypeRector.php b/rules/CodeQuality/Rector/Equal/UseIdenticalOverEqualWithSameTypeRector.php index 09032e5878c..e3a021c2da5 100644 --- a/rules/CodeQuality/Rector/Equal/UseIdenticalOverEqualWithSameTypeRector.php +++ b/rules/CodeQuality/Rector/Equal/UseIdenticalOverEqualWithSameTypeRector.php @@ -22,11 +22,6 @@ */ final class UseIdenticalOverEqualWithSameTypeRector extends AbstractRector { - public function __construct( - private readonly ExprAnalyzer $exprAnalyzer - ) { - } - public function getRuleDefinition(): RuleDefinition { return new RuleDefinition(