Skip to content

Commit 95c6573

Browse files
committed
refactor: split phpstan-baseline into smaller files
1 parent 0d3c3b1 commit 95c6573

File tree

80 files changed

+15406
-18274
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+15406
-18274
lines changed

composer.json

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,19 @@
1717
"psr/log": "^3.0"
1818
},
1919
"require-dev": {
20-
"codeigniter/phpstan-codeigniter": "^1.4",
20+
"codeigniter/phpstan-codeigniter": "^1.5",
2121
"fakerphp/faker": "^1.9",
2222
"kint-php/kint": "^5.0.4",
2323
"mikey179/vfsstream": "^1.6",
2424
"nexusphp/tachycardia": "^2.0",
2525
"phpstan/extension-installer": "^1.4",
26-
"phpstan/phpstan": "^1.11",
27-
"phpstan/phpstan-strict-rules": "^1.6",
26+
"phpstan/phpstan": "^2.0",
27+
"phpstan/phpstan-strict-rules": "^2.0",
2828
"phpunit/phpcov": "^9.0.2 || ^10.0",
2929
"phpunit/phpunit": "^10.5.16 || ^11.2",
3030
"predis/predis": "^1.1 || ^2.0",
31-
"rector/rector": "1.2.10"
31+
"rector/rector": "2.0.0-rc1",
32+
"shipmonk/phpstan-baseline-per-identifier": "^2.0"
3233
},
3334
"replace": {
3435
"codeigniter4/framework": "self.version"
@@ -110,7 +111,10 @@
110111
"utils/vendor/bin/php-cs-fixer fix --ansi --verbose --diff"
111112
],
112113
"metrics": "utils/vendor/bin/phpmetrics --config=phpmetrics.json",
113-
"phpstan:baseline": "vendor/bin/phpstan analyse --ansi --generate-baseline=phpstan-baseline.php",
114+
"phpstan:baseline": [
115+
"phpstan analyse --ansi --generate-baseline=utils/phpstan-baseline/loader.neon",
116+
"split-phpstan-baseline utils/phpstan-baseline/loader.neon"
117+
],
114118
"phpstan:check": "vendor/bin/phpstan analyse --verbose --ansi",
115119
"sa": "@analyze",
116120
"style": "@cs-fix",

phpstan-baseline.php

Lines changed: 0 additions & 18257 deletions
This file was deleted.

phpstan.neon.dist

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ services:
55
- phpstan.rules.rule
66

77
includes:
8-
- phpstan-baseline.php
8+
- utils/phpstan-baseline/loader.neon
99

1010
parameters:
1111
phpVersion: 80100
@@ -40,5 +40,6 @@ parameters:
4040
allRules: false
4141
disallowedLooseComparison: true
4242
booleansInConditions: true
43-
disallowedConstructs: true
4443
matchingInheritedMethodNames: true
44+
shipmonkBaselinePerIdentifier:
45+
directory: %currentWorkingDirectory%

system/Validation/Rules.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -359,10 +359,8 @@ public function required_with($str = null, ?string $fields = null, array $data =
359359

360360
foreach (explode(',', $fields) as $field) {
361361
if (
362-
(array_key_exists($field, $data)
363-
&& ! empty($data[$field])) // @phpstan-ignore-line Use empty()
364-
|| (str_contains($field, '.')
365-
&& ! empty(dot_array_search($field, $data))) // @phpstan-ignore-line Use empty()
362+
(array_key_exists($field, $data) && ! empty($data[$field]))
363+
|| (str_contains($field, '.') && ! empty(dot_array_search($field, $data)))
366364
) {
367365
$requiredFields[] = $field;
368366
}
@@ -409,7 +407,7 @@ public function required_without(
409407
if (
410408
(! str_contains($otherField, '.'))
411409
&& (! array_key_exists($otherField, $data)
412-
|| empty($data[$otherField])) // @phpstan-ignore-line Use empty()
410+
|| empty($data[$otherField]))
413411
) {
414412
return false;
415413
}
@@ -424,7 +422,7 @@ public function required_without(
424422
$fieldKey = $fieldSplitArray[1];
425423

426424
if (is_array($fieldData)) {
427-
return ! empty(dot_array_search($otherField, $data)[$fieldKey]); // @phpstan-ignore-line Use empty()
425+
return ! empty(dot_array_search($otherField, $data)[$fieldKey]);
428426
}
429427
$nowField = str_replace('*', $fieldKey, $otherField);
430428
$nowFieldVaule = dot_array_search($nowField, $data);

system/View/Filters.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,7 @@ public static function date_modify($value, string $adjustment)
7171
*/
7272
public static function default($value, string $default): string
7373
{
74-
return empty($value) // @phpstan-ignore-line
75-
? $default
76-
: $value;
74+
return empty($value) ? $default : $value;
7775
}
7876

7977
/**

tests/system/Debug/ExceptionsTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function testDeprecationsOnPhp81DoNotThrow(): void
7373
// We test DEPRECATED error, so cannot set `declare(strict_types=1)` in this file.
7474
strlen($maybeNull);
7575
$this->assertLogContains('error', '[DEPRECATED] strlen(): ');
76-
} catch (ErrorException) {
76+
} catch (ErrorException $e) {
7777
$this->fail('The catch block should not be reached.');
7878
} finally {
7979
restore_error_handler();

utils/phpstan-baseline/argument.type.neon

Lines changed: 378 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# total 1 error
2+
3+
parameters:
4+
ignoreErrors:
5+
-
6+
message: '#^Parameter \#1 \$array \(list\<mixed\>\) of array_values is already a list, call has no effect\.$#'
7+
count: 3
8+
path: ../../tests/system/Database/Live/MetadataTest.php
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# total 21 errors
2+
3+
parameters:
4+
ignoreErrors:
5+
-
6+
message: '#^Property CodeIgniter\\Controller\:\:\$request \(CodeIgniter\\HTTP\\CLIRequest\|CodeIgniter\\HTTP\\IncomingRequest\) does not accept CodeIgniter\\HTTP\\RequestInterface\.$#'
7+
count: 1
8+
path: ../../system/Controller.php
9+
10+
-
11+
message: '#^Property CodeIgniter\\Database\\Forge\:\:\$fields \(array\<string, array\|string\>\) does not accept array\<int\|string, int\<0, max\>\>\.$#'
12+
count: 1
13+
path: ../../system/Database/Forge.php
14+
15+
-
16+
message: '#^Property class@anonymous/tests/system/API/ResponseTraitTest\.php\:639\:\:\$format \(''html''\|''json''\|''xml''\|null\) does not accept ''txt''\.$#'
17+
count: 1
18+
path: ../../tests/system/API/ResponseTraitTest.php
19+
20+
-
21+
message: '#^Property CodeIgniter\\Commands\\Utilities\\Routes\\FilterFinderTest\:\:\$response \(CodeIgniter\\HTTP\\Response\) does not accept CodeIgniter\\HTTP\\ResponseInterface\.$#'
22+
count: 1
23+
path: ../../tests/system/Commands/Utilities/Routes/FilterFinderTest.php
24+
25+
-
26+
message: '#^Property CodeIgniter\\Database\\Live\\SQLite3\\AlterTableTest\:\:\$forge \(CodeIgniter\\Database\\SQLite3\\Forge\) does not accept CodeIgniter\\Database\\Forge\.$#'
27+
count: 1
28+
path: ../../tests/system/Database/Live/SQLite3/AlterTableTest.php
29+
30+
-
31+
message: '#^Property CodeIgniter\\Database\\Live\\SQLite3\\GetIndexDataTest\:\:\$db \(CodeIgniter\\Database\\SQLite3\\Connection\) does not accept CodeIgniter\\Database\\BaseConnection\.$#'
32+
count: 2
33+
path: ../../tests/system/Database/Live/SQLite3/GetIndexDataTest.php
34+
35+
-
36+
message: '#^Property CodeIgniter\\Database\\Live\\SQLite3\\GetIndexDataTest\:\:\$forge \(CodeIgniter\\Database\\SQLite3\\Forge\) does not accept CodeIgniter\\Database\\Forge\.$#'
37+
count: 1
38+
path: ../../tests/system/Database/Live/SQLite3/GetIndexDataTest.php
39+
40+
-
41+
message: '#^Property CodeIgniter\\Filters\\CSRFTest\:\:\$response \(CodeIgniter\\HTTP\\Response\|null\) does not accept CodeIgniter\\HTTP\\ResponseInterface\.$#'
42+
count: 2
43+
path: ../../tests/system/Filters/CSRFTest.php
44+
45+
-
46+
message: '#^Property CodeIgniter\\Filters\\DebugToolbarTest\:\:\$response \(CodeIgniter\\HTTP\\Response\) does not accept CodeIgniter\\HTTP\\ResponseInterface\.$#'
47+
count: 1
48+
path: ../../tests/system/Filters/DebugToolbarTest.php
49+
50+
-
51+
message: '#^Property CodeIgniter\\Filters\\FiltersTest\:\:\$response \(CodeIgniter\\HTTP\\Response\) does not accept CodeIgniter\\HTTP\\ResponseInterface\.$#'
52+
count: 1
53+
path: ../../tests/system/Filters/FiltersTest.php
54+
55+
-
56+
message: '#^Property CodeIgniter\\Filters\\HoneypotTest\:\:\$response \(CodeIgniter\\HTTP\\Response\|null\) does not accept CodeIgniter\\HTTP\\RequestInterface\|CodeIgniter\\HTTP\\ResponseInterface\|string\|null\.$#'
57+
count: 2
58+
path: ../../tests/system/Filters/HoneypotTest.php
59+
60+
-
61+
message: '#^Property CodeIgniter\\Filters\\HoneypotTest\:\:\$response \(CodeIgniter\\HTTP\\Response\|null\) does not accept CodeIgniter\\HTTP\\ResponseInterface\.$#'
62+
count: 4
63+
path: ../../tests/system/Filters/HoneypotTest.php
64+
65+
-
66+
message: '#^Property Config\\App\:\:\$proxyIPs \(array\<string, string\>\) does not accept array\<int, string\>\.$#'
67+
count: 1
68+
path: ../../tests/system/HTTP/IncomingRequestTest.php
69+
70+
-
71+
message: '#^Property Config\\App\:\:\$proxyIPs \(array\<string, string\>\) does not accept string\.$#'
72+
count: 1
73+
path: ../../tests/system/HTTP/IncomingRequestTest.php
74+
75+
-
76+
message: '#^Property CodeIgniter\\Helpers\\CookieHelperTest\:\:\$response \(CodeIgniter\\HTTP\\Response\) does not accept CodeIgniter\\HTTP\\ResponseInterface\.$#'
77+
count: 1
78+
path: ../../tests/system/Helpers/CookieHelperTest.php
79+
80+
-
81+
message: '#^Property CodeIgniter\\Honeypot\\HoneypotTest\:\:\$response \(CodeIgniter\\HTTP\\Response\) does not accept CodeIgniter\\HTTP\\RequestInterface\|CodeIgniter\\HTTP\\ResponseInterface\|string\|null\.$#'
82+
count: 1
83+
path: ../../tests/system/Honeypot/HoneypotTest.php
84+
85+
-
86+
message: '#^Property CodeIgniter\\Honeypot\\HoneypotTest\:\:\$response \(CodeIgniter\\HTTP\\Response\) does not accept CodeIgniter\\HTTP\\ResponseInterface\.$#'
87+
count: 3
88+
path: ../../tests/system/Honeypot/HoneypotTest.php
89+
90+
-
91+
message: '#^Property Config\\Cookie\:\:\$samesite \(''''\|''Lax''\|''None''\|''Strict''\) does not accept ''Invalid''\.$#'
92+
count: 1
93+
path: ../../tests/system/Session/SessionTest.php
94+
95+
-
96+
message: '#^Property CodeIgniter\\Test\\ControllerTestTraitTest\:\:\$uri \(string\) does not accept CodeIgniter\\HTTP\\SiteURI\.$#'
97+
count: 2
98+
path: ../../tests/system/Test/ControllerTestTraitTest.php
99+
100+
-
101+
message: '#^Property CodeIgniter\\View\\ParserPluginTest\:\:\$validator \(CodeIgniter\\Validation\\Validation\) does not accept CodeIgniter\\Validation\\ValidationInterface\.$#'
102+
count: 1
103+
path: ../../tests/system/View/ParserPluginTest.php
104+
105+
-
106+
message: '#^Property CodeIgniter\\View\\Table\:\:\$function \(\(callable\(\)\: mixed\)\|null\) does not accept ''ticklemyfancy''\.$#'
107+
count: 1
108+
path: ../../tests/system/View/TableTest.php
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# total 12 errors
2+
3+
parameters:
4+
ignoreErrors:
5+
-
6+
message: '#^Only booleans are allowed in &&, array\|int\|string\|null given on the left side\.$#'
7+
count: 1
8+
path: ../../system/BaseModel.php
9+
10+
-
11+
message: '#^Only booleans are allowed in &&, array\|string\|null given on the left side\.$#'
12+
count: 1
13+
path: ../../system/CLI/CLI.php
14+
15+
-
16+
message: '#^Only booleans are allowed in &&, string given on the left side\.$#'
17+
count: 1
18+
path: ../../system/Cache/Handlers/BaseHandler.php
19+
20+
-
21+
message: '#^Only booleans are allowed in &&, int given on the left side\.$#'
22+
count: 1
23+
path: ../../system/Commands/Server/Serve.php
24+
25+
-
26+
message: '#^Only booleans are allowed in &&, string\|null given on the left side\.$#'
27+
count: 3
28+
path: ../../system/Common.php
29+
30+
-
31+
message: '#^Only booleans are allowed in &&, string given on the left side\.$#'
32+
count: 1
33+
path: ../../system/Database/Forge.php
34+
35+
-
36+
message: '#^Only booleans are allowed in &&, int given on the left side\.$#'
37+
count: 1
38+
path: ../../system/Database/MySQLi/Connection.php
39+
40+
-
41+
message: '#^Only booleans are allowed in &&, int given on the left side\.$#'
42+
count: 1
43+
path: ../../system/Email/Email.php
44+
45+
-
46+
message: '#^Only booleans are allowed in &&, string\|null given on the left side\.$#'
47+
count: 1
48+
path: ../../system/HTTP/Response.php
49+
50+
-
51+
message: '#^Only booleans are allowed in &&, array given on the left side\.$#'
52+
count: 1
53+
path: ../../system/Model.php
54+
55+
-
56+
message: '#^Only booleans are allowed in &&, string\|null given on the left side\.$#'
57+
count: 1
58+
path: ../../system/Model.php
59+
60+
-
61+
message: '#^Only booleans are allowed in &&, array\<int\|string, array\|\(callable\)\> given on the left side\.$#'
62+
count: 1
63+
path: ../../system/Router/RouteCollection.php
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# total 1 error
2+
3+
parameters:
4+
ignoreErrors:
5+
-
6+
message: '#^Right side of && is always true\.$#'
7+
count: 1
8+
path: ../../system/Helpers/filesystem_helper.php
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# total 8 errors
2+
3+
parameters:
4+
ignoreErrors:
5+
-
6+
message: '#^Only booleans are allowed in &&, array\<string, string\> given on the right side\.$#'
7+
count: 1
8+
path: ../../system/BaseModel.php
9+
10+
-
11+
message: '#^Only booleans are allowed in &&, list\<string\> given on the right side\.$#'
12+
count: 1
13+
path: ../../system/CLI/CLI.php
14+
15+
-
16+
message: '#^Only booleans are allowed in &&, int\<0, max\> given on the right side\.$#'
17+
count: 1
18+
path: ../../system/Database/MigrationRunner.php
19+
20+
-
21+
message: '#^Only booleans are allowed in &&, string given on the right side\.$#'
22+
count: 1
23+
path: ../../system/Email/Email.php
24+
25+
-
26+
message: '#^Only booleans are allowed in &&, array\<mixed, mixed\> given on the right side\.$#'
27+
count: 2
28+
path: ../../system/HTTP/Files/FileCollection.php
29+
30+
-
31+
message: '#^Only booleans are allowed in &&, string\|null given on the right side\.$#'
32+
count: 1
33+
path: ../../system/HTTP/Response.php
34+
35+
-
36+
message: '#^Only booleans are allowed in &&, array\<string, string\> given on the right side\.$#'
37+
count: 4
38+
path: ../../system/HTTP/UserAgent.php
39+
40+
-
41+
message: '#^Only booleans are allowed in &&, string given on the right side\.$#'
42+
count: 2
43+
path: ../../system/Model.php

0 commit comments

Comments
 (0)