Php-parser: avoid usage `literal` node

Created on 31 Aug 2019  路  3Comments  路  Source: glayzzle/php-parser

We have one place where we use this node, i think we should replace this on something other https://github.com/glayzzle/php-parser/blob/master/src/parser/variable.js#L105

/cc @ichiriac what do you think? Other php parser doesn't have this node too

question wontfix

All 3 comments

It's a base class, extended by boolean, number, nowdoc, magic constants ... the name property contains the value of the literal, but as it encapsed with brackets, the expression node may be a property of another node ...

Here the ouput of nikic's implementation

foo::{$bar}();
array(
    0: Stmt_Expression(
        expr: Expr_StaticCall(
            class: Name(
                parts: array(
                    0: foo
                )
            )
            name: Expr_Variable(
                name: bar
            )
            args: array(
            )
        )
    )
)

Here it's using dirrectly the expression, without surrounding it with a node, so you loose information about brackets formatting, but from the AST point of view, it does not matters, we expect the offset to be an identifier or an expression ...

@ichiriac i don't mean remove literal node, i mean don't use this in ast directly, i will investigate this

Hi @evilebottnawi, if you want to work on it again you can still re-open this issue or a new one, I'll close it in order to keep issues clean

Was this page helpful?
0 / 5 - 0 ratings