Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions src/DocBlock/StandardTagFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,9 @@
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;
Expand Down Expand Up @@ -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,
];
Expand Down Expand Up @@ -161,6 +154,7 @@ public static function createInstance(FqsenResolver $fqsenResolver): self

$tagFactory->addService($descriptionFactory);
$tagFactory->addService($typeResolver);
$tagFactory->registerTagHandler('mixin', $phpstanTagFactory);
$tagFactory->registerTagHandler('param', $phpstanTagFactory);
$tagFactory->registerTagHandler('var', $phpstanTagFactory);
$tagFactory->registerTagHandler('return', $phpstanTagFactory);
Expand All @@ -171,6 +165,7 @@ public static function createInstance(FqsenResolver $fqsenResolver): self
$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);
Expand Down
52 changes: 52 additions & 0 deletions tests/unit/DocBlock/StandardTagFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,23 @@
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;
Expand Down Expand Up @@ -544,4 +557,43 @@ public function invalidTagProvider(): array
['@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
Comment thread
mspirkov marked this conversation as resolved.
// ['@template-extends Foo', TemplateExtends::class],
// ['@template-implements Foo', TemplateImplements::class],
];
}
}