php-cfg icon indicating copy to clipboard operation
php-cfg copied to clipboard

support of php attributes

Open eric-therond opened this issue 2 years ago • 2 comments

I would like to improve php-cfg to add information about php attributes in the CFG.

For this code sample:

#[ExampleAttribute('Hello world', 42)]
class NameOfClass {
}

Do you think the following output to generate is correct?

Block#1
    Stmt_Class
        name: LITERAL('NameOfClass')
        stmts: Block#2
        attrs_group: Block#3

Block#2

Block#3
    AttributeGroup
        attrs[0]: Block#4

Block#4
    Attribute
        name: LITERAL('ExampleAttribute')
        args[0]: LITERAL('Hello world')
        args[1]: LITERAL(42)

Eric

eric-therond avatar Jan 08 '24 16:01 eric-therond

I don't think it makes sense to put attributes in a "block". They should be in a property on the class, just like in the AST.

nikic avatar Jan 08 '24 17:01 nikic

So more something like that:

Block#1
    Stmt_Class
        name: LITERAL('NameOfClass')
        stmts: Block#2
        attrs_group[0]: ExampleAttribute('Hello world', 42)

eric-therond avatar Jan 09 '24 07:01 eric-therond