1 | <?php |
||
7 | class Valuestore implements ArrayAccess |
||
8 | { |
||
9 | /** @var string */ |
||
10 | protected $fileName; |
||
11 | |||
12 | /** |
||
13 | * @param string $fileName |
||
14 | * |
||
15 | * @return $this |
||
16 | */ |
||
17 | public static function make(string $fileName) |
||
21 | |||
22 | protected function __construct() |
||
25 | |||
26 | /** |
||
27 | * Set the filename where all values will be stored. |
||
28 | * |
||
29 | * @param string $fileName |
||
30 | * |
||
31 | * @return $this |
||
32 | */ |
||
33 | protected function setFileName(string $fileName) |
||
39 | |||
40 | /** |
||
41 | * Put a value in the store. |
||
42 | * |
||
43 | * @param string|array $name |
||
44 | * @param string|int|null $value |
||
45 | * |
||
46 | * @return $this |
||
47 | */ |
||
48 | public function put($name, $value = null) |
||
62 | |||
63 | /** |
||
64 | * Push a new value into an array. |
||
65 | * |
||
66 | * @param string $name |
||
67 | * @param $pushValue |
||
68 | * |
||
69 | * @return $this |
||
70 | */ |
||
71 | public function push(string $name, $pushValue) |
||
97 | |||
98 | /** |
||
99 | * Get a value from the store. |
||
100 | * |
||
101 | * @param string $name |
||
102 | * @param $default |
||
103 | * |
||
104 | * @return null|string |
||
105 | */ |
||
106 | public function get(string $name, $default = null) |
||
114 | |||
115 | /* |
||
116 | * Determine if the store has a value for the given name. |
||
117 | */ |
||
118 | public function has(string $name) : bool |
||
122 | |||
123 | /** |
||
124 | * Get all values from the store. |
||
125 | * |
||
126 | * @param string $startingWith |
||
127 | * |
||
128 | * @return array |
||
129 | */ |
||
130 | public function all(string $startingWith = '') : array |
||
144 | |||
145 | /** |
||
146 | * Forget a value from the store. |
||
147 | * |
||
148 | * @param string $key |
||
149 | * |
||
150 | * @return $this |
||
151 | */ |
||
152 | public function forget(string $key) |
||
162 | |||
163 | /** |
||
164 | * Flush all values from the store. |
||
165 | * |
||
166 | * @param string $startingWith |
||
167 | * |
||
168 | * @return $this |
||
169 | */ |
||
170 | public function flush(string $startingWith = '') |
||
180 | |||
181 | /** |
||
182 | * Get and forget a value from the store. |
||
183 | * |
||
184 | * @param string $name |
||
185 | * |
||
186 | * @return null|string |
||
187 | */ |
||
188 | public function pull(string $name) |
||
196 | |||
197 | /** |
||
198 | * Increment a value from the store. |
||
199 | * |
||
200 | * @param string $name |
||
201 | * @param int $by |
||
202 | * |
||
203 | * @return int|null|string |
||
204 | */ |
||
205 | public function increment(string $name, int $by = 1) |
||
215 | |||
216 | /** |
||
217 | * Decrement a value from the store. |
||
218 | * |
||
219 | * @param string $name |
||
220 | * @param int $by |
||
221 | * |
||
222 | * @return int|null|string |
||
223 | */ |
||
224 | public function decrement(string $name, int $by = 1) |
||
228 | |||
229 | protected function filterKeysStartingWith(array $values, string $startsWith) : array |
||
237 | |||
238 | protected function filterKeysNotStartingWith(array $values, string $startsWith) : array |
||
246 | |||
247 | protected function startsWith(string $haystack, string $needle) : bool |
||
251 | |||
252 | /** |
||
253 | * @param array $values |
||
254 | * |
||
255 | * @return $this |
||
256 | */ |
||
257 | protected function setContent(array $values) |
||
263 | |||
264 | /** |
||
265 | * Whether a offset exists. |
||
266 | * |
||
267 | * @link http://php.net/manual/en/arrayaccess.offsetexists.php |
||
268 | * |
||
269 | * @param mixed $offset <p> |
||
270 | * An offset to check for. |
||
271 | * </p> |
||
272 | * |
||
273 | * @return bool true on success or false on failure. |
||
274 | * </p> |
||
275 | * <p> |
||
276 | * The return value will be casted to boolean if non-boolean was returned. |
||
277 | * |
||
278 | * @since 5.0.0 |
||
279 | */ |
||
280 | public function offsetExists($offset) |
||
284 | |||
285 | /** |
||
286 | * Offset to retrieve. |
||
287 | * |
||
288 | * @link http://php.net/manual/en/arrayaccess.offsetget.php |
||
289 | * |
||
290 | * @param mixed $offset <p> |
||
291 | * The offset to retrieve. |
||
292 | * </p> |
||
293 | * |
||
294 | * @return mixed Can return all value types. |
||
295 | * |
||
296 | * @since 5.0.0 |
||
297 | */ |
||
298 | public function offsetGet($offset) |
||
302 | |||
303 | /** |
||
304 | * Offset to set. |
||
305 | * |
||
306 | * @link http://php.net/manual/en/arrayaccess.offsetset.php |
||
307 | * |
||
308 | * @param mixed $offset <p> |
||
309 | * The offset to assign the value to. |
||
310 | * </p> |
||
311 | * @param mixed $value <p> |
||
312 | * The value to set. |
||
313 | * </p> |
||
314 | * |
||
315 | * @since 5.0.0 |
||
316 | */ |
||
317 | public function offsetSet($offset, $value) |
||
321 | |||
322 | /** |
||
323 | * Offset to unset. |
||
324 | * |
||
325 | * @link http://php.net/manual/en/arrayaccess.offsetunset.php |
||
326 | * |
||
327 | * @param mixed $offset <p> |
||
328 | * The offset to unset. |
||
329 | * </p> |
||
330 | * |
||
331 | * @since 5.0.0 |
||
332 | */ |
||
333 | public function offsetUnset($offset) |
||
337 | } |
||
338 |
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: