Skip to content

Commit d4c4cd3

Browse files
committed
Test parseTagValue() with ConstTypeNode
1 parent 956e721 commit d4c4cd3

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

Diff for: tests/PHPStan/Parser/PhpDocParserTest.php

+35
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
use PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprArrayNode;
66
use PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprIntegerNode;
77
use PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprStringNode;
8+
use PHPStan\PhpDocParser\Ast\ConstExpr\ConstFetchNode;
9+
use PHPStan\PhpDocParser\Ast\Node;
810
use PHPStan\PhpDocParser\Ast\PhpDoc\DeprecatedTagValueNode;
911
use PHPStan\PhpDocParser\Ast\PhpDoc\ExtendsTagValueNode;
1012
use PHPStan\PhpDocParser\Ast\PhpDoc\GenericTagValueNode;
@@ -3046,4 +3048,37 @@ public function provideRealWorldExampleData(): \Iterator
30463048
];
30473049
}
30483050

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+
30493084
}

0 commit comments

Comments
 (0)