Skip to content

Commit aa5030c

Browse files
authored
Merge pull request #24 from Crell/v3
Add return types
2 parents 213f9db + 69df303 commit aa5030c

2 files changed

Lines changed: 17 additions & 17 deletions

File tree

src/CacheItemInterface.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ interface CacheItemInterface
3232
* @return string
3333
* The key string for this cache item.
3434
*/
35-
public function getKey();
35+
public function getKey(): string;
3636

3737
/**
3838
* Retrieves the value of the item from the cache associated with this object's key.
@@ -46,7 +46,7 @@ public function getKey();
4646
* @return mixed
4747
* The value corresponding to this cache item's key, or null if not found.
4848
*/
49-
public function get();
49+
public function get(): mixed;
5050

5151
/**
5252
* Confirms if the cache item lookup resulted in a cache hit.
@@ -57,7 +57,7 @@ public function get();
5757
* @return bool
5858
* True if the request resulted in a cache hit. False otherwise.
5959
*/
60-
public function isHit();
60+
public function isHit(): bool;
6161

6262
/**
6363
* Sets the value represented by this cache item.
@@ -72,7 +72,7 @@ public function isHit();
7272
* @return static
7373
* The invoked object.
7474
*/
75-
public function set(mixed $value);
75+
public function set(mixed $value): static;
7676

7777
/**
7878
* Sets the expiration time for this cache item.
@@ -86,7 +86,7 @@ public function set(mixed $value);
8686
* @return static
8787
* The called object.
8888
*/
89-
public function expiresAt(?\DateTimeInterface $expiration);
89+
public function expiresAt(?\DateTimeInterface $expiration): static;
9090

9191
/**
9292
* Sets the expiration time for this cache item.
@@ -101,5 +101,5 @@ public function expiresAt(?\DateTimeInterface $expiration);
101101
* @return static
102102
* The called object.
103103
*/
104-
public function expiresAfter(int|\DateInterval|null $time);
104+
public function expiresAfter(int|\DateInterval|null $time): static;
105105
}

src/CacheItemPoolInterface.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ interface CacheItemPoolInterface
2929
* @return CacheItemInterface
3030
* The corresponding Cache Item.
3131
*/
32-
public function getItem(string $key);
32+
public function getItem(string $key): CacheItemInterface;
3333

3434
/**
3535
* Returns a traversable set of cache items.
@@ -41,13 +41,13 @@ public function getItem(string $key);
4141
* If any of the keys in $keys are not a legal value a \Psr\Cache\InvalidArgumentException
4242
* MUST be thrown.
4343
*
44-
* @return array|\Traversable
45-
* A traversable collection of Cache Items keyed by the cache keys of
44+
* @return iterable
45+
* An iterable collection of Cache Items keyed by the cache keys of
4646
* each item. A Cache item will be returned for each key, even if that
4747
* key is not found. However, if no keys are specified then an empty
4848
* traversable MUST be returned instead.
4949
*/
50-
public function getItems(array $keys = []);
50+
public function getItems(array $keys = []): iterable;
5151

5252
/**
5353
* Confirms if the cache contains specified cache item.
@@ -66,15 +66,15 @@ public function getItems(array $keys = []);
6666
* @return bool
6767
* True if item exists in the cache, false otherwise.
6868
*/
69-
public function hasItem(string $key);
69+
public function hasItem(string $key): bool;
7070

7171
/**
7272
* Deletes all items in the pool.
7373
*
7474
* @return bool
7575
* True if the pool was successfully cleared. False if there was an error.
7676
*/
77-
public function clear();
77+
public function clear(): bool;
7878

7979
/**
8080
* Removes the item from the pool.
@@ -89,7 +89,7 @@ public function clear();
8989
* @return bool
9090
* True if the item was successfully removed. False if there was an error.
9191
*/
92-
public function deleteItem(string $key);
92+
public function deleteItem(string $key): bool;
9393

9494
/**
9595
* Removes multiple items from the pool.
@@ -104,7 +104,7 @@ public function deleteItem(string $key);
104104
* @return bool
105105
* True if the items were successfully removed. False if there was an error.
106106
*/
107-
public function deleteItems(array $keys);
107+
public function deleteItems(array $keys): bool;
108108

109109
/**
110110
* Persists a cache item immediately.
@@ -115,7 +115,7 @@ public function deleteItems(array $keys);
115115
* @return bool
116116
* True if the item was successfully persisted. False if there was an error.
117117
*/
118-
public function save(CacheItemInterface $item);
118+
public function save(CacheItemInterface $item): bool;
119119

120120
/**
121121
* Sets a cache item to be persisted later.
@@ -126,13 +126,13 @@ public function save(CacheItemInterface $item);
126126
* @return bool
127127
* False if the item could not be queued or if a commit was attempted and failed. True otherwise.
128128
*/
129-
public function saveDeferred(CacheItemInterface $item);
129+
public function saveDeferred(CacheItemInterface $item): bool;
130130

131131
/**
132132
* Persists any deferred cache items.
133133
*
134134
* @return bool
135135
* True if all not-yet-saved items were successfully saved or there were none. False otherwise.
136136
*/
137-
public function commit();
137+
public function commit(): bool;
138138
}

0 commit comments

Comments
 (0)