|
5 | 5 | use PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprArrayNode;
|
6 | 6 | use PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprIntegerNode;
|
7 | 7 | use PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprStringNode;
|
| 8 | +use PHPStan\PhpDocParser\Ast\ConstExpr\ConstFetchNode; |
| 9 | +use PHPStan\PhpDocParser\Ast\Node; |
8 | 10 | use PHPStan\PhpDocParser\Ast\PhpDoc\DeprecatedTagValueNode;
|
9 | 11 | use PHPStan\PhpDocParser\Ast\PhpDoc\ExtendsTagValueNode;
|
10 | 12 | use PHPStan\PhpDocParser\Ast\PhpDoc\GenericTagValueNode;
|
@@ -3046,4 +3048,37 @@ public function provideRealWorldExampleData(): \Iterator
|
3046 | 3048 | ];
|
3047 | 3049 | }
|
3048 | 3050 |
|
| 3051 | + public function dataParseTagValue(): array |
| 3052 | + { |
| 3053 | + return [ |
| 3054 | + [ |
| 3055 | + '@param', |
| 3056 | + 'DateTimeImmutable::ATOM $a', |
| 3057 | + new ParamTagValueNode( |
| 3058 | + new ConstTypeNode(new ConstFetchNode('DateTimeImmutable', 'ATOM')), |
| 3059 | + false, |
| 3060 | + '$a', |
| 3061 | + '' |
| 3062 | + ), |
| 3063 | + ], |
| 3064 | + ]; |
| 3065 | + } |
| 3066 | + |
| 3067 | + /** |
| 3068 | + * @dataProvider dataParseTagValue |
| 3069 | + * @param string $tag |
| 3070 | + * @param string $phpDoc |
| 3071 | + * @param PhpDocNode $expectedPhpDocNode |
| 3072 | + * @param int $nextTokenType |
| 3073 | + */ |
| 3074 | + public function testParseTagValue(string $tag, string $phpDoc, Node $expectedPhpDocNode, int $nextTokenType = Lexer::TOKEN_END): void |
| 3075 | + { |
| 3076 | + $tokens = new TokenIterator($this->lexer->tokenize($phpDoc)); |
| 3077 | + $actualPhpDocNode = $this->phpDocParser->parseTagValue($tokens, $tag); |
| 3078 | + |
| 3079 | + $this->assertEquals($expectedPhpDocNode, $actualPhpDocNode); |
| 3080 | + $this->assertSame((string) $expectedPhpDocNode, (string) $actualPhpDocNode); |
| 3081 | + $this->assertSame($nextTokenType, $tokens->currentTokenType()); |
| 3082 | + } |
| 3083 | + |
3049 | 3084 | }
|
0 commit comments