mirror of
https://github.com/barryvdh/ReflectionDocBlock.git
synced 2026-08-18 10:07:12 +00:00
Restores future support for annotations
In #89 the regex to parse tags was to strict. The first character after a tag had to be a single string. Annotations typically start with a parentheses. Only character not allowed after a tag is a [.
This commit is contained in:
committed by
Jaap van Otterdijk
parent
48d3720bf4
commit
183824db76
@@ -113,6 +113,12 @@ final class StandardTagFactory implements TagFactory
|
|||||||
|
|
||||||
list($tagName, $tagBody) = $this->extractTagParts($tagLine);
|
list($tagName, $tagBody) = $this->extractTagParts($tagLine);
|
||||||
|
|
||||||
|
if ($tagBody[0] === '[') {
|
||||||
|
throw new \InvalidArgumentException(
|
||||||
|
'The tag "' . $tagLine . '" does not seem to be wellformed, please check it for errors'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return $this->createTag($tagBody, $tagName, $context);
|
return $this->createTag($tagBody, $tagName, $context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,7 +167,7 @@ final class StandardTagFactory implements TagFactory
|
|||||||
private function extractTagParts($tagLine)
|
private function extractTagParts($tagLine)
|
||||||
{
|
{
|
||||||
$matches = array();
|
$matches = array();
|
||||||
if (! preg_match('/^@(' . self::REGEX_TAGNAME . ')(?:\s+([^\s].*)|$)/us', $tagLine, $matches)) {
|
if (! preg_match('/^@(' . self::REGEX_TAGNAME . ')(?:\s*([^\s].*)|$)/us', $tagLine, $matches)) {
|
||||||
throw new \InvalidArgumentException(
|
throw new \InvalidArgumentException(
|
||||||
'The tag "' . $tagLine . '" does not seem to be wellformed, please check it for errors'
|
'The tag "' . $tagLine . '" does not seem to be wellformed, please check it for errors'
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of phpDocumentor.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* @copyright 2010-2017 Mike van Riel<[email protected]>
|
||||||
|
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||||
|
* @link http://phpdoc.org
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace phpDocumentor\Reflection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @coversNothing
|
||||||
|
*/
|
||||||
|
final class DocblocksWithAnnotationsTest extends \PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
public function testDocblockWithAnnotations()
|
||||||
|
{
|
||||||
|
$docComment = <<<DOCCOMMENT
|
||||||
|
/**
|
||||||
|
* @var \DateTime[]
|
||||||
|
* @Groups({"a", "b"})
|
||||||
|
*/
|
||||||
|
DOCCOMMENT;
|
||||||
|
|
||||||
|
|
||||||
|
$factory = DocBlockFactory::createInstance();
|
||||||
|
$docblock = $factory->create($docComment);
|
||||||
|
|
||||||
|
$this->assertCount(2, $docblock->getTags());
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user