Skip to content

Commit d8e208e

Browse files
committed
Fix parsing multiple @method tags in regard to generics
1 parent 2f55c7c commit d8e208e

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

src/PhpDoc/PhpDocNodeResolver.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,11 @@ public function resolvePropertyTags(PhpDocNode $phpDocNode, NameScope $nameScope
160160
public function resolveMethodTags(PhpDocNode $phpDocNode, NameScope $nameScope): array
161161
{
162162
$resolved = [];
163+
$originalNameScope = $nameScope;
163164

164165
foreach (['@method', '@psalm-method', '@phpstan-method'] as $tagName) {
165166
foreach ($phpDocNode->getMethodTagValues($tagName) as $tagValue) {
167+
$nameScope = $originalNameScope;
166168
$templateTags = [];
167169

168170
if (count($tagValue->templateTypes) > 0 && $nameScope->getClassName() !== null) {

tests/PHPStan/Analyser/data/generic-method-tags.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
/**
88
* @method TVal doThing<TVal of mixed>(TVal $param)
9+
* @method TVal doAnotherThing(int $param)
910
*/
1011
class Test
1112
{
@@ -20,4 +21,5 @@ function test(int $int, string $string): void
2021

2122
assertType('int', $test->doThing($int));
2223
assertType('string', $test->doThing($string));
24+
assertType(TVal::class, $test->doAnotherThing($int));
2325
}

0 commit comments

Comments
 (0)