Skip to content

Bug: Concatenation changes the order of elements by prettyprinter #1041

Open
@jorgsowa

Description

Given the code:

<?php
('abc' . 1) + 2;

And running the parser on the original and PrettyPrinter format we get different AST.

Original:

array(
    0: Stmt_Expression(
        expr: Expr_BinaryOp_Plus(
            left: Expr_BinaryOp_Concat(
                left: Scalar_String(
                    value: abc
                )
                right: Scalar_Int(
                    value: 1
                )
            )
            right: Scalar_Int(
                value: 2
            )
        )
    )
)

Prettied:

array(
    0: Stmt_Expression(
        expr: Expr_BinaryOp_Concat(
            left: Scalar_String(
                value: abc
            )
            right: Expr_BinaryOp_Plus(
                left: Scalar_Int(
                    value: 1
                )
                right: Scalar_Int(
                    value: 2
                )
            )
        )
    )
)

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions