1 | <?php |
||
21 | trait FactoryTrait |
||
22 | { |
||
23 | /** |
||
24 | * fabricate the object using the definition |
||
25 | * |
||
26 | * @param object|array $definition |
||
27 | * @throws LogicException if something goes wrong |
||
28 | * @return object |
||
29 | */ |
||
30 | protected function fabricate($definition): object |
||
47 | |||
48 | /** |
||
49 | * fix object definition |
||
50 | * |
||
51 | * @param string|array $definition |
||
52 | * @return array |
||
53 | */ |
||
54 | protected function fixDefinition($definition): array |
||
66 | |||
67 | /** |
||
68 | * Instantiate service object |
||
69 | * |
||
70 | * @param string $class class name |
||
71 | * @param array $arguments constructor arguments |
||
72 | * @throws LogicException if something goes wrong |
||
73 | * @return object |
||
74 | */ |
||
75 | protected function constructObject(string $class, array $arguments): object |
||
90 | |||
91 | /** |
||
92 | * execute callable |
||
93 | * |
||
94 | * @param callable|object $callable callable |
||
95 | * @param array $arguments constructor arguments |
||
96 | * @throws LogicException if something goes wrong |
||
97 | * @return mixed |
||
98 | */ |
||
99 | protected function executeCallable($callable, array $arguments) |
||
109 | |||
110 | /** |
||
111 | * processing service aftermath |
||
112 | * |
||
113 | * @param object $object |
||
114 | * @param array $definition |
||
115 | * @return void |
||
116 | */ |
||
117 | protected function afterConstruct(object $object, array $definition): void |
||
126 | |||
127 | /** |
||
128 | * fix the 'after' part of definition |
||
129 | * |
||
130 | * @param object $object |
||
131 | * @param array $line |
||
132 | * @throws LogicException if goes wrong |
||
133 | * @return array [Callable, arguments] |
||
134 | */ |
||
135 | protected function fixMethod(object $object, array $line): array |
||
147 | } |
||
148 |
This check looks at variables that have been passed in as parameters and are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.