Skip to content

baseline error formatter is not escaping < correctly #2843

@jaydiablo

Description

@jaydiablo

Bug report

When using the baseline error format (to generate a baseline file to include to ignore legacy errors), it appears that < is not getting escaped properly.

Here's an example of one that was put in my baseline file (using PHPStan 0.12.4):

message: "#^Comparison operation \"\<\\=\" between \\*NEVER\\* and 5 is always true\\.$#"

Here's a similar error added, but with > instead of <:

message: "#^Comparison operation \"\\>\\=\" between \\*NEVER\\* and 1 is always true\\.$#"

Notice that > is getting two escaping slashes before it but < only gets one.

This seems to happen whenever < is encountered, not just on this particular message.

When trying to include the baseline file, PHPStan throws an exception:

In Decoder.php line 331:
Invalid escaping sequence < on line 64, column 13.

If I manually add the additional escape slash, the file parses fine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions