mirror of
https://github.com/barryvdh/ReflectionDocBlock.git
synced 2026-08-17 17:47:13 +00:00
Merge pull request #438 from mspirkov/fix-standard-tag-factory-2
Fix the creation of tags with types in `StandardTagFactory`
This commit is contained in:
@@ -35,12 +35,9 @@ use phpDocumentor\Reflection\DocBlock\Tags\Factory\VarFactory;
|
||||
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\See as SeeTag;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Since;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Source;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\TemplateCovariant;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Throws;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Uses;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Version;
|
||||
use phpDocumentor\Reflection\FqsenResolver;
|
||||
@@ -92,14 +89,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,
|
||||
];
|
||||
@@ -172,6 +165,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);
|
||||
|
||||
@@ -22,10 +22,23 @@ use phpDocumentor\Reflection\Assets\CustomServiceInterface;
|
||||
use phpDocumentor\Reflection\Assets\CustomTagFactory;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Author;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Deprecated;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Extends_;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Formatter;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Generic;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Implements_;
|
||||
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\Template;
|
||||
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 +557,43 @@ class StandardTagFactoryTest extends TestCase
|
||||
['@tag@invalid'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param class-string $expectedClass
|
||||
*
|
||||
* @dataProvider provideCreateWithTagWithTypesData
|
||||
*/
|
||||
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 T', Template::class],
|
||||
['@template-covariant T', TemplateCovariant::class],
|
||||
['@extends Foo<Bar>', Extends_::class],
|
||||
['@implements Foo<Bar>', Implements_::class],
|
||||
|
||||
// TODO: add factories for this tags
|
||||
// ['@template-extends Foo', TemplateExtends::class],
|
||||
// ['@template-implements Foo', TemplateImplements::class],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user