1 | <?php |
||
31 | trait FactoryTrait |
||
32 | { |
||
33 | /** |
||
34 | * @var Container |
||
35 | * @access protected |
||
36 | */ |
||
37 | protected $master; |
||
38 | |||
39 | /** |
||
40 | * Get service definition (and fix it) |
||
41 | * |
||
42 | * @param string $rawId |
||
43 | * @param array $args |
||
44 | * @return array |
||
45 | * @access protected |
||
46 | */ |
||
47 | protected function getDefinition( |
||
67 | |||
68 | /** |
||
69 | * Instantiate service object from classname |
||
70 | * |
||
71 | * @param string $class |
||
72 | * @param array $args |
||
73 | * @return object |
||
74 | * @throws LogicException if something goes wrong |
||
75 | * @access protected |
||
76 | */ |
||
77 | protected function constructObject(/*# string */ $class, array $args) |
||
97 | |||
98 | /** |
||
99 | * Match provided arguments with a method/function's reflection parameters |
||
100 | * |
||
101 | * @param \ReflectionParameter[] $reflectionParameters |
||
102 | * @param array $providedArguments |
||
103 | * @return array the resolved arguments |
||
104 | * @throws LogicException |
||
105 | * @throws NotFoundException |
||
106 | * @access protected |
||
107 | */ |
||
108 | protected function matchArguments( |
||
149 | |||
150 | /** |
||
151 | * Is $parameter same type as the $argument ? |
||
152 | * |
||
153 | * @param \ReflectionParameter $parameter |
||
154 | * @param mixed $argument |
||
155 | * @param null|string $class |
||
156 | * @return bool |
||
157 | * @access protected |
||
158 | */ |
||
159 | protected function isTypeMatched( |
||
172 | |||
173 | /** |
||
174 | * Get an object base on provided classname or interface name |
||
175 | * |
||
176 | * @param string $classname class or interface name |
||
177 | * @return object |
||
178 | * @throws \Exception if something goes wrong |
||
179 | * @access protected |
||
180 | */ |
||
181 | protected function getObjectByClass(/*# string */ $classname) |
||
192 | |||
193 | /** |
||
194 | * Get callable parameters |
||
195 | * |
||
196 | * @param callable $callable |
||
197 | * @return \ReflectionParameter[] |
||
198 | * @throws LogicException if something goes wrong |
||
199 | * @access protected |
||
200 | */ |
||
201 | protected function getCallableParameters(callable $callable)/*# : array */ |
||
220 | |||
221 | /** |
||
222 | * Is $var an object with '__invoke()' defined ? |
||
223 | * |
||
224 | * @param mixed $var |
||
225 | * @return bool |
||
226 | * @access protected |
||
227 | */ |
||
228 | protected function isInvocable($var)/*# : bool */ |
||
232 | |||
233 | /** |
||
234 | * Merge different sections of a node |
||
235 | * |
||
236 | * convert |
||
237 | * `['section1' => [[1], [2]], 'section2' => [[3], [4]]]` |
||
238 | * |
||
239 | * to |
||
240 | * `[[1], [2], [3], [4]]` |
||
241 | * |
||
242 | * @param array $nodeData |
||
243 | * @return array |
||
244 | * @access protected |
||
245 | */ |
||
246 | protected function mergeMethods(array $nodeData)/*# : array */ |
||
260 | |||
261 | /** |
||
262 | * Execute common methods defined in 'di.common' for all objects |
||
263 | * |
||
264 | * @param object $object |
||
265 | * @return $this |
||
266 | * @access protected |
||
267 | */ |
||
268 | protected function executeCommonBatch($object) |
||
286 | } |
||
287 |