From 2feafcd8f4728dd3cfe94803dcec710df8cbc9dc Mon Sep 17 00:00:00 2001 From: EriBloo <19932449+EriBloo@users.noreply.github.com> Date: Wed, 16 Oct 2024 15:42:22 +0000 Subject: [PATCH] improve type in driver and trait --- src/Concerns/CacheObjectActions.php | 3 +++ src/Contracts/Driver.php | 9 +++------ src/Drivers/CacheDriver.php | 5 +++++ 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/Concerns/CacheObjectActions.php b/src/Concerns/CacheObjectActions.php index 91db83e..a0c2ffc 100644 --- a/src/Concerns/CacheObjectActions.php +++ b/src/Concerns/CacheObjectActions.php @@ -40,6 +40,9 @@ public function delete(): bool ->delete($this); } + /** + * @return Driver + */ protected function resolveDriver(): Driver { return app()->make('cache-driver'); diff --git a/src/Contracts/Driver.php b/src/Contracts/Driver.php index ad2aa3a..14fb6a3 100644 --- a/src/Contracts/Driver.php +++ b/src/Contracts/Driver.php @@ -4,27 +4,24 @@ namespace EriBloo\CacheObjects\Contracts; +/** + * @template TValue + */ interface Driver { /** - * @template TValue - * * @param TValue $value * @param CacheObject $cacheObject */ public function set(mixed $value, CacheObject $cacheObject): string; /** - * @template TValue - * * @param CacheObject $cacheObject * @return TValue|null */ public function get(CacheObject $cacheObject): mixed; /** - * @template TValue - * * @param CacheObject $cacheObject */ public function delete(CacheObject $cacheObject): bool; diff --git a/src/Drivers/CacheDriver.php b/src/Drivers/CacheDriver.php index d39b465..d5b0033 100644 --- a/src/Drivers/CacheDriver.php +++ b/src/Drivers/CacheDriver.php @@ -12,6 +12,11 @@ use EriBloo\CacheObjects\Events\CacheObjectStored; use Illuminate\Contracts\Cache\Store; +/** + * @template TValue + * + * @implements Driver + */ final class CacheDriver implements Driver { public function __construct(