Skip to content

Commit 29e383a

Browse files
committed
Fix issue with missing registered factory
1 parent ec81b54 commit 29e383a

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed

src/DocBlockFactory.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
use phpDocumentor\Reflection\DocBlock\TagFactory;
2222
use phpDocumentor\Reflection\DocBlock\Tags\Factory\AbstractPHPStanFactory;
2323
use phpDocumentor\Reflection\DocBlock\Tags\Factory\Factory;
24+
use phpDocumentor\Reflection\DocBlock\Tags\Factory\MethodFactory;
2425
use phpDocumentor\Reflection\DocBlock\Tags\Factory\ParamFactory;
2526
use phpDocumentor\Reflection\DocBlock\Tags\Factory\PropertyFactory;
2627
use phpDocumentor\Reflection\DocBlock\Tags\Factory\PropertyReadFactory;
@@ -77,6 +78,7 @@ public static function createInstance(array $additionalTags = []): DocBlockFacto
7778
new PropertyFactory($typeResolver, $descriptionFactory),
7879
new PropertyReadFactory($typeResolver, $descriptionFactory),
7980
new PropertyWriteFactory($typeResolver, $descriptionFactory),
81+
new MethodFactory($typeResolver, $descriptionFactory)
8082
);
8183

8284
$tagFactory->addService($descriptionFactory);

tests/integration/InterpretingDocBlocksTest.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,14 @@
1717
use phpDocumentor\Reflection\DocBlock\Description;
1818
use phpDocumentor\Reflection\DocBlock\StandardTagFactory;
1919
use phpDocumentor\Reflection\DocBlock\Tag;
20+
use phpDocumentor\Reflection\DocBlock\Tags\Method;
21+
use phpDocumentor\Reflection\DocBlock\Tags\MethodParameter;
2022
use phpDocumentor\Reflection\DocBlock\Tags\Param;
2123
use phpDocumentor\Reflection\DocBlock\Tags\See;
2224
use phpDocumentor\Reflection\Types\Array_;
2325
use phpDocumentor\Reflection\Types\Integer;
2426
use phpDocumentor\Reflection\Types\String_;
27+
use phpDocumentor\Reflection\Types\Void_;
2528
use PHPUnit\Framework\TestCase;
2629

2730
/**
@@ -185,4 +188,35 @@ public function testMultilineTags(): void
185188
);
186189

187190
}
191+
192+
public function testMethodRegression(): void
193+
{
194+
$docCommment = <<<DOC
195+
/**
196+
* This is an example of a summary.
197+
*
198+
* @method void setInteger(integer \$integer)
199+
*/
200+
DOC;
201+
$factory = DocBlockFactory::createInstance();
202+
$docblock = $factory->create($docCommment);
203+
204+
self::assertEquals(
205+
[
206+
new Method(
207+
'setInteger',
208+
[],
209+
new Void_(),
210+
false,
211+
new Description(''),
212+
false,
213+
[
214+
new MethodParameter('integer', new Integer())
215+
]
216+
),
217+
],
218+
$docblock->getTags()
219+
);
220+
221+
}
188222
}

tests/unit/DocBlock/Tags/Factory/MethodFactoryTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,18 @@ public function tagProvider(): array
9595
[new MethodParameter('a', new Mixed_())]
9696
),
9797
],
98+
[
99+
'@method void setInteger(integer $integer)',
100+
new Method(
101+
'setInteger',
102+
[],
103+
new Void_(),
104+
false,
105+
new Description(''),
106+
false,
107+
[new MethodParameter('integer', new Integer())]
108+
),
109+
],
98110
[
99111
'@method myMethod($a = 1)',
100112
new Method(

0 commit comments

Comments
 (0)