Skip to content

Commit 127243f

Browse files
authored
Update to PHPStan 2 (#40)
Baselining existing issue for now since most will likely become irrelevant soon I hope.
1 parent e56d8e3 commit 127243f

5 files changed

Lines changed: 193 additions & 13 deletions

File tree

.github/workflows/static-analysis.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ jobs:
1919

2020
- name: Setup PHP
2121
uses: shivammathur/setup-php@v2
22-
with:
23-
php-version: '8.2'
2422

2523
- name: Cache Composer packages
2624
id: composer-cache

.github/workflows/test.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ jobs:
2121
- 'low'
2222
php:
2323
- '8.2'
24+
- '8.3'
25+
- '8.4'
26+
- '8.5'
27+
- '8.6-dev'
2428

2529
steps:
2630
- name: Check out code

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
"php": "^8.2"
2626
},
2727
"require-dev": {
28-
"phpstan/phpstan": "^0.12.32",
29-
"phpstan/phpstan-phpunit": "^0.12",
28+
"phpstan/phpstan": "^2.0",
29+
"phpstan/phpstan-phpunit": "^2.0",
3030
"phpunit/phpunit": "^11.0 || ^12.0 || ^13.0",
3131
"squizlabs/php_codesniffer": "^4.0"
3232
},

phpstan-baseline.neon

Lines changed: 183 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,205 @@
11
parameters:
22
ignoreErrors:
33
-
4-
message: "#^Method Firehed\\\\Input\\\\Exceptions\\\\InputException\\:\\:__construct\\(\\) has parameter \\$errors with no value type specified in iterable type array\\.$#"
4+
message: '#^Binary operation "\." between non\-falsy\-string and mixed results in an error\.$#'
5+
identifier: binaryOp.invalid
6+
count: 2
7+
path: src/Containers/ParsedInput.php
8+
9+
-
10+
message: '#^Cannot access offset \(int\|string\) on mixed\.$#'
11+
identifier: offsetAccess.nonOffsetAccessible
12+
count: 1
13+
path: src/Containers/ParsedInput.php
14+
15+
-
16+
message: '#^Cannot access offset string on mixed\.$#'
17+
identifier: offsetAccess.nonOffsetAccessible
18+
count: 2
19+
path: src/Containers/ParsedInput.php
20+
21+
-
22+
message: '#^Method Firehed\\Input\\Containers\\ParsedInput\:\:asArray\(\) should return array\<mixed\> but returns mixed\.$#'
23+
identifier: return.type
24+
count: 1
25+
path: src/Containers/ParsedInput.php
26+
27+
-
28+
message: '#^Parameter \#1 \$array of function array_keys expects array, mixed given\.$#'
29+
identifier: argument.type
30+
count: 1
31+
path: src/Containers/ParsedInput.php
32+
33+
-
34+
message: '#^Parameter \#1 \.\.\.\$arrays of function array_merge expects array, mixed given\.$#'
35+
identifier: argument.type
36+
count: 1
37+
path: src/Containers/ParsedInput.php
38+
39+
-
40+
message: '#^Parameter \#2 \$array of function array_key_exists expects array, mixed given\.$#'
41+
identifier: argument.type
42+
count: 3
43+
path: src/Containers/ParsedInput.php
44+
45+
-
46+
message: '#^Parameter \#2 \.\.\.\$arrays of function array_merge expects array, mixed given\.$#'
47+
identifier: argument.type
48+
count: 1
49+
path: src/Containers/ParsedInput.php
50+
51+
-
52+
message: '#^Parameter \#1 \$data of class Firehed\\Input\\Containers\\ParsedInput constructor expects array\<mixed\>, mixed given\.$#'
53+
identifier: argument.type
54+
count: 1
55+
path: src/Containers/RawInput.php
56+
57+
-
58+
message: '#^Parameter \#1 \$raw_input of method Firehed\\Input\\Interfaces\\ParserInterface\:\:parse\(\) expects string, mixed given\.$#'
59+
identifier: argument.type
60+
count: 1
61+
path: src/Containers/RawInput.php
62+
63+
-
64+
message: '#^Parameter \#1 \$data of method Firehed\\Input\\Containers\\ParsedInput\:\:__construct\(\) expects array\<mixed\>, mixed given\.$#'
65+
identifier: argument.type
66+
count: 1
67+
path: src/Containers/SafeInput.php
68+
69+
-
70+
message: '#^Method Firehed\\Input\\Exceptions\\InputException\:\:__construct\(\) has parameter \$errors with no value type specified in iterable type array\.$#'
71+
identifier: missingType.iterableValue
72+
count: 1
73+
path: src/Exceptions/InputException.php
74+
75+
-
76+
message: '#^Property Firehed\\Input\\Exceptions\\InputException\:\:\$invalid \(array\<string\>\) does not accept array\.$#'
77+
identifier: assign.propertyType
78+
count: 1
79+
path: src/Exceptions/InputException.php
80+
81+
-
82+
message: '#^Property Firehed\\Input\\Exceptions\\InputException\:\:\$invalid \(array\<string\>\) does not accept mixed\.$#'
83+
identifier: assign.propertyType
84+
count: 1
85+
path: src/Exceptions/InputException.php
86+
87+
-
88+
message: '#^Property Firehed\\Input\\Exceptions\\InputException\:\:\$missing \(array\<string\>\) does not accept array\.$#'
89+
identifier: assign.propertyType
90+
count: 1
91+
path: src/Exceptions/InputException.php
92+
93+
-
94+
message: '#^Property Firehed\\Input\\Exceptions\\InputException\:\:\$missing \(array\<string\>\) does not accept mixed\.$#'
95+
identifier: assign.propertyType
96+
count: 1
97+
path: src/Exceptions/InputException.php
98+
99+
-
100+
message: '#^Property Firehed\\Input\\Exceptions\\InputException\:\:\$unexpected \(array\<string\>\) does not accept array\.$#'
101+
identifier: assign.propertyType
102+
count: 1
103+
path: src/Exceptions/InputException.php
104+
105+
-
106+
message: '#^Property Firehed\\Input\\Exceptions\\InputException\:\:\$unexpected \(array\<string\>\) does not accept mixed\.$#'
107+
identifier: assign.propertyType
5108
count: 1
6109
path: src/Exceptions/InputException.php
7110

8111
-
9-
message: "#^Method Firehed\\\\Input\\\\Containers\\\\ParsedInputTest\\:\\:nestedValidationExceptions\\(\\) has no return typehint specified\\.$#"
112+
message: '#^Call to function is_array\(\) with array\<int\|string, array\<mixed\>\|string\> will always evaluate to true\.$#'
113+
identifier: function.alreadyNarrowedType
114+
count: 1
115+
path: src/Parsers/URLEncoded.php
116+
117+
-
118+
message: '#^Trait Firehed\\Input\\SafeInputTestTrait is used zero times and is not analysed\.$#'
119+
identifier: trait.unused
10120
count: 1
121+
path: src/SafeInputTestTrait.php
122+
123+
-
124+
message: '#^Trait Firehed\\Input\\ValidationTestTrait is used zero times and is not analysed\.$#'
125+
identifier: trait.unused
126+
count: 1
127+
path: src/ValidationTestTrait.php
128+
129+
-
130+
message: '#^Call to method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''Firehed\\\\Input\\\\Containers\\\\SafeInput'' and Firehed\\Input\\Containers\\SafeInput will always evaluate to true\.$#'
131+
identifier: method.alreadyNarrowedType
132+
count: 3
11133
path: tests/Containers/ParsedInputTest.php
12134

13135
-
14-
message: "#^Method Firehed\\\\Input\\\\Containers\\\\ParsedInputTest\\:\\:testValidateHandlesInputExceptions\\(\\) has parameter \\$invalid with no value type specified in iterable type array\\.$#"
136+
message: '#^Call to method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''Firehed\\\\Input…'' and Firehed\\Input\\Containers\\SafeInput will always evaluate to true\.$#'
137+
identifier: method.alreadyNarrowedType
138+
count: 3
139+
path: tests/Containers/ParsedInputTest.php
140+
141+
-
142+
message: '#^Call to method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with arguments ''Firehed\\\\Input…'', Firehed\\Input\\Containers\\ParsedInput and ''Construct failed'' will always evaluate to true\.$#'
143+
identifier: method.alreadyNarrowedType
15144
count: 1
16145
path: tests/Containers/ParsedInputTest.php
17146

18147
-
19-
message: "#^Method Firehed\\\\Input\\\\Containers\\\\ParsedInputTest\\:\\:testValidateHandlesInputExceptions\\(\\) has parameter \\$missing with no value type specified in iterable type array\\.$#"
148+
message: '#^Method Firehed\\Input\\Containers\\ParsedInputTest\:\:nestedValidationExceptions\(\) return type has no value type specified in iterable type array\.$#'
149+
identifier: missingType.iterableValue
20150
count: 1
21151
path: tests/Containers/ParsedInputTest.php
22152

23153
-
24-
message: "#^Method Firehed\\\\Input\\\\Containers\\\\ParsedInputTest\\:\\:testValidateHandlesInputExceptions\\(\\) has parameter \\$unexpected with no value type specified in iterable type array\\.$#"
154+
message: '#^Method Firehed\\Input\\Containers\\ParsedInputTest\:\:testValidateHandlesInputExceptions\(\) has parameter \$invalid with no value type specified in iterable type array\.$#'
155+
identifier: missingType.iterableValue
25156
count: 1
26157
path: tests/Containers/ParsedInputTest.php
27158

159+
-
160+
message: '#^Method Firehed\\Input\\Containers\\ParsedInputTest\:\:testValidateHandlesInputExceptions\(\) has parameter \$missing with no value type specified in iterable type array\.$#'
161+
identifier: missingType.iterableValue
162+
count: 1
163+
path: tests/Containers/ParsedInputTest.php
164+
165+
-
166+
message: '#^Method Firehed\\Input\\Containers\\ParsedInputTest\:\:testValidateHandlesInputExceptions\(\) has parameter \$unexpected with no value type specified in iterable type array\.$#'
167+
identifier: missingType.iterableValue
168+
count: 1
169+
path: tests/Containers/ParsedInputTest.php
170+
171+
-
172+
message: '#^Call to method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with arguments ''Firehed\\\\Input…'', Firehed\\Input\\Containers\\ParsedInput and ''RawInput\:\:parse\(\)…'' will always evaluate to true\.$#'
173+
identifier: method.alreadyNarrowedType
174+
count: 1
175+
path: tests/Containers/RawInputTest.php
176+
177+
-
178+
message: '#^Call to method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with arguments ''Firehed\\\\Input…'', Firehed\\Input\\Containers\\RawInput and ''Construct failed'' will always evaluate to true\.$#'
179+
identifier: method.alreadyNarrowedType
180+
count: 1
181+
path: tests/Containers/RawInputTest.php
182+
183+
-
184+
message: '#^Call to method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''Firehed\\\\Input\\\\Containers\\\\SafeInput'' and Firehed\\Input\\Containers\\SafeInput will always evaluate to true\.$#'
185+
identifier: method.alreadyNarrowedType
186+
count: 1
187+
path: tests/Containers/SafeInputTest.php
188+
189+
-
190+
message: '#^Call to method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with arguments ''Firehed\\\\Input\\\\Exceptions\\\\InputException'', Firehed\\Input\\Exceptions\\InputException and non\-falsy\-string will always evaluate to true\.$#'
191+
identifier: method.alreadyNarrowedType
192+
count: 1
193+
path: tests/Exceptions/InputExceptionTest.php
194+
195+
-
196+
message: '#^Dead catch \- LogicException is never thrown in the try block\.$#'
197+
identifier: catch.neverThrown
198+
count: 1
199+
path: tests/Exceptions/InputExceptionTest.php
200+
201+
-
202+
message: '#^Call to method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''Firehed\\\\Input\\\\Objects\\\\InputObject'' and Firehed\\Input\\Objects\\InputObject will always evaluate to true\.$#'
203+
identifier: method.alreadyNarrowedType
204+
count: 1
205+
path: tests/Objects/InputObjectTest.php
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1+
# vim: ft=yaml
12
includes:
23
- phpstan-baseline.neon
34
- vendor/phpstan/phpstan-phpunit/extension.neon
45
parameters:
5-
excludes_analyse:
6-
- vendor
76
level: max
87
paths:
9-
- src
10-
- tests
8+
- .
9+
excludePaths:
10+
- vendor

0 commit comments

Comments
 (0)