@@ -149,13 +149,13 @@ interface CacheInterface
149
149
* @throws \Psr\SimpleCache\InvalidArgumentException
150
150
* MUST be thrown if the $key string is not a legal value.
151
151
*/
152
- public function get($key, $default = null);
152
+ public function get(string $key, mixed $default = null): mixed ;
153
153
154
154
/**
155
155
* Persists data in the cache, uniquely referenced by a key with an optional expiration TTL time.
156
156
*
157
157
* @param string $key The key of the item to store.
158
- * @param mixed $value The value of the item to store. Must be serializable.
158
+ * @param mixed $value The value of the item to store, must be serializable.
159
159
* @param null|int|\DateInterval $ttl Optional. The TTL value of this item. If no value is sent and
160
160
* the driver supports TTL then the library may set a default value
161
161
* for it or let the driver take care of that.
@@ -165,7 +165,7 @@ interface CacheInterface
165
165
* @throws \Psr\SimpleCache\InvalidArgumentException
166
166
* MUST be thrown if the $key string is not a legal value.
167
167
*/
168
- public function set($key, $value, $ttl = null);
168
+ public function set(string $key, mixed $value, null|int|\DateInterval $ttl = null): bool ;
169
169
170
170
/**
171
171
* Delete an item from the cache by its unique key.
@@ -177,28 +177,28 @@ interface CacheInterface
177
177
* @throws \Psr\SimpleCache\InvalidArgumentException
178
178
* MUST be thrown if the $key string is not a legal value.
179
179
*/
180
- public function delete($key);
180
+ public function delete(string $key): bool ;
181
181
182
182
/**
183
183
* Wipes clean the entire cache's keys.
184
184
*
185
185
* @return bool True on success and false on failure.
186
186
*/
187
- public function clear();
187
+ public function clear(): bool ;
188
188
189
189
/**
190
190
* Obtains multiple cache items by their unique keys.
191
191
*
192
- * @param iterable $keys A list of keys that can obtained in a single operation.
193
- * @param mixed $default Default value to return for keys that do not exist.
192
+ * @param iterable< string > $keys A list of keys that can be obtained in a single operation.
193
+ * @param mixed $default Default value to return for keys that do not exist.
194
194
*
195
- * @return iterable A list of key => value pairs. Cache keys that do not exist or are stale will have $default as value.
195
+ * @return iterable< string , mixed > A list of key => value pairs. Cache keys that do not exist or are stale will have $default as value.
196
196
*
197
197
* @throws \Psr\SimpleCache\InvalidArgumentException
198
198
* MUST be thrown if $keys is neither an array nor a Traversable,
199
199
* or if any of the $keys are not a legal value.
200
200
*/
201
- public function getMultiple($keys, $default = null);
201
+ public function getMultiple(iterable $keys, mixed $default = null): iterable ;
202
202
203
203
/**
204
204
* Persists a set of key => value pairs in the cache, with an optional TTL.
@@ -214,28 +214,28 @@ interface CacheInterface
214
214
* MUST be thrown if $values is neither an array nor a Traversable,
215
215
* or if any of the $values are not a legal value.
216
216
*/
217
- public function setMultiple($values, $ttl = null);
217
+ public function setMultiple(iterable $values, null|int|\DateInterval $ttl = null): bool ;
218
218
219
219
/**
220
220
* Deletes multiple cache items in a single operation.
221
221
*
222
- * @param iterable $keys A list of string-based keys to be deleted.
222
+ * @param iterable< string > $keys A list of string-based keys to be deleted.
223
223
*
224
224
* @return bool True if the items were successfully removed. False if there was an error.
225
225
*
226
226
* @throws \Psr\SimpleCache\InvalidArgumentException
227
227
* MUST be thrown if $keys is neither an array nor a Traversable,
228
228
* or if any of the $keys are not a legal value.
229
229
*/
230
- public function deleteMultiple($keys);
230
+ public function deleteMultiple(iterable $keys): bool ;
231
231
232
232
/**
233
233
* Determines whether an item is present in the cache.
234
234
*
235
235
* NOTE: It is recommended that has() is only to be used for cache warming type purposes
236
236
* and not to be used within your live applications operations for get/set, as this method
237
237
* is subject to a race condition where your has() will return true and immediately after,
238
- * another script can remove it, making the state of your app out of date.
238
+ * another script can remove it making the state of your app out of date.
239
239
*
240
240
* @param string $key The cache item key.
241
241
*
@@ -244,7 +244,7 @@ interface CacheInterface
244
244
* @throws \Psr\SimpleCache\InvalidArgumentException
245
245
* MUST be thrown if the $key string is not a legal value.
246
246
*/
247
- public function has($key);
247
+ public function has(string $key): bool ;
248
248
}
249
249
~~~
250
250
0 commit comments