From d8416e69761a6a982179e869bf9daf822056eeae Mon Sep 17 00:00:00 2001 From: Plokko Date: Thu, 26 May 2022 14:25:31 +0200 Subject: [PATCH] Fix support for php-fig/cache --- src/ServiceAccountCacheItemPool.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/ServiceAccountCacheItemPool.php b/src/ServiceAccountCacheItemPool.php index 1396142..357b028 100644 --- a/src/ServiceAccountCacheItemPool.php +++ b/src/ServiceAccountCacheItemPool.php @@ -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); } @@ -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){ @@ -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); } @@ -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; @@ -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); } @@ -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); @@ -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); @@ -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; @@ -192,7 +192,7 @@ 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)) @@ -200,4 +200,4 @@ public function commit() } return true; } -} \ No newline at end of file +}