Skip to content

Commit

Permalink
Fix complex next arg (#258)
Browse files Browse the repository at this point in the history
* [DowngradePhp73] Fix complex next arg on DowngradeTrailingCommasInFunctionCallsRector

* [DowngradePhp73] Fix complex next arg on DowngradeTrailingCommasInFunctionCallsRector

* [DowngradePhp73] Fix complex next arg on DowngradeTrailingCommasInFunctionCallsRector
  • Loading branch information
samsonasik authored Dec 12, 2024
1 parent 3aebc81 commit 4a42815
Show file tree
Hide file tree
Showing 2 changed files with 494 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,17 @@ public function refactor(Node $node): ?Node
$iteration = 1;

while (isset($tokens[$args[$lastArgKey]->getEndTokenPos() + $iteration])) {
if (trim($tokens[$args[$lastArgKey]->getEndTokenPos() + $iteration]->text) === ',') {
$tokens[$args[$lastArgKey]->getEndTokenPos() + $iteration]->text = '';
if (trim($tokens[$args[$lastArgKey]->getEndTokenPos() + $iteration]->text) === '') {
++$iteration;
continue;
}

if (trim($tokens[$args[$lastArgKey]->getEndTokenPos() + $iteration]->text) !== ',') {
break;
}

++$iteration;
$tokens[$args[$lastArgKey]->getEndTokenPos() + $iteration]->text = '';
break;
}

return $node;
Expand Down
Loading

0 comments on commit 4a42815

Please sign in to comment.