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( |
||
118 | |||
119 | /** |
||
120 | * Try best to guess parameter and argument are the same type |
||
121 | * |
||
122 | * @param null|\ReflectionClass $class |
||
123 | * @param array $arguments |
||
124 | * @return bool |
||
125 | * @access protected |
||
126 | */ |
||
127 | protected function isTypeMatched($class, array $arguments)/*# : bool */ |
||
137 | |||
138 | /** |
||
139 | * Is $param required and is a class/interface |
||
140 | * |
||
141 | * @param \ReflectionParameter $param |
||
142 | * @param array $arguments |
||
143 | * @return bool |
||
144 | * @throws LogicException if mismatched arguments |
||
145 | * @access protected |
||
146 | */ |
||
147 | protected function isRequiredClass( |
||
158 | |||
159 | /** |
||
160 | * Get callable parameters |
||
161 | * |
||
162 | * @param callable $callable |
||
163 | * @return \ReflectionParameter[] |
||
164 | * @throws LogicException if something goes wrong |
||
165 | * @access protected |
||
166 | */ |
||
167 | protected function getCallableParameters(callable $callable)/*# : array */ |
||
186 | |||
187 | /** |
||
188 | * Is $var a non-closure object with '__invoke()' defined ? |
||
189 | * |
||
190 | * @param mixed $var |
||
191 | * @return bool |
||
192 | * @access protected |
||
193 | */ |
||
194 | protected function isInvocable($var)/*# : bool */ |
||
200 | |||
201 | /** |
||
202 | * Get an object base on provided classname or interface name |
||
203 | * |
||
204 | * @param string $classname class or interface name |
||
205 | * @return object |
||
206 | * @throws \Exception if something goes wrong |
||
207 | * @access protected |
||
208 | */ |
||
209 | protected function getObjectByClass(/*# string */ $classname) |
||
220 | |||
221 | /** |
||
222 | * Returns [$object, $method] if it is a callable, otherwise returns $method |
||
223 | * |
||
224 | * @param mixed $object |
||
225 | * @param mixed $method |
||
226 | * @return bool |
||
227 | * @access protected |
||
228 | */ |
||
229 | protected function getObjectMethod($object, $method)/*# : bool */ |
||
242 | |||
243 | /** |
||
244 | * Merge different sections of a node |
||
245 | * |
||
246 | * convert |
||
247 | * `['section1' => [[1], [2]], 'section2' => [[3], [4]]]` |
||
248 | * |
||
249 | * to |
||
250 | * `[[1], [2], [3], [4]]` |
||
251 | * |
||
252 | * @param array|null $nodeData |
||
253 | * @return array |
||
254 | * @access protected |
||
255 | */ |
||
256 | protected function mergeMethods($nodeData)/*# : array */ |
||
270 | |||
271 | /** |
||
272 | * Get common methods |
||
273 | * |
||
274 | * @return array |
||
275 | * @access protected |
||
276 | */ |
||
277 | protected function getCommonMethods()/*# : array */ |
||
286 | } |
||
287 |