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 | * Try best to guess parameter and argument are the same type |
||
126 | * |
||
127 | * @param null|\ReflectionClass $class |
||
128 | * @param array $arguments |
||
129 | * @return bool |
||
130 | * @access protected |
||
131 | */ |
||
132 | protected function isTypeMatched($class, array $arguments)/*# : bool */ |
||
142 | |||
143 | /** |
||
144 | * Is $param required and is a class/interface |
||
145 | * |
||
146 | * @param \ReflectionParameter $param |
||
147 | * @param array $arguments |
||
148 | * @return bool |
||
149 | * @throws LogicException if mismatched arguments |
||
150 | * @access protected |
||
151 | */ |
||
152 | protected function isRequiredClass( |
||
163 | |||
164 | /** |
||
165 | * Get an object base on provided classname or interface name |
||
166 | * |
||
167 | * @param string $classname class or interface name |
||
168 | * @return object |
||
169 | * @throws \Exception if something goes wrong |
||
170 | * @access protected |
||
171 | */ |
||
172 | protected function getObjectByClass(/*# string */ $classname) |
||
183 | |||
184 | /** |
||
185 | * Get callable parameters |
||
186 | * |
||
187 | * @param callable $callable |
||
188 | * @return \ReflectionParameter[] |
||
189 | * @throws LogicException if something goes wrong |
||
190 | * @access protected |
||
191 | */ |
||
192 | protected function getCallableParameters(callable $callable)/*# : array */ |
||
211 | |||
212 | /** |
||
213 | * Is $var an object with '__invoke()' defined ? |
||
214 | * |
||
215 | * @param mixed $var |
||
216 | * @return bool |
||
217 | * @access protected |
||
218 | */ |
||
219 | protected function isInvocable($var)/*# : bool */ |
||
223 | |||
224 | /** |
||
225 | * Merge different sections of a node |
||
226 | * |
||
227 | * convert |
||
228 | * `['section1' => [[1], [2]], 'section2' => [[3], [4]]]` |
||
229 | * |
||
230 | * to |
||
231 | * `[[1], [2], [3], [4]]` |
||
232 | * |
||
233 | * @param array $nodeData |
||
234 | * @return array |
||
235 | * @access protected |
||
236 | */ |
||
237 | protected function mergeMethods(array $nodeData)/*# : array */ |
||
251 | |||
252 | /** |
||
253 | * Execute common methods defined in 'di.common' for all objects |
||
254 | * |
||
255 | * @param object $object |
||
256 | * @return $this |
||
257 | * @access protected |
||
258 | */ |
||
259 | protected function executeCommonBatch($object) |
||
277 | } |
||
278 |