File tree 2 files changed +47
-14
lines changed
2 files changed +47
-14
lines changed Original file line number Diff line number Diff line change @@ -1127,15 +1127,13 @@ private function parseAssertParameter(TokenIterator $tokens): array
1127
1127
{
1128
1128
if ($ tokens ->isCurrentTokenType (Lexer::TOKEN_THIS_VARIABLE )) {
1129
1129
$ parameter = '$this ' ;
1130
- $ requirePropertyOrMethod = true ;
1131
1130
$ tokens ->next ();
1132
1131
} else {
1133
1132
$ parameter = $ tokens ->currentTokenValue ();
1134
- $ requirePropertyOrMethod = false ;
1135
1133
$ tokens ->consumeTokenType (Lexer::TOKEN_VARIABLE );
1136
1134
}
1137
1135
1138
- if ($ requirePropertyOrMethod || $ tokens ->isCurrentTokenType (Lexer::TOKEN_ARROW )) {
1136
+ if ($ tokens ->isCurrentTokenType (Lexer::TOKEN_ARROW )) {
1139
1137
$ tokens ->consumeTokenType (Lexer::TOKEN_ARROW );
1140
1138
1141
1139
$ propertyOrMethod = $ tokens ->currentTokenValue ();
Original file line number Diff line number Diff line change @@ -4563,21 +4563,56 @@ public function provideAssertTagsData(): Iterator
4563
4563
];
4564
4564
4565
4565
yield [
4566
- 'invalid $this ' ,
4566
+ 'OK $this ' ,
4567
4567
'/** @phpstan-assert Type $this */ ' ,
4568
4568
new PhpDocNode ([
4569
4569
new PhpDocTagNode (
4570
4570
'@phpstan-assert ' ,
4571
- new InvalidTagValueNode (
4572
- 'Type $this ' ,
4573
- new ParserException (
4574
- '*/ ' ,
4575
- Lexer::TOKEN_CLOSE_PHPDOC ,
4576
- 31 ,
4577
- Lexer::TOKEN_ARROW ,
4578
- null ,
4579
- 1
4580
- )
4571
+ new AssertTagValueNode (
4572
+ new IdentifierTypeNode ('Type ' ),
4573
+ '$this ' ,
4574
+ false ,
4575
+ ''
4576
+ )
4577
+ ),
4578
+ ]),
4579
+ ];
4580
+
4581
+ yield [
4582
+ 'OK $this with description ' ,
4583
+ '/** @phpstan-assert Type $this assert Type to $this */ ' ,
4584
+ new PhpDocNode ([
4585
+ new PhpDocTagNode (
4586
+ '@phpstan-assert ' ,
4587
+ new AssertTagValueNode (
4588
+ new IdentifierTypeNode ('Type ' ),
4589
+ '$this ' ,
4590
+ false ,
4591
+ 'assert Type to $this '
4592
+ )
4593
+ ),
4594
+ ]),
4595
+ ];
4596
+
4597
+ yield [
4598
+ 'OK $this with generic type ' ,
4599
+ '/** @phpstan-assert GenericType<T> $this */ ' ,
4600
+ new PhpDocNode ([
4601
+ new PhpDocTagNode (
4602
+ '@phpstan-assert ' ,
4603
+ new AssertTagValueNode (
4604
+ new GenericTypeNode (
4605
+ new IdentifierTypeNode ('GenericType ' ),
4606
+ [
4607
+ new IdentifierTypeNode ('T ' ),
4608
+ ],
4609
+ [
4610
+ GenericTypeNode::VARIANCE_INVARIANT ,
4611
+ ]
4612
+ ),
4613
+ '$this ' ,
4614
+ false ,
4615
+ ''
4581
4616
)
4582
4617
),
4583
4618
]),
You can’t perform that action at this time.
0 commit comments