diff --git a/src/Ast/PhpDoc/ThrowsTagValueNode.php b/src/Ast/PhpDoc/ThrowsTagValueNode.php new file mode 100644 index 0000000..32ae12d --- /dev/null +++ b/src/Ast/PhpDoc/ThrowsTagValueNode.php @@ -0,0 +1,28 @@ +type = $type; + $this->description = $description; + } + + + public function __toString(): string + { + return trim("{$this->type} {$this->description}"); + } + +} diff --git a/src/Parser/PhpDocParser.php b/src/Parser/PhpDocParser.php index e8c4346..38086dd 100644 --- a/src/Parser/PhpDocParser.php +++ b/src/Parser/PhpDocParser.php @@ -96,6 +96,10 @@ class PhpDocParser $tagValue = $this->parseReturnTagValue($tokens); break; + case '@throws': + $tagValue = $this->parseThrowsTagValue($tokens); + break; + case '@property': case '@property-read': case '@property-write': @@ -149,6 +153,14 @@ class PhpDocParser } + private function parseThrowsTagValue(TokenIterator $tokens): Ast\PhpDoc\ThrowsTagValueNode + { + $type = $this->typeParser->parse($tokens); + $description = $this->parseOptionalDescription($tokens, true); + return new Ast\PhpDoc\ThrowsTagValueNode($type, $description); + } + + private function parsePropertyTagValue(TokenIterator $tokens): Ast\PhpDoc\PropertyTagValueNode { $type = $this->typeParser->parse($tokens);