From bc789bffcf82a6e562ebf0ef86d88a7c8cc99cc1 Mon Sep 17 00:00:00 2001 From: David ML Brown Jr Date: Fri, 5 Jan 2024 08:34:22 -0800 Subject: [PATCH 1/4] Support PSR Cache version 3.0 Doesn't seem to be measurable differences between psr/cache version 2 and version 3. 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 53a327e..0c71672 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,7 @@ "php": ">=7.4", "cache/adapter-common": "^1.0", "cache/hierarchical-cache": "^1.0", - "psr/cache": "^1.0 || ^2.0", + "psr/cache": "^1.0 || ^2.0 || ^3.0", "psr/simple-cache": "^1.0" }, "require-dev": { From d7c67a1cc14bdfdc4a914d20baa3db4c3c83821d Mon Sep 17 00:00:00 2001 From: David ML Brown Jr Date: Wed, 13 Mar 2024 13:57:48 -0700 Subject: [PATCH 2/4] move things to subdirs Signed-off-by: David ML Brown Jr --- composer.json | 12 +++++++----- ArrayCachePool.php => src/ArrayCachePool.php | 0 2 files changed, 7 insertions(+), 5 deletions(-) rename ArrayCachePool.php => src/ArrayCachePool.php (100%) diff --git a/composer.json b/composer.json index 0c71672..86dacf0 100644 --- a/composer.json +++ b/composer.json @@ -41,11 +41,13 @@ "prefer-stable": true, "autoload": { "psr-4": { - "Cache\\Adapter\\PHPArray\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] + "Cache\\Adapter\\PHPArray\\": "src" + } + }, + "autoload-dev": { + "psr-4": { + "Cache\\Adapter\\PHPArray\\Tests\\": "Tests" + } }, "extra": { "branch-alias": { diff --git a/ArrayCachePool.php b/src/ArrayCachePool.php similarity index 100% rename from ArrayCachePool.php rename to src/ArrayCachePool.php From b338e8ec54b15a25d18db2c8668c5c988dd00937 Mon Sep 17 00:00:00 2001 From: David ML Brown Jr Date: Fri, 15 Mar 2024 10:03:17 -0700 Subject: [PATCH 3/4] add more typing Signed-off-by: David ML Brown Jr --- src/ArrayCachePool.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/ArrayCachePool.php b/src/ArrayCachePool.php index e988145..6ac2ea4 100644 --- a/src/ArrayCachePool.php +++ b/src/ArrayCachePool.php @@ -75,7 +75,7 @@ protected function getItemWithoutGenerateCacheKey($key) /** * {@inheritdoc} */ - protected function fetchObjectFromCache($key) + protected function fetchObjectFromCache(string $key): bool { $keys = $this->getHierarchyKey($key); @@ -96,7 +96,7 @@ protected function fetchObjectFromCache($key) /** * {@inheritdoc} */ - protected function clearAllObjectsFromCache() + protected function clearAllObjectsFromCache(): bool { $this->cache = []; @@ -106,7 +106,7 @@ protected function clearAllObjectsFromCache() /** * {@inheritdoc} */ - protected function clearOneObjectFromCache($key) + protected function clearOneObjectFromCache(string $key): bool { $this->commit(); $keys = $this->getHierarchyKey($key); @@ -120,7 +120,7 @@ protected function clearOneObjectFromCache($key) /** * {@inheritdoc} */ - protected function storeItemInCache(PhpCacheItem $item, $ttl) + protected function storeItemInCache(PhpCacheItem $item, null|int|\DateInterval $ttl): bool { $keys = $this->getHierarchyKey($item->getKey()); $value = $item->get(); @@ -158,7 +158,7 @@ protected function getDirectValue($key) /** * {@inheritdoc} */ - protected function getList($name) + protected function getList(string $name): iterable { if (!isset($this->cache[$name])) { $this->cache[$name] = []; @@ -170,7 +170,7 @@ protected function getList($name) /** * {@inheritdoc} */ - protected function removeList($name) + protected function removeList(string $name): bool { unset($this->cache[$name]); @@ -180,7 +180,7 @@ protected function removeList($name) /** * {@inheritdoc} */ - protected function appendListItem($name, $key) + protected function appendListItem(string $name, string $key) { $this->cache[$name][] = $key; } @@ -188,7 +188,7 @@ protected function appendListItem($name, $key) /** * {@inheritdoc} */ - protected function removeListItem($name, $key) + protected function removeListItem(string $name, string $key) { if (isset($this->cache[$name])) { foreach ($this->cache[$name] as $i => $item) { From 378932a37d9709f2260c2a602ac4c757853820e5 Mon Sep 17 00:00:00 2001 From: David ML Brown Jr Date: Fri, 15 Mar 2024 10:28:23 -0700 Subject: [PATCH 4/4] fix typing Signed-off-by: David ML Brown Jr --- src/ArrayCachePool.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ArrayCachePool.php b/src/ArrayCachePool.php index 6ac2ea4..c416e2f 100644 --- a/src/ArrayCachePool.php +++ b/src/ArrayCachePool.php @@ -75,7 +75,7 @@ protected function getItemWithoutGenerateCacheKey($key) /** * {@inheritdoc} */ - protected function fetchObjectFromCache(string $key): bool + protected function fetchObjectFromCache(string $key): array { $keys = $this->getHierarchyKey($key);