mirror of
https://github.com/barryvdh/ReflectionDocBlock.git
synced 2026-08-17 17:47:13 +00:00
Fix the creation of tags with types in StandardTagFactory
This commit is contained in:
@@ -92,14 +92,10 @@ final class StandardTagFactory implements TagFactory
|
||||
'author' => Author::class,
|
||||
'covers' => Covers::class,
|
||||
'deprecated' => Deprecated::class,
|
||||
// 'example' => '\phpDocumentor\Reflection\DocBlock\Tags\Example',
|
||||
'link' => LinkTag::class,
|
||||
'method' => Method::class,
|
||||
'see' => SeeTag::class,
|
||||
'since' => Since::class,
|
||||
'source' => Source::class,
|
||||
'template-covariant' => TemplateCovariant::class,
|
||||
'throw' => Throws::class,
|
||||
'uses' => Uses::class,
|
||||
'version' => Version::class,
|
||||
];
|
||||
@@ -161,6 +157,7 @@ final class StandardTagFactory implements TagFactory
|
||||
|
||||
$tagFactory->addService($descriptionFactory);
|
||||
$tagFactory->addService($typeResolver);
|
||||
$tagFactory->registerTagHandler('mixin', $phpstanTagFactory);
|
||||
$tagFactory->registerTagHandler('param', $phpstanTagFactory);
|
||||
$tagFactory->registerTagHandler('var', $phpstanTagFactory);
|
||||
$tagFactory->registerTagHandler('return', $phpstanTagFactory);
|
||||
@@ -171,6 +168,7 @@ final class StandardTagFactory implements TagFactory
|
||||
$tagFactory->registerTagHandler('extends', $phpstanTagFactory);
|
||||
$tagFactory->registerTagHandler('implements', $phpstanTagFactory);
|
||||
$tagFactory->registerTagHandler('template', $phpstanTagFactory);
|
||||
$tagFactory->registerTagHandler('template-covariant', $phpstanTagFactory);
|
||||
$tagFactory->registerTagHandler('template-extends', $phpstanTagFactory);
|
||||
$tagFactory->registerTagHandler('template-implements', $phpstanTagFactory);
|
||||
$tagFactory->registerTagHandler('throws', $phpstanTagFactory);
|
||||
|
||||
@@ -25,7 +25,18 @@ use phpDocumentor\Reflection\DocBlock\Tags\Deprecated;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Formatter;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Generic;
|
||||
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;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\TagWithType;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\TemplateCovariant;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Throws;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Var_;
|
||||
use phpDocumentor\Reflection\Fqsen;
|
||||
use phpDocumentor\Reflection\FqsenResolver;
|
||||
use phpDocumentor\Reflection\TypeResolver;
|
||||
@@ -544,4 +555,36 @@ class StandardTagFactoryTest extends TestCase
|
||||
['@tag@invalid'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideCreateWithTagWithTypesData
|
||||
*
|
||||
* @param class-string $expectedClass
|
||||
*/
|
||||
public function testCreateWithTagWithTypes(string $input, string $expectedClass): void
|
||||
{
|
||||
$tagFactory = StandardTagFactory::createInstance(new FqsenResolver());
|
||||
$tag = $tagFactory->create($input);
|
||||
|
||||
$this->assertInstanceOf($expectedClass, $tag);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<array{string, class-string}>
|
||||
*/
|
||||
public static function provideCreateWithTagWithTypesData(): array
|
||||
{
|
||||
return [
|
||||
['@mixin Foo', Mixin::class],
|
||||
['@method string do()', Method::class],
|
||||
['@param Foo $bar', Param::class],
|
||||
['@property-read Foo $bar', PropertyRead::class],
|
||||
['@property Foo $bar', Property::class],
|
||||
['@property-write Foo $bar', PropertyWrite::class],
|
||||
['@return string', Return_::class],
|
||||
['@throws Throwable', Throws::class],
|
||||
['@var string $var', Var_::class],
|
||||
['@template-covariant string', TemplateCovariant::class],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user