4
4
5
5
use Laminas \Cache \Exception \ExceptionInterface ;
6
6
7
+ /**
8
+ * NOTE: when providing integrish cache keys in iterables, internal array conversion might convert these to int, even
9
+ * tho they were non-empty-string beforehand. See https://3v4l.org/GsiBl for more details.
10
+ *
11
+ * @psalm-type CacheKeyInIterableType = non-empty-string|int
12
+ */
7
13
interface StorageInterface
8
14
{
9
- /**
10
- * Set options.
11
- */
12
15
public function setOptions (iterable |Adapter \AdapterOptions $ options ): self ;
13
16
14
- /**
15
- * Get options
16
- */
17
17
public function getOptions (): Adapter \AdapterOptions ;
18
18
19
19
/* reading */
20
20
/**
21
- * Get an item.
22
- *
23
21
* @param non-empty-string $key
24
22
* @param-out bool $success
25
23
* @return mixed Data on success, null on failure
@@ -30,8 +28,8 @@ public function getItem(string $key, bool|null &$success = null, mixed &$casToke
30
28
/**
31
29
* Get multiple items.
32
30
*
33
- * @param non-empty-list<non-empty-string > $keys
34
- * @return array<non-empty-string ,mixed> Associative array of keys and values
31
+ * @param non-empty-list<CacheKeyInIterableType > $keys
32
+ * @return array<CacheKeyInIterableType ,mixed> Associative array of keys and values
35
33
* @throws ExceptionInterface
36
34
*/
37
35
public function getItems (array $ keys ): array ;
@@ -47,8 +45,8 @@ public function hasItem(string $key): bool;
47
45
/**
48
46
* Test multiple items.
49
47
*
50
- * @param non-empty-list<non-empty-string > $keys
51
- * @return list<non-empty-string > Array of found keys
48
+ * @param non-empty-list<CacheKeyInIterableType > $keys
49
+ * @return list<CacheKeyInIterableType > Array of found keys
52
50
* @throws ExceptionInterface
53
51
*/
54
52
public function hasItems (array $ keys ): array ;
@@ -65,24 +63,25 @@ public function setItem(string $key, mixed $value): bool;
65
63
/**
66
64
* Store multiple items.
67
65
*
68
- * @param non-empty-array<non-empty-string ,mixed> $keyValuePairs
69
- * @return list<non-empty-string > Array of not stored keys
66
+ * @param non-empty-array<CacheKeyInIterableType ,mixed> $keyValuePairs
67
+ * @return list<CacheKeyInIterableType > Array of not stored keys
70
68
* @throws ExceptionInterface
71
69
*/
72
70
public function setItems (array $ keyValuePairs ): array ;
73
71
74
72
/**
75
73
* Add an item.
76
74
*
75
+ * @param non-empty-string $key
77
76
* @throws ExceptionInterface
78
77
*/
79
78
public function addItem (string $ key , mixed $ value ): bool ;
80
79
81
80
/**
82
81
* Add multiple items.
83
82
*
84
- * @param non-empty-array<non-empty-string ,mixed> $keyValuePairs
85
- * @return list<non-empty-string > Array of not stored keys
83
+ * @param non-empty-array<CacheKeyInIterableType ,mixed> $keyValuePairs
84
+ * @return list<CacheKeyInIterableType > Array of not stored keys
86
85
* @throws ExceptionInterface
87
86
*/
88
87
public function addItems (array $ keyValuePairs ): array ;
@@ -98,8 +97,8 @@ public function replaceItem(string $key, mixed $value): bool;
98
97
/**
99
98
* Replace multiple existing items.
100
99
*
101
- * @param non-empty-array<non-empty-string ,mixed> $keyValuePairs
102
- * @return list<non-empty-string > Array of not stored keys
100
+ * @param non-empty-array<CacheKeyInIterableType ,mixed> $keyValuePairs
101
+ * @return list<CacheKeyInIterableType > Array of not stored keys
103
102
* @throws ExceptionInterface
104
103
*/
105
104
public function replaceItems (array $ keyValuePairs ): array ;
@@ -130,8 +129,8 @@ public function touchItem(string $key): bool;
130
129
/**
131
130
* Reset lifetime of multiple items.
132
131
*
133
- * @param non-empty-list<non-empty-string > $keys
134
- * @return list<non-empty-string > Array of not updated keys
132
+ * @param non-empty-list<CacheKeyInIterableType > $keys
133
+ * @return list<CacheKeyInIterableType > Array of not updated keys
135
134
* @throws ExceptionInterface
136
135
*/
137
136
public function touchItems (array $ keys ): array ;
@@ -147,8 +146,8 @@ public function removeItem(string $key): bool;
147
146
/**
148
147
* Remove multiple items.
149
148
*
150
- * @param non-empty-list<non-empty-string > $keys
151
- * @return list<non-empty-string > Array of not removed keys
149
+ * @param non-empty-list<CacheKeyInIterableType > $keys
150
+ * @return list<CacheKeyInIterableType > Array of not removed keys
152
151
* @throws ExceptionInterface
153
152
*/
154
153
public function removeItems (array $ keys ): array ;
0 commit comments