Skip to content

Commit

Permalink
Add @phan- prefixes for recognized doc tags
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
anomiex authored and ondrejmirtes committed Apr 3, 2024
1 parent 86e4d5a commit cd06d6b
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/Parser/PhpDocParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ public function parseTagValue(TokenIterator $tokens, string $tag): Ast\PhpDoc\Ph
case '@param':
case '@phpstan-param':
case '@psalm-param':
case '@phan-param':
$tagValue = $this->parseParamTagValue($tokens);
break;

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

case '@return':
case '@phpstan-return':
case '@psalm-return':
case '@phan-return':
case '@phan-real-return':
$tagValue = $this->parseReturnTagValue($tokens);
break;

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

case '@mixin':
case '@phan-mixin':
$tagValue = $this->parseMixinTagValue($tokens);
break;

Expand All @@ -446,18 +451,23 @@ public function parseTagValue(TokenIterator $tokens, string $tag): Ast\PhpDoc\Ph
case '@psalm-property':
case '@psalm-property-read':
case '@psalm-property-write':
case '@phan-property':
case '@phan-property-read':
case '@phan-property-write':
$tagValue = $this->parsePropertyTagValue($tokens);
break;

case '@method':
case '@phpstan-method':
case '@psalm-method':
case '@phan-method':
$tagValue = $this->parseMethodTagValue($tokens);
break;

case '@template':
case '@phpstan-template':
case '@psalm-template':
case '@phan-template':
case '@template-covariant':
case '@phpstan-template-covariant':
case '@psalm-template-covariant':
Expand All @@ -474,6 +484,8 @@ function ($tokens) {

case '@extends':
case '@phpstan-extends':
case '@phan-extends':
case '@phan-inherits':
case '@template-extends':
$tagValue = $this->parseExtendsTagValue('@extends', $tokens);
break;
Expand All @@ -492,6 +504,7 @@ function ($tokens) {

case '@phpstan-type':
case '@psalm-type':
case '@phan-type':
$tagValue = $this->parseTypeAliasTagValue($tokens);
break;

Expand All @@ -506,6 +519,9 @@ function ($tokens) {
case '@psalm-assert':
case '@psalm-assert-if-true':
case '@psalm-assert-if-false':
case '@phan-assert':
case '@phan-assert-if-true':
case '@phan-assert-if-false':
$tagValue = $this->parseAssertTagValue($tokens);
break;

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

// support psalm-type syntax
// support phan-type/psalm-type syntax
$tokens->tryConsumeTokenType(Lexer::TOKEN_EQUAL);

if ($this->preserveTypeAliasesWithInvalidTypes) {
Expand Down

0 comments on commit cd06d6b

Please sign in to comment.