|
22 | 22 | use phpDocumentor\Reflection\Assets\CustomTagFactory; |
23 | 23 | use phpDocumentor\Reflection\DocBlock\Tags\Author; |
24 | 24 | use phpDocumentor\Reflection\DocBlock\Tags\Deprecated; |
| 25 | +use phpDocumentor\Reflection\DocBlock\Tags\Extends_; |
25 | 26 | use phpDocumentor\Reflection\DocBlock\Tags\Formatter; |
26 | 27 | use phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter; |
27 | 28 | use phpDocumentor\Reflection\DocBlock\Tags\Generic; |
| 29 | +use phpDocumentor\Reflection\DocBlock\Tags\Implements_; |
| 30 | +use phpDocumentor\Reflection\DocBlock\Tags\Method; |
| 31 | +use phpDocumentor\Reflection\DocBlock\Tags\Mixin; |
| 32 | +use phpDocumentor\Reflection\DocBlock\Tags\Param; |
| 33 | +use phpDocumentor\Reflection\DocBlock\Tags\Property; |
| 34 | +use phpDocumentor\Reflection\DocBlock\Tags\PropertyRead; |
| 35 | +use phpDocumentor\Reflection\DocBlock\Tags\PropertyWrite; |
| 36 | +use phpDocumentor\Reflection\DocBlock\Tags\Return_; |
28 | 37 | use phpDocumentor\Reflection\DocBlock\Tags\See; |
| 38 | +use phpDocumentor\Reflection\DocBlock\Tags\Template; |
| 39 | +use phpDocumentor\Reflection\DocBlock\Tags\TemplateCovariant; |
| 40 | +use phpDocumentor\Reflection\DocBlock\Tags\Throws; |
| 41 | +use phpDocumentor\Reflection\DocBlock\Tags\Var_; |
29 | 42 | use phpDocumentor\Reflection\Fqsen; |
30 | 43 | use phpDocumentor\Reflection\FqsenResolver; |
31 | 44 | use phpDocumentor\Reflection\TypeResolver; |
@@ -544,4 +557,43 @@ public function invalidTagProvider(): array |
544 | 557 | ['@tag@invalid'], |
545 | 558 | ]; |
546 | 559 | } |
| 560 | + |
| 561 | + /** |
| 562 | + * @param class-string $expectedClass |
| 563 | + * |
| 564 | + * @dataProvider provideCreateWithTagWithTypesData |
| 565 | + */ |
| 566 | + public function testCreateWithTagWithTypes(string $input, string $expectedClass): void |
| 567 | + { |
| 568 | + $tagFactory = StandardTagFactory::createInstance(new FqsenResolver()); |
| 569 | + $tag = $tagFactory->create($input); |
| 570 | + |
| 571 | + $this->assertInstanceOf($expectedClass, $tag); |
| 572 | + } |
| 573 | + |
| 574 | + /** |
| 575 | + * @return list<array{string, class-string}> |
| 576 | + */ |
| 577 | + public static function provideCreateWithTagWithTypesData(): array |
| 578 | + { |
| 579 | + return [ |
| 580 | + ['@mixin Foo', Mixin::class], |
| 581 | + ['@method string do()', Method::class], |
| 582 | + ['@param Foo $bar', Param::class], |
| 583 | + ['@property-read Foo $bar', PropertyRead::class], |
| 584 | + ['@property Foo $bar', Property::class], |
| 585 | + ['@property-write Foo $bar', PropertyWrite::class], |
| 586 | + ['@return string', Return_::class], |
| 587 | + ['@throws Throwable', Throws::class], |
| 588 | + ['@var string $var', Var_::class], |
| 589 | + ['@template T', Template::class], |
| 590 | + ['@template-covariant T', TemplateCovariant::class], |
| 591 | + ['@extends Foo<Bar>', Extends_::class], |
| 592 | + ['@implements Foo<Bar>', Implements_::class], |
| 593 | + |
| 594 | + // TODO: add factories for this tags |
| 595 | + // ['@template-extends Foo', TemplateExtends::class], |
| 596 | + // ['@template-implements Foo', TemplateImplements::class], |
| 597 | + ]; |
| 598 | + } |
547 | 599 | } |
0 commit comments