Skip to content

Commit 6df8b61

Browse files
authored
Fix: Correct typehint on repository retrieval methods (#53025)
* widen typehint on repository get * replace Closure(): mixed with mixed * fix type tests
1 parent 5caf767 commit 6df8b61

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

src/Illuminate/Cache/Repository.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,9 @@ public function missing($key)
101101
/**
102102
* Retrieve an item from the cache by key.
103103
*
104-
* @template TCacheValue
105-
*
106104
* @param array|string $key
107-
* @param TCacheValue|(\Closure(): TCacheValue) $default
108-
* @return (TCacheValue is null ? mixed : TCacheValue)
105+
* @param mixed $default
106+
* @return mixed
109107
*/
110108
public function get($key, $default = null): mixed
111109
{
@@ -198,11 +196,9 @@ protected function handleManyResult($keys, $key, $value)
198196
/**
199197
* Retrieve an item from the cache and delete it.
200198
*
201-
* @template TCacheValue
202-
*
203199
* @param array|string $key
204-
* @param TCacheValue|(\Closure(): TCacheValue) $default
205-
* @return (TCacheValue is null ? mixed : TCacheValue)
200+
* @param mixed $default
201+
* @return mixed
206202
*/
207203
public function pull($key, $default = null)
208204
{

types/Cache/Repository.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
$cache = resolve(Repository::class);
99

1010
assertType('mixed', $cache->get('key'));
11-
assertType('int', $cache->get('cache', 27));
12-
assertType('int', $cache->get('cache', function (): int {
11+
assertType('mixed', $cache->get('cache', 27));
12+
assertType('mixed', $cache->get('cache', function (): int {
1313
return 26;
1414
}));
1515

1616
assertType('mixed', $cache->pull('key'));
17-
assertType('int', $cache->pull('cache', 28));
18-
assertType('int', $cache->pull('cache', function (): int {
17+
assertType('mixed', $cache->pull('cache', 28));
18+
assertType('mixed', $cache->pull('cache', function (): int {
1919
return 30;
2020
}));
2121
assertType('int', $cache->sear('cache', function (): int {

0 commit comments

Comments
 (0)