Skip to content

Commit 0d47d4c

Browse files
committed
Check for variable name in parameters before adding to uses
1 parent b55c3bc commit 0d47d4c

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

rules/DowngradePhp74/Rector/ArrowFunction/ArrowFunctionToAnonymousFunctionRector.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,16 @@ public function refactor(Node $node): Closure
9898
);
9999

100100
if (! $isFound) {
101-
$anonymousFunctionFactory->uses[] = new ClosureUse($node->expr->expr);
101+
$isAlsoParam = in_array(
102+
$node->expr->expr->name,
103+
array_map(function($param) {
104+
return $param->var->name;
105+
}, $node->params)
106+
);
107+
108+
if (! $isAlsoParam) {
109+
$anonymousFunctionFactory->uses[] = new ClosureUse($node->expr->expr);
110+
}
102111
}
103112
}
104113

0 commit comments

Comments
 (0)