1 | <?php |
||
8 | class Valuestore implements ArrayAccess, Countable |
||
9 | { |
||
10 | /** @var string */ |
||
11 | protected $fileName; |
||
12 | |||
13 | /** |
||
14 | * @param string $fileName |
||
15 | * |
||
16 | * @return $this |
||
17 | */ |
||
18 | public static function make(string $fileName) |
||
22 | |||
23 | protected function __construct() |
||
26 | |||
27 | /** |
||
28 | * Set the filename where all values will be stored. |
||
29 | * |
||
30 | * @param string $fileName |
||
31 | * |
||
32 | * @return $this |
||
33 | */ |
||
34 | protected function setFileName(string $fileName) |
||
40 | |||
41 | /** |
||
42 | * Put a value in the store. |
||
43 | * |
||
44 | * @param string|array $name |
||
45 | * @param string|int|null $value |
||
46 | * |
||
47 | * @return $this |
||
48 | */ |
||
49 | public function put($name, $value = null) |
||
63 | |||
64 | /** |
||
65 | * Push a new value into an array. |
||
66 | * |
||
67 | * @param string $name |
||
68 | * @param $pushValue |
||
69 | * |
||
70 | * @return $this |
||
71 | */ |
||
72 | public function push(string $name, $pushValue) |
||
98 | |||
99 | /** |
||
100 | * Get a value from the store. |
||
101 | * |
||
102 | * @param string $name |
||
103 | * @param $default |
||
104 | * |
||
105 | * @return null|string |
||
106 | */ |
||
107 | public function get(string $name, $default = null) |
||
115 | |||
116 | /* |
||
117 | * Determine if the store has a value for the given name. |
||
118 | */ |
||
119 | public function has(string $name) : bool |
||
123 | |||
124 | /** |
||
125 | * Get all values from the store. |
||
126 | * |
||
127 | * @return array |
||
128 | */ |
||
129 | public function all() : array |
||
137 | |||
138 | /** |
||
139 | * Get all keys starting with a given string from the store. |
||
140 | * |
||
141 | * @param string $startingWith |
||
142 | * |
||
143 | * @return array |
||
144 | */ |
||
145 | public function allStartingWith(string $startingWith = '') : array |
||
155 | |||
156 | /** |
||
157 | * Forget a value from the store. |
||
158 | * |
||
159 | * @param string $key |
||
160 | * |
||
161 | * @return $this |
||
162 | */ |
||
163 | public function forget(string $key) |
||
173 | |||
174 | /** |
||
175 | * Flush all values from the store. |
||
176 | * |
||
177 | * @return $this |
||
178 | */ |
||
179 | public function flush() |
||
183 | |||
184 | /** |
||
185 | * Flush all values which keys start with a given string. |
||
186 | * |
||
187 | * @param string $startingWith |
||
188 | * |
||
189 | * @return $this |
||
190 | */ |
||
191 | public function flushStartingWith(string $startingWith = '') |
||
201 | |||
202 | /** |
||
203 | * Get and forget a value from the store. |
||
204 | * |
||
205 | * @param string $name |
||
206 | * |
||
207 | * @return null|string |
||
208 | */ |
||
209 | public function pull(string $name) |
||
217 | |||
218 | /** |
||
219 | * Increment a value from the store. |
||
220 | * |
||
221 | * @param string $name |
||
222 | * @param int $by |
||
223 | * |
||
224 | * @return int|null|string |
||
225 | */ |
||
226 | public function increment(string $name, int $by = 1) |
||
236 | |||
237 | /** |
||
238 | * Decrement a value from the store. |
||
239 | * |
||
240 | * @param string $name |
||
241 | * @param int $by |
||
242 | * |
||
243 | * @return int|null|string |
||
244 | */ |
||
245 | public function decrement(string $name, int $by = 1) |
||
249 | |||
250 | /** |
||
251 | * Whether a offset exists. |
||
252 | * |
||
253 | * @link http://php.net/manual/en/arrayaccess.offsetexists.php |
||
254 | * |
||
255 | * @param mixed $offset |
||
256 | * |
||
257 | * @return bool |
||
258 | */ |
||
259 | public function offsetExists($offset) |
||
263 | |||
264 | /** |
||
265 | * Offset to retrieve. |
||
266 | * |
||
267 | * @link http://php.net/manual/en/arrayaccess.offsetget.php |
||
268 | * |
||
269 | * @param mixed $offset |
||
270 | * |
||
271 | * @return mixed |
||
272 | */ |
||
273 | public function offsetGet($offset) |
||
277 | |||
278 | /** |
||
279 | * Offset to set. |
||
280 | * |
||
281 | * @link http://php.net/manual/en/arrayaccess.offsetset.php |
||
282 | * |
||
283 | * @param mixed $offset |
||
284 | * @param mixed $value |
||
285 | */ |
||
286 | public function offsetSet($offset, $value) |
||
290 | |||
291 | /** |
||
292 | * Offset to unset. |
||
293 | * |
||
294 | * @link http://php.net/manual/en/arrayaccess.offsetunset.php |
||
295 | * |
||
296 | * @param mixed $offset |
||
297 | */ |
||
298 | public function offsetUnset($offset) |
||
302 | |||
303 | protected function filterKeysStartingWith(array $values, string $startsWith) : array |
||
311 | |||
312 | protected function filterKeysNotStartingWith(array $values, string $startsWith) : array |
||
320 | |||
321 | protected function startsWith(string $haystack, string $needle) : bool |
||
325 | |||
326 | /** |
||
327 | * @param array $values |
||
328 | * |
||
329 | * @return $this |
||
330 | */ |
||
331 | protected function setContent(array $values) |
||
341 | |||
342 | /** |
||
343 | * Count elements of an object. |
||
344 | * |
||
345 | * @link http://php.net/manual/en/countable.count.php |
||
346 | * |
||
347 | * @return int The custom count as an integer. |
||
348 | * </p> |
||
349 | * <p> |
||
350 | * The return value is cast to an integer. |
||
351 | * |
||
352 | * @since 5.1.0 |
||
353 | */ |
||
354 | public function count() |
||
358 | } |
||
359 |
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: