mirror of
https://github.com/danog/phpdoc-parser.git
synced 2024-11-26 20:15:11 +01:00
add support for @throws tag value parsing
This commit is contained in:
parent
72864aad33
commit
f8a1d21be1
28
src/Ast/PhpDoc/ThrowsTagValueNode.php
Normal file
28
src/Ast/PhpDoc/ThrowsTagValueNode.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php declare(strict_types = 1);
|
||||
|
||||
namespace PHPStan\PhpDocParser\Ast\PhpDoc;
|
||||
|
||||
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
|
||||
|
||||
class ThrowsTagValueNode implements PhpDocTagValueNode
|
||||
{
|
||||
|
||||
/** @var TypeNode */
|
||||
public $type;
|
||||
|
||||
/** @var string (may be empty) */
|
||||
public $description;
|
||||
|
||||
public function __construct(TypeNode $type, string $description)
|
||||
{
|
||||
$this->type = $type;
|
||||
$this->description = $description;
|
||||
}
|
||||
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
return trim("{$this->type} {$this->description}");
|
||||
}
|
||||
|
||||
}
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user