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 | * @access protected |
||
106 | */ |
||
107 | protected function matchArguments( |
||
123 | |||
124 | /** |
||
125 | * Is $parameter same type as the $argument ? |
||
126 | * |
||
127 | * @param \ReflectionParameter $parameter |
||
128 | * @param array $arguments |
||
129 | * @param null|string $class |
||
130 | * @return bool |
||
131 | * @access protected |
||
132 | */ |
||
133 | protected function isTypeMatched( |
||
146 | |||
147 | /** |
||
148 | * Is $param required and is a class/interface |
||
149 | * |
||
150 | * @param \ReflectionParameter $param |
||
151 | * @param array $arguments |
||
152 | * @return bool |
||
153 | * @throws LogicException if mismatched arguments |
||
154 | * @access protected |
||
155 | */ |
||
156 | protected function isRequiredClass( |
||
176 | |||
177 | /** |
||
178 | * Get an object base on provided classname or interface name |
||
179 | * |
||
180 | * @param string $classname class or interface name |
||
181 | * @return object |
||
182 | * @throws \Exception if something goes wrong |
||
183 | * @access protected |
||
184 | */ |
||
185 | protected function getObjectByClass(/*# string */ $classname) |
||
196 | |||
197 | /** |
||
198 | * Get callable parameters |
||
199 | * |
||
200 | * @param callable $callable |
||
201 | * @return \ReflectionParameter[] |
||
202 | * @throws LogicException if something goes wrong |
||
203 | * @access protected |
||
204 | */ |
||
205 | protected function getCallableParameters(callable $callable)/*# : array */ |
||
224 | |||
225 | /** |
||
226 | * Is $var an object with '__invoke()' defined ? |
||
227 | * |
||
228 | * @param mixed $var |
||
229 | * @return bool |
||
230 | * @access protected |
||
231 | */ |
||
232 | protected function isInvocable($var)/*# : bool */ |
||
236 | |||
237 | /** |
||
238 | * Merge different sections of a node |
||
239 | * |
||
240 | * convert |
||
241 | * `['section1' => [[1], [2]], 'section2' => [[3], [4]]]` |
||
242 | * |
||
243 | * to |
||
244 | * `[[1], [2], [3], [4]]` |
||
245 | * |
||
246 | * @param array $nodeData |
||
247 | * @return array |
||
248 | * @access protected |
||
249 | */ |
||
250 | protected function mergeMethods(array $nodeData)/*# : array */ |
||
264 | |||
265 | /** |
||
266 | * Execute common methods defined in 'di.common' for all objects |
||
267 | * |
||
268 | * @param object $object |
||
269 | * @return $this |
||
270 | * @access protected |
||
271 | */ |
||
272 | protected function executeCommonBatch($object) |
||
290 | } |
||
291 |