Skip to content

Whitespace improperly removed from end of heredoc lines #2026

Open

Description

@karptonite

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

Activity

  1. czosel commented on Jul 10, 2022

    @czosel
    Collaborator

    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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions