-
Notifications
You must be signed in to change notification settings - Fork 72
fix: remove trailing newline in flexible heredoc/nowdoc value #469
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Hi @czosel, problem comes from here : https://github.com/glayzzle/php-parser/blob/master/src/parser/scalar.js#L227 In this function I remove the last line break, but here the last char is the indentation, so you should before checking add an extra check on indentation, remove the trailing indentation, and then keep the strip of last line break. |
4dfb2c6
to
8101f4f
Compare
Thanks for the pointer @ichiriac! I added a fix for nowdoc, but heredoc now I still have to figure out heredoc. Do you have another pointer? 😉 Update: Tests in prettier are passing now, because we're printing heredoc differently using |
Not sure, but from reading the code it may be handled here : https://github.com/glayzzle/php-parser/blob/master/src/parser/scalar.js#L329
The problem here is that you may also have tokens T_ENCAPSED_AND_WHITESPACE at the start;, middle, and at the end ... so you should include the fix here : https://github.com/glayzzle/php-parser/blob/master/src/parser/scalar.js#L435 By testing if the last node kind is a
|
8101f4f
to
b8560a8
Compare
b8560a8
to
6e372ba
Compare
Thanks again for the pointers @ichiriac - I made the changes. I didn't need to remove the indentation for heredoc, because that's already done in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perfect 👍 ready to merge 💯
Fixes #468