mirror of
https://github.com/barryvdh/ReflectionDocBlock.git
synced 2026-08-18 01:57:13 +00:00
Made the Tag::createInstance() create generic tag objects when there are uppercase letters in the tag name
(this fixes phpDocumentor/phpDocumentor2#672).
This commit is contained in:
@@ -68,7 +68,8 @@ class Tag implements \Reflector
|
|||||||
).'Tag';
|
).'Tag';
|
||||||
$class_name = 'phpDocumentor\\Reflection\\DocBlock\\Tag\\' . $tag_name;
|
$class_name = 'phpDocumentor\\Reflection\\DocBlock\\Tag\\' . $tag_name;
|
||||||
|
|
||||||
return (@class_exists($class_name))
|
return ($matches[1] === strtolower($matches[1])
|
||||||
|
&& @class_exists($class_name))
|
||||||
? new $class_name($matches[1], isset($matches[2]) ? $matches[2] : '')
|
? new $class_name($matches[1], isset($matches[2]) ? $matches[2] : '')
|
||||||
: new self($matches[1], isset($matches[2]) ? $matches[2] : '');
|
: new self($matches[1], isset($matches[2]) ? $matches[2] : '');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -93,6 +93,45 @@ DOCBLOCK;
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testTagCaseSensitivity()
|
||||||
|
{
|
||||||
|
$fixture = <<<DOCBLOCK
|
||||||
|
/**
|
||||||
|
* This is a short description.
|
||||||
|
*
|
||||||
|
* This is a long description.
|
||||||
|
*
|
||||||
|
* @method null something()
|
||||||
|
* @Method({"GET", "POST"})
|
||||||
|
*/
|
||||||
|
DOCBLOCK;
|
||||||
|
$object = new DocBlock($fixture);
|
||||||
|
$this->assertEquals(
|
||||||
|
'This is a short description.',
|
||||||
|
$object->getShortDescription()
|
||||||
|
);
|
||||||
|
$this->assertEquals(
|
||||||
|
'This is a long description.',
|
||||||
|
$object->getLongDescription()->getContents()
|
||||||
|
);
|
||||||
|
$tags = $object->getTags();
|
||||||
|
$this->assertEquals(2, count($tags));
|
||||||
|
$this->assertTrue($object->hasTag('method'));
|
||||||
|
$this->assertTrue($object->hasTag('Method'));
|
||||||
|
$this->assertInstanceOf(
|
||||||
|
__NAMESPACE__ . '\DocBlock\Tag\MethodTag',
|
||||||
|
$tags[0]
|
||||||
|
);
|
||||||
|
$this->assertInstanceOf(
|
||||||
|
__NAMESPACE__ . '\DocBlock\Tag',
|
||||||
|
$tags[1]
|
||||||
|
);
|
||||||
|
$this->assertNotInstanceOf(
|
||||||
|
__NAMESPACE__ . '\DocBlock\Tag\MethodTag',
|
||||||
|
$tags[1]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests whether a type is expanded with the given namespace and that a
|
* Tests whether a type is expanded with the given namespace and that a
|
||||||
* keyword is not expanded.
|
* keyword is not expanded.
|
||||||
|
|||||||
Reference in New Issue
Block a user