Skip to content

Commit 264bd1f

Browse files
committed
Handle tag specialization correctly
1 parent ed7b791 commit 264bd1f

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/DocBlock/StandardTagFactory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
final class StandardTagFactory implements TagFactory
6969
{
7070
/** PCRE regular expression matching a tag name. */
71-
public const REGEX_TAGNAME = '[\w\-\_\\\\]+';
71+
public const REGEX_TAGNAME = '[\w\-\_\\\\:]+';
7272

7373
/**
7474
* @var string[] An array with a tag as a key, and an
@@ -194,7 +194,7 @@ public function registerTagHandler(string $tagName, string $handler) : void
194194
private function extractTagParts(string $tagLine) : array
195195
{
196196
$matches = [];
197-
if (!preg_match('/^@(' . self::REGEX_TAGNAME . ')((?:[\s\(\{:])\s*([^\s].*)|$)/us', $tagLine, $matches)) {
197+
if (!preg_match('/^@(' . self::REGEX_TAGNAME . ')((?:[\s\(\{])\s*([^\s].*)|$)/us', $tagLine, $matches)) {
198198
throw new InvalidArgumentException(
199199
'The tag "' . $tagLine . '" does not seem to be wellformed, please check it for errors'
200200
);

tests/unit/DocBlock/StandardTagFactoryTest.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -372,9 +372,14 @@ public function validTagProvider() : array
372372
'@tag',
373373
],
374374
'tag specialization' => [
375-
'@tag:some-spec',
376-
'tag',
377-
'@tag :some-spec',
375+
'@tag:some-spec body',
376+
'tag:some-spec',
377+
'@tag:some-spec body',
378+
],
379+
'tag specialization(a)' => [
380+
'@tag:some-spec(body)',
381+
'tag:some-spec',
382+
'@tag:some-spec (body)',
378383
],
379384
'tag with textual description' => [
380385
'@tag some text',

0 commit comments

Comments
 (0)