From db20357bfbe78458c2098fbee6c4fa600dc6261d Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 7 Jul 2021 14:43:50 +0200 Subject: [PATCH] [Cache] fix bad merge --- src/Symfony/Component/Cache/Adapter/ArrayAdapter.php | 2 +- src/Symfony/Component/Cache/Adapter/ChainAdapter.php | 2 +- src/Symfony/Component/Cache/Adapter/NullAdapter.php | 2 +- src/Symfony/Component/Cache/Adapter/ProxyAdapter.php | 2 +- .../Component/Cache/Adapter/TagAwareAdapter.php | 2 +- src/Symfony/Component/Cache/CacheItem.php | 10 ++++++++-- .../Component/Cache/Traits/AbstractAdapterTrait.php | 2 +- src/Symfony/Component/Cache/Traits/RedisTrait.php | 4 ++-- 8 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/Symfony/Component/Cache/Adapter/ArrayAdapter.php b/src/Symfony/Component/Cache/Adapter/ArrayAdapter.php index ce55b231a2..2aa42f2113 100644 --- a/src/Symfony/Component/Cache/Adapter/ArrayAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/ArrayAdapter.php @@ -312,7 +312,7 @@ class ArrayAdapter implements AdapterInterface, CacheInterface, LoggerAwareInter $this->clear(); } - private function generateItems(array $keys, float $now, \Closure $f) + private function generateItems(array $keys, float $now, \Closure $f): \Generator { foreach ($keys as $i => $key) { if (!$isHit = isset($this->expiries[$key]) && ($this->expiries[$key] > $now || !$this->deleteItem($key))) { diff --git a/src/Symfony/Component/Cache/Adapter/ChainAdapter.php b/src/Symfony/Component/Cache/Adapter/ChainAdapter.php index f7586b7b01..e9e92acc6b 100644 --- a/src/Symfony/Component/Cache/Adapter/ChainAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/ChainAdapter.php @@ -147,7 +147,7 @@ class ChainAdapter implements AdapterInterface, CacheInterface, PruneableInterfa return $this->generateItems($this->adapters[0]->getItems($keys), 0); } - private function generateItems(iterable $items, int $adapterIndex) + private function generateItems(iterable $items, int $adapterIndex): \Generator { $missing = []; $misses = []; diff --git a/src/Symfony/Component/Cache/Adapter/NullAdapter.php b/src/Symfony/Component/Cache/Adapter/NullAdapter.php index fd85840556..e204eb3ff5 100644 --- a/src/Symfony/Component/Cache/Adapter/NullAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/NullAdapter.php @@ -143,7 +143,7 @@ class NullAdapter implements AdapterInterface, CacheInterface return $this->deleteItem($key); } - private function generateItems(array $keys) + private function generateItems(array $keys): \Generator { $f = $this->createCacheItem; diff --git a/src/Symfony/Component/Cache/Adapter/ProxyAdapter.php b/src/Symfony/Component/Cache/Adapter/ProxyAdapter.php index 4d21931327..6ea6b455b9 100644 --- a/src/Symfony/Component/Cache/Adapter/ProxyAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/ProxyAdapter.php @@ -244,7 +244,7 @@ class ProxyAdapter implements AdapterInterface, CacheInterface, PruneableInterfa return $this->pool->$method($innerItem); } - private function generateItems(iterable $items) + private function generateItems(iterable $items): \Generator { $f = $this->createCacheItem; diff --git a/src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php b/src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php index 6c7815b0ff..c0bdafd3c2 100644 --- a/src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php @@ -329,7 +329,7 @@ class TagAwareAdapter implements TagAwareAdapterInterface, TagAwareCacheInterfac $this->commit(); } - private function generateItems(iterable $items, array $tagKeys) + private function generateItems(iterable $items, array $tagKeys): \Generator { $bufferedItems = $itemTags = []; $f = $this->setCacheItemTags; diff --git a/src/Symfony/Component/Cache/CacheItem.php b/src/Symfony/Component/Cache/CacheItem.php index 0a3f07d7a9..cf39b4cc8e 100644 --- a/src/Symfony/Component/Cache/CacheItem.php +++ b/src/Symfony/Component/Cache/CacheItem.php @@ -76,9 +76,15 @@ final class CacheItem implements ItemInterface * * @return $this */ - public function expiresAt(?\DateTimeInterface $expiration): self + public function expiresAt($expiration): self { - $this->expiry = null !== $expiration ? (float) $expiration->format('U.u') : null; + if (null === $expiration) { + $this->expiry = null; + } elseif ($expiration instanceof \DateTimeInterface) { + $this->expiry = (float) $expiration->format('U.u'); + } else { + throw new InvalidArgumentException(sprintf('Expiration date must implement DateTimeInterface or be null, "%s" given.', get_debug_type($expiration))); + } return $this; } diff --git a/src/Symfony/Component/Cache/Traits/AbstractAdapterTrait.php b/src/Symfony/Component/Cache/Traits/AbstractAdapterTrait.php index ad594add3b..d2804c591f 100644 --- a/src/Symfony/Component/Cache/Traits/AbstractAdapterTrait.php +++ b/src/Symfony/Component/Cache/Traits/AbstractAdapterTrait.php @@ -332,7 +332,7 @@ trait AbstractAdapterTrait } } - private function generateItems(iterable $items, array &$keys): iterable + private function generateItems(iterable $items, array &$keys): \Generator { $f = $this->createCacheItem; diff --git a/src/Symfony/Component/Cache/Traits/RedisTrait.php b/src/Symfony/Component/Cache/Traits/RedisTrait.php index ea0405ce93..f7bbe9ea3d 100644 --- a/src/Symfony/Component/Cache/Traits/RedisTrait.php +++ b/src/Symfony/Component/Cache/Traits/RedisTrait.php @@ -84,9 +84,9 @@ trait RedisTrait * * @param array $options See self::$defaultConnectionOptions * - * @throws InvalidArgumentException when the DSN is invalid - * * @return \Redis|\RedisCluster|RedisClusterProxy|RedisProxy|\Predis\ClientInterface According to the "class" option + * + * @throws InvalidArgumentException when the DSN is invalid */ public static function createConnection(string $dsn, array $options = []) {