16
16
use InvalidArgumentException ;
17
17
use phpDocumentor \Reflection \DocBlock ;
18
18
use phpDocumentor \Reflection \DocBlockFactoryInterface ;
19
+ use phpDocumentor \Reflection \Php \Factory \Reducer \Reducer ;
19
20
use phpDocumentor \Reflection \Php \ProjectFactoryStrategy ;
20
21
use phpDocumentor \Reflection \Php \StrategyContainer ;
21
22
use phpDocumentor \Reflection \Types \Context ;
@@ -31,9 +32,14 @@ abstract class AbstractFactory implements ProjectFactoryStrategy
31
32
{
32
33
private DocBlockFactoryInterface $ docBlockFactory ;
33
34
34
- public function __construct (DocBlockFactoryInterface $ docBlockFactory )
35
+ /** @var iterable<Reducer> */
36
+ private iterable $ reducers ;
37
+
38
+ /** @param iterable<Reducer> $recuders */
39
+ public function __construct (DocBlockFactoryInterface $ docBlockFactory , iterable $ recuders = [])
35
40
{
36
41
$ this ->docBlockFactory = $ docBlockFactory ;
42
+ $ this ->reducers = $ recuders ;
37
43
}
38
44
39
45
/**
@@ -55,7 +61,10 @@ public function create(ContextStack $context, object $object, StrategyContainer
55
61
);
56
62
}
57
63
58
- $ this ->doCreate ($ context , $ object , $ strategies );
64
+ $ element = $ this ->doCreate ($ context , $ object , $ strategies );
65
+ foreach ($ this ->reducers as $ reducer ) {
66
+ $ element = $ reducer ->reduce ($ context , $ object , $ strategies , $ element );
67
+ }
59
68
}
60
69
61
70
/**
@@ -66,7 +75,7 @@ public function create(ContextStack $context, object $object, StrategyContainer
66
75
*
67
76
* @param NodeAbstract|object $object object to convert to an Element
68
77
*/
69
- abstract protected function doCreate (ContextStack $ context , object $ object , StrategyContainer $ strategies ): void ;
78
+ abstract protected function doCreate (ContextStack $ context , object $ object , StrategyContainer $ strategies ): ? object ;
70
79
71
80
protected function createDocBlock (?Doc $ docBlock = null , ?Context $ context = null ): ?DocBlock
72
81
{
0 commit comments