Skip to content

Commit bd4d12d

Browse files
committed
Make tags case-insensitive
1 parent 4521bde commit bd4d12d

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

Diff for: src/DocBlock/Tag/Factory/MutableTagFactoryInterface.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ interface MutableTagFactoryInterface extends TagFactoryInterface
1414
* the custom {@see TagFactoryInterface} to which processing of this tag will
1515
* be delegated.
1616
*
17-
* @param non-empty-string|list<non-empty-string> $tags
17+
* @param non-empty-lowercase-string|list<non-empty-lowercase-string> $tags
1818
*/
1919
public function register(string|array $tags, TagFactoryInterface $delegate): void;
2020
}

Diff for: src/DocBlock/Tag/Factory/TagFactory.php

+8-4
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
final class TagFactory implements MutableTagFactoryInterface
1515
{
1616
/**
17-
* @var array<non-empty-string, TagFactoryInterface>
17+
* @var array<non-empty-lowercase-string, TagFactoryInterface>
1818
*/
1919
private array $factories;
2020

2121
/**
22-
* @param iterable<non-empty-string, TagFactoryInterface> $factories
22+
* @param iterable<non-empty-lowercase-string, TagFactoryInterface> $factories
2323
*/
2424
public function __construct(iterable $factories = [])
2525
{
@@ -32,14 +32,18 @@ public function __construct(iterable $factories = [])
3232

3333
public function register(array|string $tags, TagFactoryInterface $delegate): void
3434
{
35-
foreach ((array) $tags as $tag) {
35+
if (\is_string($tags)) {
36+
$tags = [$tags];
37+
}
38+
39+
foreach ($tags as $tag) {
3640
$this->factories[$tag] = $delegate;
3741
}
3842
}
3943

4044
public function create(string $tag, string $content, DescriptionParserInterface $descriptions): TagInterface
4145
{
42-
$delegate = $this->factories[$tag] ?? null;
46+
$delegate = $this->factories[\strtolower($tag)] ?? null;
4347

4448
if ($delegate !== null) {
4549
try {

0 commit comments

Comments
 (0)