Skip to content

Commit

Permalink
Fix support for php-fig/cache
Browse files Browse the repository at this point in the history
  • Loading branch information
Plokko committed May 26, 2022
1 parent 08ef193 commit d8416e6
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/ServiceAccountCacheItemPool.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function __construct(array $config=null)
* @return CacheItemInterface
* The corresponding Cache Item.
*/
public function getItem($key)
public function getItem(string $key): CacheItemInterface
{
return $this->cache->get(self::CACHE_PREFIX.$key)?:new Item($key);
}
Expand All @@ -72,7 +72,7 @@ public function getItem($key)
* key is not found. However, if no keys are specified then an empty
* traversable MUST be returned instead.
*/
public function getItems(array $keys = array())
public function getItems(array $keys = array()): iterable
{
$items = [];
foreach($keys AS $k){
Expand All @@ -98,7 +98,7 @@ public function getItems(array $keys = array())
* @return bool
* True if item exists in the cache, false otherwise.
*/
public function hasItem($key)
public function hasItem($key): bool
{
return $this->cache->has(self::CACHE_PREFIX.$key);
}
Expand All @@ -109,7 +109,7 @@ public function hasItem($key)
* @return bool
* True if the pool was successfully cleared. False if there was an error.
*/
public function clear()
public function clear(): bool
{
$this->cache->flush();
return true;
Expand All @@ -128,7 +128,7 @@ public function clear()
* @return bool
* True if the item was successfully removed. False if there was an error.
*/
public function deleteItem($key)
public function deleteItem($key): bool
{
return $this->cache->delete(self::CACHE_PREFIX.$key);
}
Expand All @@ -144,7 +144,7 @@ public function deleteItem($key)
* @return bool
* True if the items were successfully removed. False if there was an error.
*/
public function deleteItems(array $keys)
public function deleteItems(array $keys): bool
{
foreach($keys AS $key){
$this->deleteItem($key);
Expand All @@ -161,7 +161,7 @@ public function deleteItems(array $keys)
* @return bool
* True if the item was successfully persisted. False if there was an error.
*/
public function save(CacheItemInterface $item)
public function save(CacheItemInterface $item): bool
{
try {
$this->cache->set(self::CACHE_PREFIX.$item->getKey(), $item,$this->ttl);
Expand All @@ -180,7 +180,7 @@ public function save(CacheItemInterface $item)
* @return bool
* False if the item could not be queued or if a commit was attempted and failed. True otherwise.
*/
public function saveDeferred(CacheItemInterface $item)
public function saveDeferred(CacheItemInterface $item): bool
{
$this->deferred[] = $item;
return true;
Expand All @@ -192,12 +192,12 @@ public function saveDeferred(CacheItemInterface $item)
* @return bool
* True if all not-yet-saved items were successfully saved or there were none. False otherwise.
*/
public function commit()
public function commit(): bool
{
foreach($this->deferred AS $item){
if(!$this->save($item))
return false;
}
return true;
}
}
}

0 comments on commit d8416e6

Please sign in to comment.