Skip to content

Commit ccb61b2

Browse files
committed
remove trailing in printer
1 parent c97b23d commit ccb61b2

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

lib/PhpParser/PrettyPrinterAbstract.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,13 @@ protected function p(
765765
$pos = $subEndPos + 1;
766766
}
767767

768-
$result .= $this->origTokens->getTokenCode($pos, $endPos + 1, $indentAdjustment);
768+
$tokenCode = $this->origTokens->getTokenCode($pos, $endPos + 1, $indentAdjustment);
769+
if ($node instanceof Expr\CallLike && $node->isFirstClassCallable()) {
770+
$tokenCode = trim($tokenCode, ',');
771+
}
772+
773+
$result .= $tokenCode;
774+
769775
return $result;
770776
}
771777

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Replace args with VariadicPlaceholder should remove trailing comma
2+
-----
3+
<?php
4+
strlen(
5+
'test',
6+
);
7+
8+
strlen('another',);
9+
-----
10+
$stmts[0]->expr->args = [new Node\VariadicPlaceholder()];
11+
$stmts[1]->expr->args = [new Node\VariadicPlaceholder()];
12+
-----
13+
<?php
14+
strlen(
15+
...
16+
);
17+
18+
strlen(...);

0 commit comments

Comments
 (0)