Skip to content

Commit f93a6b7

Browse files
committed
Register tags
1 parent cca538e commit f93a6b7

File tree

2 files changed

+77
-67
lines changed

2 files changed

+77
-67
lines changed

src/DocBlock/StandardTagFactory.php

Lines changed: 53 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -13,46 +13,47 @@
1313

1414
namespace phpDocumentor\Reflection\DocBlock;
1515

16+
use function trim;
17+
use function count;
18+
use function strpos;
19+
use function sprintf;
20+
use ReflectionMethod;
21+
use function get_class;
22+
use function is_object;
23+
use function preg_match;
24+
use ReflectionNamedType;
25+
use ReflectionParameter;
26+
use function array_merge;
27+
use function array_slice;
28+
use Webmozart\Assert\Assert;
1629
use InvalidArgumentException;
30+
use function array_key_exists;
31+
use function call_user_func_array;
32+
use phpDocumentor\Reflection\FqsenResolver;
33+
use phpDocumentor\Reflection\DocBlock\Tags\Uses;
34+
use phpDocumentor\Reflection\DocBlock\Tags\Var_;
35+
use phpDocumentor\Reflection\DocBlock\Tags\Mixin;
36+
use phpDocumentor\Reflection\DocBlock\Tags\Param;
37+
use phpDocumentor\Reflection\DocBlock\Tags\Since;
1738
use phpDocumentor\Reflection\DocBlock\Tags\Author;
1839
use phpDocumentor\Reflection\DocBlock\Tags\Covers;
19-
use phpDocumentor\Reflection\DocBlock\Tags\Deprecated;
20-
use phpDocumentor\Reflection\DocBlock\Tags\Factory\Factory;
21-
use phpDocumentor\Reflection\DocBlock\Tags\Generic;
22-
use phpDocumentor\Reflection\DocBlock\Tags\InvalidTag;
23-
use phpDocumentor\Reflection\DocBlock\Tags\Link as LinkTag;
2440
use phpDocumentor\Reflection\DocBlock\Tags\Method;
25-
use phpDocumentor\Reflection\DocBlock\Tags\Mixin;
26-
use phpDocumentor\Reflection\DocBlock\Tags\Param;
41+
use phpDocumentor\Reflection\DocBlock\Tags\Source;
42+
use phpDocumentor\Reflection\DocBlock\Tags\Throws;
43+
use phpDocumentor\Reflection\DocBlock\Tags\Generic;
44+
45+
use phpDocumentor\Reflection\DocBlock\Tags\Return_;
46+
use phpDocumentor\Reflection\DocBlock\Tags\Version;
2747
use phpDocumentor\Reflection\DocBlock\Tags\Property;
48+
use phpDocumentor\Reflection\DocBlock\Tags\Deprecated;
49+
use phpDocumentor\Reflection\DocBlock\Tags\InvalidTag;
2850
use phpDocumentor\Reflection\DocBlock\Tags\PropertyRead;
2951
use phpDocumentor\Reflection\DocBlock\Tags\PropertyWrite;
30-
use phpDocumentor\Reflection\DocBlock\Tags\Return_;
3152
use phpDocumentor\Reflection\DocBlock\Tags\See as SeeTag;
32-
use phpDocumentor\Reflection\DocBlock\Tags\Since;
33-
use phpDocumentor\Reflection\DocBlock\Tags\Source;
34-
use phpDocumentor\Reflection\DocBlock\Tags\Throws;
35-
use phpDocumentor\Reflection\DocBlock\Tags\Uses;
36-
use phpDocumentor\Reflection\DocBlock\Tags\Var_;
37-
use phpDocumentor\Reflection\DocBlock\Tags\Version;
38-
use phpDocumentor\Reflection\FqsenResolver;
3953
use phpDocumentor\Reflection\Types\Context as TypeContext;
40-
use ReflectionMethod;
41-
use ReflectionNamedType;
42-
use ReflectionParameter;
43-
use Webmozart\Assert\Assert;
44-
45-
use function array_key_exists;
46-
use function array_merge;
47-
use function array_slice;
48-
use function call_user_func_array;
49-
use function count;
50-
use function get_class;
51-
use function is_object;
52-
use function preg_match;
53-
use function sprintf;
54-
use function strpos;
55-
use function trim;
54+
use phpDocumentor\Reflection\DocBlock\Tags\Factory\Factory;
55+
use phpDocumentor\Reflection\DocBlock\Tags\Link as LinkTag;
56+
use phpDocumentor\Reflection\DocBlock\Tags\TemplateCovariant;
5657

5758
/**
5859
* Creates a Tag object given the contents of a tag.
@@ -81,26 +82,27 @@ final class StandardTagFactory implements TagFactory
8182
* FQCN to a class that handles it as an array value.
8283
*/
8384
private array $tagHandlerMappings = [
84-
'author' => Author::class,
85-
'covers' => Covers::class,
86-
'deprecated' => Deprecated::class,
87-
// 'example' => '\phpDocumentor\Reflection\DocBlock\Tags\Example',
88-
'link' => LinkTag::class,
89-
'mixin' => Mixin::class,
90-
'method' => Method::class,
91-
'param' => Param::class,
92-
'property-read' => PropertyRead::class,
93-
'property' => Property::class,
94-
'property-write' => PropertyWrite::class,
95-
'return' => Return_::class,
96-
'see' => SeeTag::class,
97-
'since' => Since::class,
98-
'source' => Source::class,
99-
'throw' => Throws::class,
100-
'throws' => Throws::class,
101-
'uses' => Uses::class,
102-
'var' => Var_::class,
103-
'version' => Version::class,
85+
'author' => Author::class,
86+
'covers' => Covers::class,
87+
'deprecated' => Deprecated::class,
88+
// 'example' => '\phpDocumentor\Reflection\DocBlock\Tags\Example',
89+
'link' => LinkTag::class,
90+
'mixin' => Mixin::class,
91+
'method' => Method::class,
92+
'param' => Param::class,
93+
'property-read' => PropertyRead::class,
94+
'property' => Property::class,
95+
'property-write' => PropertyWrite::class,
96+
'return' => Return_::class,
97+
'see' => SeeTag::class,
98+
'since' => Since::class,
99+
'source' => Source::class,
100+
'template-covariant' => TemplateCovariant::class,
101+
'throw' => Throws::class,
102+
'throws' => Throws::class,
103+
'uses' => Uses::class,
104+
'var' => Var_::class,
105+
'version' => Version::class,
104106
];
105107

106108
/**

src/DocBlockFactory.php

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,35 +13,37 @@
1313

1414
namespace phpDocumentor\Reflection;
1515

16-
use InvalidArgumentException;
1716
use LogicException;
18-
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
19-
use phpDocumentor\Reflection\DocBlock\StandardTagFactory;
17+
use InvalidArgumentException;
18+
use Webmozart\Assert\Assert;
2019
use phpDocumentor\Reflection\DocBlock\Tag;
2120
use phpDocumentor\Reflection\DocBlock\TagFactory;
22-
use phpDocumentor\Reflection\DocBlock\Tags\Factory\AbstractPHPStanFactory;
21+
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
22+
use phpDocumentor\Reflection\DocBlock\StandardTagFactory;
2323
use phpDocumentor\Reflection\DocBlock\Tags\Factory\Factory;
24-
use phpDocumentor\Reflection\DocBlock\Tags\Factory\MethodFactory;
24+
use phpDocumentor\Reflection\DocBlock\Tags\Factory\VarFactory;
2525
use phpDocumentor\Reflection\DocBlock\Tags\Factory\ParamFactory;
26+
use phpDocumentor\Reflection\DocBlock\Tags\Factory\MethodFactory;
27+
use phpDocumentor\Reflection\DocBlock\Tags\Factory\ReturnFactory;
28+
use phpDocumentor\Reflection\DocBlock\Tags\Factory\ExtendsFactory;
2629
use phpDocumentor\Reflection\DocBlock\Tags\Factory\PropertyFactory;
30+
use phpDocumentor\Reflection\DocBlock\Tags\Factory\TemplateFactory;
31+
use phpDocumentor\Reflection\DocBlock\Tags\Factory\ImplementsFactory;
2732
use phpDocumentor\Reflection\DocBlock\Tags\Factory\PropertyReadFactory;
2833
use phpDocumentor\Reflection\DocBlock\Tags\Factory\PropertyWriteFactory;
29-
use phpDocumentor\Reflection\DocBlock\Tags\Factory\ReturnFactory;
30-
use phpDocumentor\Reflection\DocBlock\Tags\Factory\VarFactory;
31-
use phpDocumentor\Reflection\DocBlock\Tags\Factory\ImplementsFactory;
32-
use Webmozart\Assert\Assert;
34+
use phpDocumentor\Reflection\DocBlock\Tags\Factory\AbstractPHPStanFactory;
3335

34-
use function array_shift;
36+
use function trim;
3537
use function count;
38+
use function strpos;
39+
use function substr;
3640
use function explode;
3741
use function is_object;
38-
use function method_exists;
3942
use function preg_match;
40-
use function preg_replace;
43+
use function array_shift;
4144
use function str_replace;
42-
use function strpos;
43-
use function substr;
44-
use function trim;
45+
use function preg_replace;
46+
use function method_exists;
4547

4648
final class DocBlockFactory implements DocBlockFactoryInterface
4749
{
@@ -78,7 +80,9 @@ public static function createInstance(array $additionalTags = []): DocBlockFacto
7880
new PropertyReadFactory($typeResolver, $descriptionFactory),
7981
new PropertyWriteFactory($typeResolver, $descriptionFactory),
8082
new MethodFactory($typeResolver, $descriptionFactory),
81-
new ImplementsFactory($typeResolver, $descriptionFactory)
83+
new ImplementsFactory($typeResolver, $descriptionFactory),
84+
new TemplateFactory($typeResolver, $descriptionFactory),
85+
new ExtendsFactory($typeResolver, $descriptionFactory),
8286
);
8387

8488
$tagFactory->addService($descriptionFactory);
@@ -90,7 +94,11 @@ public static function createInstance(array $additionalTags = []): DocBlockFacto
9094
$tagFactory->registerTagHandler('property-read', $phpstanTagFactory);
9195
$tagFactory->registerTagHandler('property-write', $phpstanTagFactory);
9296
$tagFactory->registerTagHandler('method', $phpstanTagFactory);
97+
$tagFactory->registerTagHandler('extends', $phpstanTagFactory);
9398
$tagFactory->registerTagHandler('implements', $phpstanTagFactory);
99+
$tagFactory->registerTagHandler('template', $phpstanTagFactory);
100+
$tagFactory->registerTagHandler('template-extends', $phpstanTagFactory);
101+
$tagFactory->registerTagHandler('template-implements', $phpstanTagFactory);
94102

95103
$docBlockFactory = new self($descriptionFactory, $tagFactory);
96104
foreach ($additionalTags as $tagName => $tagHandler) {

0 commit comments

Comments
 (0)