Skip to content

Commit 1f09614

Browse files
authored
Merge pull request #7858 from paulbalandan/phpstan-cache-types
fix: add types for cache handlers
2 parents 60b22bf + a2e8e5c commit 1f09614

9 files changed

Lines changed: 17 additions & 55 deletions

phpstan-baseline.php

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -16,61 +16,11 @@
1616
'count' => 1,
1717
'path' => __DIR__ . '/system/BaseModel.php',
1818
];
19-
$ignoreErrors[] = [
20-
'message' => '#^Method CodeIgniter\\\\Cache\\\\Handlers\\\\BaseHandler\\:\\:deleteMatching\\(\\) has no return type specified\\.$#',
21-
'count' => 1,
22-
'path' => __DIR__ . '/system/Cache/Handlers/BaseHandler.php',
23-
];
24-
$ignoreErrors[] = [
25-
'message' => '#^Method CodeIgniter\\\\Cache\\\\Handlers\\\\BaseHandler\\:\\:remember\\(\\) has parameter \\$callback with no signature specified for Closure\\.$#',
26-
'count' => 1,
27-
'path' => __DIR__ . '/system/Cache/Handlers/BaseHandler.php',
28-
];
29-
$ignoreErrors[] = [
30-
'message' => '#^Method CodeIgniter\\\\Cache\\\\Handlers\\\\DummyHandler\\:\\:deleteMatching\\(\\) has no return type specified\\.$#',
31-
'count' => 1,
32-
'path' => __DIR__ . '/system/Cache/Handlers/DummyHandler.php',
33-
];
34-
$ignoreErrors[] = [
35-
'message' => '#^Method CodeIgniter\\\\Cache\\\\Handlers\\\\DummyHandler\\:\\:remember\\(\\) has parameter \\$callback with no signature specified for Closure\\.$#',
36-
'count' => 1,
37-
'path' => __DIR__ . '/system/Cache/Handlers/DummyHandler.php',
38-
];
39-
$ignoreErrors[] = [
40-
'message' => '#^Method CodeIgniter\\\\Cache\\\\Handlers\\\\FileHandler\\:\\:deleteMatching\\(\\) has no return type specified\\.$#',
41-
'count' => 1,
42-
'path' => __DIR__ . '/system/Cache/Handlers/FileHandler.php',
43-
];
44-
$ignoreErrors[] = [
45-
'message' => '#^Method CodeIgniter\\\\Cache\\\\Handlers\\\\MemcachedHandler\\:\\:deleteMatching\\(\\) has no return type specified\\.$#',
46-
'count' => 1,
47-
'path' => __DIR__ . '/system/Cache/Handlers/MemcachedHandler.php',
48-
];
49-
$ignoreErrors[] = [
50-
'message' => '#^Method CodeIgniter\\\\Cache\\\\Handlers\\\\PredisHandler\\:\\:deleteMatching\\(\\) has no return type specified\\.$#',
51-
'count' => 1,
52-
'path' => __DIR__ . '/system/Cache/Handlers/PredisHandler.php',
53-
];
54-
$ignoreErrors[] = [
55-
'message' => '#^Method CodeIgniter\\\\Cache\\\\Handlers\\\\RedisHandler\\:\\:deleteMatching\\(\\) has no return type specified\\.$#',
56-
'count' => 1,
57-
'path' => __DIR__ . '/system/Cache/Handlers/RedisHandler.php',
58-
];
59-
$ignoreErrors[] = [
60-
'message' => '#^Method CodeIgniter\\\\Cache\\\\Handlers\\\\WincacheHandler\\:\\:deleteMatching\\(\\) has no return type specified\\.$#',
61-
'count' => 1,
62-
'path' => __DIR__ . '/system/Cache/Handlers/WincacheHandler.php',
63-
];
6419
$ignoreErrors[] = [
6520
'message' => '#^Method CodeIgniter\\\\CodeIgniter\\:\\:bootstrapEnvironment\\(\\) has no return type specified\\.$#',
6621
'count' => 1,
6722
'path' => __DIR__ . '/system/CodeIgniter.php',
6823
];
69-
$ignoreErrors[] = [
70-
'message' => '#^Method CodeIgniter\\\\CodeIgniter\\:\\:cache\\(\\) has no return type specified\\.$#',
71-
'count' => 1,
72-
'path' => __DIR__ . '/system/CodeIgniter.php',
73-
];
7424
$ignoreErrors[] = [
7525
'message' => '#^Method CodeIgniter\\\\CodeIgniter\\:\\:callExit\\(\\) has no return type specified\\.$#',
7626
'count' => 1,
@@ -1436,11 +1386,6 @@
14361386
'count' => 1,
14371387
'path' => __DIR__ . '/system/Test/Mock/MockCache.php',
14381388
];
1439-
$ignoreErrors[] = [
1440-
'message' => '#^Method CodeIgniter\\\\Test\\\\Mock\\\\MockCache\\:\\:remember\\(\\) has parameter \\$callback with no signature specified for Closure\\.$#',
1441-
'count' => 1,
1442-
'path' => __DIR__ . '/system/Test/Mock/MockCache.php',
1443-
];
14441389
$ignoreErrors[] = [
14451390
'message' => '#^Method CodeIgniter\\\\Test\\\\Mock\\\\MockCodeIgniter\\:\\:callExit\\(\\) has no return type specified\\.$#',
14461391
'count' => 1,

system/Cache/Handlers/BaseHandler.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ public static function validateKey($key, $prefix = ''): string
7777
* @param string $key Cache item name
7878
* @param int $ttl Time to live
7979
* @param Closure $callback Callback return value
80+
* @phpstan-param Closure(): mixed $callback
8081
*
8182
* @return array|bool|float|int|object|string|null
8283
*/
@@ -98,6 +99,8 @@ public function remember(string $key, int $ttl, Closure $callback)
9899
*
99100
* @param string $pattern Cache items glob-style pattern
100101
*
102+
* @return int|never
103+
*
101104
* @throws Exception
102105
*/
103106
public function deleteMatching(string $pattern)

system/Cache/Handlers/DummyHandler.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ public function delete(string $key)
5959

6060
/**
6161
* {@inheritDoc}
62+
*
63+
* @return int
6264
*/
6365
public function deleteMatching(string $pattern)
6466
{

system/Cache/Handlers/FileHandler.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ public function delete(string $key)
127127

128128
/**
129129
* {@inheritDoc}
130+
*
131+
* @return int
130132
*/
131133
public function deleteMatching(string $pattern)
132134
{

system/Cache/Handlers/MemcachedHandler.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,8 @@ public function delete(string $key)
188188

189189
/**
190190
* {@inheritDoc}
191+
*
192+
* @return never
191193
*/
192194
public function deleteMatching(string $pattern)
193195
{

system/Cache/Handlers/PredisHandler.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ public function delete(string $key)
150150

151151
/**
152152
* {@inheritDoc}
153+
*
154+
* @return int
153155
*/
154156
public function deleteMatching(string $pattern)
155157
{

system/Cache/Handlers/RedisHandler.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@ public function delete(string $key)
176176

177177
/**
178178
* {@inheritDoc}
179+
*
180+
* @return int
179181
*/
180182
public function deleteMatching(string $pattern)
181183
{

system/Cache/Handlers/WincacheHandler.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ public function delete(string $key)
7373

7474
/**
7575
* {@inheritDoc}
76+
*
77+
* @return never
7678
*/
7779
public function deleteMatching(string $pattern)
7880
{

system/CodeIgniter.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,8 @@ public function displayCache(Cache $config)
701701
* Tells the app that the final output should be cached.
702702
*
703703
* @deprecated 4.4.0 Moved to ResponseCache::setTtl(). to No longer used.
704+
*
705+
* @return void
704706
*/
705707
public static function cache(int $time)
706708
{

0 commit comments

Comments
 (0)