1 | <?php |
||
91 | class Config |
||
92 | { |
||
93 | const ENV_ALL = 'all'; |
||
94 | |||
95 | const ENV_PROD = 'prod'; |
||
96 | |||
97 | const ENV_PREP = 'prep'; |
||
98 | |||
99 | const ENV_DEV = 'dev'; |
||
100 | |||
101 | const ENV_LOCAL = 'local'; |
||
102 | |||
103 | const RUNTIME_ALL = 0; |
||
104 | |||
105 | const RUNTIME_CONSOLE = 1; |
||
106 | |||
107 | const RUNTIME_WEB = 2; |
||
108 | |||
109 | /** |
||
110 | * Constructor |
||
111 | * |
||
112 | * @param string $id |
||
113 | * @param string $basePath |
||
114 | * @param array $applicationConfig |
||
115 | */ |
||
116 | public function __construct($id, $basePath, array $applicationConfig = []) |
||
122 | |||
123 | private $_env; |
||
124 | |||
125 | /** |
||
126 | * Assign the env to each component, module or application that defined inside the callback. |
||
127 | * |
||
128 | * Callback function has one parameter with the current {{luya\Config}} object. |
||
129 | * |
||
130 | * @param string $env The environment to assigne inside the callback. |
||
131 | * @param callable $callback function(\luya\Config $config) |
||
132 | * @return $this |
||
133 | */ |
||
134 | public function env($env, callable $callback) |
||
146 | |||
147 | /** |
||
148 | * register application level config |
||
149 | * |
||
150 | * @param array $config The array to configure |
||
151 | * @return ConfigDefinition |
||
152 | */ |
||
153 | public function application(array $config) |
||
157 | |||
158 | /** |
||
159 | * Register one or more bootstrap entries into the bootstrap section. |
||
160 | * |
||
161 | * @param array $config An array with bootstrap entries, its common to use the module name |
||
162 | * @return ConfigDefinition |
||
163 | */ |
||
164 | public function bootstrap(array $config) |
||
168 | |||
169 | /** |
||
170 | * Register a module. |
||
171 | * |
||
172 | * @param string $id The module identifier. |
||
173 | * @param string|array $config The configuration for the given module. If a string is given this will be taken as `class` property. |
||
174 | * @return ConfigDefinition |
||
175 | */ |
||
176 | public function module($id, $config) |
||
180 | |||
181 | /** |
||
182 | * Run a callable functions for the defined env when toArray() is called. |
||
183 | * |
||
184 | * @param callable $fn The function to run, the first argument of the closure is the {{luya\Config}} object. |
||
185 | * @return ConfigDefinition |
||
186 | * @since 1.0.23 |
||
187 | */ |
||
188 | public function callback(callable $fn) |
||
192 | |||
193 | /** |
||
194 | * Register a component |
||
195 | * |
||
196 | * @param string $id The id of the component |
||
197 | * @param string|array $config The configuration for the given module. If a string is given this will be taken as `class` property. |
||
198 | * @param string $runtime The runtime for the component: all, web or console |
||
199 | * @return ConfigDefinition |
||
200 | */ |
||
201 | public function component($id, $config, $runtime = self::RUNTIME_ALL) |
||
205 | |||
206 | /** |
||
207 | * Register a web runtime component. |
||
208 | * |
||
209 | * @param string $id The id of the component |
||
210 | * @param string|array $config The configuration for the given module. If a string is given this will be taken as `class` property. |
||
211 | * @return ConfigDefinition |
||
212 | */ |
||
213 | public function webComponent($id, $config) |
||
217 | |||
218 | /** |
||
219 | * Register a console runtime component. |
||
220 | * |
||
221 | * @param string $id The id of the component |
||
222 | * @param string|array $config The configuration for the given module. If a string is given this will be taken as `class` property. |
||
223 | * @return ConfigDefinition |
||
224 | */ |
||
225 | public function consoleComponent($id, $config) |
||
229 | |||
230 | private $_definitions = []; |
||
231 | |||
232 | /** |
||
233 | * Add a definition into the definitions bag. |
||
234 | * |
||
235 | * @param ConfigDefinition $definition |
||
236 | * @return ConfigDefinition |
||
237 | */ |
||
238 | private function addDefinition(ConfigDefinition $definition) |
||
248 | |||
249 | private $_isCliRuntime; |
||
250 | |||
251 | /** |
||
252 | * Whether runtime is cli or not |
||
253 | * |
||
254 | * @return boolean |
||
255 | */ |
||
256 | public function isCliRuntime() |
||
264 | |||
265 | /** |
||
266 | * Setter method for runtime. |
||
267 | * |
||
268 | * > This method is mainly used for unit testing. |
||
269 | * |
||
270 | * @param boolean $value |
||
271 | */ |
||
272 | public function setCliRuntime($value) |
||
276 | |||
277 | /** |
||
278 | * Export the given configuration as array for certain envs. |
||
279 | * |
||
280 | * @param array $envs A list of environments to export. if nothing is given all enviroments will be returned. |
||
281 | * @return array The configuration array |
||
282 | */ |
||
283 | public function toArray(array $envs = []) |
||
304 | |||
305 | /** |
||
306 | * Append a given definition int othe config |
||
307 | * |
||
308 | * @param array $config |
||
309 | * @param ConfigDefinition $definition |
||
310 | */ |
||
311 | private function appendConfig(&$config, ConfigDefinition $definition) |
||
341 | |||
342 | /** |
||
343 | * Add a array key based component definition. |
||
344 | * |
||
345 | * @param array $config |
||
346 | * @param ConfigDefinition $definition |
||
347 | * @param string $section |
||
348 | */ |
||
349 | private function handleKeyBaseMerge(&$config, ConfigDefinition $definition, $section) |
||
363 | } |
||
364 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: