diff --git a/src/Symfony/Component/PropertyInfo/Extractor/PhpStanExtractor.php b/src/Symfony/Component/PropertyInfo/Extractor/PhpStanExtractor.php index 52a4a78f2537f..429f43202543d 100644 --- a/src/Symfony/Component/PropertyInfo/Extractor/PhpStanExtractor.php +++ b/src/Symfony/Component/PropertyInfo/Extractor/PhpStanExtractor.php @@ -99,6 +99,14 @@ public function getTypes(string $class, string $property, array $context = []): continue; } + if ( + $tagDocNode->value instanceof ParamTagValueNode + && null === $prefix + && $tagDocNode->value->parameterName !== '$'.$property + ) { + continue; + } + foreach ($this->phpStanTypeHelper->getTypes($tagDocNode->value, $nameScope) as $type) { switch ($type->getClassName()) { case 'self': @@ -239,10 +247,6 @@ private function getDocBlockFromProperty(string $class, string $property): ?arra $phpDocNode = $this->phpDocParser->parse($tokens); $tokens->consumeTokenType(Lexer::TOKEN_END); - if (self::MUTATOR === $source && !$this->filterDocBlockParams($phpDocNode, $property)) { - return null; - } - return [$phpDocNode, $source, $reflectionProperty->class]; } diff --git a/src/Symfony/Component/PropertyInfo/Tests/Extractor/PhpStanExtractorTestDoc.php b/src/Symfony/Component/PropertyInfo/Tests/Extractor/PhpStanExtractorTest.php similarity index 99% rename from src/Symfony/Component/PropertyInfo/Tests/Extractor/PhpStanExtractorTestDoc.php rename to src/Symfony/Component/PropertyInfo/Tests/Extractor/PhpStanExtractorTest.php index 7565994ee0c8c..9b49e70e202a7 100644 --- a/src/Symfony/Component/PropertyInfo/Tests/Extractor/PhpStanExtractorTestDoc.php +++ b/src/Symfony/Component/PropertyInfo/Tests/Extractor/PhpStanExtractorTest.php @@ -467,6 +467,7 @@ public function php80TypesProvider() return [ [Php80Dummy::class, 'promotedAndMutated', [new Type(Type::BUILTIN_TYPE_STRING)]], [Php80Dummy::class, 'promoted', null], + [Php80Dummy::class, 'collection', [new Type(Type::BUILTIN_TYPE_ARRAY, collection: true, collectionValueType: new Type(Type::BUILTIN_TYPE_STRING))]], [Php80PromotedDummy::class, 'promoted', null], ]; } diff --git a/src/Symfony/Component/PropertyInfo/Tests/Fixtures/Php80Dummy.php b/src/Symfony/Component/PropertyInfo/Tests/Fixtures/Php80Dummy.php index e7ae2fc83bfec..dc985fea0b212 100644 --- a/src/Symfony/Component/PropertyInfo/Tests/Fixtures/Php80Dummy.php +++ b/src/Symfony/Component/PropertyInfo/Tests/Fixtures/Php80Dummy.php @@ -17,8 +17,9 @@ class Php80Dummy /** * @param string $promotedAndMutated + * @param array $collection */ - public function __construct(private mixed $promoted, private mixed $promotedAndMutated) + public function __construct(private mixed $promoted, private mixed $promotedAndMutated, private array $collection) { }