Custom Rector rule removing blank line and ?> #6803
Unanswered
freiondrej-lmc
asked this question in
Q&A
Replies: 1 comment 3 replies
-
Hi Ondra, thanks for sharing your use case. That's probably job of Standard printer output: As for the spacing, it should be handled by coding standrad, not by AST. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
I'm writing a custom rector rule. It has been an amazing experience, Rector has been a really good companion! 👏
Anyway, I'm following the new Rector book on how to write a rule using TDD, so I have several fixtures to check everything works as expected. I encountered a very strange behavior with one of the fixtures. It contains a class with two node changes being applied, the rule works with
PhpParser\Node\Stmt\Expression
. However, the test fails showing me that there were two unexpected changes as well - 1) a blank line between the use statements and the class definition is removed, 2) the?>
at the very end of the file is removed. The fixtures where only one node change is applied don't have this problem.It is very well possible that I'm doing something wrong in the way the two nodes are manipulated, but I suspect this to be a different problem because I'm definitely not manipulating neither blank line before the class nor the closing
?>
tag.Tried with rector 0.11.60.
Do you have any idea what should I do to prevent this behavior? Thank you! 🙂
Beta Was this translation helpful? Give feedback.
All reactions