Skip to content

Attributes are not loaded correctly #98

@alanpoulain

Description

@alanpoulain

Version: 3.6.4

Bug Description

When loading from the code (PhpFile::fromCode($content)), attribute arguments are not loaded as expected: arguments are "duplicated".
For instance, with this attribute:

#[AnAttribute(foo: 'bar')]

The loaded arguments will be:

$args = ['foo' => new Literal("foo: 'bar'")];

Expected Behavior

The loaded arguments should be:

$args = ['foo' => new Literal("'bar'")];

Possible Solution

The issue comes from the call to getReformattedContents which gets everything inside the attribute as raw. It shouldn't be the case when loading content.

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