Skip to content

Commit d65911a

Browse files
committed
:octocat: dependency update & phpstan happy
1 parent 48747ae commit d65911a

File tree

9 files changed

+65
-31
lines changed

9 files changed

+65
-31
lines changed

.idea/inspectionProfiles/Project_Default.xml

Lines changed: 1 addition & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@
5858
"phpbench/phpbench": "^1.4",
5959
"phpunit/phpunit": "^11.5",
6060
"phpmd/phpmd": "^2.15",
61-
"phpstan/phpstan": "^2.1.13",
61+
"phpstan/phpstan": "^2.1.17",
6262
"phpstan/phpstan-deprecation-rules": "^2.0",
6363
"setasign/fpdf": "^1.8.6",
64-
"slevomat/coding-standard": "^8.15",
65-
"squizlabs/php_codesniffer": "^3.12"
64+
"slevomat/coding-standard": "^8.19",
65+
"squizlabs/php_codesniffer": "^3.13"
6666
},
6767
"suggest": {
6868
"chillerlan/php-authenticator": "Yet another Google authenticator! Also creates URIs for mobile apps.",

phpcs.xml.dist

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,6 @@
143143
<rule ref="Generic.ControlStructures.InlineControlStructure"/>
144144
<rule ref="Generic.Formatting.DisallowMultipleStatements"/>
145145
<!--<rule ref="Generic.Formatting.MultipleStatementAlignment"/>-->
146-
<rule ref="Generic.Formatting.NoSpaceAfterCast"/>
147-
<rule ref="Generic.Functions.CallTimePassByReference"/>
148146
<rule ref="Generic.NamingConventions.InterfaceNameSuffix"/>
149147
<rule ref="Generic.NamingConventions.TraitNameSuffix"/>
150148
<rule ref="Generic.PHP.BacktickOperator"/>
@@ -179,7 +177,6 @@
179177

180178

181179
<rule ref="Squiz.Arrays.ArrayBracketSpacing"/>
182-
<rule ref="Squiz.Classes.DuplicateProperty"/>
183180
<rule ref="Squiz.Classes.LowercaseClassKeywords"/>
184181
<rule ref="Squiz.Classes.SelfMemberReference"/>
185182
<rule ref="Squiz.Commenting.DocCommentAlignment"/>
@@ -237,6 +234,12 @@
237234
<exclude-pattern>examples</exclude-pattern>
238235
</rule>
239236

237+
<rule ref="Generic.Formatting.SpaceAfterCast">
238+
<properties>
239+
<property name="spacing" value="0"/>
240+
</properties>
241+
</rule>
242+
240243
<rule ref="Generic.Formatting.SpaceAfterNot">
241244
<properties>
242245
<property name="spacing" value="0" />

phpstan-baseline.neon

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,12 +240,36 @@ parameters:
240240
count: 1
241241
path: tests/Data/DataInterfaceTestAbstract.php
242242

243+
-
244+
message: '#^Parameter \#1 \$data of class chillerlan\\QRCode\\Data\\Byte constructor expects string, string\|false given\.$#'
245+
identifier: argument.type
246+
count: 1
247+
path: tests/Data/ECITest.php
248+
243249
-
244250
message: '#^Parameter \#2 \$to_encoding of function mb_convert_encoding expects string, string\|null given\.$#'
245251
identifier: argument.type
246252
count: 1
247253
path: tests/Data/ECITest.php
248254

255+
-
256+
message: '#^Parameter \#1 \$string of function bin2hex expects string, string\|false given\.$#'
257+
identifier: argument.type
258+
count: 1
259+
path: tests/Data/HanziTest.php
260+
261+
-
262+
message: '#^Anonymous function should return string but returns string\|false\.$#'
263+
identifier: return.type
264+
count: 1
265+
path: tests/Data/KanjiTest.php
266+
267+
-
268+
message: '#^Parameter \#1 \$string of function bin2hex expects string, string\|false given\.$#'
269+
identifier: argument.type
270+
count: 1
271+
path: tests/Data/KanjiTest.php
272+
249273
-
250274
message: '#^Parameter \#1 \$blob of method chillerlan\\QRCode\\QRCode\:\:readFromBlob\(\) expects string, GdImage\|string given\.$#'
251275
identifier: argument.type

src/Data/ECI.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,13 @@ public static function decodeSegment(BitBuffer $bitBuffer, int $versionNumber):s
151151
}
152152
}
153153

154-
return mb_convert_encoding($data, mb_internal_encoding(), $encoding);
154+
$encoded = mb_convert_encoding($data, mb_internal_encoding(), $encoding);
155+
156+
if($encoded === false){
157+
throw new QRCodeDataException('mb_convert_encoding() error'); // @codeCoverageIgnore
158+
}
159+
160+
return $encoded;
155161
}
156162

157163
}

src/Data/Hanzi.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,13 @@ public static function decodeSegment(BitBuffer $bitBuffer, int $versionNumber):s
188188
$length--;
189189
}
190190

191-
return mb_convert_encoding(implode('', $buffer), mb_internal_encoding(), self::ENCODING);
191+
$encoded = mb_convert_encoding(implode('', $buffer), mb_internal_encoding(), self::ENCODING);
192+
193+
if($encoded === false){
194+
throw new QRCodeDataException('mb_convert_encoding() error'); // @codeCoverageIgnore
195+
}
196+
197+
return $encoded;
192198
}
193199

194200
}

src/Data/Kanji.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,13 @@ public static function decodeSegment(BitBuffer $bitBuffer, int $versionNumber):s
174174
$length--;
175175
}
176176

177-
return mb_convert_encoding(implode('', $buffer), mb_internal_encoding(), self::ENCODING);
177+
$encoded = mb_convert_encoding(implode('', $buffer), mb_internal_encoding(), self::ENCODING);
178+
179+
if($encoded === false){
180+
throw new QRCodeDataException('mb_convert_encoding() error'); // @codeCoverageIgnore
181+
}
182+
183+
return $encoded;
178184
}
179185

180186
}

src/Decoder/Decoder.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ final class Decoder{
3333
private EccLevel|null $eccLevel = null;
3434
private MaskPattern|null $maskPattern = null;
3535
private BitBuffer $bitBuffer;
36+
/** @noinspection PhpPropertyOnlyWrittenInspection (currently unused) */
37+
private SettingsContainerInterface|QROptions $options;
38+
private Version|null $version = null;
39+
private EccLevel|null $eccLevel = null;
40+
private MaskPattern|null $maskPattern = null;
41+
private BitBuffer $bitBuffer;
3642

3743
public function __construct(SettingsContainerInterface|QROptions $options = new QROptions){
3844
$this->options = $options;

src/QRCode.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,10 @@ public function addEciSegment(int $encoding, string $data):static{
262262
if($eciCharsetName !== null){
263263
$data = mb_convert_encoding($data, $eciCharsetName, mb_internal_encoding());
264264

265+
if($data === false){
266+
throw new QRCodeException('mb_convert_encoding() error'); // @codeCoverageIgnore
267+
}
268+
265269
return $this
266270
->addEciDesignator($eciCharset->getID())
267271
->addByteSegment($data)

0 commit comments

Comments
 (0)