mirror of
https://github.com/barryvdh/ReflectionDocBlock.git
synced 2026-08-18 01:57:13 +00:00
Register tags
This commit is contained in:
@@ -13,46 +13,47 @@ declare(strict_types=1);
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Author;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Covers;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Deprecated;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Factory\Factory;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Generic;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\InvalidTag;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Link as LinkTag;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Method;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Mixin;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Param;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Property;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\PropertyRead;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\PropertyWrite;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Return_;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\See as SeeTag;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Since;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Source;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Throws;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Uses;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Var_;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Version;
|
||||
use phpDocumentor\Reflection\FqsenResolver;
|
||||
use phpDocumentor\Reflection\Types\Context as TypeContext;
|
||||
use ReflectionMethod;
|
||||
use ReflectionNamedType;
|
||||
use ReflectionParameter;
|
||||
use Webmozart\Assert\Assert;
|
||||
|
||||
use function array_key_exists;
|
||||
use function array_merge;
|
||||
use function array_slice;
|
||||
use function call_user_func_array;
|
||||
use function trim;
|
||||
use function count;
|
||||
use function strpos;
|
||||
use function sprintf;
|
||||
use ReflectionMethod;
|
||||
use function get_class;
|
||||
use function is_object;
|
||||
use function preg_match;
|
||||
use function sprintf;
|
||||
use function strpos;
|
||||
use function trim;
|
||||
use ReflectionNamedType;
|
||||
use ReflectionParameter;
|
||||
use function array_merge;
|
||||
use function array_slice;
|
||||
use Webmozart\Assert\Assert;
|
||||
use InvalidArgumentException;
|
||||
use function array_key_exists;
|
||||
use function call_user_func_array;
|
||||
use phpDocumentor\Reflection\FqsenResolver;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Uses;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Var_;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Mixin;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Param;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Since;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Author;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Covers;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Method;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Source;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Throws;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Generic;
|
||||
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Return_;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Version;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Property;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Deprecated;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\InvalidTag;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\PropertyRead;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\PropertyWrite;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\See as SeeTag;
|
||||
use phpDocumentor\Reflection\Types\Context as TypeContext;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Factory\Factory;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Link as LinkTag;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\TemplateCovariant;
|
||||
|
||||
/**
|
||||
* Creates a Tag object given the contents of a tag.
|
||||
@@ -81,26 +82,27 @@ final class StandardTagFactory implements TagFactory
|
||||
* FQCN to a class that handles it as an array value.
|
||||
*/
|
||||
private array $tagHandlerMappings = [
|
||||
'author' => Author::class,
|
||||
'covers' => Covers::class,
|
||||
'deprecated' => Deprecated::class,
|
||||
// 'example' => '\phpDocumentor\Reflection\DocBlock\Tags\Example',
|
||||
'link' => LinkTag::class,
|
||||
'mixin' => Mixin::class,
|
||||
'method' => Method::class,
|
||||
'param' => Param::class,
|
||||
'property-read' => PropertyRead::class,
|
||||
'property' => Property::class,
|
||||
'property-write' => PropertyWrite::class,
|
||||
'return' => Return_::class,
|
||||
'see' => SeeTag::class,
|
||||
'since' => Since::class,
|
||||
'source' => Source::class,
|
||||
'throw' => Throws::class,
|
||||
'throws' => Throws::class,
|
||||
'uses' => Uses::class,
|
||||
'var' => Var_::class,
|
||||
'version' => Version::class,
|
||||
'author' => Author::class,
|
||||
'covers' => Covers::class,
|
||||
'deprecated' => Deprecated::class,
|
||||
// 'example' => '\phpDocumentor\Reflection\DocBlock\Tags\Example',
|
||||
'link' => LinkTag::class,
|
||||
'mixin' => Mixin::class,
|
||||
'method' => Method::class,
|
||||
'param' => Param::class,
|
||||
'property-read' => PropertyRead::class,
|
||||
'property' => Property::class,
|
||||
'property-write' => PropertyWrite::class,
|
||||
'return' => Return_::class,
|
||||
'see' => SeeTag::class,
|
||||
'since' => Since::class,
|
||||
'source' => Source::class,
|
||||
'template-covariant' => TemplateCovariant::class,
|
||||
'throw' => Throws::class,
|
||||
'throws' => Throws::class,
|
||||
'uses' => Uses::class,
|
||||
'var' => Var_::class,
|
||||
'version' => Version::class,
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
+26
-18
@@ -13,35 +13,37 @@ declare(strict_types=1);
|
||||
|
||||
namespace phpDocumentor\Reflection;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use LogicException;
|
||||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||
use phpDocumentor\Reflection\DocBlock\StandardTagFactory;
|
||||
use InvalidArgumentException;
|
||||
use Webmozart\Assert\Assert;
|
||||
use phpDocumentor\Reflection\DocBlock\Tag;
|
||||
use phpDocumentor\Reflection\DocBlock\TagFactory;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Factory\AbstractPHPStanFactory;
|
||||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||
use phpDocumentor\Reflection\DocBlock\StandardTagFactory;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Factory\Factory;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Factory\MethodFactory;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Factory\VarFactory;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Factory\ParamFactory;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Factory\MethodFactory;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Factory\ReturnFactory;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Factory\ExtendsFactory;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Factory\PropertyFactory;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Factory\TemplateFactory;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Factory\ImplementsFactory;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Factory\PropertyReadFactory;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Factory\PropertyWriteFactory;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Factory\ReturnFactory;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Factory\VarFactory;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Factory\ImplementsFactory;
|
||||
use Webmozart\Assert\Assert;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Factory\AbstractPHPStanFactory;
|
||||
|
||||
use function array_shift;
|
||||
use function trim;
|
||||
use function count;
|
||||
use function explode;
|
||||
use function is_object;
|
||||
use function method_exists;
|
||||
use function preg_match;
|
||||
use function preg_replace;
|
||||
use function str_replace;
|
||||
use function strpos;
|
||||
use function substr;
|
||||
use function trim;
|
||||
use function explode;
|
||||
use function is_object;
|
||||
use function preg_match;
|
||||
use function array_shift;
|
||||
use function str_replace;
|
||||
use function preg_replace;
|
||||
use function method_exists;
|
||||
|
||||
final class DocBlockFactory implements DocBlockFactoryInterface
|
||||
{
|
||||
@@ -78,7 +80,9 @@ final class DocBlockFactory implements DocBlockFactoryInterface
|
||||
new PropertyReadFactory($typeResolver, $descriptionFactory),
|
||||
new PropertyWriteFactory($typeResolver, $descriptionFactory),
|
||||
new MethodFactory($typeResolver, $descriptionFactory),
|
||||
new ImplementsFactory($typeResolver, $descriptionFactory)
|
||||
new ImplementsFactory($typeResolver, $descriptionFactory),
|
||||
new TemplateFactory($typeResolver, $descriptionFactory),
|
||||
new ExtendsFactory($typeResolver, $descriptionFactory),
|
||||
);
|
||||
|
||||
$tagFactory->addService($descriptionFactory);
|
||||
@@ -90,7 +94,11 @@ final class DocBlockFactory implements DocBlockFactoryInterface
|
||||
$tagFactory->registerTagHandler('property-read', $phpstanTagFactory);
|
||||
$tagFactory->registerTagHandler('property-write', $phpstanTagFactory);
|
||||
$tagFactory->registerTagHandler('method', $phpstanTagFactory);
|
||||
$tagFactory->registerTagHandler('extends', $phpstanTagFactory);
|
||||
$tagFactory->registerTagHandler('implements', $phpstanTagFactory);
|
||||
$tagFactory->registerTagHandler('template', $phpstanTagFactory);
|
||||
$tagFactory->registerTagHandler('template-extends', $phpstanTagFactory);
|
||||
$tagFactory->registerTagHandler('template-implements', $phpstanTagFactory);
|
||||
|
||||
$docBlockFactory = new self($descriptionFactory, $tagFactory);
|
||||
foreach ($additionalTags as $tagName => $tagHandler) {
|
||||
|
||||
Reference in New Issue
Block a user