diff --git a/composer.json b/composer.json index 53a327e..86dacf0 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": { @@ -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 92% rename from ArrayCachePool.php rename to src/ArrayCachePool.php index e988145..c416e2f 100644 --- a/ArrayCachePool.php +++ b/src/ArrayCachePool.php @@ -75,7 +75,7 @@ protected function getItemWithoutGenerateCacheKey($key) /** * {@inheritdoc} */ - protected function fetchObjectFromCache($key) + protected function fetchObjectFromCache(string $key): array { $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) {