@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | $byte2 = ord($string[($i + 1)]); |
100 | 100 | |
101 | 101 | // byte 1 unused and vendor ranges |
102 | - if($byte1 < 0x81 || ($byte1 > 0x84 && $byte1 < 0x88) || ($byte1 > 0x9f && $byte1 < 0xe0) || $byte1 > 0xea){ |
|
102 | + if($byte1 < 0x81 || ($byte1 > 0x84 && $byte1 < 0x88) || ($byte1 > 0x9f && $byte1 < 0xe0) || $byte1 > 0xea){ |
|
103 | 103 | return false; |
104 | 104 | } |
105 | 105 | |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | $len = strlen($this->data); |
129 | 129 | |
130 | 130 | for($i = 0; ($i + 1) < $len; $i += 2){ |
131 | - $c = (((0xff & ord($this->data[$i])) << 8) | (0xff & ord($this->data[($i + 1)]))); |
|
131 | + $c = (((0xff & ord($this->data[$i])) << 8)|(0xff & ord($this->data[($i + 1)]))); |
|
132 | 132 | |
133 | 133 | if($c >= 0x8140 && $c <= 0x9ffc){ |
134 | 134 | $c -= 0x8140; |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | $length = $bitBuffer->read(self::getLengthBits($versionNumber)); |
159 | 159 | |
160 | 160 | if($bitBuffer->available() < ($length * 13)){ |
161 | - throw new QRCodeDataException('not enough bits available'); // @codeCoverageIgnore |
|
161 | + throw new QRCodeDataException('not enough bits available'); // @codeCoverageIgnore |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | // Each character will require 2 bytes. Read the characters as 2-byte pairs and decode as SJIS afterwards |
@@ -168,15 +168,15 @@ discard block |
||
168 | 168 | while($length > 0){ |
169 | 169 | // Each 13 bits encodes a 2-byte character |
170 | 170 | $twoBytes = $bitBuffer->read(13); |
171 | - $assembledTwoBytes = ((((int)($twoBytes / 0x0c0)) << 8) | ($twoBytes % 0x0c0)); |
|
171 | + $assembledTwoBytes = ((((int)($twoBytes / 0x0c0)) << 8)|($twoBytes % 0x0c0)); |
|
172 | 172 | |
173 | 173 | $assembledTwoBytes += ($assembledTwoBytes < 0x01f00) |
174 | 174 | ? 0x08140 // In the 0x8140 to 0x9FFC range |
175 | 175 | : 0x0c140; // In the 0xE040 to 0xEBBF range |
176 | 176 | |
177 | 177 | $buffer[$offset] = chr(0xff & ($assembledTwoBytes >> 8)); |
178 | - $buffer[($offset + 1)] = chr(0xff & $assembledTwoBytes); |
|
179 | - $offset += 2; |
|
178 | + $buffer[($offset + 1)] = chr(0xff&$assembledTwoBytes); |
|
179 | + $offset += 2; |
|
180 | 180 | $length--; |
181 | 181 | } |
182 | 182 |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | $len = strlen($this->data); |
132 | 132 | |
133 | 133 | for($i = 0; ($i + 1) < $len; $i += 2){ |
134 | - $c = (((0xff & ord($this->data[$i])) << 8) | (0xff & ord($this->data[($i + 1)]))); |
|
134 | + $c = (((0xff & ord($this->data[$i])) << 8)|(0xff & ord($this->data[($i + 1)]))); |
|
135 | 135 | |
136 | 136 | if($c >= 0xa1a1 && $c <= 0xaafe){ |
137 | 137 | $c -= 0x0a1a1; |
@@ -177,15 +177,15 @@ discard block |
||
177 | 177 | while($length > 0){ |
178 | 178 | // Each 13 bits encodes a 2-byte character |
179 | 179 | $twoBytes = $bitBuffer->read(13); |
180 | - $assembledTwoBytes = ((((int)($twoBytes / 0x060)) << 8) | ($twoBytes % 0x060)); |
|
180 | + $assembledTwoBytes = ((((int)($twoBytes / 0x060)) << 8)|($twoBytes % 0x060)); |
|
181 | 181 | |
182 | 182 | $assembledTwoBytes += ($assembledTwoBytes < 0x00a00) // 0x003BF |
183 | 183 | ? 0x0a1a1 // In the 0xA1A1 to 0xAAFE range |
184 | 184 | : 0x0a6a1; // In the 0xB0A1 to 0xFAFE range |
185 | 185 | |
186 | 186 | $buffer[$offset] = chr(0xff & ($assembledTwoBytes >> 8)); |
187 | - $buffer[($offset + 1)] = chr(0xff & $assembledTwoBytes); |
|
188 | - $offset += 2; |
|
187 | + $buffer[($offset + 1)] = chr(0xff&$assembledTwoBytes); |
|
188 | + $offset += 2; |
|
189 | 189 | $length--; |
190 | 190 | } |
191 | 191 |
@@ -73,10 +73,10 @@ discard block |
||
73 | 73 | $bitBuffer->put($this->encoding, 8); |
74 | 74 | } |
75 | 75 | elseif($this->encoding < 16384){ |
76 | - $bitBuffer->put(($this->encoding | 0x8000), 16); |
|
76 | + $bitBuffer->put(($this->encoding|0x8000), 16); |
|
77 | 77 | } |
78 | 78 | elseif($this->encoding < 1000000){ |
79 | - $bitBuffer->put(($this->encoding | 0xC00000), 24); |
|
79 | + $bitBuffer->put(($this->encoding|0xC00000), 24); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | return $this; |
@@ -96,11 +96,11 @@ discard block |
||
96 | 96 | } |
97 | 97 | // two bytes |
98 | 98 | elseif(($firstByte & 0b11000000) === 0b10000000){ |
99 | - $id = ((($firstByte & 0b00111111) << 8) | $bitBuffer->read(8)); |
|
99 | + $id = ((($firstByte & 0b00111111) << 8)|$bitBuffer->read(8)); |
|
100 | 100 | } |
101 | 101 | // three bytes |
102 | 102 | elseif(($firstByte & 0b11100000) === 0b11000000){ |
103 | - $id = ((($firstByte & 0b00011111) << 16) | $bitBuffer->read(16)); |
|
103 | + $id = ((($firstByte & 0b00011111) << 16)|$bitBuffer->read(16)); |
|
104 | 104 | } |
105 | 105 | else{ |
106 | 106 | throw new QRCodeDataException(sprintf('error decoding ECI value first byte: %08b', $firstByte)); // @codeCoverageIgnore |
@@ -19,16 +19,16 @@ discard block |
||
19 | 19 | */ |
20 | 20 | final class ECICharset{ |
21 | 21 | |
22 | - public const CP437 = 0; // Code page 437, DOS Latin US |
|
23 | - 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 |
|
24 | - public const CP437_WO_GLI = 2; // An equivalent code table to CP437, without the return-to-GLI 0 logic |
|
25 | - public const ISO_IEC_8859_1 = 3; // Latin-1 (Default) |
|
26 | - public const ISO_IEC_8859_2 = 4; // Latin-2 |
|
27 | - public const ISO_IEC_8859_3 = 5; // Latin-3 |
|
28 | - public const ISO_IEC_8859_4 = 6; // Latin-4 |
|
29 | - public const ISO_IEC_8859_5 = 7; // Latin/Cyrillic |
|
30 | - public const ISO_IEC_8859_6 = 8; // Latin/Arabic |
|
31 | - public const ISO_IEC_8859_7 = 9; // Latin/Greek |
|
22 | + public const CP437 = 0; // Code page 437, DOS Latin US |
|
23 | + 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 |
|
24 | + public const CP437_WO_GLI = 2; // An equivalent code table to CP437, without the return-to-GLI 0 logic |
|
25 | + public const ISO_IEC_8859_1 = 3; // Latin-1 (Default) |
|
26 | + public const ISO_IEC_8859_2 = 4; // Latin-2 |
|
27 | + public const ISO_IEC_8859_3 = 5; // Latin-3 |
|
28 | + public const ISO_IEC_8859_4 = 6; // Latin-4 |
|
29 | + public const ISO_IEC_8859_5 = 7; // Latin/Cyrillic |
|
30 | + public const ISO_IEC_8859_6 = 8; // Latin/Arabic |
|
31 | + public const ISO_IEC_8859_7 = 9; // Latin/Greek |
|
32 | 32 | public const ISO_IEC_8859_8 = 10; // Latin/Hebrew |
33 | 33 | public const ISO_IEC_8859_9 = 11; // Latin-5 |
34 | 34 | public const ISO_IEC_8859_10 = 12; // Latin-6 |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | * @see \mb_convert_encoding() |
119 | 119 | * @see \iconv() |
120 | 120 | */ |
121 | - public function getName():?string{ |
|
121 | + public function getName(): ?string{ |
|
122 | 122 | return (self::MB_ENCODINGS[$this->charsetID] ?? null); |
123 | 123 | } |
124 | 124 |
@@ -48,11 +48,11 @@ |
||
48 | 48 | */ |
49 | 49 | public const LENGTH_BITS = [ |
50 | 50 | self::NUMBER => [10, 12, 14], |
51 | - self::ALPHANUM => [ 9, 11, 13], |
|
52 | - self::BYTE => [ 8, 16, 16], |
|
53 | - self::KANJI => [ 8, 10, 12], |
|
54 | - self::HANZI => [ 8, 10, 12], |
|
55 | - self::ECI => [ 0, 0, 0], |
|
51 | + self::ALPHANUM => [9, 11, 13], |
|
52 | + self::BYTE => [8, 16, 16], |
|
53 | + self::KANJI => [8, 10, 12], |
|
54 | + self::HANZI => [8, 10, 12], |
|
55 | + self::ECI => [0, 0, 0], |
|
56 | 56 | ]; |
57 | 57 | |
58 | 58 | /** |
@@ -37,46 +37,46 @@ discard block |
||
37 | 37 | */ |
38 | 38 | private const MAX_BITS = [ |
39 | 39 | // [ L, M, Q, H] // v => modules |
40 | - [ 0, 0, 0, 0], // 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 | + [0, 0, 0, 0], // 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, |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | */ |
151 | 151 | public function __construct(int $eccLevel){ |
152 | 152 | |
153 | - if((0b11 & $eccLevel) !== $eccLevel){ |
|
153 | + if((0b11&$eccLevel) !== $eccLevel){ |
|
154 | 154 | throw new QRCodeException('invalid ECC level'); |
155 | 155 | } |
156 | 156 |
@@ -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->getSize(); |
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->getSize(); |
419 | 419 | $stateCount = $this->getCrossCheckStateCount(); |
420 | 420 |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | * |
59 | 59 | * @return \chillerlan\QRCode\Detector\AlignmentPattern|null |
60 | 60 | */ |
61 | - public function find(int $startX, int $startY, int $width, int $height):?AlignmentPattern{ |
|
61 | + public function find(int $startX, int $startY, int $width, int $height): ?AlignmentPattern{ |
|
62 | 62 | $maxJ = ($startX + $width); |
63 | 63 | $middleI = ($startY + ($height / 2)); |
64 | 64 | $stateCount = []; |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | * |
174 | 174 | * @return \chillerlan\QRCode\Detector\AlignmentPattern|null if we have found the same pattern twice, or null if not |
175 | 175 | */ |
176 | - private function handlePossibleCenter(array $stateCount, int $i, int $j):?AlignmentPattern{ |
|
176 | + private function handlePossibleCenter(array $stateCount, int $i, int $j): ?AlignmentPattern{ |
|
177 | 177 | $stateCountTotal = ($stateCount[0] + $stateCount[1] + $stateCount[2]); |
178 | 178 | $centerJ = $this->centerFromEnd($stateCount, $j); |
179 | 179 | $centerI = $this->crossCheckVertical($i, (int)$centerJ, (2 * $stateCount[1]), $stateCountTotal); |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | * |
223 | 223 | * @return float|null vertical center of alignment pattern, or null if not found |
224 | 224 | */ |
225 | - private function crossCheckVertical(int $startI, int $centerJ, int $maxCount, int $originalStateCountTotal):?float{ |
|
225 | + private function crossCheckVertical(int $startI, int $centerJ, int $maxCount, int $originalStateCountTotal): ?float{ |
|
226 | 226 | $maxI = $this->matrix->getSize(); |
227 | 227 | $stateCount = []; |
228 | 228 | $stateCount[0] = 0; |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | } |
152 | 152 | |
153 | 153 | $otherToX = (int)($fromX + ($otherToX - $fromX) * $scale); |
154 | - $result += $this->sizeOfBlackWhiteBlackRun((int)$fromX, (int)$fromY, $otherToX, $otherToY); |
|
154 | + $result += $this->sizeOfBlackWhiteBlackRun((int)$fromX, (int)$fromY, $otherToX, $otherToY); |
|
155 | 155 | |
156 | 156 | // Middle pixel is double-counted this way; subtract 1 |
157 | 157 | return ($result - 1.0); |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | int $estAlignmentX, |
277 | 277 | int $estAlignmentY, |
278 | 278 | float $allowanceFactor |
279 | - ):?AlignmentPattern{ |
|
279 | + ): ?AlignmentPattern{ |
|
280 | 280 | // Look for an alignment pattern (3 modules in size) around where it should be |
281 | 281 | $dimension = $this->matrix->getSize(); |
282 | 282 | $allowance = (int)($allowanceFactor * $overallEstModuleSize); |