mirror of
https://github.com/barryvdh/ReflectionDocBlock.git
synced 2026-08-18 10:07:12 +00:00
Written unit tests for return tag
This commit is contained in:
committed by
Mike van Riel
parent
75bb275a99
commit
255bc6ffda
@@ -1,11 +1,11 @@
|
||||
<?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-2011 Mike van Riel / Naenius (http://www.naenius.com)
|
||||
* @copyright 2010-2015 Mike van Riel<mike@phpdoc.org>
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
@@ -14,13 +14,13 @@ namespace phpDocumentor\Reflection\DocBlock\Tags;
|
||||
|
||||
use phpDocumentor\Reflection\DocBlock\Description;
|
||||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||
use phpDocumentor\Reflection\DocBlock\Type\Collection;
|
||||
use phpDocumentor\Reflection\Type;
|
||||
use phpDocumentor\Reflection\TypeResolver;
|
||||
use phpDocumentor\Reflection\Types\Context;
|
||||
use Webmozart\Assert\Assert;
|
||||
|
||||
/**
|
||||
* Reflection class for a @return tag in a Docblock.
|
||||
* Reflection class for a {@}return tag in a Docblock.
|
||||
*/
|
||||
final class Return_ extends BaseTag
|
||||
{
|
||||
@@ -31,8 +31,8 @@ final class Return_ extends BaseTag
|
||||
|
||||
public function __construct(Type $type, Description $description = null)
|
||||
{
|
||||
$this->description = $description;
|
||||
$this->type = $type;
|
||||
$this->description = $description;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -45,19 +45,17 @@ final class Return_ extends BaseTag
|
||||
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] : '');
|
||||
$description = $descriptionFactory->create(isset($parts[1]) ? $parts[1] : '', $context);
|
||||
|
||||
return new static($type, $description);
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return $this->type . ' ' . $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type section of the variable.
|
||||
*
|
||||
@@ -67,4 +65,9 @@ final class Return_ extends BaseTag
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return $this->type . ' ' . $this->description;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user