Skip to content

Commit 4a42815

Browse files
authored
Fix complex next arg (#258)
* [DowngradePhp73] Fix complex next arg on DowngradeTrailingCommasInFunctionCallsRector * [DowngradePhp73] Fix complex next arg on DowngradeTrailingCommasInFunctionCallsRector * [DowngradePhp73] Fix complex next arg on DowngradeTrailingCommasInFunctionCallsRector
1 parent 3aebc81 commit 4a42815

File tree

2 files changed

+494
-3
lines changed

2 files changed

+494
-3
lines changed

rules/DowngradePhp73/Rector/FuncCall/DowngradeTrailingCommasInFunctionCallsRector.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,17 @@ public function refactor(Node $node): ?Node
9393
$iteration = 1;
9494

9595
while (isset($tokens[$args[$lastArgKey]->getEndTokenPos() + $iteration])) {
96-
if (trim($tokens[$args[$lastArgKey]->getEndTokenPos() + $iteration]->text) === ',') {
97-
$tokens[$args[$lastArgKey]->getEndTokenPos() + $iteration]->text = '';
96+
if (trim($tokens[$args[$lastArgKey]->getEndTokenPos() + $iteration]->text) === '') {
97+
++$iteration;
98+
continue;
99+
}
100+
101+
if (trim($tokens[$args[$lastArgKey]->getEndTokenPos() + $iteration]->text) !== ',') {
98102
break;
99103
}
100104

101-
++$iteration;
105+
$tokens[$args[$lastArgKey]->getEndTokenPos() + $iteration]->text = '';
106+
break;
102107
}
103108

104109
return $node;

0 commit comments

Comments
 (0)