File tree Expand file tree Collapse file tree 2 files changed +63
-0
lines changed Expand file tree Collapse file tree 2 files changed +63
-0
lines changed Original file line number Diff line number Diff line change @@ -358,6 +358,9 @@ private function parseOptionalVariableName(TokenIterator $tokens): string
358358 if ($ tokens ->isCurrentTokenType (Lexer::TOKEN_VARIABLE )) {
359359 $ parameterName = $ tokens ->currentTokenValue ();
360360 $ tokens ->next ();
361+ } elseif ($ tokens ->isCurrentTokenType (Lexer::TOKEN_THIS_VARIABLE )) {
362+ $ parameterName = '$this ' ;
363+ $ tokens ->next ();
361364
362365 } else {
363366 $ parameterName = '' ;
Original file line number Diff line number Diff line change @@ -417,6 +417,66 @@ public function provideVarTagsData(): \Iterator
417417 ]),
418418 ];
419419
420+ yield [
421+ 'OK without description with variable $this ' ,
422+ '/** @var Foo $this */ ' ,
423+ new PhpDocNode ([
424+ new PhpDocTagNode (
425+ '@var ' ,
426+ new VarTagValueNode (
427+ new IdentifierTypeNode ('Foo ' ),
428+ '$this ' ,
429+ ''
430+ )
431+ ),
432+ ]),
433+ ];
434+
435+ yield [
436+ 'OK without description and with no space between type and variable name with variable $this ' ,
437+ '/** @var Foo$this */ ' ,
438+ new PhpDocNode ([
439+ new PhpDocTagNode (
440+ '@var ' ,
441+ new VarTagValueNode (
442+ new IdentifierTypeNode ('Foo ' ),
443+ '$this ' ,
444+ ''
445+ )
446+ ),
447+ ]),
448+ ];
449+
450+ yield [
451+ 'OK with description with variable $this ' ,
452+ '/** @var Foo $this Testing */ ' ,
453+ new PhpDocNode ([
454+ new PhpDocTagNode (
455+ '@var ' ,
456+ new VarTagValueNode (
457+ new IdentifierTypeNode ('Foo ' ),
458+ '$this ' ,
459+ 'Testing '
460+ )
461+ ),
462+ ]),
463+ ];
464+
465+ yield [
466+ 'OK with description and with no space between type and variable name with variable $this ' ,
467+ '/** @var Foo$this Testing */ ' ,
468+ new PhpDocNode ([
469+ new PhpDocTagNode (
470+ '@var ' ,
471+ new VarTagValueNode (
472+ new IdentifierTypeNode ('Foo ' ),
473+ '$this ' ,
474+ 'Testing '
475+ )
476+ ),
477+ ]),
478+ ];
479+
420480 yield [
421481 'OK with variable name and description and without all optional spaces ' ,
422482 '/** @var(Foo)$foo#desc*/ ' ,
You can’t perform that action at this time.
0 commit comments