1 | <?php |
||
25 | trait ConfigTrait |
||
26 | { |
||
27 | |||
28 | /** |
||
29 | * Reference to the Config object. |
||
30 | * |
||
31 | * @since 0.1.2 |
||
32 | * |
||
33 | * @var ConfigInterface |
||
34 | */ |
||
35 | protected $config; |
||
36 | |||
37 | /** |
||
38 | * Process the passed-in configuration file. |
||
39 | * |
||
40 | * @since 0.1.2 |
||
41 | * |
||
42 | * @param ConfigInterface $config The Config to process. |
||
43 | * @param string ... List of keys. |
||
44 | * |
||
45 | * @throws FailedToProcessConfigException If the arguments could not be parsed into a Config. |
||
46 | */ |
||
47 | 4 | protected function processConfig(ConfigInterface $config) |
|
65 | |||
66 | /** |
||
67 | * Check whether the Config has a specific key. |
||
68 | * |
||
69 | * To get a value several levels deep, add the keys for each level as a comma-separated list. |
||
70 | * |
||
71 | * @since 0.1.2 |
||
72 | * @since 0.1.5 Accepts list of keys. |
||
73 | * |
||
74 | * @param string|array $_ List of keys. |
||
75 | * |
||
76 | * @return bool Whether the key is known. |
||
77 | */ |
||
78 | 2 | protected function hasConfigKey($_) |
|
84 | |||
85 | /** |
||
86 | * Get the Config value for a specific key. |
||
87 | * |
||
88 | * To get a value several levels deep, add the keys for each level as a comma-separated list. |
||
89 | * |
||
90 | * @since 0.1.2 |
||
91 | * @since 0.1.5 Accepts list of keys. |
||
92 | * |
||
93 | * @param string|array $_ List of keys. |
||
94 | * |
||
95 | * @return mixed Value of the key. |
||
96 | */ |
||
97 | 2 | protected function getConfigKey($_) |
|
103 | |||
104 | /** |
||
105 | * Get the callable Config value for a specific key. |
||
106 | * |
||
107 | * If the fetched value is indeed a callable, it will be executed with the provided arguments, and the resultant |
||
108 | * value will be returned instead. |
||
109 | * |
||
110 | * @since 0.4.8 |
||
111 | * |
||
112 | * @param string|array $key Key or array of nested keys. |
||
113 | * @param array $args Optional. Array of arguments to pass to the callable. |
||
114 | * |
||
115 | * @return mixed Resultant value of the key's callable. |
||
116 | */ |
||
117 | 1 | protected function getConfigCallable($key, array $args = []) |
|
127 | |||
128 | /** |
||
129 | * Get a (multi-dimensional) array of all the configuration settings. |
||
130 | * |
||
131 | * @since 0.1.4 |
||
132 | * |
||
133 | * @return array All the configuration settings. |
||
134 | */ |
||
135 | 1 | protected function getConfigArray() |
|
139 | |||
140 | /** |
||
141 | * Get an array of all the keys that are known by the Config. |
||
142 | * |
||
143 | * @since 0.1.2 |
||
144 | * |
||
145 | * @return array Array of strings containing all the keys. |
||
146 | */ |
||
147 | 1 | protected function getConfigKeys() |
|
151 | |||
152 | /** |
||
153 | * Get a default configuration in case none was injected into the constructor. |
||
154 | * |
||
155 | * The name and path of the configuration needs to be set as a const called DEFAULT_CONFIG within the class |
||
156 | * containing the trait. The path needs to be relative to the location of the containing class file. |
||
157 | * |
||
158 | * @since 0.4.2 |
||
159 | * |
||
160 | * @return ConfigInterface Configuration settings to use. |
||
161 | */ |
||
162 | 1 | protected function fetchDefaultConfig() |
|
170 | |||
171 | /** |
||
172 | * Get a configuration from a specified $file. |
||
173 | * |
||
174 | * If file is not accessible or readable, returns an empty Config. |
||
175 | * |
||
176 | * @since 0.4.2 |
||
177 | * |
||
178 | * @return ConfigInterface Configuration settings to use. |
||
179 | */ |
||
180 | 2 | protected function fetchConfig($configFile) |
|
188 | } |
||
189 |
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: