Skip to content

Invalid output caused by combo of if statement, inline node, and comment #517

@ionrocks

Description

@ionrocks

Input:

<?php
if (true) {
    ?>inline<?php
    // comment
}

Output:

<?php
if (true) { ?>inline<?php
    // comment
    // comment
    ?>}

Note the extra closing tag that has been added, which makes the code invalid, and that the comment is duplicated, which is unexpected.

If you comment out this line, it doesn't print out the closing tag that breaks the code, but it also removes the closing tag from the test file inline3.php.

If you comment out the line above, prettier throws the following error, I think about inline3.php again.

Comment "// test" was not printed. Please report this error!

I've tried to debug, but the printing system is quite large. I'll still keep looking, but might as well put it out to the community too!

Problem aslo with

<!DOCTYPE html>
<html lang="de">
<head>
    <?php /* ups */
    if (1==1)
    {
        echo 'FOO';
    } ?>
</head>
<body>
</body>
</html>

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions