mirror of
https://github.com/barryvdh/ReflectionDocBlock.git
synced 2026-08-17 17:47:13 +00:00
Merge pull request #67 from mbed67/fix-bug-in-collection
fix for bug #1672 in phpDocumentor2
This commit is contained in:
@@ -161,7 +161,8 @@ class Collection extends \ArrayObject
|
||||
$namespace_aliases = $this->context->getNamespaceAliases();
|
||||
// if the first segment is not an alias; prepend namespace name and
|
||||
// return
|
||||
if (!isset($namespace_aliases[$type_parts[0]])) {
|
||||
if (!isset($namespace_aliases[$type_parts[0]]) &&
|
||||
!isset($namespace_aliases[strstr($type_parts[0], '::', true)])) {
|
||||
$namespace = $this->context->getNamespace();
|
||||
if ('' !== $namespace) {
|
||||
$namespace .= self::OPERATOR_NAMESPACE;
|
||||
@@ -169,6 +170,12 @@ class Collection extends \ArrayObject
|
||||
return self::OPERATOR_NAMESPACE . $namespace . $type;
|
||||
}
|
||||
|
||||
if (strpos($type_parts[0], '::')) {
|
||||
$type_parts[] = strstr($type_parts[0], '::');
|
||||
$type_parts[0] = $namespace_aliases[strstr($type_parts[0], '::', true)];
|
||||
return implode('', $type_parts);
|
||||
}
|
||||
|
||||
$type_parts[0] = $namespace_aliases[$type_parts[0]];
|
||||
$type = implode(self::OPERATOR_NAMESPACE, $type_parts);
|
||||
}
|
||||
|
||||
@@ -123,6 +123,26 @@ class CollectionTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertSame($expected, $collection->getArrayCopy());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $fixture
|
||||
* @param array $expected
|
||||
*
|
||||
* @dataProvider provideTypesToExpandWithPropertyOrMethod
|
||||
* @covers phpDocumentor\Reflection\DocBlock\Type\Collection::add
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAddMethodsAndProperties($fixture, $expected)
|
||||
{
|
||||
$collection = new Collection(
|
||||
array(),
|
||||
new Context(null, array('LinkDescriptor' => '\phpDocumentor\LinkDescriptor'))
|
||||
);
|
||||
$collection->add($fixture);
|
||||
|
||||
$this->assertSame($expected, $collection->getArrayCopy());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers phpDocumentor\Reflection\DocBlock\Type\Collection::add
|
||||
* @expectedException InvalidArgumentException
|
||||
@@ -177,6 +197,14 @@ class CollectionTest extends \PHPUnit_Framework_TestCase
|
||||
'DocBlock[]|int[]',
|
||||
array($namespace.'DocBlock[]', 'int[]')
|
||||
),
|
||||
array(
|
||||
'LinkDescriptor::setLink()',
|
||||
array($namespace.'LinkDescriptor::setLink()')
|
||||
),
|
||||
array(
|
||||
'Alias\LinkDescriptor::setLink()',
|
||||
array('\My\Space\Aliasing\LinkDescriptor::setLink()')
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -192,4 +220,34 @@ class CollectionTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
return $this->provideTypesToExpand($method, '\\');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the method and property types and their expected values to test
|
||||
* the retrieval of types.
|
||||
*
|
||||
* @param string $method Name of the method consuming this data provider.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function provideTypesToExpandWithPropertyOrMethod($method)
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
'LinkDescriptor::setLink()',
|
||||
array('\phpDocumentor\LinkDescriptor::setLink()')
|
||||
),
|
||||
array(
|
||||
'phpDocumentor\LinkDescriptor::setLink()',
|
||||
array('\phpDocumentor\LinkDescriptor::setLink()')
|
||||
),
|
||||
array(
|
||||
'LinkDescriptor::$link',
|
||||
array('\phpDocumentor\LinkDescriptor::$link')
|
||||
),
|
||||
array(
|
||||
'phpDocumentor\LinkDescriptor::$link',
|
||||
array('\phpDocumentor\LinkDescriptor::$link')
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user