Skip to content

Commit 6576459

Browse files
committed
early check
1 parent 3891e2d commit 6576459

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

rules/DeadCode/Rector/Ternary/RemoveUselessTernaryRector.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,6 @@ public function getNodeTypes(): array
6262
*/
6363
public function refactor(Node $node): ?Node
6464
{
65-
if ($node->if instanceof Expr && ! $this->nodeComparator->areNodesEqual($node->if, $node->cond)) {
66-
return null;
67-
}
68-
6965
/**
7066
* if condition is negated, skip
7167
* switch negated ternary condition early via SwitchNegatedTernaryRector for that
@@ -75,6 +71,10 @@ public function refactor(Node $node): ?Node
7571
return null;
7672
}
7773

74+
if ($node->if instanceof Expr && ! $this->nodeComparator->areNodesEqual($node->if, $node->cond)) {
75+
return null;
76+
}
77+
7878
$nativeType = $this->nodeTypeResolver->getNativeType($node->cond);
7979
if ($nativeType instanceof BooleanType && $this->valueResolver->isFalse($node->else)) {
8080
return $node->cond;

0 commit comments

Comments
 (0)