Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bf255fa

Browse files
bug #46611 [PropertyInfo] Fix multi phpdoc covered promoted properties (ostrolucky, simPod)
This PR was merged into the 6.1 branch. Discussion ---------- [PropertyInfo] Fix multi phpdoc covered promoted properties | Q | A | ------------- | --- | Branch? | 6.1 | Bug fix? | yes | Tickets | Fix #46550 | License | MIT I came up with this solution Commits ------- f503e37 [PropertyInfo] Fix multi phpdoc covered promoted properties 1605b57 [PropertyInfo] Add failing test case for multi phpdoc covered promoted properties
2 parents 5bb4827 + f503e37 commit bf255fa

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

src/Symfony/Component/PropertyInfo/Extractor/PhpStanExtractor.php

+8-4
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,14 @@ public function getTypes(string $class, string $property, array $context = []):
9999
continue;
100100
}
101101

102+
if (
103+
$tagDocNode->value instanceof ParamTagValueNode
104+
&& null === $prefix
105+
&& $tagDocNode->value->parameterName !== '$'.$property
106+
) {
107+
continue;
108+
}
109+
102110
foreach ($this->phpStanTypeHelper->getTypes($tagDocNode->value, $nameScope) as $type) {
103111
switch ($type->getClassName()) {
104112
case 'self':
@@ -239,10 +247,6 @@ private function getDocBlockFromProperty(string $class, string $property): ?arra
239247
$phpDocNode = $this->phpDocParser->parse($tokens);
240248
$tokens->consumeTokenType(Lexer::TOKEN_END);
241249

242-
if (self::MUTATOR === $source && !$this->filterDocBlockParams($phpDocNode, $property)) {
243-
return null;
244-
}
245-
246250
return [$phpDocNode, $source, $reflectionProperty->class];
247251
}
248252

src/Symfony/Component/PropertyInfo/Tests/Extractor/PhpStanExtractorTestDoc.php renamed to src/Symfony/Component/PropertyInfo/Tests/Extractor/PhpStanExtractorTest.php

+1
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,7 @@ public function php80TypesProvider()
467467
return [
468468
[Php80Dummy::class, 'promotedAndMutated', [new Type(Type::BUILTIN_TYPE_STRING)]],
469469
[Php80Dummy::class, 'promoted', null],
470+
[Php80Dummy::class, 'collection', [new Type(Type::BUILTIN_TYPE_ARRAY, collection: true, collectionValueType: new Type(Type::BUILTIN_TYPE_STRING))]],
470471
[Php80PromotedDummy::class, 'promoted', null],
471472
];
472473
}

src/Symfony/Component/PropertyInfo/Tests/Fixtures/Php80Dummy.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ class Php80Dummy
1717

1818
/**
1919
* @param string $promotedAndMutated
20+
* @param array<string> $collection
2021
*/
21-
public function __construct(private mixed $promoted, private mixed $promotedAndMutated)
22+
public function __construct(private mixed $promoted, private mixed $promotedAndMutated, private array $collection)
2223
{
2324
}
2425

0 commit comments

Comments
 (0)