From 29e383a759d575c66317e5229284dd0b8aca7e53 Mon Sep 17 00:00:00 2001 From: Jaapio Date: Mon, 14 Nov 2022 22:00:05 +0100 Subject: [PATCH] Fix issue with missing registered factory --- src/DocBlockFactory.php | 2 ++ .../integration/InterpretingDocBlocksTest.php | 34 +++++++++++++++++++ .../Tags/Factory/MethodFactoryTest.php | 12 +++++++ 3 files changed, 48 insertions(+) diff --git a/src/DocBlockFactory.php b/src/DocBlockFactory.php index 46eb87f..507a4ec 100644 --- a/src/DocBlockFactory.php +++ b/src/DocBlockFactory.php @@ -21,6 +21,7 @@ use phpDocumentor\Reflection\DocBlock\Tag; use phpDocumentor\Reflection\DocBlock\TagFactory; use phpDocumentor\Reflection\DocBlock\Tags\Factory\AbstractPHPStanFactory; use phpDocumentor\Reflection\DocBlock\Tags\Factory\Factory; +use phpDocumentor\Reflection\DocBlock\Tags\Factory\MethodFactory; use phpDocumentor\Reflection\DocBlock\Tags\Factory\ParamFactory; use phpDocumentor\Reflection\DocBlock\Tags\Factory\PropertyFactory; use phpDocumentor\Reflection\DocBlock\Tags\Factory\PropertyReadFactory; @@ -77,6 +78,7 @@ final class DocBlockFactory implements DocBlockFactoryInterface new PropertyFactory($typeResolver, $descriptionFactory), new PropertyReadFactory($typeResolver, $descriptionFactory), new PropertyWriteFactory($typeResolver, $descriptionFactory), + new MethodFactory($typeResolver, $descriptionFactory) ); $tagFactory->addService($descriptionFactory); diff --git a/tests/integration/InterpretingDocBlocksTest.php b/tests/integration/InterpretingDocBlocksTest.php index 5ebc29c..05045c7 100644 --- a/tests/integration/InterpretingDocBlocksTest.php +++ b/tests/integration/InterpretingDocBlocksTest.php @@ -17,11 +17,14 @@ use Mockery as m; use phpDocumentor\Reflection\DocBlock\Description; use phpDocumentor\Reflection\DocBlock\StandardTagFactory; use phpDocumentor\Reflection\DocBlock\Tag; +use phpDocumentor\Reflection\DocBlock\Tags\Method; +use phpDocumentor\Reflection\DocBlock\Tags\MethodParameter; use phpDocumentor\Reflection\DocBlock\Tags\Param; use phpDocumentor\Reflection\DocBlock\Tags\See; use phpDocumentor\Reflection\Types\Array_; use phpDocumentor\Reflection\Types\Integer; use phpDocumentor\Reflection\Types\String_; +use phpDocumentor\Reflection\Types\Void_; use PHPUnit\Framework\TestCase; /** @@ -185,4 +188,35 @@ DOC; ); } + + public function testMethodRegression(): void + { + $docCommment = <<create($docCommment); + + self::assertEquals( + [ + new Method( + 'setInteger', + [], + new Void_(), + false, + new Description(''), + false, + [ + new MethodParameter('integer', new Integer()) + ] + ), + ], + $docblock->getTags() + ); + + } } diff --git a/tests/unit/DocBlock/Tags/Factory/MethodFactoryTest.php b/tests/unit/DocBlock/Tags/Factory/MethodFactoryTest.php index 2daad8b..59f148d 100644 --- a/tests/unit/DocBlock/Tags/Factory/MethodFactoryTest.php +++ b/tests/unit/DocBlock/Tags/Factory/MethodFactoryTest.php @@ -95,6 +95,18 @@ final class MethodFactoryTest extends TagFactoryTestCase [new MethodParameter('a', new Mixed_())] ), ], + [ + '@method void setInteger(integer $integer)', + new Method( + 'setInteger', + [], + new Void_(), + false, + new Description(''), + false, + [new MethodParameter('integer', new Integer())] + ), + ], [ '@method myMethod($a = 1)', new Method(