mirror of
https://github.com/barryvdh/ReflectionDocBlock.git
synced 2026-08-18 18:13:13 +00:00
Refactored throws tag
This commit is contained in:
committed by
Mike van Riel
parent
447acda736
commit
6b92695a71
@@ -1,20 +1,72 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* phpDocumentor
|
* This file is part of phpDocumentor.
|
||||||
*
|
*
|
||||||
* PHP Version 5.3
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
*
|
*
|
||||||
* @author Mike van Riel <mike[email protected]>
|
* @copyright 2010-2015 Mike van Riel<mike@phpdoc.org>
|
||||||
* @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
|
|
||||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||||
* @link http://phpdoc.org
|
* @link http://phpdoc.org
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace phpDocumentor\Reflection\DocBlock\Tags;
|
namespace phpDocumentor\Reflection\DocBlock\Tags;
|
||||||
|
|
||||||
|
use phpDocumentor\Reflection\DocBlock\Description;
|
||||||
|
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||||
|
use phpDocumentor\Reflection\Type;
|
||||||
|
use phpDocumentor\Reflection\TypeResolver;
|
||||||
|
use phpDocumentor\Reflection\Types\Context;
|
||||||
|
use Webmozart\Assert\Assert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reflection class for a @throws tag in a Docblock.
|
* Reflection class for a {@}throws tag in a Docblock.
|
||||||
*/
|
*/
|
||||||
class Throws extends Return_
|
final class Throws extends BaseTag
|
||||||
{
|
{
|
||||||
|
protected $name = 'throws';
|
||||||
|
|
||||||
|
/** @var Type */
|
||||||
|
private $type;
|
||||||
|
|
||||||
|
public function __construct(Type $type, Description $description = null)
|
||||||
|
{
|
||||||
|
$this->type = $type;
|
||||||
|
$this->description = $description;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public static function create(
|
||||||
|
$body,
|
||||||
|
TypeResolver $typeResolver = null,
|
||||||
|
DescriptionFactory $descriptionFactory = null,
|
||||||
|
Context $context = null
|
||||||
|
) {
|
||||||
|
Assert::string($body);
|
||||||
|
Assert::allNotNull([$typeResolver, $descriptionFactory]);
|
||||||
|
|
||||||
|
$parts = preg_split('/\s+/Su', $body, 2);
|
||||||
|
|
||||||
|
$type = $typeResolver->resolve(isset($parts[0]) ? $parts[0] : '', $context);
|
||||||
|
$description = $descriptionFactory->create(isset($parts[1]) ? $parts[1] : '', $context);
|
||||||
|
|
||||||
|
return new static($type, $description);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the type section of the variable.
|
||||||
|
*
|
||||||
|
* @return Type
|
||||||
|
*/
|
||||||
|
public function getType()
|
||||||
|
{
|
||||||
|
return $this->type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function __toString()
|
||||||
|
{
|
||||||
|
return $this->type . ' ' . $this->description;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user