File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change 1010use PhpParser \Node \Scalar \Int_ ;
1111use PhpParser \Node \Scalar \String_ ;
1212use PhpParser \Node \Stmt ;
13+ use PhpParser \Node \VariadicPlaceholder ;
1314use PhpParser \PrettyPrinter \Standard ;
1415
1516class PrettyPrinterTest extends CodeTestAbstract {
@@ -305,4 +306,29 @@ public function testInvalidIndent(): void {
305306 $ this ->expectExceptionMessage ('Option "indent" must either be all spaces or a single tab ' );
306307 new PrettyPrinter \Standard (['indent ' => "\t " ]);
307308 }
309+
310+ public function testTrailingCommaArgToFirstClassCallable (): void {
311+ $ parser = (new ParserFactory ())->createForNewestSupportedVersion ();
312+ $ traverser = new NodeTraverser (new NodeVisitor \CloningVisitor ());
313+
314+ $ oldStmts = $ parser ->parse (<<<'CODE'
315+ <?php strlen("test",);
316+ CODE
317+ );
318+ $ oldTokens = $ parser ->getTokens ();
319+ $ newStmts = $ traverser ->traverse ($ oldStmts );
320+
321+ $ funcCall = $ newStmts [0 ]->expr ;
322+ $ funcCall ->args = [new VariadicPlaceholder ()];
323+
324+ $ prettyPrinter = new PrettyPrinter \Standard ();
325+ $ expected = <<<'CODE'
326+ <?php strlen(...);
327+ CODE;
328+
329+ $ this ->assertEquals (
330+ $ expected ,
331+ $ prettyPrinter ->printFormatPreserving ($ newStmts , $ oldStmts , $ oldTokens )
332+ );
333+ }
308334}
You can’t perform that action at this time.
0 commit comments