Skip to content

[PropertyInfo] Extracting short description does not work with @param annotation on promoted properties #60380

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
vuryss opened this issue May 8, 2025 · 2 comments

Comments

@vuryss
Copy link
Contributor

vuryss commented May 8, 2025

Symfony version(s) affected

7.x

Description

There are several methods to add a description to a property:

  • Just a plain comment on top of the property like this:
    /**
     * This is a description for property
     */
    public string $property;
  • With the @var annotation describing type and giving short description:
    /**
     * @var float this should be included in the description if no other description is provided
     */
    public float $property;
  • When the property is promoted - from the @param annotation of the constructor comment:
    /**
     * @param string $property Some short description here
     */
    public function __construct(
        public string $property,
    ) {
    }

First two work, third one does not because of this line: https://github.com/symfony/property-info/blob/f00fd9685ecdbabe82ca25c7b739ce7bba99302c/Extractor/PhpDocExtractor.php#L95 which considers only a @var annotation instead of also @param annotation if this is a promoted property. Param annotation is successfully extracted by the findDocBlock, but it remains unused here.

How to reproduce

Have a class with constructor like this:

    /**
     * @param string $property Some short description here
     */
    public function __construct(
        public string $property,
    ) {
    }

And extract the summary:

$description = $propertyInfoExtractor->getShortDescription($className, $propertyName);

Possible Solution

Consider also @param annotations in the aforementioned place in the code.

Additional Context

No response

@xabbuh
Copy link
Member

xabbuh commented May 8, 2025

see #59540

@vuryss
Copy link
Contributor Author

vuryss commented May 9, 2025

Ok guess didn't search well enough. Closing as duplicate of #59540

@vuryss vuryss closed this as completed May 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants