Skip to content

Commit c450bb8

Browse files
Allow a colon in tag names for namespacing.
1 parent f23b147 commit c450bb8

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

src/DocBlockParser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ private function extractTagsAndArguments(array $lines) : array
9898
foreach ($lines as $line) {
9999
if ($currentState === $stateSearchStartOfTag) {
100100
// pattern: ^@<name-of-tag><optional: space plus rest of line>
101-
$pattern = '(^@([a-z-]+)( (.*))?$)';
101+
$pattern = '(^@([a-z:-]+)( (.*))?$)';
102102
$count = preg_match($pattern, $line, $matches);
103103
if (1 !== $count) {
104104
continue;

tests/PhpUnit/DocBlockParserTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ public function it_parses_single_line_annotations_of_a_doc_block()
9090
* @some-tag some argument string for the first some-tag
9191
* @some-tag some other argument string for the second some-tag
9292
* @othertag some argument string for another tag
93+
* @namespaced:tag some argument
9394
*/
9495
DocBlock;
9596

@@ -113,6 +114,11 @@ public function it_parses_single_line_annotations_of_a_doc_block()
113114
'some argument string for another tag',
114115
Annotations::CONTEXT_CLASS
115116
);
117+
$expectedAnnotations->add(
118+
'namespaced:tag',
119+
'some argument',
120+
Annotations::CONTEXT_CLASS
121+
);
116122

117123
$this->assertEquals($expectedAnnotations, $annotations);
118124
}

0 commit comments

Comments
 (0)