Skip to content

Commit

Permalink
[BUGFIX] Use arg as var name instead of fixed one
Browse files Browse the repository at this point in the history
Resolves: #3940
  • Loading branch information
helsner authored and simonschaufi committed Dec 22, 2023
1 parent 28a1d68 commit 1619626
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ public function refactor(Node $node): ?Node
$explodeFuncCall = $this->nodeFactory->createFuncCall('explode', [',', $node->args[1]]);

$itemVariable = new Variable('item');
$elementVariable = new Variable($this->nodeNameResolver->getName($node->args[0]->value) ?? 'element');

$stmts = [new Return_(new Equal(new Variable('element'), $itemVariable))];
$stmts = [new Return_(new Equal($elementVariable, $itemVariable))];

$closureFunction = $this->anonymousFunctionFactory->create([new Param($itemVariable)], $stmts, null);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ $list = '1,2,3';

$newList = GeneralUtility::rmFromList($element, $list);

$newElementVarName = '1';
$newListVarName = '1,2,3';

$newListTwo = GeneralUtility::rmFromList($newElementVarName, $newListVarName);

?>
-----
<?php
Expand All @@ -24,4 +29,11 @@ $newList = implode(',', array_filter(explode(',', $list), function ($item) use (
return $element == $item;
}));

$newElementVarName = '1';
$newListVarName = '1,2,3';

$newListTwo = implode(',', array_filter(explode(',', $newListVarName), function ($item) use ($newElementVarName) {
return $newElementVarName == $item;
}));

?>

0 comments on commit 1619626

Please sign in to comment.