diff --git a/src/Ast/PhpDoc/PhpDocNode.php b/src/Ast/PhpDoc/PhpDocNode.php index 8a3b5139..73998aef 100644 --- a/src/Ast/PhpDoc/PhpDocNode.php +++ b/src/Ast/PhpDoc/PhpDocNode.php @@ -45,10 +45,10 @@ public function getTagsByName(string $tagName): array /** * @return VarTagValueNode[] */ - public function getVarTagValues(): array + public function getVarTagValues(string $tagName = '@var'): array { return array_column( - array_filter($this->getTagsByName('@var'), static function (PhpDocTagNode $tag): bool { + array_filter($this->getTagsByName($tagName), static function (PhpDocTagNode $tag): bool { return $tag->value instanceof VarTagValueNode; }), 'value' @@ -59,10 +59,10 @@ public function getVarTagValues(): array /** * @return ParamTagValueNode[] */ - public function getParamTagValues(): array + public function getParamTagValues(string $tagName = '@param'): array { return array_column( - array_filter($this->getTagsByName('@param'), static function (PhpDocTagNode $tag): bool { + array_filter($this->getTagsByName($tagName), static function (PhpDocTagNode $tag): bool { return $tag->value instanceof ParamTagValueNode; }), 'value' @@ -73,10 +73,10 @@ public function getParamTagValues(): array /** * @return TemplateTagValueNode[] */ - public function getTemplateTagValues(): array + public function getTemplateTagValues(string $tagName = '@template'): array { return array_column( - array_filter($this->getTagsByName('@template'), static function (PhpDocTagNode $tag): bool { + array_filter($this->getTagsByName($tagName), static function (PhpDocTagNode $tag): bool { return $tag->value instanceof TemplateTagValueNode; }), 'value' @@ -87,10 +87,10 @@ public function getTemplateTagValues(): array /** * @return ExtendsTagValueNode[] */ - public function getExtendsTagValues(): array + public function getExtendsTagValues(string $tagName = '@extends'): array { return array_column( - array_filter($this->getTagsByName('@extends'), static function (PhpDocTagNode $tag): bool { + array_filter($this->getTagsByName($tagName), static function (PhpDocTagNode $tag): bool { return $tag->value instanceof ExtendsTagValueNode; }), 'value' @@ -101,10 +101,10 @@ public function getExtendsTagValues(): array /** * @return ImplementsTagValueNode[] */ - public function getImplementsTagValues(): array + public function getImplementsTagValues(string $tagName = '@implements'): array { return array_column( - array_filter($this->getTagsByName('@implements'), static function (PhpDocTagNode $tag): bool { + array_filter($this->getTagsByName($tagName), static function (PhpDocTagNode $tag): bool { return $tag->value instanceof ImplementsTagValueNode; }), 'value' @@ -115,10 +115,10 @@ public function getImplementsTagValues(): array /** * @return UsesTagValueNode[] */ - public function getUsesTagValues(): array + public function getUsesTagValues(string $tagName = '@uses'): array { return array_column( - array_filter($this->getTagsByName('@uses'), static function (PhpDocTagNode $tag): bool { + array_filter($this->getTagsByName($tagName), static function (PhpDocTagNode $tag): bool { return $tag->value instanceof UsesTagValueNode; }), 'value' @@ -129,10 +129,10 @@ public function getUsesTagValues(): array /** * @return ReturnTagValueNode[] */ - public function getReturnTagValues(): array + public function getReturnTagValues(string $tagName = '@return'): array { return array_column( - array_filter($this->getTagsByName('@return'), static function (PhpDocTagNode $tag): bool { + array_filter($this->getTagsByName($tagName), static function (PhpDocTagNode $tag): bool { return $tag->value instanceof ReturnTagValueNode; }), 'value' @@ -143,10 +143,10 @@ public function getReturnTagValues(): array /** * @return ThrowsTagValueNode[] */ - public function getThrowsTagValues(): array + public function getThrowsTagValues(string $tagName = '@throws'): array { return array_column( - array_filter($this->getTagsByName('@throws'), static function (PhpDocTagNode $tag): bool { + array_filter($this->getTagsByName($tagName), static function (PhpDocTagNode $tag): bool { return $tag->value instanceof ThrowsTagValueNode; }), 'value' @@ -171,10 +171,10 @@ public function getDeprecatedTagValues(): array /** * @return PropertyTagValueNode[] */ - public function getPropertyTagValues(): array + public function getPropertyTagValues(string $tagName = '@property'): array { return array_column( - array_filter($this->getTagsByName('@property'), static function (PhpDocTagNode $tag): bool { + array_filter($this->getTagsByName($tagName), static function (PhpDocTagNode $tag): bool { return $tag->value instanceof PropertyTagValueNode; }), 'value' @@ -185,10 +185,10 @@ public function getPropertyTagValues(): array /** * @return PropertyTagValueNode[] */ - public function getPropertyReadTagValues(): array + public function getPropertyReadTagValues(string $tagName = '@property-read'): array { return array_column( - array_filter($this->getTagsByName('@property-read'), static function (PhpDocTagNode $tag): bool { + array_filter($this->getTagsByName($tagName), static function (PhpDocTagNode $tag): bool { return $tag->value instanceof PropertyTagValueNode; }), 'value' @@ -199,10 +199,10 @@ public function getPropertyReadTagValues(): array /** * @return PropertyTagValueNode[] */ - public function getPropertyWriteTagValues(): array + public function getPropertyWriteTagValues(string $tagName = '@property-write'): array { return array_column( - array_filter($this->getTagsByName('@property-write'), static function (PhpDocTagNode $tag): bool { + array_filter($this->getTagsByName($tagName), static function (PhpDocTagNode $tag): bool { return $tag->value instanceof PropertyTagValueNode; }), 'value' @@ -213,10 +213,10 @@ public function getPropertyWriteTagValues(): array /** * @return MethodTagValueNode[] */ - public function getMethodTagValues(): array + public function getMethodTagValues(string $tagName = '@method'): array { return array_column( - array_filter($this->getTagsByName('@method'), static function (PhpDocTagNode $tag): bool { + array_filter($this->getTagsByName($tagName), static function (PhpDocTagNode $tag): bool { return $tag->value instanceof MethodTagValueNode; }), 'value' diff --git a/src/Parser/PhpDocParser.php b/src/Parser/PhpDocParser.php index 898d8130..e6d79b3d 100644 --- a/src/Parser/PhpDocParser.php +++ b/src/Parser/PhpDocParser.php @@ -115,14 +115,20 @@ public function parseTagValue(TokenIterator $tokens, string $tag): Ast\PhpDoc\Ph switch ($tag) { case '@param': + case '@phpstan-param': + case '@psalm-param': $tagValue = $this->parseParamTagValue($tokens); break; case '@var': + case '@phpstan-var': + case '@psalm-var': $tagValue = $this->parseVarTagValue($tokens); break; case '@return': + case '@phpstan-return': + case '@psalm-return': $tagValue = $this->parseReturnTagValue($tokens); break; @@ -137,21 +143,43 @@ public function parseTagValue(TokenIterator $tokens, string $tag): Ast\PhpDoc\Ph case '@property': case '@property-read': case '@property-write': + case '@phpstan-property': + case '@phpstan-property-read': + case '@phpstan-property-write': + case '@psalm-property': + case '@psalm-property-read': + case '@psalm-property-write': $tagValue = $this->parsePropertyTagValue($tokens); break; case '@method': + case '@phpstan-method': + case '@psalm-method': $tagValue = $this->parseMethodTagValue($tokens); break; case '@template': + case '@phpstan-template': + case '@psalm-template': $tagValue = $this->parseTemplateTagValue($tokens); break; case '@extends': + case '@phpstan-extends': + case '@template-extends': + $tagValue = $this->parseExtendsTagValue('@extends', $tokens); + break; + case '@implements': + case '@phpstan-implements': + case '@template-implements': + $tagValue = $this->parseExtendsTagValue('@implements', $tokens); + break; + case '@uses': - $tagValue = $this->parseExtendsTagValue($tag, $tokens); + case '@phpstan-uses': + case '@template-use': + $tagValue = $this->parseExtendsTagValue('@uses', $tokens); break; default: