1 | <?php |
||
30 | trait FactoryTrait |
||
31 | { |
||
32 | /** |
||
33 | * @var Container |
||
34 | * @access protected |
||
35 | */ |
||
36 | protected $master; |
||
37 | |||
38 | /** |
||
39 | * Get service definition (and fix it) |
||
40 | * |
||
41 | * @param string $rawId |
||
42 | * @param array $args |
||
43 | * @return array |
||
44 | * @access protected |
||
45 | */ |
||
46 | protected function getDefinition( |
||
66 | |||
67 | /** |
||
68 | * Instantiate service object from classname |
||
69 | * |
||
70 | * @param string $class |
||
71 | * @param array $args |
||
72 | * @return object |
||
73 | * @throws LogicException if something goes wrong |
||
74 | * @access protected |
||
75 | */ |
||
76 | protected function constructObject(/*# string */ $class, array $args) |
||
96 | |||
97 | /** |
||
98 | * Match provided arguments with a method/function's reflection parameters |
||
99 | * |
||
100 | * @param \ReflectionParameter[] $reflectionParameters |
||
101 | * @param array $providedArguments |
||
102 | * @return array the resolved arguments |
||
103 | * @throws LogicException |
||
104 | * @access protected |
||
105 | */ |
||
106 | protected function matchArguments( |
||
129 | |||
130 | /** |
||
131 | * Try best to guess parameter and argument are the same type |
||
132 | * |
||
133 | * @param null|\ReflectionClass $class |
||
134 | * @param array $arguments |
||
135 | * @return bool |
||
136 | * @access protected |
||
137 | */ |
||
138 | protected function isTypeMatched($class, array $arguments)/*# : bool */ |
||
148 | |||
149 | /** |
||
150 | * Is $param required and is a class/interface |
||
151 | * |
||
152 | * @param \ReflectionParameter $param |
||
153 | * @param array $arguments |
||
154 | * @return bool |
||
155 | * @throws LogicException if mismatched arguments |
||
156 | * @access protected |
||
157 | */ |
||
158 | protected function isRequiredClass( |
||
169 | |||
170 | /** |
||
171 | * Get an object base on provided classname or interface name |
||
172 | * |
||
173 | * @param string $classname class or interface name |
||
174 | * @return object |
||
175 | * @throws \Exception if something goes wrong |
||
176 | * @access protected |
||
177 | */ |
||
178 | protected function getObjectByClass(/*# string */ $classname) |
||
189 | |||
190 | /** |
||
191 | * Get callable parameters |
||
192 | * |
||
193 | * @param callable $callable |
||
194 | * @return \ReflectionParameter[] |
||
195 | * @throws LogicException if something goes wrong |
||
196 | * @access protected |
||
197 | */ |
||
198 | protected function getCallableParameters(callable $callable)/*# : array */ |
||
217 | |||
218 | /** |
||
219 | * Is $var an object with '__invoke()' defined ? |
||
220 | * |
||
221 | * @param mixed $var |
||
222 | * @return bool |
||
223 | * @access protected |
||
224 | */ |
||
225 | protected function isInvocable($var)/*# : bool */ |
||
229 | |||
230 | /** |
||
231 | * Merge different sections of a node |
||
232 | * |
||
233 | * convert |
||
234 | * `['section1' => [[1], [2]], 'section2' => [[3], [4]]]` |
||
235 | * |
||
236 | * to |
||
237 | * `[[1], [2], [3], [4]]` |
||
238 | * |
||
239 | * @param array $nodeData |
||
240 | * @return array |
||
241 | * @access protected |
||
242 | */ |
||
243 | protected function mergeMethods(array $nodeData)/*# : array */ |
||
257 | |||
258 | /** |
||
259 | * Execute common methods defined in 'di.common' for all objects |
||
260 | * |
||
261 | * @param object $object |
||
262 | * @return $this |
||
263 | * @access protected |
||
264 | */ |
||
265 | protected function executeCommonBatch($object) |
||
283 | } |
||
284 |