plugin-php icon indicating copy to clipboard operation
plugin-php copied to clipboard

Whitespace improperly removed from end of heredoc lines

Open karptonite opened this issue 2 years ago • 1 comments

@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!

karptonite avatar Jul 02 '22 01:07 karptonite

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!

czosel avatar Jul 10 '22 20:07 czosel