From 6898bbcbe52314dd6ea5367efa3c8786621bedeb Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Tue, 1 Feb 2022 16:58:18 +0100 Subject: [PATCH 1/4] Add generic hints to Cache Facades --- src/Illuminate/Support/Facades/Cache.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Illuminate/Support/Facades/Cache.php b/src/Illuminate/Support/Facades/Cache.php index 70aa1dc48395..7cc91f38088c 100755 --- a/src/Illuminate/Support/Facades/Cache.php +++ b/src/Illuminate/Support/Facades/Cache.php @@ -3,6 +3,8 @@ namespace Illuminate\Support\Facades; /** + * @template TCached of mixed + * * @method static \Illuminate\Cache\TaggedCache tags(array|mixed $names) * @method static \Illuminate\Contracts\Cache\Lock lock(string $name, int $seconds = 0, mixed $owner = null) * @method static \Illuminate\Contracts\Cache\Lock restoreLock(string $name, string $owner) @@ -17,11 +19,11 @@ * @method static bool put(string $key, $value, \DateTimeInterface|\DateInterval|int $ttl = null) * @method static int|bool decrement(string $key, $value = 1) * @method static int|bool increment(string $key, $value = 1) - * @method static mixed get(string $key, mixed $default = null) - * @method static mixed pull(string $key, mixed $default = null) - * @method static mixed remember(string $key, \DateTimeInterface|\DateInterval|int $ttl, \Closure $callback) - * @method static mixed rememberForever(string $key, \Closure $callback) - * @method static mixed sear(string $key, \Closure $callback) + * @method static null|TCached get(string $key, TCached $default = null) + * @method static null|TCached pull(string $key, TCached $default = null) + * @method static TCached remember(string $key, \DateTimeInterface|\DateInterval|int $ttl, \Closure(): TCached $callback) + * @method static TCached rememberForever(string $key, \Closure(): TCached $callback) + * @method static TCached sear(string $key, \Closure(): TCached $callback) * * @see \Illuminate\Cache\CacheManager * @see \Illuminate\Cache\Repository From fd889c37e8b1aee126b073255ad2dd8758ec2ab5 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Tue, 1 Feb 2022 17:06:17 +0100 Subject: [PATCH 2/4] Update Repository.php --- src/Illuminate/Contracts/Cache/Repository.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/Illuminate/Contracts/Cache/Repository.php b/src/Illuminate/Contracts/Cache/Repository.php index 5b78af57e4b0..970491b526e9 100644 --- a/src/Illuminate/Contracts/Cache/Repository.php +++ b/src/Illuminate/Contracts/Cache/Repository.php @@ -10,9 +10,10 @@ interface Repository extends CacheInterface /** * Retrieve an item from the cache and delete it. * + * @template TCached of mixed * @param string $key - * @param mixed $default - * @return mixed + * @param null|TCached $default + * @return null|TCached */ public function pull($key, $default = null); @@ -66,9 +67,10 @@ public function forever($key, $value); /** * Get an item from the cache, or execute the given Closure and store the result. * + * @template TCached of mixed * @param string $key * @param \DateTimeInterface|\DateInterval|int|null $ttl - * @param \Closure $callback + * @param \Closure(): TCached $callback * @return mixed */ public function remember($key, $ttl, Closure $callback); @@ -76,17 +78,19 @@ public function remember($key, $ttl, Closure $callback); /** * Get an item from the cache, or execute the given Closure and store the result forever. * + * @template TCached of mixed * @param string $key - * @param \Closure $callback - * @return mixed + * @param \Closure(): TCached $callback + * @return TCached */ public function sear($key, Closure $callback); /** * Get an item from the cache, or execute the given Closure and store the result forever. * + * @template TCached of mixed * @param string $key - * @param \Closure $callback + * @param \Closure(): TCached $callback * @return mixed */ public function rememberForever($key, Closure $callback); From 1ef689e7af94e3deede9192ad8d350df32918e3c Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Tue, 1 Feb 2022 17:07:00 +0100 Subject: [PATCH 3/4] Update Repository.php --- src/Illuminate/Contracts/Cache/Repository.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Illuminate/Contracts/Cache/Repository.php b/src/Illuminate/Contracts/Cache/Repository.php index 970491b526e9..0e8a11318f7a 100644 --- a/src/Illuminate/Contracts/Cache/Repository.php +++ b/src/Illuminate/Contracts/Cache/Repository.php @@ -71,7 +71,7 @@ public function forever($key, $value); * @param string $key * @param \DateTimeInterface|\DateInterval|int|null $ttl * @param \Closure(): TCached $callback - * @return mixed + * @return TCached */ public function remember($key, $ttl, Closure $callback); @@ -91,7 +91,7 @@ public function sear($key, Closure $callback); * @template TCached of mixed * @param string $key * @param \Closure(): TCached $callback - * @return mixed + * @return TCached */ public function rememberForever($key, Closure $callback); From 83c20ee748440bfbfa38a8102ff2ec1aa986eace Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Tue, 1 Feb 2022 17:07:50 +0100 Subject: [PATCH 4/4] Update Repository.php --- src/Illuminate/Contracts/Cache/Repository.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Illuminate/Contracts/Cache/Repository.php b/src/Illuminate/Contracts/Cache/Repository.php index 0e8a11318f7a..26b0d0fed0c7 100644 --- a/src/Illuminate/Contracts/Cache/Repository.php +++ b/src/Illuminate/Contracts/Cache/Repository.php @@ -11,6 +11,7 @@ interface Repository extends CacheInterface * Retrieve an item from the cache and delete it. * * @template TCached of mixed + * * @param string $key * @param null|TCached $default * @return null|TCached @@ -68,6 +69,7 @@ public function forever($key, $value); * Get an item from the cache, or execute the given Closure and store the result. * * @template TCached of mixed + * * @param string $key * @param \DateTimeInterface|\DateInterval|int|null $ttl * @param \Closure(): TCached $callback @@ -79,6 +81,7 @@ public function remember($key, $ttl, Closure $callback); * Get an item from the cache, or execute the given Closure and store the result forever. * * @template TCached of mixed + * * @param string $key * @param \Closure(): TCached $callback * @return TCached @@ -89,6 +92,7 @@ public function sear($key, Closure $callback); * Get an item from the cache, or execute the given Closure and store the result forever. * * @template TCached of mixed + * * @param string $key * @param \Closure(): TCached $callback * @return TCached