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 | * @param string $startingWith |
||
128 | * |
||
129 | * @return array |
||
130 | */ |
||
131 | public function all(string $startingWith = '') : array |
||
145 | |||
146 | /** |
||
147 | * Forget a value from the store. |
||
148 | * |
||
149 | * @param string $key |
||
150 | * |
||
151 | * @return $this |
||
152 | */ |
||
153 | public function forget(string $key) |
||
163 | |||
164 | /** |
||
165 | * Flush all values from the store. |
||
166 | * |
||
167 | * @param string $startingWith |
||
168 | * |
||
169 | * @return $this |
||
170 | */ |
||
171 | public function flush(string $startingWith = '') |
||
181 | |||
182 | /** |
||
183 | * Get and forget a value from the store. |
||
184 | * |
||
185 | * @param string $name |
||
186 | * |
||
187 | * @return null|string |
||
188 | */ |
||
189 | public function pull(string $name) |
||
197 | |||
198 | /** |
||
199 | * Increment a value from the store. |
||
200 | * |
||
201 | * @param string $name |
||
202 | * @param int $by |
||
203 | * |
||
204 | * @return int|null|string |
||
205 | */ |
||
206 | public function increment(string $name, int $by = 1) |
||
216 | |||
217 | /** |
||
218 | * Decrement a value from the store. |
||
219 | * |
||
220 | * @param string $name |
||
221 | * @param int $by |
||
222 | * |
||
223 | * @return int|null|string |
||
224 | */ |
||
225 | public function decrement(string $name, int $by = 1) |
||
229 | |||
230 | /** |
||
231 | * Whether a offset exists. |
||
232 | * |
||
233 | * @link http://php.net/manual/en/arrayaccess.offsetexists.php |
||
234 | * |
||
235 | * @param mixed $offset |
||
236 | * |
||
237 | * @return bool |
||
238 | */ |
||
239 | public function offsetExists($offset) |
||
243 | |||
244 | /** |
||
245 | * Offset to retrieve. |
||
246 | * |
||
247 | * @link http://php.net/manual/en/arrayaccess.offsetget.php |
||
248 | * |
||
249 | * @param mixed $offset |
||
250 | * |
||
251 | * @return mixed |
||
252 | */ |
||
253 | public function offsetGet($offset) |
||
257 | |||
258 | /** |
||
259 | * Offset to set. |
||
260 | * |
||
261 | * @link http://php.net/manual/en/arrayaccess.offsetset.php |
||
262 | * |
||
263 | * @param mixed $offset |
||
264 | * @param mixed $value |
||
265 | */ |
||
266 | public function offsetSet($offset, $value) |
||
270 | |||
271 | /** |
||
272 | * Offset to unset. |
||
273 | * |
||
274 | * @link http://php.net/manual/en/arrayaccess.offsetunset.php |
||
275 | * |
||
276 | * @param mixed $offset |
||
277 | */ |
||
278 | public function offsetUnset($offset) |
||
282 | |||
283 | protected function filterKeysStartingWith(array $values, string $startsWith) : array |
||
291 | |||
292 | protected function filterKeysNotStartingWith(array $values, string $startsWith) : array |
||
300 | |||
301 | protected function startsWith(string $haystack, string $needle) : bool |
||
305 | |||
306 | /** |
||
307 | * @param array $values |
||
308 | * |
||
309 | * @return $this |
||
310 | */ |
||
311 | protected function setContent(array $values) |
||
321 | |||
322 | /** |
||
323 | * Count elements of an object |
||
324 | * @link http://php.net/manual/en/countable.count.php |
||
325 | * @return int The custom count as an integer. |
||
326 | * </p> |
||
327 | * <p> |
||
328 | * The return value is cast to an integer. |
||
329 | * @since 5.1.0 |
||
330 | */ |
||
331 | public function count() |
||
335 | } |
||
336 |
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: