Skip to content

Commit 0f32180

Browse files
committed
Add parameter types
This is a breaking change since consumers may be providing entities that can be converted to a string. Implementations that implement v2, however, are also implementing v1 as of PHP 7.2, so such implementations can use a require statement of `^1|^2`. Usage libraries also can use a require statement of `^1|^2` so long as they are passing the specific variable type
1 parent 8ffc7a5 commit 0f32180

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
}
1111
],
1212
"require": {
13-
"php": ">=5.3.0"
13+
"php": ">=8.0.0"
1414
},
1515
"autoload": {
1616
"psr-4": {
@@ -19,7 +19,7 @@
1919
},
2020
"extra": {
2121
"branch-alias": {
22-
"dev-master": "1.0.x-dev"
22+
"dev-master": "2.0.x-dev"
2323
}
2424
}
2525
}

src/CacheInterface.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ interface CacheInterface
1515
* @throws \Psr\SimpleCache\InvalidArgumentException
1616
* MUST be thrown if the $key string is not a legal value.
1717
*/
18-
public function get($key, $default = null);
18+
public function get(string $key, mixed $default = null);
1919

2020
/**
2121
* Persists data in the cache, uniquely referenced by a key with an optional expiration TTL time.
@@ -31,7 +31,7 @@ public function get($key, $default = null);
3131
* @throws \Psr\SimpleCache\InvalidArgumentException
3232
* MUST be thrown if the $key string is not a legal value.
3333
*/
34-
public function set($key, $value, $ttl = null);
34+
public function set(string $key, mixed $value, null|int|\DateInterval $ttl = null);
3535

3636
/**
3737
* Delete an item from the cache by its unique key.
@@ -43,7 +43,7 @@ public function set($key, $value, $ttl = null);
4343
* @throws \Psr\SimpleCache\InvalidArgumentException
4444
* MUST be thrown if the $key string is not a legal value.
4545
*/
46-
public function delete($key);
46+
public function delete(string $key);
4747

4848
/**
4949
* Wipes clean the entire cache's keys.
@@ -64,7 +64,7 @@ public function clear();
6464
* MUST be thrown if $keys is neither an array nor a Traversable,
6565
* or if any of the $keys are not a legal value.
6666
*/
67-
public function getMultiple($keys, $default = null);
67+
public function getMultiple(iterable $keys, mixed $default = null);
6868

6969
/**
7070
* Persists a set of key => value pairs in the cache, with an optional TTL.
@@ -80,7 +80,7 @@ public function getMultiple($keys, $default = null);
8080
* MUST be thrown if $values is neither an array nor a Traversable,
8181
* or if any of the $values are not a legal value.
8282
*/
83-
public function setMultiple($values, $ttl = null);
83+
public function setMultiple(iterable $values, null|int|\DateInterval $ttl = null);
8484

8585
/**
8686
* Deletes multiple cache items in a single operation.
@@ -93,7 +93,7 @@ public function setMultiple($values, $ttl = null);
9393
* MUST be thrown if $keys is neither an array nor a Traversable,
9494
* or if any of the $keys are not a legal value.
9595
*/
96-
public function deleteMultiple($keys);
96+
public function deleteMultiple(iterable $keys);
9797

9898
/**
9999
* Determines whether an item is present in the cache.
@@ -110,5 +110,5 @@ public function deleteMultiple($keys);
110110
* @throws \Psr\SimpleCache\InvalidArgumentException
111111
* MUST be thrown if the $key string is not a legal value.
112112
*/
113-
public function has($key);
113+
public function has(string $key);
114114
}

0 commit comments

Comments
 (0)