mirror of
https://github.com/barryvdh/ReflectionDocBlock.git
synced 2026-08-18 01:57:13 +00:00
Handle tag specialization correctly
This commit is contained in:
@@ -68,7 +68,7 @@ use function trim;
|
||||
final class StandardTagFactory implements TagFactory
|
||||
{
|
||||
/** PCRE regular expression matching a tag name. */
|
||||
public const REGEX_TAGNAME = '[\w\-\_\\\\]+';
|
||||
public const REGEX_TAGNAME = '[\w\-\_\\\\:]+';
|
||||
|
||||
/**
|
||||
* @var string[] An array with a tag as a key, and an
|
||||
@@ -194,7 +194,7 @@ final class StandardTagFactory implements TagFactory
|
||||
private function extractTagParts(string $tagLine) : array
|
||||
{
|
||||
$matches = [];
|
||||
if (!preg_match('/^@(' . self::REGEX_TAGNAME . ')((?:[\s\(\{:])\s*([^\s].*)|$)/us', $tagLine, $matches)) {
|
||||
if (!preg_match('/^@(' . self::REGEX_TAGNAME . ')((?:[\s\(\{])\s*([^\s].*)|$)/us', $tagLine, $matches)) {
|
||||
throw new InvalidArgumentException(
|
||||
'The tag "' . $tagLine . '" does not seem to be wellformed, please check it for errors'
|
||||
);
|
||||
|
||||
@@ -372,9 +372,14 @@ class StandardTagFactoryTest extends TestCase
|
||||
'@tag',
|
||||
],
|
||||
'tag specialization' => [
|
||||
'@tag:some-spec',
|
||||
'tag',
|
||||
'@tag :some-spec',
|
||||
'@tag:some-spec body',
|
||||
'tag:some-spec',
|
||||
'@tag:some-spec body',
|
||||
],
|
||||
'tag specialization(a)' => [
|
||||
'@tag:some-spec(body)',
|
||||
'tag:some-spec',
|
||||
'@tag:some-spec (body)',
|
||||
],
|
||||
'tag with textual description' => [
|
||||
'@tag some text',
|
||||
|
||||
Reference in New Issue
Block a user