Skip to content

Commit cd06d6b

Browse files
anomiexondrejmirtes
authored andcommittedApr 3, 2024
Add @phan- prefixes for recognized doc tags
The following prefixes are added: * `@phan-assert` * `@phan-assert-if-false` * `@phan-assert-if-true` * `@phan-extends` * `@phan-inherits` * `@phan-method` * `@phan-mixin` * `@phan-param` * `@phan-property` * `@phan-property-read` * `@phan-property-write` * `@phan-real-return` * `@phan-return` * `@phan-template` * `@phan-type` * `@phan-var` No changes to any of the parsing were made, as the syntaxes seem to match what's already done for the existing unprefixed tags and/or the existing `@psalm-` and `@phpstan-` prefixed tags.
1 parent 86e4d5a commit cd06d6b

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed
 

‎src/Parser/PhpDocParser.php

+17-1
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,7 @@ public function parseTagValue(TokenIterator $tokens, string $tag): Ast\PhpDoc\Ph
384384
case '@param':
385385
case '@phpstan-param':
386386
case '@psalm-param':
387+
case '@phan-param':
387388
$tagValue = $this->parseParamTagValue($tokens);
388389
break;
389390

@@ -405,12 +406,15 @@ public function parseTagValue(TokenIterator $tokens, string $tag): Ast\PhpDoc\Ph
405406
case '@var':
406407
case '@phpstan-var':
407408
case '@psalm-var':
409+
case '@phan-var':
408410
$tagValue = $this->parseVarTagValue($tokens);
409411
break;
410412

411413
case '@return':
412414
case '@phpstan-return':
413415
case '@psalm-return':
416+
case '@phan-return':
417+
case '@phan-real-return':
414418
$tagValue = $this->parseReturnTagValue($tokens);
415419
break;
416420

@@ -420,6 +424,7 @@ public function parseTagValue(TokenIterator $tokens, string $tag): Ast\PhpDoc\Ph
420424
break;
421425

422426
case '@mixin':
427+
case '@phan-mixin':
423428
$tagValue = $this->parseMixinTagValue($tokens);
424429
break;
425430

@@ -446,18 +451,23 @@ public function parseTagValue(TokenIterator $tokens, string $tag): Ast\PhpDoc\Ph
446451
case '@psalm-property':
447452
case '@psalm-property-read':
448453
case '@psalm-property-write':
454+
case '@phan-property':
455+
case '@phan-property-read':
456+
case '@phan-property-write':
449457
$tagValue = $this->parsePropertyTagValue($tokens);
450458
break;
451459

452460
case '@method':
453461
case '@phpstan-method':
454462
case '@psalm-method':
463+
case '@phan-method':
455464
$tagValue = $this->parseMethodTagValue($tokens);
456465
break;
457466

458467
case '@template':
459468
case '@phpstan-template':
460469
case '@psalm-template':
470+
case '@phan-template':
461471
case '@template-covariant':
462472
case '@phpstan-template-covariant':
463473
case '@psalm-template-covariant':
@@ -474,6 +484,8 @@ function ($tokens) {
474484

475485
case '@extends':
476486
case '@phpstan-extends':
487+
case '@phan-extends':
488+
case '@phan-inherits':
477489
case '@template-extends':
478490
$tagValue = $this->parseExtendsTagValue('@extends', $tokens);
479491
break;
@@ -492,6 +504,7 @@ function ($tokens) {
492504

493505
case '@phpstan-type':
494506
case '@psalm-type':
507+
case '@phan-type':
495508
$tagValue = $this->parseTypeAliasTagValue($tokens);
496509
break;
497510

@@ -506,6 +519,9 @@ function ($tokens) {
506519
case '@psalm-assert':
507520
case '@psalm-assert-if-true':
508521
case '@psalm-assert-if-false':
522+
case '@phan-assert':
523+
case '@phan-assert-if-true':
524+
case '@phan-assert-if-false':
509525
$tagValue = $this->parseAssertTagValue($tokens);
510526
break;
511527

@@ -1091,7 +1107,7 @@ private function parseTypeAliasTagValue(TokenIterator $tokens): Ast\PhpDoc\TypeA
10911107
$alias = $tokens->currentTokenValue();
10921108
$tokens->consumeTokenType(Lexer::TOKEN_IDENTIFIER);
10931109

1094-
// support psalm-type syntax
1110+
// support phan-type/psalm-type syntax
10951111
$tokens->tryConsumeTokenType(Lexer::TOKEN_EQUAL);
10961112

10971113
if ($this->preserveTypeAliasesWithInvalidTypes) {

0 commit comments

Comments
 (0)
Failed to load comments.