From 21c9722e779fbeae151da28d74229ed00ef91668 Mon Sep 17 00:00:00 2001 From: David ML Brown Jr Date: Fri, 5 Jan 2024 09:05:00 -0800 Subject: [PATCH 1/5] Add psr/cache version 3.0 support There's no measurable difference between 2.0 and 3.0 Signed-off-by: David ML Brown Jr --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 003eac5..551f724 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "homepage": "http://www.php-cache.com/en/latest/", "require": { "php": ">=7.4", - "psr/cache": "^1.0 || ^2.0", + "psr/cache": "^1.0 || ^2.0 || ^3.0", "psr/simple-cache": "^1.0" }, "require-dev": { From a83942764ac96c6aa808589657e8db7b1902e2e7 Mon Sep 17 00:00:00 2001 From: David ML Brown Jr Date: Wed, 13 Mar 2024 13:59:42 -0700 Subject: [PATCH 2/5] move some things to src Signed-off-by: David ML Brown Jr --- composer.json | 12 +++++++----- {Exception => src/Exception}/CacheException.php | 0 .../Exception}/InvalidArgumentException.php | 0 SimpleCacheBridge.php => src/SimpleCacheBridge.php | 0 4 files changed, 7 insertions(+), 5 deletions(-) rename {Exception => src/Exception}/CacheException.php (100%) rename {Exception => src/Exception}/InvalidArgumentException.php (100%) rename SimpleCacheBridge.php => src/SimpleCacheBridge.php (100%) diff --git a/composer.json b/composer.json index 551f724..ea7a0bd 100644 --- a/composer.json +++ b/composer.json @@ -35,11 +35,13 @@ "prefer-stable": true, "autoload": { "psr-4": { - "Cache\\Bridge\\SimpleCache\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] + "Cache\\Bridge\\SimpleCache\\": "src" + } + }, + "autoload-dev": { + "psr-4": { + "Cache\\Bridge\\SimpleCache\\Tests\\": "tests" + } }, "extra": { "branch-alias": { diff --git a/Exception/CacheException.php b/src/Exception/CacheException.php similarity index 100% rename from Exception/CacheException.php rename to src/Exception/CacheException.php diff --git a/Exception/InvalidArgumentException.php b/src/Exception/InvalidArgumentException.php similarity index 100% rename from Exception/InvalidArgumentException.php rename to src/Exception/InvalidArgumentException.php diff --git a/SimpleCacheBridge.php b/src/SimpleCacheBridge.php similarity index 100% rename from SimpleCacheBridge.php rename to src/SimpleCacheBridge.php From ed927219ddff2748b012492fab9002694db1ee1e Mon Sep 17 00:00:00 2001 From: David ML Brown Jr Date: Wed, 13 Mar 2024 14:30:46 -0700 Subject: [PATCH 3/5] add some typing Signed-off-by: David ML Brown Jr --- src/SimpleCacheBridge.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/SimpleCacheBridge.php b/src/SimpleCacheBridge.php index a0047be..68c3405 100644 --- a/src/SimpleCacheBridge.php +++ b/src/SimpleCacheBridge.php @@ -40,7 +40,7 @@ public function __construct(CacheItemPoolInterface $cacheItemPool) /** * {@inheritdoc} */ - public function get($key, $default = null) + public function get($key, mixed $default = null): mixed { try { $item = $this->cacheItemPool->getItem($key); @@ -58,7 +58,7 @@ public function get($key, $default = null) /** * {@inheritdoc} */ - public function set($key, $value, $ttl = null) + public function set($key, mixed $value, null|int|\DateInterval $ttl = null): bool { try { $item = $this->cacheItemPool->getItem($key); @@ -75,7 +75,7 @@ public function set($key, $value, $ttl = null) /** * {@inheritdoc} */ - public function delete($key) + public function delete(string $key): bool { try { return $this->cacheItemPool->deleteItem($key); @@ -87,7 +87,7 @@ public function delete($key) /** * {@inheritdoc} */ - public function clear() + public function clear(): bool { return $this->cacheItemPool->clear(); } @@ -95,7 +95,7 @@ public function clear() /** * {@inheritdoc} */ - public function getMultiple($keys, $default = null) + public function getMultiple(iterable $keys, mixed $default = null): iterable { if (!is_array($keys)) { if (!$keys instanceof \Traversable) { From 741b339e048e9cedd26f39369e9295e435f3d5a6 Mon Sep 17 00:00:00 2001 From: David ML Brown Jr Date: Wed, 13 Mar 2024 14:33:03 -0700 Subject: [PATCH 4/5] missed one Signed-off-by: David ML Brown Jr --- src/SimpleCacheBridge.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SimpleCacheBridge.php b/src/SimpleCacheBridge.php index 68c3405..4a931c0 100644 --- a/src/SimpleCacheBridge.php +++ b/src/SimpleCacheBridge.php @@ -122,7 +122,7 @@ public function getMultiple(iterable $keys, mixed $default = null): iterable * * @return \Generator */ - private function generateValues($default, $items) + private function generateValues(mixed $default, $items) { foreach ($items as $key => $item) { /** @type $item CacheItemInterface */ @@ -137,7 +137,7 @@ private function generateValues($default, $items) /** * {@inheritdoc} */ - public function setMultiple($values, $ttl = null) + public function setMultiple(iterable $values, null|int|\DateInterval $ttl = null) { if (!is_array($values)) { if (!$values instanceof \Traversable) { From c6fcfe5df293ecb87b9580b7e1ecfa6bb8130caa Mon Sep 17 00:00:00 2001 From: David ML Brown Jr Date: Wed, 13 Mar 2024 14:39:26 -0700 Subject: [PATCH 5/5] add typing Signed-off-by: David ML Brown Jr --- src/SimpleCacheBridge.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/SimpleCacheBridge.php b/src/SimpleCacheBridge.php index 4a931c0..f00cde4 100644 --- a/src/SimpleCacheBridge.php +++ b/src/SimpleCacheBridge.php @@ -137,7 +137,7 @@ private function generateValues(mixed $default, $items) /** * {@inheritdoc} */ - public function setMultiple(iterable $values, null|int|\DateInterval $ttl = null) + public function setMultiple(iterable $values, null|int|\DateInterval $ttl = null): bool { if (!is_array($values)) { if (!$values instanceof \Traversable) { @@ -191,7 +191,7 @@ public function setMultiple(iterable $values, null|int|\DateInterval $ttl = null /** * {@inheritdoc} */ - public function deleteMultiple($keys) + public function deleteMultiple(iterable $keys): bool { if (!is_array($keys)) { if (!$keys instanceof \Traversable) { @@ -213,7 +213,7 @@ public function deleteMultiple($keys) /** * {@inheritdoc} */ - public function has($key) + public function has(string $key): bool { try { return $this->cacheItemPool->hasItem($key);