@@ -18,16 +18,16 @@ discard block |
||
18 | 18 | */ |
19 | 19 | final class ECICharset{ |
20 | 20 | |
21 | - public const CP437 = 0; // Code page 437, DOS Latin US |
|
22 | - public const ISO_IEC_8859_1_GLI = 1; // GLI encoding with characters 0 to 127 identical to ISO/IEC 646 and characters 128 to 255 identical to ISO 8859-1 |
|
23 | - public const CP437_WO_GLI = 2; // An equivalent code table to CP437, without the return-to-GLI 0 logic |
|
24 | - public const ISO_IEC_8859_1 = 3; // Latin-1 (Default) |
|
25 | - public const ISO_IEC_8859_2 = 4; // Latin-2 |
|
26 | - public const ISO_IEC_8859_3 = 5; // Latin-3 |
|
27 | - public const ISO_IEC_8859_4 = 6; // Latin-4 |
|
28 | - public const ISO_IEC_8859_5 = 7; // Latin/Cyrillic |
|
29 | - public const ISO_IEC_8859_6 = 8; // Latin/Arabic |
|
30 | - public const ISO_IEC_8859_7 = 9; // Latin/Greek |
|
21 | + public const CP437 = 0; // Code page 437, DOS Latin US |
|
22 | + public const ISO_IEC_8859_1_GLI = 1; // GLI encoding with characters 0 to 127 identical to ISO/IEC 646 and characters 128 to 255 identical to ISO 8859-1 |
|
23 | + public const CP437_WO_GLI = 2; // An equivalent code table to CP437, without the return-to-GLI 0 logic |
|
24 | + public const ISO_IEC_8859_1 = 3; // Latin-1 (Default) |
|
25 | + public const ISO_IEC_8859_2 = 4; // Latin-2 |
|
26 | + public const ISO_IEC_8859_3 = 5; // Latin-3 |
|
27 | + public const ISO_IEC_8859_4 = 6; // Latin-4 |
|
28 | + public const ISO_IEC_8859_5 = 7; // Latin/Cyrillic |
|
29 | + public const ISO_IEC_8859_6 = 8; // Latin/Arabic |
|
30 | + public const ISO_IEC_8859_7 = 9; // Latin/Greek |
|
31 | 31 | public const ISO_IEC_8859_8 = 10; // Latin/Hebrew |
32 | 32 | public const ISO_IEC_8859_9 = 11; // Latin-5 |
33 | 33 | public const ISO_IEC_8859_10 = 12; // Latin-6 |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | * @see \mb_convert_encoding() |
118 | 118 | * @see \iconv() |
119 | 119 | */ |
120 | - public function getName():?string{ |
|
120 | + public function getName(): ?string{ |
|
121 | 121 | return self::MB_ENCODINGS[$this->charsetID]; |
122 | 122 | } |
123 | 123 |
@@ -60,7 +60,7 @@ |
||
60 | 60 | protected function setLuminancePixels():void{ |
61 | 61 | |
62 | 62 | if($this->options->readerGrayscale){ |
63 | - imagefilter($this->gdImage, IMG_FILTER_GRAYSCALE); |
|
63 | + imagefilter($this->gdImage, IMG_FILTER_GRAYSCALE); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | if($this->options->readerIncreaseContrast){ |
@@ -67,12 +67,12 @@ |
||
67 | 67 | |
68 | 68 | if(($firstByte & 0xc0) === 0x80){ |
69 | 69 | // two bytes |
70 | - return new ECICharset((($firstByte & 0x3f) << 8) | $bitBuffer->read(8)); |
|
70 | + return new ECICharset((($firstByte & 0x3f) << 8)|$bitBuffer->read(8)); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | if(($firstByte & 0xe0) === 0xC0){ |
74 | 74 | // three bytes |
75 | - return new ECICharset((($firstByte & 0x1f) << 16) | $bitBuffer->read(16)); |
|
75 | + return new ECICharset((($firstByte & 0x1f) << 16)|$bitBuffer->read(16)); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | throw new QRCodeDataException('error decoding ECI value'); |
@@ -37,46 +37,46 @@ discard block |
||
37 | 37 | */ |
38 | 38 | private const MAX_BITS = [ |
39 | 39 | // [ L, M, Q, H] // v => modules |
40 | - [ null, null, null, null], // 0 => will be ignored, index starts at 1 |
|
41 | - [ 152, 128, 104, 72], // 1 => 21 |
|
42 | - [ 272, 224, 176, 128], // 2 => 25 |
|
43 | - [ 440, 352, 272, 208], // 3 => 29 |
|
44 | - [ 640, 512, 384, 288], // 4 => 33 |
|
45 | - [ 864, 688, 496, 368], // 5 => 37 |
|
46 | - [ 1088, 864, 608, 480], // 6 => 41 |
|
47 | - [ 1248, 992, 704, 528], // 7 => 45 |
|
48 | - [ 1552, 1232, 880, 688], // 8 => 49 |
|
49 | - [ 1856, 1456, 1056, 800], // 9 => 53 |
|
50 | - [ 2192, 1728, 1232, 976], // 10 => 57 |
|
51 | - [ 2592, 2032, 1440, 1120], // 11 => 61 |
|
52 | - [ 2960, 2320, 1648, 1264], // 12 => 65 |
|
53 | - [ 3424, 2672, 1952, 1440], // 13 => 69 NICE! |
|
54 | - [ 3688, 2920, 2088, 1576], // 14 => 73 |
|
55 | - [ 4184, 3320, 2360, 1784], // 15 => 77 |
|
56 | - [ 4712, 3624, 2600, 2024], // 16 => 81 |
|
57 | - [ 5176, 4056, 2936, 2264], // 17 => 85 |
|
58 | - [ 5768, 4504, 3176, 2504], // 18 => 89 |
|
59 | - [ 6360, 5016, 3560, 2728], // 19 => 93 |
|
60 | - [ 6888, 5352, 3880, 3080], // 20 => 97 |
|
61 | - [ 7456, 5712, 4096, 3248], // 21 => 101 |
|
62 | - [ 8048, 6256, 4544, 3536], // 22 => 105 |
|
63 | - [ 8752, 6880, 4912, 3712], // 23 => 109 |
|
64 | - [ 9392, 7312, 5312, 4112], // 24 => 113 |
|
65 | - [10208, 8000, 5744, 4304], // 25 => 117 |
|
66 | - [10960, 8496, 6032, 4768], // 26 => 121 |
|
67 | - [11744, 9024, 6464, 5024], // 27 => 125 |
|
68 | - [12248, 9544, 6968, 5288], // 28 => 129 |
|
69 | - [13048, 10136, 7288, 5608], // 29 => 133 |
|
70 | - [13880, 10984, 7880, 5960], // 30 => 137 |
|
71 | - [14744, 11640, 8264, 6344], // 31 => 141 |
|
72 | - [15640, 12328, 8920, 6760], // 32 => 145 |
|
73 | - [16568, 13048, 9368, 7208], // 33 => 149 |
|
74 | - [17528, 13800, 9848, 7688], // 34 => 153 |
|
75 | - [18448, 14496, 10288, 7888], // 35 => 157 |
|
76 | - [19472, 15312, 10832, 8432], // 36 => 161 |
|
77 | - [20528, 15936, 11408, 8768], // 37 => 165 |
|
78 | - [21616, 16816, 12016, 9136], // 38 => 169 |
|
79 | - [22496, 17728, 12656, 9776], // 39 => 173 |
|
40 | + [null, null, null, null], // 0 => will be ignored, index starts at 1 |
|
41 | + [152, 128, 104, 72], // 1 => 21 |
|
42 | + [272, 224, 176, 128], // 2 => 25 |
|
43 | + [440, 352, 272, 208], // 3 => 29 |
|
44 | + [640, 512, 384, 288], // 4 => 33 |
|
45 | + [864, 688, 496, 368], // 5 => 37 |
|
46 | + [1088, 864, 608, 480], // 6 => 41 |
|
47 | + [1248, 992, 704, 528], // 7 => 45 |
|
48 | + [1552, 1232, 880, 688], // 8 => 49 |
|
49 | + [1856, 1456, 1056, 800], // 9 => 53 |
|
50 | + [2192, 1728, 1232, 976], // 10 => 57 |
|
51 | + [2592, 2032, 1440, 1120], // 11 => 61 |
|
52 | + [2960, 2320, 1648, 1264], // 12 => 65 |
|
53 | + [3424, 2672, 1952, 1440], // 13 => 69 NICE! |
|
54 | + [3688, 2920, 2088, 1576], // 14 => 73 |
|
55 | + [4184, 3320, 2360, 1784], // 15 => 77 |
|
56 | + [4712, 3624, 2600, 2024], // 16 => 81 |
|
57 | + [5176, 4056, 2936, 2264], // 17 => 85 |
|
58 | + [5768, 4504, 3176, 2504], // 18 => 89 |
|
59 | + [6360, 5016, 3560, 2728], // 19 => 93 |
|
60 | + [6888, 5352, 3880, 3080], // 20 => 97 |
|
61 | + [7456, 5712, 4096, 3248], // 21 => 101 |
|
62 | + [8048, 6256, 4544, 3536], // 22 => 105 |
|
63 | + [8752, 6880, 4912, 3712], // 23 => 109 |
|
64 | + [9392, 7312, 5312, 4112], // 24 => 113 |
|
65 | + [10208, 8000, 5744, 4304], // 25 => 117 |
|
66 | + [10960, 8496, 6032, 4768], // 26 => 121 |
|
67 | + [11744, 9024, 6464, 5024], // 27 => 125 |
|
68 | + [12248, 9544, 6968, 5288], // 28 => 129 |
|
69 | + [13048, 10136, 7288, 5608], // 29 => 133 |
|
70 | + [13880, 10984, 7880, 5960], // 30 => 137 |
|
71 | + [14744, 11640, 8264, 6344], // 31 => 141 |
|
72 | + [15640, 12328, 8920, 6760], // 32 => 145 |
|
73 | + [16568, 13048, 9368, 7208], // 33 => 149 |
|
74 | + [17528, 13800, 9848, 7688], // 34 => 153 |
|
75 | + [18448, 14496, 10288, 7888], // 35 => 157 |
|
76 | + [19472, 15312, 10832, 8432], // 36 => 161 |
|
77 | + [20528, 15936, 11408, 8768], // 37 => 165 |
|
78 | + [21616, 16816, 12016, 9136], // 38 => 169 |
|
79 | + [22496, 17728, 12656, 9776], // 39 => 173 |
|
80 | 80 | [23648, 18672, 13328, 10208], // 40 => 177 |
81 | 81 | ]; |
82 | 82 | |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | * @var int[][] |
89 | 89 | */ |
90 | 90 | private const FORMAT_PATTERN = [ |
91 | - [ // L |
|
91 | + [// L |
|
92 | 92 | 0b111011111000100, |
93 | 93 | 0b111001011110011, |
94 | 94 | 0b111110110101010, |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | 0b110110001000001, |
99 | 99 | 0b110100101110110, |
100 | 100 | ], |
101 | - [ // M |
|
101 | + [// M |
|
102 | 102 | 0b101010000010010, |
103 | 103 | 0b101000100100101, |
104 | 104 | 0b101111001111100, |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | 0b100111110010111, |
109 | 109 | 0b100101010100000, |
110 | 110 | ], |
111 | - [ // Q |
|
111 | + [// Q |
|
112 | 112 | 0b011010101011111, |
113 | 113 | 0b011000001101000, |
114 | 114 | 0b011111100110001, |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | 0b010111011011010, |
119 | 119 | 0b010101111101101, |
120 | 120 | ], |
121 | - [ // H |
|
121 | + [// H |
|
122 | 122 | 0b001011010001001, |
123 | 123 | 0b001001110111110, |
124 | 124 | 0b001110011100111, |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | */ |
148 | 148 | public function __construct(int $eccLevel){ |
149 | 149 | |
150 | - if((0b11 & $eccLevel) !== $eccLevel){ |
|
150 | + if((0b11&$eccLevel) !== $eccLevel){ |
|
151 | 151 | throw new QRCodeException('invalid ECC level'); |
152 | 152 | } |
153 | 153 |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | * @return float|null vertical center of finder pattern, or null if not found |
331 | 331 | * @noinspection DuplicatedCode |
332 | 332 | */ |
333 | - private function crossCheckVertical(int $startI, int $centerJ, int $maxCount, int $originalStateCountTotal):?float{ |
|
333 | + private function crossCheckVertical(int $startI, int $centerJ, int $maxCount, int $originalStateCountTotal): ?float{ |
|
334 | 334 | $maxI = $this->matrix->size(); |
335 | 335 | $stateCount = $this->getCrossCheckStateCount(); |
336 | 336 | |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | * check a vertical cross-check and locate the real center of the alignment pattern. |
415 | 415 | * @noinspection DuplicatedCode |
416 | 416 | */ |
417 | - private function crossCheckHorizontal(int $startJ, int $centerI, int $maxCount, int $originalStateCountTotal):?float{ |
|
417 | + private function crossCheckHorizontal(int $startJ, int $centerI, int $maxCount, int $originalStateCountTotal): ?float{ |
|
418 | 418 | $maxJ = $this->matrix->size(); |
419 | 419 | $stateCount = $this->getCrossCheckStateCount(); |
420 | 420 |
@@ -457,7 +457,7 @@ |
||
457 | 457 | /** |
458 | 458 | * clamp the logo space values between 0 and maximum length (177 modules at version 40) |
459 | 459 | */ |
460 | - protected function clampLogoSpaceValue(?int $value):?int{ |
|
460 | + protected function clampLogoSpaceValue(?int $value): ?int{ |
|
461 | 461 | |
462 | 462 | if($value === null){ |
463 | 463 | return null; |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | * @see \chillerlan\QRCode\Common\Version::AUTO |
36 | 36 | * @var int |
37 | 37 | */ |
38 | - public const VERSION_AUTO = Version::AUTO; |
|
38 | + public const VERSION_AUTO = Version::AUTO; |
|
39 | 39 | |
40 | 40 | /** |
41 | 41 | * @deprecated 5.0.0 use MaskPattern::AUTO instead |
@@ -84,28 +84,28 @@ discard block |
||
84 | 84 | * @see \chillerlan\QRCode\Output\QROutputInterface::MARKUP_SVG |
85 | 85 | * @var string |
86 | 86 | */ |
87 | - public const OUTPUT_MARKUP_SVG = QROutputInterface::MARKUP_SVG; |
|
87 | + public const OUTPUT_MARKUP_SVG = QROutputInterface::MARKUP_SVG; |
|
88 | 88 | |
89 | 89 | /** |
90 | 90 | * @deprecated 5.0.0 use QROutputInterface::GDIMAGE_PNG instead |
91 | 91 | * @see \chillerlan\QRCode\Output\QROutputInterface::GDIMAGE_PNG |
92 | 92 | * @var string |
93 | 93 | */ |
94 | - public const OUTPUT_IMAGE_PNG = QROutputInterface::GDIMAGE_PNG; |
|
94 | + public const OUTPUT_IMAGE_PNG = QROutputInterface::GDIMAGE_PNG; |
|
95 | 95 | |
96 | 96 | /** |
97 | 97 | * @deprecated 5.0.0 use QROutputInterface::GDIMAGE_JPG instead |
98 | 98 | * @see \chillerlan\QRCode\Output\QROutputInterface::GDIMAGE_JPG |
99 | 99 | * @var string |
100 | 100 | */ |
101 | - public const OUTPUT_IMAGE_JPG = QROutputInterface::GDIMAGE_JPG; |
|
101 | + public const OUTPUT_IMAGE_JPG = QROutputInterface::GDIMAGE_JPG; |
|
102 | 102 | |
103 | 103 | /** |
104 | 104 | * @deprecated 5.0.0 use QROutputInterface::GDIMAGE_GIF instead |
105 | 105 | * @see \chillerlan\QRCode\Output\QROutputInterface::GDIMAGE_GIF |
106 | 106 | * @var string |
107 | 107 | */ |
108 | - public const OUTPUT_IMAGE_GIF = QROutputInterface::GDIMAGE_GIF; |
|
108 | + public const OUTPUT_IMAGE_GIF = QROutputInterface::GDIMAGE_GIF; |
|
109 | 109 | |
110 | 110 | /** |
111 | 111 | * @deprecated 5.0.0 use QROutputInterface::STRING_JSON instead |
@@ -126,35 +126,35 @@ discard block |
||
126 | 126 | * @see \chillerlan\QRCode\Output\QROutputInterface::IMAGICK |
127 | 127 | * @var string |
128 | 128 | */ |
129 | - public const OUTPUT_IMAGICK = QROutputInterface::IMAGICK; |
|
129 | + public const OUTPUT_IMAGICK = QROutputInterface::IMAGICK; |
|
130 | 130 | |
131 | 131 | /** |
132 | 132 | * @deprecated 5.0.0 use QROutputInterface::FPDF instead |
133 | 133 | * @see \chillerlan\QRCode\Output\QROutputInterface::FPDF |
134 | 134 | * @var string |
135 | 135 | */ |
136 | - public const OUTPUT_FPDF = QROutputInterface::FPDF; |
|
136 | + public const OUTPUT_FPDF = QROutputInterface::FPDF; |
|
137 | 137 | |
138 | 138 | /** |
139 | 139 | * @deprecated 5.0.0 use QROutputInterface::EPS instead |
140 | 140 | * @see \chillerlan\QRCode\Output\QROutputInterface::EPS |
141 | 141 | * @var string |
142 | 142 | */ |
143 | - public const OUTPUT_EPS = QROutputInterface::EPS; |
|
143 | + public const OUTPUT_EPS = QROutputInterface::EPS; |
|
144 | 144 | |
145 | 145 | /** |
146 | 146 | * @deprecated 5.0.0 use QROutputInterface::CUSTOM instead |
147 | 147 | * @see \chillerlan\QRCode\Output\QROutputInterface::CUSTOM |
148 | 148 | * @var string |
149 | 149 | */ |
150 | - public const OUTPUT_CUSTOM = QROutputInterface::CUSTOM; |
|
150 | + public const OUTPUT_CUSTOM = QROutputInterface::CUSTOM; |
|
151 | 151 | |
152 | 152 | /** |
153 | 153 | * @deprecated 5.0.0 use QROutputInterface::MODES instead |
154 | 154 | * @see \chillerlan\QRCode\Output\QROutputInterface::MODES |
155 | 155 | * @var string[] |
156 | 156 | */ |
157 | - public const OUTPUT_MODES = QROutputInterface::MODES; |
|
157 | + public const OUTPUT_MODES = QROutputInterface::MODES; |
|
158 | 158 | |
159 | 159 | /** |
160 | 160 | * The settings container |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | * @throws \chillerlan\QRCode\Output\QRCodeOutputException |
272 | 272 | */ |
273 | 273 | protected function initOutputInterface(QRMatrix $matrix):QROutputInterface{ |
274 | - $outputInterface =( QROutputInterface::MODES[$this->options->outputType] ?? null); |
|
274 | + $outputInterface = (QROutputInterface::MODES[$this->options->outputType] ?? null); |
|
275 | 275 | |
276 | 276 | if($this->options->outputType === QROutputInterface::CUSTOM){ |
277 | 277 | $outputInterface = $this->options->outputInterface; |
@@ -36,8 +36,8 @@ discard block |
||
36 | 36 | // This class uses 5x5 blocks to compute local luminance, where each block is 8x8 pixels. |
37 | 37 | // So this is the smallest dimension in each axis we can accept. |
38 | 38 | private const BLOCK_SIZE_POWER = 3; |
39 | - private const BLOCK_SIZE = 8; // ...0100...00 |
|
40 | - private const BLOCK_SIZE_MASK = 7; // ...0011...11 |
|
39 | + private const BLOCK_SIZE = 8; // ...0100...00 |
|
40 | + private const BLOCK_SIZE_MASK = 7; // ...0011...11 |
|
41 | 41 | private const MINIMUM_DIMENSION = 40; |
42 | 42 | private const MIN_DYNAMIC_RANGE = 24; |
43 | 43 | |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | |
235 | 235 | for($xx = 0; $xx < self::BLOCK_SIZE; $xx++){ |
236 | 236 | $pixel = ((int)($this->luminances[(int)($offset + $xx)]) & 0xff); |
237 | - $sum += $pixel; |
|
237 | + $sum += $pixel; |
|
238 | 238 | // still looking for good contrast |
239 | 239 | if($pixel < $min){ |
240 | 240 | $min = $pixel; |
@@ -220,8 +220,8 @@ discard block |
||
220 | 220 | // Should return null, but, some QR codes apparently do not mask this info. |
221 | 221 | // Try again by actually masking the pattern first. |
222 | 222 | $formatInfo = $this->doDecodeFormatInformation( |
223 | - ($formatInfoBits1 ^ $this::FORMAT_INFO_MASK_QR), |
|
224 | - ($formatInfoBits2 ^ $this::FORMAT_INFO_MASK_QR) |
|
223 | + ($formatInfoBits1^$this::FORMAT_INFO_MASK_QR), |
|
224 | + ($formatInfoBits2^$this::FORMAT_INFO_MASK_QR) |
|
225 | 225 | ); |
226 | 226 | |
227 | 227 | // still nothing??? |
@@ -246,13 +246,13 @@ discard block |
||
246 | 246 | ? $this->check($j, $i) |
247 | 247 | : $this->check($i, $j); |
248 | 248 | |
249 | - return ($bit) ? (($versionBits << 1) | 0x1) : ($versionBits << 1); |
|
249 | + return ($bit) ? (($versionBits << 1)|0x1) : ($versionBits << 1); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | /** |
253 | 253 | * Returns information about the format it specifies, or null if it doesn't seem to match any known pattern |
254 | 254 | */ |
255 | - private function doDecodeFormatInformation(int $maskedFormatInfo1, int $maskedFormatInfo2):?int{ |
|
255 | + private function doDecodeFormatInformation(int $maskedFormatInfo1, int $maskedFormatInfo2): ?int{ |
|
256 | 256 | $bestDifference = PHP_INT_MAX; |
257 | 257 | $bestFormatInfo = 0; |
258 | 258 | |
@@ -348,7 +348,7 @@ discard block |
||
348 | 348 | /** |
349 | 349 | * Decodes the version information from the given bit sequence, returns null if no valid match is found. |
350 | 350 | */ |
351 | - private function decodeVersionInformation(int $versionBits):?Version{ |
|
351 | + private function decodeVersionInformation(int $versionBits): ?Version{ |
|
352 | 352 | $bestDifference = PHP_INT_MAX; |
353 | 353 | $bestVersion = 0; |
354 | 354 |