Add arg on new without parentheses should add ) close#1134
Closed
samsonasik wants to merge 1 commit into
Closed
Conversation
Contributor
|
@samsonasik Intersting. I'm almost certain this must have worked before. |
Contributor
Author
|
It never working before iirc, when you have |
Owner
|
Thanks for the report! The way insertion into an empty argument list usually works is by finding the next |
nikic
added a commit
that referenced
this pull request
Dec 6, 2025
Fixes the issue reported in #1134.
Owner
|
I believe 8c360e2 should fix the issue. |
Contributor
Author
|
@nikic yes, that's works, thank you. Btw, could you look on my and @TomasVotruba PRs if you have a chance, thank you. |
Contributor
|
Thank you 👍 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
@TomasVotruba this is detected on our rector-symfony rule:
can be run with:
vendor/bin/phpunit test/PhpParser/PrettyPrinterTest.php --filter "addArgNewWithoutParentheses" PHPUnit 9.6.29 by Sebastian Bergmann and contributors. F 1 / 1 (100%) Time: 00:00.007, Memory: 12.00 MB There was 1 failure: 1) PhpParser\PrettyPrinterTest::testFormatPreservingPrint with data set "Users/samsonasik/www/PHP-Parser/test/code/formatPreservation/addArgNewWithoutParentheses.test#0" ('Add Arg New Without Parenthes....test)', '<?php\nnew DateTime;', '$stmts[0]->expr->args = [new ...w'))];', '<?php\nnew DateTime('now');', null) Add Arg New Without Parentheses (/Users/samsonasik/www/PHP-Parser/test/code/formatPreservation/addArgNewWithoutParentheses.test) Failed asserting that two strings are identical. --- Expected +++ Actual @@ @@ '<?php -new DateTime('now');' +new DateTime'now'<?php +new DateTime;' /Users/samsonasik/www/PHP-Parser/test/PhpParser/PrettyPrinterTest.php:236 FAILURES! Tests: 1, Assertions: 1, Failures: 1.that only green when using
()on the very first.which new without parentheses got invalid diff, and we tricked to set origNode null there.
This test for it, hopefully can be fixed here instead.