Add arg on new without parentheses should add ) close #1134
+9
−0
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.