Skip to content

Commit 8698047

Browse files
committed
feat: update psalm 4 => 5
chore: migrate to PHPUnit11 chore: fix formatting
1 parent 8d53cbe commit 8698047

16 files changed

+45
-46
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424
"php": ">=8.1"
2525
},
2626
"require-dev": {
27-
"phpunit/phpunit": "^7.5 | ^8.0 | ^9.0",
27+
"phpunit/phpunit": "^10.5.17",
2828
"rector/rector": "^0.13.6",
2929
"symplify/easy-coding-standard": "^11.0",
30-
"vimeo/psalm": "^4.24"
30+
"vimeo/psalm": "^5.23.1"
3131
},
3232
"autoload": {
3333
"psr-4": {

lib/Common/BitMatrix.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public function set(int|float $x, int|float $y): void
113113
//$this->bits[$offset] = intval32bits($this->bits[$offset]);
114114

115115
//}
116-
//16777216
116+
//16777216
117117
}
118118

119119
public function _unset($x, $y): void

lib/Common/Detector/MathUtils.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ private function __construct()
3030
* values. -2.5 rounds to -3, not -2. For purposes here it makes no difference.
3131
*
3232
* @param float $d real value to round
33-
*
34-
* @return int {@code int}
33+
*
34+
* @return int
3535
*/
3636
public static function round(float $d)
3737
{

lib/Common/Detector/MonochromeRectangleDetector.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ private function findCornerFromCenter(
165165
): \Zxing\ResultPoint {
166166
$lastRange = null;
167167
for ($y = $centerY, $x = $centerX;
168-
$y < $bottom && $y >= $top && $x < $right && $x >= $left;
169-
$y += $deltaY, $x += $deltaX) {
168+
$y < $bottom && $y >= $top && $x < $right && $x >= $left;
169+
$y += $deltaY, $x += $deltaX) {
170170
$range = 0;
171171
if ($deltaX == 0) {
172172
// horizontal slices, up and down

lib/Common/Reedsolomon/GenericGF.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,13 @@ public function multiply(int|float|null $a, int|float|null $b)
172172
return $this->expTable[($this->logTable[$a] + $this->logTable[$b]) % ($this->size - 1)];
173173
}
174174

175+
/** @return int */
175176
public function getSize()
176177
{
177178
return $this->size;
178179
}
179180

181+
/** @return int */
180182
public function getGeneratorBase()
181183
{
182184
return $this->generatorBase;

lib/IMagickLuminanceSource.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,17 @@ public function rotateCounterClockwise45(): void
6161
* Converts shorthand memory notation value to bytes
6262
* From http://php.net/manual/en/function.ini-get.php
6363
*
64-
* @param int $val Memory size shorthand notation string
64+
* @param string $val Memory size shorthand notation string
65+
*
66+
* @return float|int|string
6567
*/
66-
protected static function kmgStringToBytes(string $val)
68+
protected static function kmgStringToBytes(string $val): int|float|string
6769
{
6870
$val = trim($val);
6971
$last = strtolower($val[strlen($val) - 1]);
7072
$val = substr($val, 0, -1);
7173
switch ($last) {
72-
// The 'G' modifier is available since PHP 5.1.0
74+
// The 'G' modifier is available since PHP 5.1.0
7375
case 'g':
7476
$val *= 1024;
7577
// no break

lib/Qrcode/Decoder/Decoder.php

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,13 @@ public function __construct()
4040
$this->rsDecoder = new ReedSolomonDecoder(GenericGF::$QR_CODE_FIELD_256);
4141
}
4242

43-
public function decode(BitMatrix|BitMatrixParser $variable, array|null $hints = null): string|DecoderResult
43+
/**
44+
* @throws FormatException
45+
* @throws ChecksumException
46+
*/
47+
public function decode(BitMatrix|BitMatrixParser $variable, array|null $hints = null): string|DecoderResult
4448
{
45-
if (is_array($variable)) {
46-
return $this->decodeImage($variable, $hints);
47-
} elseif ($variable instanceof BitMatrix) {
48-
return $this->decodeBits($variable, $hints);
49-
} elseif ($variable instanceof BitMatrixParser) {
50-
return $this->decodeParser($variable, $hints);
51-
}
52-
die('decode error Decoder.php');
49+
return $this->decodeBits($variable, $hints);
5350
}
5451

5552
/**
@@ -93,7 +90,6 @@ public function decodeImage(array $image, $hints = null): string|DecoderResult
9390
*/
9491
public function decodeBits(\Zxing\Common\BitMatrix $bits, $hints = null): string|DecoderResult
9592
{
96-
9793
// Construct a parser and read version, error-correction level
9894
$parser = new BitMatrixParser($bits);
9995
$fe = null;
@@ -107,7 +103,6 @@ public function decodeBits(\Zxing\Common\BitMatrix $bits, $hints = null): string
107103
}
108104

109105
try {
110-
111106
// Revert the bit matrix
112107
$parser->remask();
113108

lib/Qrcode/Detector/AlignmentPatternFinder.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public function find()
126126
return $this->possibleCenters[0];
127127
}
128128

129-
throw new NotFoundException("Bottom right alignment pattern not found");
129+
throw new NotFoundException("Bottom right alignment pattern not found");
130130
}
131131

132132
/**
@@ -198,9 +198,9 @@ private static function centerFromEnd(array $stateCount, int $end)
198198
* alignment pattern to see if the same proportion is detected.</p>
199199
*
200200
* @param int $startI row where an alignment pattern was detected
201-
* @param float $centerJ center of the section that appears to cross an alignment pattern
201+
* @param int $centerJ center of the section that appears to cross an alignment pattern
202202
* @param int $maxCount maximum reasonable number of modules that should be
203-
* observed in any reading state, based on the results of the horizontal scan
203+
* observed in any reading state, based on the results of the horizontal scan
204204
*
205205
* @return float vertical center of alignment pattern, or {@link Float#NaN} if not found
206206
*/

lib/Qrcode/Detector/Detector.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
use Zxing\DecodeHintType;
2626
use Zxing\FormatException;
2727
use Zxing\NotFoundException;
28-
use Zxing\Qrcode\Decoder\Version;
2928
use Zxing\ResultPoint;
3029
use Zxing\ResultPointCallback;
3130

@@ -54,7 +53,6 @@ public function __construct(private BitMatrix $image)
5453
*/
5554
final public function detect(array $hints = null): DetectorResult
5655
{/*Map<DecodeHintType,?>*/
57-
5856
$resultPointCallback = ($hints !== null && array_key_exists('NEED_RESULT_POINT_CALLBACK', $hints)) ?
5957
$hints['NEED_RESULT_POINT_CALLBACK'] : null;
6058
/* resultPointCallback = hints == null ? null :
@@ -82,7 +80,6 @@ final protected function processFinderPatternInfo(FinderPatternInfo $info): \Zxi
8280
$alignmentPattern = null;
8381
// Anything above version 1 has an alignment pattern
8482
if ((is_countable($provisionalVersion->getAlignmentPatternCenters()) ? count($provisionalVersion->getAlignmentPatternCenters()) : 0) > 0) {
85-
8683
// Guess where a "bottom right" finder pattern would have been
8784
$bottomRightX = $topRight->getX() - $topLeft->getX() + $bottomLeft->getX();
8885
$bottomRightY = $topRight->getY() - $topLeft->getY() + $bottomLeft->getY();
@@ -405,7 +402,7 @@ private static function createTransform(
405402
}
406403

407404
private static function sampleGrid(
408-
$image,
405+
BitMatrix $image,
409406
PerspectiveTransform $transform,
410407
int $dimension
411408
): \Zxing\Common\BitMatrix {
@@ -414,7 +411,7 @@ private static function sampleGrid(
414411
return $sampler->sampleGrid_($image, $dimension, $dimension, $transform);
415412
}
416413

417-
final protected function getImage()
414+
final protected function getImage(): BitMatrix
418415
{
419416
return $this->image;
420417
}

lib/Qrcode/Detector/FinderPattern.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
namespace Zxing\Qrcode\Detector;
1919

20-
use Zxing\ResultPoint;
20+
use Zxing\ResultPoint;
2121

2222
/**
2323
* <p>Encapsulates a finder pattern, which are the three square patterns found in

0 commit comments

Comments
 (0)