Skip to content

Commit 770e067

Browse files
authored
refactor: Fix phpstan varTag.type errors (#9480)
* refactor: Update return types `ReflectionHelper` * refactor: Update types in RedisHandler::deleteMatching() * refactor: Remove unnecessary hints * refactor: TimeTrait::$timezone can be a string * refactor: Refresh phpstan baseline
1 parent 686e9ae commit 770e067

File tree

7 files changed

+12
-44
lines changed

7 files changed

+12
-44
lines changed

system/Cache/Handlers/RedisHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ public function deleteMatching(string $pattern)
181181
$iterator = null;
182182

183183
do {
184-
/** @var false|list<string>|Redis $keys */
184+
/** @var false|list<string> $keys */
185185
$keys = $this->redis->scan($iterator, $pattern);
186186

187187
if (is_array($keys)) {

system/Commands/Generators/MigrationGenerator.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,7 @@ protected function prepare(string $class): string
112112
$data['DBGroup'] = is_string($DBGroup) ? $DBGroup : 'default';
113113
$data['DBDriver'] = config(Database::class)->{$data['DBGroup']}['DBDriver'];
114114

115-
/** @var SessionConfig|null $session */
116-
$session = config(SessionConfig::class);
117-
118-
$data['matchIP'] = $session->matchIP;
115+
$data['matchIP'] = config(SessionConfig::class)->matchIP;
119116
}
120117

121118
return $this->parseTemplate($class, [], [], $data);

system/HTTP/CURLRequest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,7 @@ public function __construct(App $config, URI $uri, ?ResponseInterface $response
125125
$this->baseURI = $uri->useRawQueryString();
126126
$this->defaultOptions = $options;
127127

128-
/** @var ConfigCURLRequest|null $configCURLRequest */
129-
$configCURLRequest = config(ConfigCURLRequest::class);
130-
$this->shareOptions = $configCURLRequest->shareOptions ?? true;
128+
$this->shareOptions = config(ConfigCURLRequest::class)->shareOptions ?? true;
131129

132130
$this->config = $this->defaultConfig;
133131
$this->parseOptions($options);

system/I18n/TimeTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
trait TimeTrait
3333
{
3434
/**
35-
* @var DateTimeZone
35+
* @var DateTimeZone|string
3636
*/
3737
protected $timezone;
3838

system/Test/ReflectionHelper.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ trait ReflectionHelper
3131
* @param object|string $obj object or class name
3232
* @param string $method method name
3333
*
34-
* @return Closure
35-
* @phpstan-return Closure(mixed ...$args): mixed
34+
* @return Closure(mixed ...$args): mixed
3635
*
3736
* @throws ReflectionException
3837
*/

tests/system/Commands/Utilities/ConfigCheckTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ public function testCommandConfigCheckNonexistentClass(): void
8989

9090
public function testConfigCheckWithKintEnabledUsesKintD(): void
9191
{
92-
/** @var Closure(object): string $command */
92+
/**
93+
* @var Closure(mixed...): string
94+
*/
9395
$command = $this->getPrivateMethodInvoker(
9496
new ConfigCheck(service('logger'), service('commands')),
9597
'getKintD',
@@ -105,7 +107,9 @@ public function testConfigCheckWithKintEnabledUsesKintD(): void
105107

106108
public function testConfigCheckWithKintDisabledUsesVarDump(): void
107109
{
108-
/** @var Closure(object): string $command */
110+
/**
111+
* @var Closure(mixed...): string
112+
*/
109113
$command = $this->getPrivateMethodInvoker(
110114
new ConfigCheck(service('logger'), service('commands')),
111115
'getVarDump',

utils/phpstan-baseline/varTag.type.neon

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,7 @@
1-
# total 9 errors
1+
# total 2 errors
22

33
parameters:
44
ignoreErrors:
5-
-
6-
message: '#^PHPDoc tag @var with type list\<string\>\|Redis\|false is not subtype of type array\<int, string\>\|false\.$#'
7-
count: 1
8-
path: ../../system/Cache/Handlers/RedisHandler.php
9-
10-
-
11-
message: '#^PHPDoc tag @var with type Config\\Session\|null is not subtype of type Config\\Session\.$#'
12-
count: 1
13-
path: ../../system/Commands/Generators/MigrationGenerator.php
14-
15-
-
16-
message: '#^PHPDoc tag @var with type Config\\CURLRequest\|null is not subtype of type Config\\CURLRequest\.$#'
17-
count: 1
18-
path: ../../system/HTTP/CURLRequest.php
19-
20-
-
21-
message: '#^PHPDoc tag @var with type string is not subtype of type DateTimeZone\.$#'
22-
count: 1
23-
path: ../../system/I18n/Time.php
24-
25-
-
26-
message: '#^PHPDoc tag @var with type string is not subtype of type DateTimeZone\.$#'
27-
count: 1
28-
path: ../../system/I18n/TimeLegacy.php
29-
30-
-
31-
message: '#^PHPDoc tag @var with type Closure\(object\)\: string is not subtype of type Closure\(mixed \.\.\.\)\: mixed\.$#'
32-
count: 2
33-
path: ../../tests/system/Commands/Utilities/ConfigCheckTest.php
34-
355
-
366
message: '#^PHPDoc tag @var with type Tests\\Support\\Entity\\UserWithCasts is not subtype of type list\<array\{\}\>\|null\.$#'
377
count: 1

0 commit comments

Comments
 (0)