plugin-php
plugin-php copied to clipboard
Whitespace improperly removed from end of heredoc lines
@prettier/plugin-php v0.18.8 Playground link
Input:
<?php
$foo = <<<EOT
foo
EOT;
Output:
<?php
$foo = <<<EOT
foo
EOT;
For PHP 7.3 and up, prettier PHP is improperly removing whitespace from the ends of lines in heredoc strings. Note that there are space characters after "foo" in the Input string that are missing in the formatted output. Prettier should not be touching whitespace inside of a string.
This broke an application for us, where we were hashing such strings to generate filenames.
Let me know if you have any questions about this!
Thanks for the bug report @karptonite! After a first glance at the AST it looks to me like the problem is not in the parser, but in this repository. I probably won't have the chance to take closer look until early august, so if anyone else does, please go ahead!