|
1 | 1 | <?php
|
2 | 2 | /**
|
3 |
| - * phpDocumentor |
| 3 | + * This file is part of phpDocumentor. |
4 | 4 | *
|
5 |
| - * PHP Version 5.3 |
| 5 | + * For the full copyright and license information, please view the LICENSE |
| 6 | + * file that was distributed with this source code. |
6 | 7 | *
|
7 |
| - * @author Mike van Riel <[email protected]> |
8 |
| - * @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com) |
| 8 | + * @copyright 2010-2015 Mike van Riel<[email protected]> |
9 | 9 | * @license http://www.opensource.org/licenses/mit-license.php MIT
|
10 | 10 | * @link http://phpdoc.org
|
11 | 11 | */
|
12 | 12 |
|
13 | 13 | namespace phpDocumentor\Reflection\DocBlock\Tags;
|
14 | 14 |
|
| 15 | +use phpDocumentor\Reflection\DocBlock\Description; |
| 16 | +use phpDocumentor\Reflection\DocBlock\DescriptionFactory; |
| 17 | +use phpDocumentor\Reflection\Type; |
| 18 | +use phpDocumentor\Reflection\TypeResolver; |
| 19 | +use phpDocumentor\Reflection\Types\Context; |
| 20 | +use Webmozart\Assert\Assert; |
| 21 | + |
15 | 22 | /**
|
16 |
| - * Reflection class for a @throws tag in a Docblock. |
| 23 | + * Reflection class for a {@}throws tag in a Docblock. |
17 | 24 | */
|
18 |
| -class Throws extends Return_ |
| 25 | +final class Throws extends BaseTag |
19 | 26 | {
|
| 27 | + protected $name = 'throws'; |
| 28 | + |
| 29 | + /** @var Type */ |
| 30 | + private $type; |
| 31 | + |
| 32 | + public function __construct(Type $type, Description $description = null) |
| 33 | + { |
| 34 | + $this->type = $type; |
| 35 | + $this->description = $description; |
| 36 | + } |
| 37 | + |
| 38 | + /** |
| 39 | + * {@inheritdoc} |
| 40 | + */ |
| 41 | + public static function create( |
| 42 | + $body, |
| 43 | + TypeResolver $typeResolver = null, |
| 44 | + DescriptionFactory $descriptionFactory = null, |
| 45 | + Context $context = null |
| 46 | + ) { |
| 47 | + Assert::string($body); |
| 48 | + Assert::allNotNull([$typeResolver, $descriptionFactory]); |
| 49 | + |
| 50 | + $parts = preg_split('/\s+/Su', $body, 2); |
| 51 | + |
| 52 | + $type = $typeResolver->resolve(isset($parts[0]) ? $parts[0] : '', $context); |
| 53 | + $description = $descriptionFactory->create(isset($parts[1]) ? $parts[1] : '', $context); |
| 54 | + |
| 55 | + return new static($type, $description); |
| 56 | + } |
| 57 | + |
| 58 | + /** |
| 59 | + * Returns the type section of the variable. |
| 60 | + * |
| 61 | + * @return Type |
| 62 | + */ |
| 63 | + public function getType() |
| 64 | + { |
| 65 | + return $this->type; |
| 66 | + } |
| 67 | + |
| 68 | + public function __toString() |
| 69 | + { |
| 70 | + return $this->type . ' ' . $this->description; |
| 71 | + } |
20 | 72 | }
|
0 commit comments