1 | <?php |
||
32 | trait FactoryHelperTrait |
||
33 | { |
||
34 | use ResolverAwareTrait; |
||
35 | |||
36 | /** |
||
37 | * Get service definition |
||
38 | * |
||
39 | * @param string $rawId |
||
40 | * @param array $args |
||
41 | * @return array |
||
42 | * @access protected |
||
43 | */ |
||
44 | protected function getDefinition( |
||
63 | |||
64 | /** |
||
65 | * Instantiate service object from classname |
||
66 | * |
||
67 | * @param string $class |
||
68 | * @param array $args |
||
69 | * @return object |
||
70 | * @throws LogicException if something goes wrong |
||
71 | * @access protected |
||
72 | */ |
||
73 | protected function constructObject(/*# string */ $class, array $args) |
||
90 | |||
91 | /** |
||
92 | * Match provided arguments with a method/function's reflection parameters |
||
93 | * |
||
94 | * @param \ReflectionParameter[] $reflectionParameters |
||
95 | * @param array $providedArguments |
||
96 | * @return array the resolved arguments |
||
97 | * @throws LogicException |
||
98 | * @access protected |
||
99 | */ |
||
100 | protected function matchArguments( |
||
117 | |||
118 | /** |
||
119 | * Try best to guess parameter and argument are the same type |
||
120 | * |
||
121 | * @param null|\ReflectionClass $class |
||
122 | * @param array $arguments |
||
123 | * @return bool |
||
124 | * @access protected |
||
125 | */ |
||
126 | protected function isTypeMatched($class, array $arguments)/*# : bool */ |
||
136 | |||
137 | /** |
||
138 | * Is $param required and is a class/interface |
||
139 | * |
||
140 | * @param \ReflectionParameter $param |
||
141 | * @param array $arguments |
||
142 | * @return bool |
||
143 | * @throws LogicException if mismatched arguments |
||
144 | * @access protected |
||
145 | */ |
||
146 | protected function isRequiredClass( |
||
157 | |||
158 | /** |
||
159 | * Get callable parameters |
||
160 | * |
||
161 | * @param callable $callable |
||
162 | * @return \ReflectionParameter[] |
||
163 | * @throws LogicException if something goes wrong |
||
164 | * @access protected |
||
165 | */ |
||
166 | protected function getCallableParameters(callable $callable)/*# : array */ |
||
185 | |||
186 | /** |
||
187 | * Is $var a non-closure object with '__invoke()' defined ? |
||
188 | * |
||
189 | * @param mixed $var |
||
190 | * @return bool |
||
191 | * @access protected |
||
192 | */ |
||
193 | protected function isInvocable($var)/*# : bool */ |
||
199 | |||
200 | /** |
||
201 | * Get an object base on provided classname or interface name |
||
202 | * |
||
203 | * @param string $classname class or interface name |
||
204 | * @return object |
||
205 | * @throws \Exception if something goes wrong |
||
206 | * @access protected |
||
207 | */ |
||
208 | protected function getObjectByClass(/*# string */ $classname) |
||
219 | |||
220 | /** |
||
221 | * Returns [$object, $method] if it is a callable, otherwise returns $method |
||
222 | * |
||
223 | * @param mixed $object |
||
224 | * @param mixed $method |
||
225 | * @return bool |
||
226 | * @access protected |
||
227 | */ |
||
228 | protected function getObjectMethod($object, $method)/*# : bool */ |
||
241 | |||
242 | /** |
||
243 | * Merge different sections of a node |
||
244 | * |
||
245 | * convert |
||
246 | * `['section1' => [[1], [2]], 'section2' => [[3], [4]]]` |
||
247 | * |
||
248 | * to |
||
249 | * `[[1], [2], [3], [4]]` |
||
250 | * |
||
251 | * @param array|null $nodeData |
||
252 | * @return array |
||
253 | * @access protected |
||
254 | */ |
||
255 | protected function mergeMethods($nodeData)/*# : array */ |
||
269 | |||
270 | /** |
||
271 | * Get common methods |
||
272 | * |
||
273 | * @return array |
||
274 | * @access protected |
||
275 | */ |
||
276 | protected function getCommonMethods()/*# : array */ |
||
285 | } |
||
286 |