diff --git a/rules/EarlyReturn/NodeAnalyzer/IfAndAnalyzer.php b/rules/EarlyReturn/NodeAnalyzer/IfAndAnalyzer.php index a0c4ea3917e..b6db68fe25c 100644 --- a/rules/EarlyReturn/NodeAnalyzer/IfAndAnalyzer.php +++ b/rules/EarlyReturn/NodeAnalyzer/IfAndAnalyzer.php @@ -40,15 +40,7 @@ public function isIfStmtExprUsedInNextReturn(If_ $if, Return_ $return): bool $ifExprs = $this->betterNodeFinder->findInstanceOf($if->stmts, Expr::class); return (bool) $this->betterNodeFinder->findFirst( $return->expr, - function (Node $node) use ($ifExprs): bool { - foreach ($ifExprs as $ifExpr) { - if ($this->nodeComparator->areNodesEqual($node, $ifExpr)) { - return true; - } - } - - return false; - } + fn (Node $node): bool => $this->nodeComparator->isNodeEqual($node, $ifExprs) ); } }