We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d025cdd commit b38a156Copy full SHA for b38a156
rules/EarlyReturn/Rector/Return_/PreparedValueToEarlyReturnRector.php
@@ -110,12 +110,12 @@ public function refactor(Node $node): ?StmtsAwareInterface
110
return null;
111
}
112
113
- if ($stmt instanceof For_ || $stmt instanceof Foreach_ || $stmt instanceof While_ || $stmt instanceof Do_) {
+ if (($stmt instanceof For_ || $stmt instanceof Foreach_ || $stmt instanceof While_ || $stmt instanceof Do_) && $initialAssign instanceof Assign) {
114
$isReassignInLoop = (bool) $this->betterNodeFinder->findFirst(
115
$stmt,
116
fn (Node $node): bool => $node instanceof Assign && $this->nodeComparator->areNodesEqual(
117
$node->var,
118
- $initialAssign?->var
+ $initialAssign->var
119
)
120
);
121
0 commit comments