From 3d7c016a430d776cad1c6c56c6d87eeb92906667 Mon Sep 17 00:00:00 2001 From: Henrik Elsner Date: Fri, 22 Dec 2023 14:46:07 +0100 Subject: [PATCH] [BUGFIX] Use arg as var name instead of fixed one Resolves: #3940 --- ...stituteMethodRmFromListOfGeneralUtilityRector.php | 3 ++- .../Fixture/remove_from_list_to_array_filter.php.inc | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Rector/v11/v3/SubstituteMethodRmFromListOfGeneralUtilityRector.php b/src/Rector/v11/v3/SubstituteMethodRmFromListOfGeneralUtilityRector.php index b83b9703a..8c53d8b3e 100644 --- a/src/Rector/v11/v3/SubstituteMethodRmFromListOfGeneralUtilityRector.php +++ b/src/Rector/v11/v3/SubstituteMethodRmFromListOfGeneralUtilityRector.php @@ -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)); - $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); diff --git a/tests/Rector/v11/v3/SubstituteMethodRmFromListOfGeneralUtilityRector/Fixture/remove_from_list_to_array_filter.php.inc b/tests/Rector/v11/v3/SubstituteMethodRmFromListOfGeneralUtilityRector/Fixture/remove_from_list_to_array_filter.php.inc index 345317e33..e991f3883 100644 --- a/tests/Rector/v11/v3/SubstituteMethodRmFromListOfGeneralUtilityRector/Fixture/remove_from_list_to_array_filter.php.inc +++ b/tests/Rector/v11/v3/SubstituteMethodRmFromListOfGeneralUtilityRector/Fixture/remove_from_list_to_array_filter.php.inc @@ -9,6 +9,11 @@ $list = '1,2,3'; $newList = GeneralUtility::rmFromList($element, $list); +$newElementVarName = '1'; +$newListVarName = '1,2,3'; + +$newListTwo = GeneralUtility::rmFromList($newElementVarName, $newListVarName); + ?> -----