|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* This file is part of phpDocumentor. |
|
4
|
|
|
* |
|
5
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
6
|
|
|
* file that was distributed with this source code. |
|
7
|
|
|
* |
|
8
|
|
|
* @copyright 2010-${YEAR} Mike van Riel<[email protected]> |
|
9
|
|
|
* @license http://www.opensource.org/licenses/mit-license.php MIT |
|
10
|
|
|
* @link http://phpdoc.org |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
namespace phpDocumentor\Application\Builder; |
|
14
|
|
|
|
|
15
|
|
|
use phpDocumentor\Descriptor\Builder\AssemblerFactory; |
|
16
|
|
|
use phpDocumentor\Descriptor\Builder\Reflector\ArgumentAssembler; |
|
17
|
|
|
use phpDocumentor\Descriptor\Builder\Reflector\ClassAssembler; |
|
18
|
|
|
use phpDocumentor\Descriptor\Builder\Reflector\ConstantAssembler; |
|
19
|
|
|
use phpDocumentor\Descriptor\Builder\Reflector\FileAssembler; |
|
20
|
|
|
use phpDocumentor\Descriptor\Builder\Reflector\FunctionAssembler; |
|
21
|
|
|
use phpDocumentor\Descriptor\Builder\Reflector\InterfaceAssembler; |
|
22
|
|
|
use phpDocumentor\Descriptor\Builder\Reflector\MethodAssembler; |
|
23
|
|
|
use phpDocumentor\Descriptor\Builder\Reflector\NamespaceAssembler; |
|
24
|
|
|
use phpDocumentor\Descriptor\Builder\Reflector\PropertyAssembler; |
|
25
|
|
|
use phpDocumentor\Descriptor\Builder\Reflector\Tags\AuthorAssembler; |
|
26
|
|
|
use phpDocumentor\Descriptor\Builder\Reflector\Tags\DeprecatedAssembler; |
|
27
|
|
|
use phpDocumentor\Descriptor\Builder\Reflector\Tags\ExampleAssembler; |
|
28
|
|
|
use phpDocumentor\Descriptor\Builder\Reflector\Tags\GenericTagAssembler; |
|
29
|
|
|
use phpDocumentor\Descriptor\Builder\Reflector\Tags\LinkAssembler; |
|
30
|
|
|
use phpDocumentor\Descriptor\Builder\Reflector\Tags\MethodAssembler as MethodTagAssembler; |
|
31
|
|
|
use phpDocumentor\Descriptor\Builder\Reflector\Tags\ParamAssembler; |
|
32
|
|
|
use phpDocumentor\Descriptor\Builder\Reflector\Tags\PropertyAssembler as PropertyTagAssembler; |
|
33
|
|
|
use phpDocumentor\Descriptor\Builder\Reflector\Tags\ReturnAssembler; |
|
34
|
|
|
use phpDocumentor\Descriptor\Builder\Reflector\Tags\SeeAssembler; |
|
35
|
|
|
use phpDocumentor\Descriptor\Builder\Reflector\Tags\SinceAssembler; |
|
36
|
|
|
use phpDocumentor\Descriptor\Builder\Reflector\Tags\ThrowsAssembler; |
|
37
|
|
|
use phpDocumentor\Descriptor\Builder\Reflector\Tags\UsesAssembler; |
|
38
|
|
|
use phpDocumentor\Descriptor\Builder\Reflector\Tags\VarAssembler; |
|
39
|
|
|
use phpDocumentor\Descriptor\Builder\Reflector\Tags\VersionAssembler; |
|
40
|
|
|
use phpDocumentor\Descriptor\Builder\Reflector\TraitAssembler; |
|
41
|
|
|
use phpDocumentor\Reflection\DocBlock\ExampleFinder; |
|
42
|
|
|
use phpDocumentor\Reflection\DocBlock\Tag; |
|
43
|
|
|
use phpDocumentor\Reflection\DocBlock\Tags; |
|
44
|
|
|
use phpDocumentor\Reflection\DocBlock\Tags\Author; |
|
45
|
|
|
use phpDocumentor\Reflection\DocBlock\Tags\Deprecated; |
|
46
|
|
|
use phpDocumentor\Reflection\DocBlock\Tags\Example; |
|
47
|
|
|
use phpDocumentor\Reflection\DocBlock\Tags\Link; |
|
48
|
|
|
use phpDocumentor\Reflection\DocBlock\Tags\Param; |
|
49
|
|
|
use phpDocumentor\Reflection\DocBlock\Tags\Return_; |
|
50
|
|
|
use phpDocumentor\Reflection\DocBlock\Tags\See; |
|
51
|
|
|
use phpDocumentor\Reflection\DocBlock\Tags\Since; |
|
52
|
|
|
use phpDocumentor\Reflection\DocBlock\Tags\Throws; |
|
53
|
|
|
use phpDocumentor\Reflection\DocBlock\Tags\Uses; |
|
54
|
|
|
use phpDocumentor\Reflection\DocBlock\Tags\Var_; |
|
55
|
|
|
use phpDocumentor\Reflection\DocBlock\Tags\Version; |
|
56
|
|
|
use phpDocumentor\Reflection\Php\Argument; |
|
57
|
|
|
use phpDocumentor\Reflection\Php\Class_; |
|
58
|
|
|
use phpDocumentor\Reflection\Php\Constant; |
|
59
|
|
|
use phpDocumentor\Reflection\Php\File; |
|
60
|
|
|
use phpDocumentor\Reflection\Php\Function_; |
|
61
|
|
|
use phpDocumentor\Reflection\Php\Interface_; |
|
62
|
|
|
use phpDocumentor\Reflection\Php\Method; |
|
63
|
|
|
use phpDocumentor\Reflection\Php\Namespace_; |
|
64
|
|
|
use phpDocumentor\Reflection\Php\Property; |
|
65
|
|
|
use phpDocumentor\Reflection\Php\Trait_; |
|
66
|
|
|
|
|
67
|
|
|
final class AssemblerFactoryFactory |
|
68
|
|
|
{ |
|
69
|
|
|
public static function create(ExampleFinder $exampleFinder) |
|
70
|
|
|
{ |
|
71
|
|
|
$factory = new AssemblerFactory(); |
|
72
|
|
|
// @codingStandardsIgnoreStart because we limit the verbosity by making all closures single-line |
|
73
|
|
|
$fileMatcher = function ($criteria) { |
|
74
|
|
|
return $criteria instanceof File; |
|
75
|
|
|
}; |
|
76
|
|
|
$constantMatcher = function ($criteria) { |
|
77
|
|
|
return $criteria instanceof Constant; // || $criteria instanceof ClassConstant; |
|
78
|
|
|
}; |
|
79
|
|
|
$traitMatcher = function ($criteria) { |
|
80
|
|
|
return $criteria instanceof Trait_; |
|
81
|
|
|
}; |
|
82
|
|
|
$classMatcher = function ($criteria) { |
|
83
|
|
|
return $criteria instanceof Class_; |
|
84
|
|
|
}; |
|
85
|
|
|
$interfaceMatcher = function ($criteria) { |
|
86
|
|
|
return $criteria instanceof Interface_; |
|
87
|
|
|
}; |
|
88
|
|
|
$propertyMatcher = function ($criteria) { |
|
89
|
|
|
return $criteria instanceof Property; |
|
90
|
|
|
}; |
|
91
|
|
|
$methodMatcher = function ($criteria) { |
|
92
|
|
|
return $criteria instanceof Method; |
|
93
|
|
|
}; |
|
94
|
|
|
$argumentMatcher = function ($criteria) { |
|
95
|
|
|
return $criteria instanceof Argument; |
|
96
|
|
|
}; |
|
97
|
|
|
$functionMatcher = function ($criteria) { |
|
98
|
|
|
return $criteria instanceof Function_; |
|
99
|
|
|
}; |
|
100
|
|
|
$namespaceMatcher = function ($criteria) { |
|
101
|
|
|
return $criteria instanceof Namespace_; |
|
102
|
|
|
}; |
|
103
|
|
|
|
|
104
|
|
|
$authorMatcher = function ($criteria) { |
|
105
|
|
|
return $criteria instanceof Author; |
|
106
|
|
|
}; |
|
107
|
|
|
$deprecatedMatcher = function ($criteria) { |
|
108
|
|
|
return $criteria instanceof Deprecated; |
|
109
|
|
|
}; |
|
110
|
|
|
$exampleMatcher = function ($criteria) { |
|
111
|
|
|
return $criteria instanceof Example; |
|
112
|
|
|
}; |
|
113
|
|
|
$linkMatcher = function ($criteria) { |
|
114
|
|
|
return $criteria instanceof Link; |
|
115
|
|
|
}; |
|
116
|
|
|
$methodTagMatcher = function ($criteria) { |
|
117
|
|
|
return $criteria instanceof Tags\Method; |
|
118
|
|
|
}; |
|
119
|
|
|
$propertyTagMatcher = function ($criteria) { |
|
120
|
|
|
return $criteria instanceof Tags\Property; |
|
121
|
|
|
}; |
|
122
|
|
|
$paramMatcher = function ($criteria) { |
|
123
|
|
|
return $criteria instanceof Param; |
|
124
|
|
|
}; |
|
125
|
|
|
$throwsMatcher = function ($criteria) { |
|
126
|
|
|
return $criteria instanceof Throws; |
|
127
|
|
|
}; |
|
128
|
|
|
$returnMatcher = function ($criteria) { |
|
129
|
|
|
return $criteria instanceof Return_; |
|
130
|
|
|
}; |
|
131
|
|
|
$usesMatcher = function ($criteria) { |
|
132
|
|
|
return $criteria instanceof Uses; |
|
133
|
|
|
}; |
|
134
|
|
|
$seeMatcher = function ($criteria) { |
|
135
|
|
|
return $criteria instanceof See; |
|
136
|
|
|
}; |
|
137
|
|
|
$sinceMatcher = function ($criteria) { |
|
138
|
|
|
return $criteria instanceof Since; |
|
139
|
|
|
}; |
|
140
|
|
|
$varMatcher = function ($criteria) { |
|
141
|
|
|
return $criteria instanceof Var_; |
|
142
|
|
|
}; |
|
143
|
|
|
$versionMatcher = function ($criteria) { |
|
144
|
|
|
return $criteria instanceof Version; |
|
145
|
|
|
}; |
|
146
|
|
|
|
|
147
|
|
|
$tagFallbackMatcher = function ($criteria) { |
|
148
|
|
|
return $criteria instanceof Tag; |
|
149
|
|
|
}; |
|
150
|
|
|
// @codingStandardsIgnoreEnd |
|
151
|
|
|
|
|
152
|
|
|
$argumentAssembler = new ArgumentAssembler(); |
|
153
|
|
|
$factory->register($fileMatcher, new FileAssembler()); |
|
154
|
|
|
$factory->register($constantMatcher, new ConstantAssembler()); |
|
155
|
|
|
$factory->register($traitMatcher, new TraitAssembler()); |
|
156
|
|
|
$factory->register($classMatcher, new ClassAssembler()); |
|
157
|
|
|
$factory->register($interfaceMatcher, new InterfaceAssembler()); |
|
158
|
|
|
$factory->register($propertyMatcher, new PropertyAssembler()); |
|
159
|
|
|
$factory->register($argumentMatcher, $argumentAssembler); |
|
160
|
|
|
$factory->register($methodMatcher, new MethodAssembler($argumentAssembler)); |
|
161
|
|
|
$factory->register($functionMatcher, new FunctionAssembler($argumentAssembler)); |
|
162
|
|
|
$factory->register($namespaceMatcher, new NamespaceAssembler()); |
|
163
|
|
|
|
|
164
|
|
|
$factory->register($authorMatcher, new AuthorAssembler()); |
|
165
|
|
|
$factory->register($deprecatedMatcher, new DeprecatedAssembler()); |
|
166
|
|
|
$factory->register($exampleMatcher, new ExampleAssembler($exampleFinder)); |
|
167
|
|
|
$factory->register($linkMatcher, new LinkAssembler()); |
|
168
|
|
|
$factory->register($methodTagMatcher, new MethodTagAssembler()); |
|
169
|
|
|
$factory->register($propertyTagMatcher, new PropertyTagAssembler()); |
|
170
|
|
|
$factory->register($varMatcher, new VarAssembler()); |
|
171
|
|
|
$factory->register($paramMatcher, new ParamAssembler()); |
|
172
|
|
|
$factory->register($throwsMatcher, new ThrowsAssembler()); |
|
173
|
|
|
$factory->register($returnMatcher, new ReturnAssembler()); |
|
174
|
|
|
$factory->register($usesMatcher, new UsesAssembler()); |
|
175
|
|
|
$factory->register($seeMatcher, new SeeAssembler()); |
|
176
|
|
|
$factory->register($sinceMatcher, new SinceAssembler()); |
|
177
|
|
|
$factory->register($versionMatcher, new VersionAssembler()); |
|
178
|
|
|
|
|
179
|
|
|
$factory->registerFallback($tagFallbackMatcher, new GenericTagAssembler()); |
|
180
|
|
|
|
|
181
|
|
|
return $factory; |
|
182
|
|
|
} |
|
183
|
|
|
} |
|
184
|
|
|
|