Skip to content

Commit 605e369

Browse files
Seldaekondrejmirtes
authored andcommitted
Fix wildcard parsing to end if a space follows, fixes phpstan/phpstan#5628
1 parent d622b7c commit 605e369

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

src/Parser/ConstExprParser.php

+4
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ public function parse(TokenIterator $tokens, bool $trimStrings = false): Ast\Con
7070
$classConstantName .= '*';
7171
$lastType = Lexer::TOKEN_WILDCARD;
7272

73+
if ($tokens->getSkippedHorizontalWhiteSpaceIfAny() !== '') {
74+
break;
75+
}
76+
7377
continue;
7478
}
7579

tests/PHPStan/Parser/PhpDocParserTest.php

+45
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,22 @@ public function provideParamTagsData(): \Iterator
226226
]),
227227
];
228228

229+
yield [
230+
'OK const wildcard with description',
231+
'/** @param self::* $foo optional description */',
232+
new PhpDocNode([
233+
new PhpDocTagNode(
234+
'@param',
235+
new ParamTagValueNode(
236+
new ConstTypeNode(new ConstFetchNode('self', '*')),
237+
false,
238+
'$foo',
239+
'optional description'
240+
)
241+
),
242+
]),
243+
];
244+
229245
yield [
230246
'invalid without type, parameter name and description',
231247
'/** @param */',
@@ -579,6 +595,21 @@ public function provideVarTagsData(): \Iterator
579595
]),
580596
];
581597

598+
yield [
599+
'OK with variable name and description and const expression',
600+
'/** @var self::* $foo optional description */',
601+
new PhpDocNode([
602+
new PhpDocTagNode(
603+
'@var',
604+
new VarTagValueNode(
605+
new ConstTypeNode(new ConstFetchNode('self', '*')),
606+
'$foo',
607+
'optional description'
608+
)
609+
),
610+
]),
611+
];
612+
582613
yield [
583614
'invalid without type, variable name and description',
584615
'/** @var */',
@@ -1079,6 +1110,20 @@ public function provideReturnTagsData(): \Iterator
10791110
),
10801111
]),
10811112
];
1113+
1114+
yield [
1115+
'OK with constant wildcard and description',
1116+
'/** @return self::* example description */',
1117+
new PhpDocNode([
1118+
new PhpDocTagNode(
1119+
'@return',
1120+
new ReturnTagValueNode(
1121+
new ConstTypeNode(new ConstFetchNode('self', '*')),
1122+
'example description'
1123+
)
1124+
),
1125+
]),
1126+
];
10821127
}
10831128

10841129

0 commit comments

Comments
 (0)