1 | <?php |
||
32 | trait FactoryTrait |
||
33 | { |
||
34 | /** |
||
35 | * @var Container |
||
36 | * @access protected |
||
37 | */ |
||
38 | protected $master; |
||
39 | |||
40 | /** |
||
41 | * Get service definition (and fix it) |
||
42 | * |
||
43 | * @param string $rawId |
||
44 | * @param array $args |
||
45 | * @return array |
||
46 | * @access protected |
||
47 | */ |
||
48 | protected function getDefinition( |
||
68 | |||
69 | /** |
||
70 | * Instantiate service object from classname |
||
71 | * |
||
72 | * @param string $class |
||
73 | * @param array $args |
||
74 | * @return object |
||
75 | * @throws LogicException if something goes wrong |
||
76 | * @access protected |
||
77 | */ |
||
78 | protected function constructObject(/*# string */ $class, array $args) |
||
98 | |||
99 | /** |
||
100 | * Match provided arguments with a method/function's reflection parameters |
||
101 | * |
||
102 | * @param \ReflectionParameter[] $reflectionParameters |
||
103 | * @param array $providedArguments |
||
104 | * @return array the resolved arguments |
||
105 | * @throws LogicException |
||
106 | * @access protected |
||
107 | */ |
||
108 | protected function matchArguments( |
||
126 | |||
127 | /** |
||
128 | * Try best to guess parameter and argument are the same type |
||
129 | * |
||
130 | * @param null|\ReflectionClass $class |
||
131 | * @param array $arguments |
||
132 | * @return bool |
||
133 | * @access protected |
||
134 | */ |
||
135 | protected function isTypeMatched($class, array $arguments)/*# : bool */ |
||
145 | |||
146 | /** |
||
147 | * Is $param required and is a class/interface |
||
148 | * |
||
149 | * @param \ReflectionParameter $param |
||
150 | * @param array $arguments |
||
151 | * @return bool |
||
152 | * @throws LogicException if mismatched arguments |
||
153 | * @access protected |
||
154 | */ |
||
155 | protected function isRequiredClass( |
||
166 | |||
167 | /** |
||
168 | * Get an object base on provided classname or interface name |
||
169 | * |
||
170 | * @param string $classname class or interface name |
||
171 | * @return object |
||
172 | * @throws \Exception if something goes wrong |
||
173 | * @access protected |
||
174 | */ |
||
175 | protected function getObjectByClass(/*# string */ $classname) |
||
194 | |||
195 | /** |
||
196 | * Get callable parameters |
||
197 | * |
||
198 | * @param callable $callable |
||
199 | * @return \ReflectionParameter[] |
||
200 | * @throws LogicException if something goes wrong |
||
201 | * @access protected |
||
202 | */ |
||
203 | protected function getCallableParameters(callable $callable)/*# : array */ |
||
222 | |||
223 | /** |
||
224 | * Is $var a non-closure object with '__invoke()' defined ? |
||
225 | * |
||
226 | * @param mixed $var |
||
227 | * @return bool |
||
228 | * @access protected |
||
229 | */ |
||
230 | protected function isInvocable($var)/*# : bool */ |
||
236 | |||
237 | /** |
||
238 | * Get object by different mapped |
||
239 | * |
||
240 | * @param mixed $mapped |
||
241 | * @param string $classname |
||
242 | * @return object |
||
243 | * @access protected |
||
244 | */ |
||
245 | protected function getObjectByType($mapped, /*# string */ $classname) |
||
265 | |||
266 | /** |
||
267 | * Merge different sections of a node |
||
268 | * |
||
269 | * convert |
||
270 | * `['section1' => [[1], [2]], 'section2' => [[3], [4]]]` |
||
271 | * |
||
272 | * to |
||
273 | * `[[1], [2], [3], [4]]` |
||
274 | * |
||
275 | * @param array $nodeData |
||
276 | * @return array |
||
277 | * @access protected |
||
278 | */ |
||
279 | protected function mergeMethods(array $nodeData)/*# : array */ |
||
293 | } |
||
294 |