@@ -5309,6 +5309,110 @@ public function provideTypeAliasTagsData(): Iterator
53095309 ),
53105310 ]),
53115311 ];
5312+
5313+ yield [
5314+ 'OK with template types and psalm-type syntax ' ,
5315+ '/** @psalm-type Foo<T> = list<T> */ ' ,
5316+ new PhpDocNode ([
5317+ new PhpDocTagNode (
5318+ '@psalm-type ' ,
5319+ new TypeAliasTagValueNode (
5320+ 'Foo ' ,
5321+ new GenericTypeNode (
5322+ new IdentifierTypeNode ('list ' ),
5323+ [new IdentifierTypeNode ('T ' )],
5324+ [GenericTypeNode::VARIANCE_INVARIANT ],
5325+ ),
5326+ [
5327+ new TemplateTagValueNode ('T ' , null , '' ),
5328+ ],
5329+ ),
5330+ ),
5331+ ]),
5332+ ];
5333+
5334+ yield [
5335+ 'OK with template types and a trailing comma ' ,
5336+ '/** @phpstan-type Pair<TFirst, TSecond,> TFirst */ ' ,
5337+ new PhpDocNode ([
5338+ new PhpDocTagNode (
5339+ '@phpstan-type ' ,
5340+ new TypeAliasTagValueNode (
5341+ 'Pair ' ,
5342+ new IdentifierTypeNode ('TFirst ' ),
5343+ [
5344+ new TemplateTagValueNode ('TFirst ' , null , '' ),
5345+ new TemplateTagValueNode ('TSecond ' , null , '' ),
5346+ ],
5347+ ),
5348+ ),
5349+ ]),
5350+ ];
5351+
5352+ yield [
5353+ 'OK multiline with comments and a trailing comma ' ,
5354+ '/**
5355+ * @phpstan-type Pair<
5356+ * TFirst, // the first one
5357+ * TSecond of object = stdClass, // the second one
5358+ * > TFirst
5359+ */ ' ,
5360+ new PhpDocNode ([
5361+ new PhpDocTagNode (
5362+ '@phpstan-type ' ,
5363+ new TypeAliasTagValueNode (
5364+ 'Pair ' ,
5365+ new IdentifierTypeNode ('TFirst ' ),
5366+ [
5367+ new TemplateTagValueNode ('TFirst ' , null , '' ),
5368+ new TemplateTagValueNode ('TSecond ' , new IdentifierTypeNode ('object ' ), '' , new IdentifierTypeNode ('stdClass ' )),
5369+ ],
5370+ ),
5371+ ),
5372+ ]),
5373+ ];
5374+
5375+ yield [
5376+ 'invalid without closing angle bracket ' ,
5377+ '/** @phpstan-type Foo<T T */ ' ,
5378+ new PhpDocNode ([
5379+ new PhpDocTagNode (
5380+ '@phpstan-type ' ,
5381+ new InvalidTagValueNode (
5382+ 'Foo<T T ' ,
5383+ new ParserException (
5384+ 'T ' ,
5385+ Lexer::TOKEN_IDENTIFIER ,
5386+ 24 ,
5387+ Lexer::TOKEN_CLOSE_ANGLE_BRACKET ,
5388+ null ,
5389+ 1 ,
5390+ ),
5391+ ),
5392+ ),
5393+ ]),
5394+ ];
5395+
5396+ yield [
5397+ 'invalid without template types ' ,
5398+ '/** @phpstan-type Foo<> T */ ' ,
5399+ new PhpDocNode ([
5400+ new PhpDocTagNode (
5401+ '@phpstan-type ' ,
5402+ new InvalidTagValueNode (
5403+ 'Foo<> T ' ,
5404+ new ParserException (
5405+ '> ' ,
5406+ Lexer::TOKEN_CLOSE_ANGLE_BRACKET ,
5407+ 22 ,
5408+ Lexer::TOKEN_IDENTIFIER ,
5409+ null ,
5410+ 1 ,
5411+ ),
5412+ ),
5413+ ),
5414+ ]),
5415+ ];
53125416 }
53135417
53145418 public function provideTypeAliasImportTagsData (): Iterator
@@ -7928,6 +8032,23 @@ public function dataDeepNodesLinesAndIndexes(): iterable
79288032 [1 , 1 , 3 , 1 ], // GenericTagValueNode is empty so start index is higher than end index
79298033 ],
79308034 ];
8035+ yield [
8036+ '/** ' . PHP_EOL .
8037+ ' * @phpstan-type Pair< ' . PHP_EOL .
8038+ ' * TFirst, ' . PHP_EOL .
8039+ ' * TSecond of object ' . PHP_EOL .
8040+ ' * > TFirst ' . PHP_EOL .
8041+ ' */ ' ,
8042+ [
8043+ [1 , 6 , 0 , 22 ], // PhpDocNode
8044+ [2 , 5 , 2 , 20 ], // PhpDocTagNode
8045+ [2 , 5 , 4 , 20 ], // TypeAliasTagValueNode
8046+ [3 , 3 , 8 , 8 ], // TemplateTagValueNode TFirst
8047+ [4 , 4 , 12 , 16 ], // TemplateTagValueNode TSecond
8048+ [4 , 4 , 16 , 16 ], // IdentifierTypeNode object
8049+ [5 , 5 , 20 , 20 ], // IdentifierTypeNode TFirst
8050+ ],
8051+ ];
79318052 }
79328053
79338054 /**
0 commit comments