rector-src icon indicating copy to clipboard operation
rector-src copied to clipboard

[e2e][Printer] Handle crash indentation on AddParamBasedOnParentClassMethodRector

Open samsonasik opened this issue 1 year ago • 3 comments

Fixes https://github.com/rectorphp/rector/issues/8712

Step to reproduce only via e2e test:

cd e2e/print-new-node 
composer install
php ../e2eTestRunner.php 

without this patch, it will cause error:

➜  print-new-node git:(indentation-crash-error) php ../e2eTestRunner.php
 2/2 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%    ---------- begin diff ----------
@@ @@
-[ERROR] Could not process "./print-new-node/src/ExtendingTestClass.php" file, due
-         to:
-         "System error: "Rector\PhpParser\Printer\BetterStandardPrinter::p(): Return value must be of type string, null
-         returned"
-         Run Rector with "--debug" option and post the report here: https://github.com/rectorphp/rector/issues/new". On line: 154

For note: I already tried set origNode = null on the target rule, but no luck, it only resolvable via printer.

samsonasik avatar Jul 03 '24 15:07 samsonasik

Fixed 🎉 /cc @RuesimOfCode

samsonasik avatar Jul 03 '24 15:07 samsonasik

All checks have passed 🎉 @TomasVotruba I think it is ready.

samsonasik avatar Jul 03 '24 15:07 samsonasik

This looks like bug in php-parser itself. If that's true, we should report it first there with a reproducer.

TomasVotruba avatar Jul 03 '24 16:07 TomasVotruba

Ready to go :+1:

TomasVotruba avatar Jul 12 '24 08:07 TomasVotruba

I can't approve my own PR, i think this is ready, just probably concern about renaming method bc break :)

samsonasik avatar Jul 12 '24 09:07 samsonasik