mirror of
https://github.com/barryvdh/ReflectionDocBlock.git
synced 2026-08-17 17:47:13 +00:00
Moved the type separation into ReturnTag, for consistency with the type merging that is currently there.
This commit is contained in:
@@ -53,7 +53,7 @@ class ReturnTag extends Tag
|
||||
public function getTypes()
|
||||
{
|
||||
$types = new \phpDocumentor\Reflection\DocBlock\Type\Collection(
|
||||
array($this->type),
|
||||
explode('|', $this->type),
|
||||
$this->docblock ? $this->docblock->getNamespace() : null,
|
||||
$this->docblock ? $this->docblock->getNamespaceAliases() : array()
|
||||
);
|
||||
|
||||
@@ -22,9 +22,6 @@ namespace phpDocumentor\Reflection\DocBlock\Type;
|
||||
*/
|
||||
class Collection extends \ArrayObject
|
||||
{
|
||||
/** @var string Definition of the OR operator for types */
|
||||
const OPERATOR_OR = '|';
|
||||
|
||||
/** @var string Definition of the ARRAY operator for types */
|
||||
const OPERATOR_ARRAY = '[]';
|
||||
|
||||
@@ -167,16 +164,11 @@ class Collection extends \ArrayObject
|
||||
.var_export($type, true)
|
||||
);
|
||||
}
|
||||
|
||||
// separate the type by the OR operator
|
||||
$type_parts = explode(self::OPERATOR_OR, $type);
|
||||
foreach ($type_parts as $part) {
|
||||
$expanded_type = $this->expand($part);
|
||||
$expanded_type = $this->expand($type);
|
||||
if ($expanded_type) {
|
||||
$this[] = $expanded_type;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Analyzes the given type and returns the FQCN variant.
|
||||
|
||||
@@ -148,7 +148,9 @@ class CollectionTest extends \PHPUnit_Framework_TestCase
|
||||
$collection = new Collection();
|
||||
$collection->setNamespace('\My\Space');
|
||||
$collection->setNamespaceAliases(array('Alias' => '\My\Space\Aliasing'));
|
||||
$collection->add($fixture);
|
||||
foreach ($fixture as $type) {
|
||||
$collection->add($type);
|
||||
}
|
||||
|
||||
$this->assertSame($expected, $collection->getArrayCopy());
|
||||
}
|
||||
@@ -166,7 +168,9 @@ class CollectionTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$collection = new Collection();
|
||||
$collection->setNamespaceAliases(array('Alias' => '\My\Space\Aliasing'));
|
||||
$collection->add($fixture);
|
||||
foreach ($fixture as $type) {
|
||||
$collection->add($type);
|
||||
}
|
||||
|
||||
$this->assertSame($expected, $collection->getArrayCopy());
|
||||
}
|
||||
@@ -195,34 +199,34 @@ class CollectionTest extends \PHPUnit_Framework_TestCase
|
||||
public function provideTypesToExpand($method, $namespace = '\My\Space\\')
|
||||
{
|
||||
return array(
|
||||
array('', array()),
|
||||
array(' ', array()),
|
||||
array('int', array('int')),
|
||||
array('int ', array('int')),
|
||||
array('string', array('string')),
|
||||
array('DocBlock', array($namespace.'DocBlock')),
|
||||
array('DocBlock[]', array($namespace.'DocBlock[]')),
|
||||
array(' DocBlock ', array($namespace.'DocBlock')),
|
||||
array('\My\Space\DocBlock', array('\My\Space\DocBlock')),
|
||||
array('Alias\DocBlock', array('\My\Space\Aliasing\DocBlock')),
|
||||
array(array(''), array()),
|
||||
array(array(' '), array()),
|
||||
array(array('int'), array('int')),
|
||||
array(array('int '), array('int')),
|
||||
array(array('string'), array('string')),
|
||||
array(array('DocBlock'), array($namespace.'DocBlock')),
|
||||
array(array('DocBlock[]'), array($namespace.'DocBlock[]')),
|
||||
array(array(' DocBlock '), array($namespace.'DocBlock')),
|
||||
array(array('\My\Space\DocBlock'), array('\My\Space\DocBlock')),
|
||||
array(array('Alias\DocBlock'), array('\My\Space\Aliasing\DocBlock')),
|
||||
array(
|
||||
'DocBlock|Tag',
|
||||
array('DocBlock', 'Tag'),
|
||||
array($namespace .'DocBlock', $namespace .'Tag')
|
||||
),
|
||||
array(
|
||||
'DocBlock|null',
|
||||
array('DocBlock', 'null'),
|
||||
array($namespace.'DocBlock', 'null')
|
||||
),
|
||||
array(
|
||||
'\My\Space\DocBlock|Tag',
|
||||
array('\My\Space\DocBlock', 'Tag'),
|
||||
array('\My\Space\DocBlock', $namespace.'Tag')
|
||||
),
|
||||
array(
|
||||
'DocBlock[]|null',
|
||||
array('DocBlock[]', 'null'),
|
||||
array($namespace.'DocBlock[]', 'null')
|
||||
),
|
||||
array(
|
||||
'DocBlock[]|int[]',
|
||||
array('DocBlock[]', 'int[]'),
|
||||
array($namespace.'DocBlock[]', 'int[]')
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user