diff --git a/composer.json b/composer.json index 003eac5..ea7a0bd 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": { @@ -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 91% rename from SimpleCacheBridge.php rename to src/SimpleCacheBridge.php index a0047be..f00cde4 100644 --- a/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) { @@ -122,7 +122,7 @@ public function getMultiple($keys, $default = null) * * @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): bool { if (!is_array($values)) { if (!$values instanceof \Traversable) { @@ -191,7 +191,7 @@ public function setMultiple($values, $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);