Skip to content

Heredoc containing \n cannot be parsed for indenting #2015

@karptonite

Description

@karptonite

Playground link

Input:

<?php
function foo() {
    $message .= <<<EOT
    Please read this message.\n  We apologize for the inconvenience.
    EOT;
}

Output:

Invalid body indentation level (expecting an indentation at least 4) on line 5

  3 |     $message .= <<<EOT
  4 |     Please read this message.\n  We apologize for the inconvenience.
> 5 |     EOT;
    |    ^
  6 | }
  7 |

Expected:

<?php
function foo() {
    $message .= <<<EOT
    Please read this message.\n  We apologize for the inconvenience.
    EOT;
}

Basically, the \n in the middle of the heredoc appears to confuse either the parser or prettier.

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