Skip to content

[TypeInfo] Reading @var on promoted properties #59959

@jack-worman

Description

@jack-worman

Symfony version(s) affected

7.2.4

Description

The @var tag is no longer read for promoted properties.

The bug was introduced in #59681

The example in the documentation no longer works: https://symfony.com/doc/current/components/type_info.html#phpdoc-parsing

How to reproduce

class Dummy
{
    public function __construct(
        /** @var list<string> $tags */
        public array $tags,
    ) {
    }
}

$typeResolver = TypeResolver::create();
var_export($typeResolver->resolve(new \ReflectionProperty(Dummy::class, 'tags'))); // only "array" instead of "list<string>"

Possible Solution

The correct solution is to prioritize the @var annotation on the property and then fallback to the @param annotation on the constructor

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions