Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions rules/Php74/Rector/Closure/ClosureToArrowFunctionRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,15 @@ public function refactor(Node $node): ?Node
return null;
}

// convert a directly nested closure in the same pass, so each closure node is handled once
// instead of leaving the inner one for another traverse pass
if ($returnExpr instanceof Closure) {
$nestedArrowFunction = $this->refactor($returnExpr);
if ($nestedArrowFunction instanceof Expr) {
$returnExpr = $nestedArrowFunction;
}
}

$attributes = $node->getAttributes();
unset($attributes[AttributeKey::ORIGINAL_NODE]);

Expand Down
Loading