1 | <?php |
||
9 | class Config |
||
10 | { |
||
11 | use PathHelpers; |
||
12 | |||
13 | /** |
||
14 | * Instance of self. |
||
15 | * |
||
16 | * @var Config |
||
17 | */ |
||
18 | private static $instance; |
||
19 | |||
20 | /** |
||
21 | * Phalcon config instance. |
||
22 | * |
||
23 | * @var PhalconConfig |
||
24 | */ |
||
25 | protected $config; |
||
26 | |||
27 | /** |
||
28 | * The original config array. |
||
29 | * |
||
30 | * @var array |
||
31 | */ |
||
32 | protected $original; |
||
33 | |||
34 | /** |
||
35 | * Default setting values. |
||
36 | * |
||
37 | * @var array |
||
38 | */ |
||
39 | const DEFAULTS = [ |
||
40 | 'migratorType' => 'fileDate', |
||
41 | 'migrationRepository' => 'database', |
||
42 | ]; |
||
43 | |||
44 | /** |
||
45 | * Private constructor. |
||
46 | * |
||
47 | * @param array $configArray |
||
|
|||
48 | */ |
||
49 | private function __construct() |
||
52 | |||
53 | /** |
||
54 | * Get config values by key from PhalconConfig. |
||
55 | * |
||
56 | * @param string $key |
||
57 | * |
||
58 | * @return mixed |
||
59 | */ |
||
60 | public function __get($key) |
||
68 | |||
69 | /** |
||
70 | * Get instance of self with config array set. |
||
71 | * |
||
72 | * @param array $configArray |
||
73 | * |
||
74 | * @return Config |
||
75 | */ |
||
76 | public static function getInstance() |
||
84 | |||
85 | /** |
||
86 | * Set config using config data in di or passed data. |
||
87 | * |
||
88 | * @param array|string $userConfig If string, config path. If array, data. |
||
89 | * @param bool $merge If true, merge given config array into current. |
||
90 | */ |
||
91 | public function setConfig($userConfig = null, $merge = true) |
||
111 | |||
112 | /** |
||
113 | * Get a value by key from config. |
||
114 | * |
||
115 | * @param string|array $key |
||
116 | * |
||
117 | * @return mixed |
||
118 | */ |
||
119 | public function get($key) |
||
123 | |||
124 | /** |
||
125 | * Get nested values. |
||
126 | * |
||
127 | * @param array $keyArray |
||
128 | * |
||
129 | * @return mixed |
||
130 | */ |
||
131 | public function getNested(array $keyArray) |
||
145 | |||
146 | /** |
||
147 | * Return true if config array has given value. |
||
148 | * |
||
149 | * @param mixed $value |
||
150 | * |
||
151 | * @return bool |
||
152 | */ |
||
153 | public function has($value) |
||
169 | |||
170 | /** |
||
171 | * Get a setting's default value. |
||
172 | * |
||
173 | * @param string $key |
||
174 | * |
||
175 | * @return mixed|null |
||
176 | */ |
||
177 | public function getDefault($key) |
||
183 | |||
184 | /** |
||
185 | * Set an item in the config. |
||
186 | * |
||
187 | * @param mixed $keys |
||
188 | * @param mixed $value |
||
189 | */ |
||
190 | public function set($keys, $value) |
||
208 | |||
209 | /** |
||
210 | * Remove an item from the config. |
||
211 | * |
||
212 | * @param mixed $keys |
||
213 | */ |
||
214 | public function remove($keys) |
||
230 | |||
231 | /** |
||
232 | * Set the config array to its original values. |
||
233 | */ |
||
234 | public function refresh() |
||
238 | |||
239 | /** |
||
240 | * Return the config array. |
||
241 | * |
||
242 | * @return array |
||
243 | */ |
||
244 | public function toArray() |
||
252 | |||
253 | /** |
||
254 | * Make a variable an array if not one already. |
||
255 | * |
||
256 | * @param mixed $value |
||
257 | * |
||
258 | * @return array |
||
259 | */ |
||
260 | protected function makeArray($value) |
||
268 | |||
269 | /** |
||
270 | * Validate that a setting exists. |
||
271 | * |
||
272 | * @param array $settings |
||
273 | * |
||
274 | * @throws InvalidConfig |
||
275 | */ |
||
276 | public function validate(array $settings) |
||
282 | |||
283 | /** |
||
284 | * Merge the given config with the current one. |
||
285 | * |
||
286 | * @param PhalconConfig $config |
||
287 | */ |
||
288 | public function merge(PhalconConfig $config) |
||
292 | |||
293 | /** |
||
294 | * Return the config key count. |
||
295 | * |
||
296 | * @return int |
||
297 | */ |
||
298 | public function count() |
||
302 | } |
||
303 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.