Should Rector be able to move files? #9212
-
|
Hello 👋🏽 We were discussing some refactoring project to do with Rector, but found out Rector does not have any API to move files. Can (or should) Rector be able to move files? I think it'd be good addition, if it's possible technically. |
Beta Was this translation helpful? Give feedback.
Answered by
samsonasik
Jun 15, 2025
Replies: 1 comment
-
|
I think you can use native php function for that, for printing content, you can use $content = $this->betterStandardPrinter->prettyPrintFile($stmts);
file_put_content('/path/to/file.php', $content); |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
samsonasik
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think you can use native php function for that, for printing content, you can use
BetterStandardPrinter::prettyPrintFile()for given stmts for its file content.https://github.com/rectorphp/rector/blob/62a3cdc00af34a0f2cf4ee7dc2f0a05bef0d3051/src/PhpParser/Printer/BetterStandardPrinter.php#L99C21-L104