Skip to content

Commit 03372e8

Browse files
fix: extract no type @param annotation with PhpStanExtractor
1 parent 653e42d commit 03372e8

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
use PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode;
1717
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode;
1818
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode;
19+
use PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode;
20+
use PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode;
1921
use PHPStan\PhpDocParser\Lexer\Lexer;
2022
use PHPStan\PhpDocParser\Parser\ConstExprParser;
2123
use PHPStan\PhpDocParser\Parser\PhpDocParser;
@@ -206,7 +208,7 @@ public function getType(string $class, string $property, array $context = []): ?
206208
$types = [];
207209

208210
foreach ($docNode->getTagsByName($tag) as $tagDocNode) {
209-
if ($tagDocNode->value instanceof InvalidTagValueNode) {
211+
if (!$tagDocNode->value instanceof ParamTagValueNode && !$tagDocNode->value instanceof ReturnTagValueNode && !$tagDocNode->value instanceof VarTagValueNode) {
210212
continue;
211213
}
212214

src/Symfony/Component/PropertyInfo/Tests/Extractor/PhpStanExtractorTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,7 @@ public static function invalidTypesProvider(): iterable
694694
yield 'stat' => ['stat'];
695695
yield 'foo' => ['foo'];
696696
yield 'bar' => ['bar'];
697+
yield 'baz' => ['baz'];
697698
}
698699

699700
/**

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,11 @@ public function getBar()
4747
{
4848
return 'bar';
4949
}
50+
51+
/**
52+
* @param $baz
53+
*/
54+
public function setBaz($baz)
55+
{
56+
}
5057
}

0 commit comments

Comments
 (0)