Closed
Description
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