Closed as not planned
Closed as not planned
Description
Symfony version(s) affected
7.2
Description
Hi,
I'm facing weird issue in SF 7.2. Using local-aliases (https://phpstan.org/writing-php-code/phpdoc-types#local-type-aliases) with @phpstan-type
is badly resolved by extractors.
How to reproduce
<?php
use Symfony\Component\PropertyInfo\Extractor\PhpStanExtractor;
use Symfony\Component\PropertyInfo\Extractor\ReflectionExtractor;
use Symfony\Component\PropertyInfo\PropertyInfoExtractor;
/** @phpstan-type AspectRatio 1.0|1.1|1.2|1.3|1.4|1.5|1.6|1.7|1.8|1.9|2.0 */
class Test1234
{
/** @param AspectRatio|null $aspectRatio */
public function __construct(public float|null $aspectRatio)
{
}
}
$propertyInfo = new PropertyInfoExtractor(
listExtractors: [],
typeExtractors: [new PhpStanExtractor(), new ReflectionExtractor()],
descriptionExtractors: [],
accessExtractors: [],
initializableExtractors: []
);
$types = $propertyInfo->getTypes(Test1234::class, 'aspectRatio');
dump($types);
Resulted in this output:
array:1 [▼
0 => Symfony\Component\PropertyInfo\Type {#42 ▼
-collectionKeyType: []
-collectionValueType: []
-builtinType: "object"
-nullable: true
-class: "AspectRatio" <== this class not exists
-collection: false
}
]
But I expected this output instead:
array:1 [▼
0 => Symfony\Component\PropertyInfo\Type {#23 ▼
-collectionKeyType: []
-collectionValueType: []
-builtinType: "float"
-nullable: true
-class: null
-collection: false
}
]
Possible Solution
Exactly the same result is expected when we set PropertyInfoExtrator
to typeExtractors: [new ReflectionExtractor()]
.
I don't know how to fix this, but I guess this bug is maybe related with phpstan/phpdoc-parser
by #58800
Thanks for help!
Additional Context
No response