Skip to content

Commit 747a38d

Browse files
committed
:octocat: phpstan 2.0
1 parent 98f1859 commit 747a38d

File tree

5 files changed

+84
-49
lines changed

5 files changed

+84
-49
lines changed

composer.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@
5858
"phpbench/phpbench": "^1.3",
5959
"phpunit/phpunit": "^11.3",
6060
"phpmd/phpmd": "^2.15",
61-
"phpstan/phpstan": "^1.12",
62-
"phpstan/phpstan-deprecation-rules": "^1.2",
61+
"phpstan/phpstan": "^2.0",
62+
"phpstan/phpstan-deprecation-rules": "^2.0",
6363
"setasign/fpdf": "^1.8.2",
6464
"slevomat/coding-standard": "^8.15",
6565
"squizlabs/php_codesniffer": "^3.10"

phpstan-baseline.neon

+82-41
Original file line numberDiff line numberDiff line change
@@ -1,206 +1,247 @@
11
parameters:
22
ignoreErrors:
33
-
4-
message: "#^Property chillerlan\\\\QRCodeBenchmark\\\\DecoderBenchmark\\:\\:\\$imageBlob \\(string\\) does not accept GdImage\\|string\\.$#"
4+
message: '#^Property chillerlan\\QRCodeBenchmark\\DecoderBenchmark\:\:\$imageBlob \(string\) does not accept GdImage\|string\.$#'
5+
identifier: assign.propertyType
56
count: 1
67
path: benchmark/DecoderBenchmark.php
78

89
-
9-
message: "#^Parameter \\#1 \\$segment of method chillerlan\\\\QRCode\\\\QRCode\\:\\:addSegment\\(\\) expects chillerlan\\\\QRCode\\\\Data\\\\QRDataModeInterface, object given\\.$#"
10+
message: '#^Parameter \#1 \$segment of method chillerlan\\QRCode\\QRCode\:\:addSegment\(\) expects chillerlan\\QRCode\\Data\\QRDataModeInterface, object given\.$#'
11+
identifier: argument.type
1012
count: 1
1113
path: benchmark/QRCodeBenchmark.php
1214

1315
-
14-
message: "#^Parameter \\#2 \\$dataSegments of class chillerlan\\\\QRCode\\\\Data\\\\QRData constructor expects array\\<chillerlan\\\\QRCode\\\\Data\\\\QRDataModeInterface\\>, array\\<int, object\\> given\\.$#"
16+
message: '#^Parameter \#2 \$dataSegments of class chillerlan\\QRCode\\Data\\QRData constructor expects array\<chillerlan\\QRCode\\Data\\QRDataModeInterface\>, array\<int, object\> given\.$#'
17+
identifier: argument.type
1518
count: 2
1619
path: benchmark/QRDataBenchmark.php
1720

1821
-
19-
message: "#^Parameter \\#1 \\$string of function strtolower expects string, int\\|string given\\.$#"
22+
message: '#^Parameter \#1 \$string of function strtolower expects string, int\|string given\.$#'
23+
identifier: argument.type
2024
count: 1
2125
path: benchmark/generate-markdown.php
2226

2327
-
24-
message: "#^Offset 'name' does not exist on array\\<int, mixed\\>\\.$#"
28+
message: '#^Offset ''name'' does not exist on array\<int, mixed\>\.$#'
29+
identifier: offsetAccess.notFound
2530
count: 1
2631
path: benchmark/parse-common.php
2732

2833
-
29-
message: "#^Offset 'results' does not exist on array\\<int, mixed\\>\\.$#"
34+
message: '#^Offset ''results'' does not exist on array\<int, mixed\>\.$#'
35+
identifier: offsetAccess.notFound
3036
count: 1
3137
path: benchmark/parse-common.php
3238

3339
-
34-
message: "#^Offset 0 does not exist on array\\{\\}\\.$#"
40+
message: '#^Offset 0 does not exist on array\{\}\.$#'
41+
identifier: offsetAccess.notFound
3542
count: 1
3643
path: benchmark/parse-common.php
3744

3845
-
39-
message: "#^Function chillerlan\\\\QRCodeBenchmark\\\\parseLine\\(\\) return type has no value type specified in iterable type array\\.$#"
46+
message: '#^Function chillerlan\\QRCodeBenchmark\\parseLine\(\) return type has no value type specified in iterable type array\.$#'
47+
identifier: missingType.iterableValue
4048
count: 1
4149
path: benchmark/parse-result.php
4250

4351
-
44-
message: "#^Parameter \\#1 \\$string of function trim expects string, string\\|false given\\.$#"
52+
message: '#^Parameter \#1 \$string of function trim expects string, string\|false given\.$#'
53+
identifier: argument.type
4554
count: 1
4655
path: benchmark/parse-result.php
4756

4857
-
49-
message: "#^Property chillerlan\\\\QRCode\\\\QROptions\\:\\:\\$eccLevel \\(int\\) does not accept string\\.$#"
58+
message: '#^Property chillerlan\\QRCode\\QROptions\:\:\$eccLevel \(int\) does not accept string\.$#'
59+
identifier: assign.propertyType
5060
count: 1
5161
path: examples/custom_output.php
5262

5363
-
54-
message: "#^Parameter \\#1 \\$width of function imagecreatetruecolor expects int\\<1, max\\>, int given\\.$#"
64+
message: '#^Parameter \#1 \$width of function imagecreatetruecolor expects int\<1, max\>, int given\.$#'
65+
identifier: argument.type
5566
count: 1
5667
path: examples/imageWithText.php
5768

5869
-
59-
message: "#^Parameter \\#2 \\$color of function imagecolortransparent expects int\\|null, int\\<0, max\\>\\|false given\\.$#"
70+
message: '#^Parameter \#2 \$color of function imagecolortransparent expects int\|null, int\<0, max\>\|false given\.$#'
71+
identifier: argument.type
6072
count: 1
6173
path: examples/imageWithText.php
6274

6375
-
64-
message: "#^Parameter \\#2 \\$height of function imagecreatetruecolor expects int\\<1, max\\>, int given\\.$#"
76+
message: '#^Parameter \#2 \$height of function imagecreatetruecolor expects int\<1, max\>, int given\.$#'
77+
identifier: argument.type
6578
count: 1
6679
path: examples/imageWithText.php
6780

6881
-
69-
message: "#^Parameter \\#6 \\$color of function imagechar expects int, int\\<0, max\\>\\|false given\\.$#"
82+
message: '#^Parameter \#6 \$color of function imagechar expects int, int\<0, max\>\|false given\.$#'
83+
identifier: argument.type
7084
count: 1
7185
path: examples/imageWithText.php
7286

7387
-
74-
message: "#^Parameter \\#6 \\$color of function imagefilledrectangle expects int, int\\<0, max\\>\\|false given\\.$#"
88+
message: '#^Parameter \#6 \$color of function imagefilledrectangle expects int, int\<0, max\>\|false given\.$#'
89+
identifier: argument.type
7590
count: 1
7691
path: examples/imageWithText.php
7792

7893
-
79-
message: "#^Parameter \\#1 \\(Intervention\\\\Image\\\\Interfaces\\\\ImageInterface\\|string\\) of echo cannot be converted to string\\.$#"
94+
message: '#^Parameter \#1 \(Intervention\\Image\\Interfaces\\ImageInterface\|string\) of echo cannot be converted to string\.$#'
95+
identifier: echo.nonString
8096
count: 1
8197
path: examples/intervention-image.php
8298

8399
-
84-
message: "#^Method RandomDotsSVGOutput\\:\\:collectModules\\(\\) should return array\\<int, mixed\\> but returns array\\<int\\|string, array\\<int, mixed\\>\\>\\.$#"
100+
message: '#^Method RandomDotsSVGOutput\:\:collectModules\(\) should return array\<int, mixed\> but returns array\<int\|string, list\<mixed\>\>\.$#'
101+
identifier: return.type
85102
count: 1
86103
path: examples/svgRandomColoredDots.php
87104

88105
-
89-
message: "#^Method RoundQuietzoneSVGoutput\\:\\:collectModules\\(\\) should return array\\<int, mixed\\> but returns array\\<int\\|string, array\\<int, mixed\\>\\>\\.$#"
106+
message: '#^Method RoundQuietzoneSVGoutput\:\:collectModules\(\) should return array\<int, mixed\> but returns array\<int\|string, list\<mixed\>\>\.$#'
107+
identifier: return.type
90108
count: 1
91109
path: examples/svgRoundQuietzone.php
92110

93111
-
94-
message: "#^Parameter \\#1 \\$data of function imagecreatefromstring expects string, string\\|false given\\.$#"
112+
message: '#^Parameter \#1 \$data of function imagecreatefromstring expects string, string\|false given\.$#'
113+
identifier: argument.type
95114
count: 1
96115
path: src/Common/GDLuminanceSource.php
97116

98117
-
99-
message: "#^Parameter \\#1 \\$gdImage of class chillerlan\\\\QRCode\\\\Common\\\\GDLuminanceSource constructor expects GdImage, GdImage\\|false given\\.$#"
118+
message: '#^Parameter \#1 \$gdImage of class chillerlan\\QRCode\\Common\\GDLuminanceSource constructor expects GdImage, GdImage\|false given\.$#'
119+
identifier: argument.type
100120
count: 2
101121
path: src/Common/GDLuminanceSource.php
102122

103123
-
104-
message: "#^Parameter \\#2 \\$color of function imagecolorsforindex expects int, int\\<0, max\\>\\|false given\\.$#"
124+
message: '#^Parameter \#2 \$color of function imagecolorsforindex expects int, int\<0, max\>\|false given\.$#'
125+
identifier: argument.type
105126
count: 1
106127
path: src/Common/GDLuminanceSource.php
107128

108129
-
109-
message: "#^Parameter \\#1 \\$maskPattern of class chillerlan\\\\QRCode\\\\Common\\\\MaskPattern constructor expects int, int\\|false given\\.$#"
130+
message: '#^Parameter \#1 \$maskPattern of class chillerlan\\QRCode\\Common\\MaskPattern constructor expects int, int\|false given\.$#'
131+
identifier: argument.type
110132
count: 1
111133
path: src/Common/MaskPattern.php
112134

113135
-
114-
message: "#^Method chillerlan\\\\QRCode\\\\Common\\\\Version\\:\\:getRSBlocks\\(\\) return type has no value type specified in iterable type array\\.$#"
136+
message: '#^Method chillerlan\\QRCode\\Common\\Version\:\:getRSBlocks\(\) return type has no value type specified in iterable type array\.$#'
137+
identifier: missingType.iterableValue
115138
count: 1
116139
path: src/Common/Version.php
117140

118141
-
119-
message: "#^Parameter \\#1 \\$encoding of function mb_detect_order expects non\\-empty\\-list\\<non\\-falsy\\-string\\>\\|non\\-falsy\\-string\\|null, array\\{string, 'UTF\\-8', 'GB2312', 'GB18030', 'CP936', 'EUC\\-CN', 'HZ'\\} given\\.$#"
142+
message: '#^Parameter \#1 \$encoding of function mb_detect_order expects non\-empty\-list\<non\-falsy\-string\>\|non\-falsy\-string\|null, array\{string, ''UTF\-8'', ''GB2312'', ''GB18030'', ''CP936'', ''EUC\-CN'', ''HZ''\} given\.$#'
143+
identifier: argument.type
120144
count: 1
121145
path: src/Data/Hanzi.php
122146

123147
-
124-
message: "#^Parameter \\#1 \\$encoding of function mb_detect_order expects non\\-empty\\-list\\<non\\-falsy\\-string\\>\\|non\\-falsy\\-string\\|null, array\\{string, 'UTF\\-8', 'SJIS', 'SJIS\\-2004'\\} given\\.$#"
148+
message: '#^Parameter \#1 \$encoding of function mb_detect_order expects non\-empty\-list\<non\-falsy\-string\>\|non\-falsy\-string\|null, array\{string, ''UTF\-8'', ''SJIS'', ''SJIS\-2004''\} given\.$#'
149+
identifier: argument.type
125150
count: 1
126151
path: src/Data/Kanji.php
127152

128153
-
129-
message: "#^Parameter \\#1 \\$version of class chillerlan\\\\QRCode\\\\Data\\\\ReedSolomonEncoder constructor expects chillerlan\\\\QRCode\\\\Common\\\\Version, chillerlan\\\\QRCode\\\\Common\\\\Version\\|null given\\.$#"
154+
message: '#^Parameter \#1 \$version of class chillerlan\\QRCode\\Data\\ReedSolomonEncoder constructor expects chillerlan\\QRCode\\Common\\Version, chillerlan\\QRCode\\Common\\Version\|null given\.$#'
155+
identifier: argument.type
130156
count: 1
131157
path: src/Data/QRMatrix.php
132158

133159
-
134-
message: "#^Parameter \\#2 \\$eccLevel of class chillerlan\\\\QRCode\\\\Data\\\\ReedSolomonEncoder constructor expects chillerlan\\\\QRCode\\\\Common\\\\EccLevel, chillerlan\\\\QRCode\\\\Common\\\\EccLevel\\|null given\\.$#"
160+
message: '#^Parameter \#2 \$eccLevel of class chillerlan\\QRCode\\Data\\ReedSolomonEncoder constructor expects chillerlan\\QRCode\\Common\\EccLevel, chillerlan\\QRCode\\Common\\EccLevel\|null given\.$#'
161+
identifier: argument.type
135162
count: 1
136163
path: src/Data/QRMatrix.php
137164

138165
-
139-
message: "#^Parameter \\#1 \\$maskPattern of method chillerlan\\\\QRCode\\\\Data\\\\QRMatrix\\:\\:mask\\(\\) expects chillerlan\\\\QRCode\\\\Common\\\\MaskPattern, chillerlan\\\\QRCode\\\\Common\\\\MaskPattern\\|null given\\.$#"
166+
message: '#^Parameter \#1 \$maskPattern of method chillerlan\\QRCode\\Data\\QRMatrix\:\:mask\(\) expects chillerlan\\QRCode\\Common\\MaskPattern, chillerlan\\QRCode\\Common\\MaskPattern\|null given\.$#'
167+
identifier: argument.type
140168
count: 1
141169
path: src/Decoder/BitMatrix.php
142170

143171
-
144-
message: "#^Parameter \\#1 \\$version of class chillerlan\\\\QRCode\\\\Data\\\\QRMatrix constructor expects chillerlan\\\\QRCode\\\\Common\\\\Version, chillerlan\\\\QRCode\\\\Common\\\\Version\\|null given\\.$#"
172+
message: '#^Parameter \#1 \$version of class chillerlan\\QRCode\\Data\\QRMatrix constructor expects chillerlan\\QRCode\\Common\\Version, chillerlan\\QRCode\\Common\\Version\|null given\.$#'
173+
identifier: argument.type
145174
count: 1
146175
path: src/Decoder/BitMatrix.php
147176

148177
-
149-
message: "#^Parameter \\#2 \\$b of method chillerlan\\\\QRCode\\\\Decoder\\\\BitMatrix\\:\\:numBitsDiffering\\(\\) expects int, int\\|null given\\.$#"
178+
message: '#^Parameter \#2 \$b of method chillerlan\\QRCode\\Decoder\\BitMatrix\:\:numBitsDiffering\(\) expects int, int\|null given\.$#'
179+
identifier: argument.type
150180
count: 1
151181
path: src/Decoder/BitMatrix.php
152182

153183
-
154-
message: "#^Parameter \\#2 \\$eccLevel of class chillerlan\\\\QRCode\\\\Data\\\\QRMatrix constructor expects chillerlan\\\\QRCode\\\\Common\\\\EccLevel, chillerlan\\\\QRCode\\\\Common\\\\EccLevel\\|null given\\.$#"
184+
message: '#^Parameter \#2 \$eccLevel of class chillerlan\\QRCode\\Data\\QRMatrix constructor expects chillerlan\\QRCode\\Common\\EccLevel, chillerlan\\QRCode\\Common\\EccLevel\|null given\.$#'
185+
identifier: argument.type
155186
count: 1
156187
path: src/Decoder/BitMatrix.php
157188

158189
-
159-
message: "#^Property chillerlan\\\\QRCode\\\\Decoder\\\\Decoder\\:\\:\\$options is never read, only written\\.$#"
190+
message: '#^Property chillerlan\\QRCode\\Decoder\\Decoder\:\:\$options is never read, only written\.$#'
191+
identifier: property.onlyWritten
160192
count: 1
161193
path: src/Decoder/Decoder.php
162194

163195
-
164-
message: "#^Method chillerlan\\\\QRCode\\\\Decoder\\\\ReedSolomonDecoder\\:\\:deinterleaveRawBytes\\(\\) return type has no value type specified in iterable type array\\.$#"
196+
message: '#^Method chillerlan\\QRCode\\Decoder\\ReedSolomonDecoder\:\:deinterleaveRawBytes\(\) return type has no value type specified in iterable type array\.$#'
197+
identifier: missingType.iterableValue
165198
count: 1
166199
path: src/Decoder/ReedSolomonDecoder.php
167200

168201
-
169-
message: "#^Parameter \\#1 \\$width of function imagecreatetruecolor expects int\\<1, max\\>, int given\\.$#"
202+
message: '#^Parameter \#1 \$width of function imagecreatetruecolor expects int\<1, max\>, int given\.$#'
203+
identifier: argument.type
170204
count: 1
171205
path: src/Output/QRGdImage.php
172206

173207
-
174-
message: "#^Parameter \\#2 \\$height of function imagecreatetruecolor expects int\\<1, max\\>, int given\\.$#"
208+
message: '#^Parameter \#2 \$height of function imagecreatetruecolor expects int\<1, max\>, int given\.$#'
209+
identifier: argument.type
175210
count: 1
176211
path: src/Output/QRGdImage.php
177212

178213
-
179-
message: "#^Method chillerlan\\\\QRCodeTest\\\\Common\\\\MaskPatternTest\\:\\:assertMask\\(\\) has parameter \\$expected with no value type specified in iterable type array\\.$#"
214+
message: '#^Method chillerlan\\QRCodeTest\\Common\\MaskPatternTest\:\:assertMask\(\) has parameter \$expected with no value type specified in iterable type array\.$#'
215+
identifier: missingType.iterableValue
180216
count: 1
181217
path: tests/Common/MaskPatternTest.php
182218

183219
-
184-
message: "#^Method chillerlan\\\\QRCodeTest\\\\Common\\\\MaskPatternTest\\:\\:maskPatternProvider\\(\\) return type has no value type specified in iterable type array\\.$#"
220+
message: '#^Method chillerlan\\QRCodeTest\\Common\\MaskPatternTest\:\:maskPatternProvider\(\) return type has no value type specified in iterable type array\.$#'
221+
identifier: missingType.iterableValue
185222
count: 1
186223
path: tests/Common/MaskPatternTest.php
187224

188225
-
189-
message: "#^Method chillerlan\\\\QRCodeTest\\\\Common\\\\MaskPatternTest\\:\\:testMask\\(\\) has parameter \\$expected with no value type specified in iterable type array\\.$#"
226+
message: '#^Method chillerlan\\QRCodeTest\\Common\\MaskPatternTest\:\:testMask\(\) has parameter \$expected with no value type specified in iterable type array\.$#'
227+
identifier: missingType.iterableValue
190228
count: 1
191229
path: tests/Common/MaskPatternTest.php
192230

193231
-
194-
message: "#^Parameter \\#1 \\$string of static method chillerlan\\\\QRCode\\\\Data\\\\QRDataModeInterface\\:\\:validateString\\(\\) expects string, string\\|false given\\.$#"
232+
message: '#^Parameter \#1 \$string of static method chillerlan\\QRCode\\Data\\QRDataModeInterface\:\:validateString\(\) expects string, string\|false given\.$#'
233+
identifier: argument.type
195234
count: 1
196235
path: tests/Data/DataInterfaceTestAbstract.php
197236

198237
-
199-
message: "#^Parameter \\#2 \\$to_encoding of function mb_convert_encoding expects string, string\\|null given\\.$#"
238+
message: '#^Parameter \#2 \$to_encoding of function mb_convert_encoding expects string, string\|null given\.$#'
239+
identifier: argument.type
200240
count: 1
201241
path: tests/Data/ECITest.php
202242

203243
-
204-
message: "#^Parameter \\#1 \\$blob of method chillerlan\\\\QRCode\\\\QRCode\\:\\:readFromBlob\\(\\) expects string, GdImage\\|string given\\.$#"
244+
message: '#^Parameter \#1 \$blob of method chillerlan\\QRCode\\QRCode\:\:readFromBlob\(\) expects string, GdImage\|string given\.$#'
245+
identifier: argument.type
205246
count: 1
206247
path: tests/Data/QRDataTest.php

src/Detector/PerspectiveTransform.php

-3
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,6 @@ private function set(
5151
return $this;
5252
}
5353

54-
/**
55-
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
56-
*/
5754
public function quadrilateralToQuadrilateral(
5855
float $x0, float $y0, float $x1, float $y1, float $x2, float $y2, float $x3, float $y3,
5956
float $x0p, float $y0p, float $x1p, float $y1p, float $x2p, float $y2p, float $x3p, float $y3p,

src/QRCode.php

-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
* @author Smiley <[email protected]>
77
* @copyright 2015 Smiley
88
* @license MIT
9-
*
10-
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
119
*/
1210
declare(strict_types=1);
1311

tests/QRMaxLengthTrait.php

-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ public static function getMaxLengthForMode(int $mode, Version $version, EccLevel
102102
throw new QRCodeException('invalid $ecc');
103103
}
104104

105-
/** @SuppressWarnings(PHPMD.UndefinedVariable) */
106105
$maxlength = static::MAX_LENGTH[$ver][$dataMode][$ecc];
107106

108107
// Hanzi mode sets an additional 4 bit long subset identifier

0 commit comments

Comments
 (0)