@@ -70,7 +70,7 @@ |
||
70 | 70 | * @return string|\Imagick |
71 | 71 | */ |
72 | 72 | public function dump(string $file = null){ |
73 | - $file ??= $this->options->cachefile; |
|
73 | + $file ??= $this->options->cachefile; |
|
74 | 74 | $this->imagick = new Imagick; |
75 | 75 | |
76 | 76 | $this->imagick->newImage( |
@@ -129,7 +129,7 @@ |
||
129 | 129 | |
130 | 130 | // scale down to the expected size |
131 | 131 | if($this->options->drawCircularModules && $this->options->scale <= 20){ |
132 | - $this->image = imagescale($this->image, $this->length/10, $this->length/10, IMG_BICUBIC); |
|
132 | + $this->image = imagescale($this->image, $this->length / 10, $this->length / 10, IMG_BICUBIC); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | if($this->options->returnResource){ |
@@ -37,45 +37,45 @@ discard block |
||
37 | 37 | */ |
38 | 38 | private const MAX_BITS = [ |
39 | 39 | // v => [ L, M, Q, H] // modules |
40 | - 1 => [ 152, 128, 104, 72], // 21 |
|
41 | - 2 => [ 272, 224, 176, 128], // 25 |
|
42 | - 3 => [ 440, 352, 272, 208], // 29 |
|
43 | - 4 => [ 640, 512, 384, 288], // 33 |
|
44 | - 5 => [ 864, 688, 496, 368], // 37 |
|
45 | - 6 => [ 1088, 864, 608, 480], // 41 |
|
46 | - 7 => [ 1248, 992, 704, 528], // 45 |
|
47 | - 8 => [ 1552, 1232, 880, 688], // 49 |
|
48 | - 9 => [ 1856, 1456, 1056, 800], // 53 |
|
49 | - 10 => [ 2192, 1728, 1232, 976], // 57 |
|
50 | - 11 => [ 2592, 2032, 1440, 1120], // 61 |
|
51 | - 12 => [ 2960, 2320, 1648, 1264], // 65 |
|
52 | - 13 => [ 3424, 2672, 1952, 1440], // 69 NICE! |
|
53 | - 14 => [ 3688, 2920, 2088, 1576], // 73 |
|
54 | - 15 => [ 4184, 3320, 2360, 1784], // 77 |
|
55 | - 16 => [ 4712, 3624, 2600, 2024], // 81 |
|
56 | - 17 => [ 5176, 4056, 2936, 2264], // 85 |
|
57 | - 18 => [ 5768, 4504, 3176, 2504], // 89 |
|
58 | - 19 => [ 6360, 5016, 3560, 2728], // 93 |
|
59 | - 20 => [ 6888, 5352, 3880, 3080], // 97 |
|
60 | - 21 => [ 7456, 5712, 4096, 3248], // 101 |
|
61 | - 22 => [ 8048, 6256, 4544, 3536], // 105 |
|
62 | - 23 => [ 8752, 6880, 4912, 3712], // 109 |
|
63 | - 24 => [ 9392, 7312, 5312, 4112], // 113 |
|
64 | - 25 => [10208, 8000, 5744, 4304], // 117 |
|
65 | - 26 => [10960, 8496, 6032, 4768], // 121 |
|
66 | - 27 => [11744, 9024, 6464, 5024], // 125 |
|
67 | - 28 => [12248, 9544, 6968, 5288], // 129 |
|
68 | - 29 => [13048, 10136, 7288, 5608], // 133 |
|
69 | - 30 => [13880, 10984, 7880, 5960], // 137 |
|
70 | - 31 => [14744, 11640, 8264, 6344], // 141 |
|
71 | - 32 => [15640, 12328, 8920, 6760], // 145 |
|
72 | - 33 => [16568, 13048, 9368, 7208], // 149 |
|
73 | - 34 => [17528, 13800, 9848, 7688], // 153 |
|
74 | - 35 => [18448, 14496, 10288, 7888], // 157 |
|
75 | - 36 => [19472, 15312, 10832, 8432], // 161 |
|
76 | - 37 => [20528, 15936, 11408, 8768], // 165 |
|
77 | - 38 => [21616, 16816, 12016, 9136], // 169 |
|
78 | - 39 => [22496, 17728, 12656, 9776], // 173 |
|
40 | + 1 => [152, 128, 104, 72], // 21 |
|
41 | + 2 => [272, 224, 176, 128], // 25 |
|
42 | + 3 => [440, 352, 272, 208], // 29 |
|
43 | + 4 => [640, 512, 384, 288], // 33 |
|
44 | + 5 => [864, 688, 496, 368], // 37 |
|
45 | + 6 => [1088, 864, 608, 480], // 41 |
|
46 | + 7 => [1248, 992, 704, 528], // 45 |
|
47 | + 8 => [1552, 1232, 880, 688], // 49 |
|
48 | + 9 => [1856, 1456, 1056, 800], // 53 |
|
49 | + 10 => [2192, 1728, 1232, 976], // 57 |
|
50 | + 11 => [2592, 2032, 1440, 1120], // 61 |
|
51 | + 12 => [2960, 2320, 1648, 1264], // 65 |
|
52 | + 13 => [3424, 2672, 1952, 1440], // 69 NICE! |
|
53 | + 14 => [3688, 2920, 2088, 1576], // 73 |
|
54 | + 15 => [4184, 3320, 2360, 1784], // 77 |
|
55 | + 16 => [4712, 3624, 2600, 2024], // 81 |
|
56 | + 17 => [5176, 4056, 2936, 2264], // 85 |
|
57 | + 18 => [5768, 4504, 3176, 2504], // 89 |
|
58 | + 19 => [6360, 5016, 3560, 2728], // 93 |
|
59 | + 20 => [6888, 5352, 3880, 3080], // 97 |
|
60 | + 21 => [7456, 5712, 4096, 3248], // 101 |
|
61 | + 22 => [8048, 6256, 4544, 3536], // 105 |
|
62 | + 23 => [8752, 6880, 4912, 3712], // 109 |
|
63 | + 24 => [9392, 7312, 5312, 4112], // 113 |
|
64 | + 25 => [10208, 8000, 5744, 4304], // 117 |
|
65 | + 26 => [10960, 8496, 6032, 4768], // 121 |
|
66 | + 27 => [11744, 9024, 6464, 5024], // 125 |
|
67 | + 28 => [12248, 9544, 6968, 5288], // 129 |
|
68 | + 29 => [13048, 10136, 7288, 5608], // 133 |
|
69 | + 30 => [13880, 10984, 7880, 5960], // 137 |
|
70 | + 31 => [14744, 11640, 8264, 6344], // 141 |
|
71 | + 32 => [15640, 12328, 8920, 6760], // 145 |
|
72 | + 33 => [16568, 13048, 9368, 7208], // 149 |
|
73 | + 34 => [17528, 13800, 9848, 7688], // 153 |
|
74 | + 35 => [18448, 14496, 10288, 7888], // 157 |
|
75 | + 36 => [19472, 15312, 10832, 8432], // 161 |
|
76 | + 37 => [20528, 15936, 11408, 8768], // 165 |
|
77 | + 38 => [21616, 16816, 12016, 9136], // 169 |
|
78 | + 39 => [22496, 17728, 12656, 9776], // 173 |
|
79 | 79 | 40 => [23648, 18672, 13328, 10208], // 177 |
80 | 80 | ]; |
81 | 81 | |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | * @var int[][] |
88 | 88 | */ |
89 | 89 | private const FORMAT_PATTERN = [ |
90 | - [ // L |
|
90 | + [// L |
|
91 | 91 | 0b111011111000100, |
92 | 92 | 0b111001011110011, |
93 | 93 | 0b111110110101010, |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | 0b110110001000001, |
98 | 98 | 0b110100101110110, |
99 | 99 | ], |
100 | - [ // M |
|
100 | + [// M |
|
101 | 101 | 0b101010000010010, |
102 | 102 | 0b101000100100101, |
103 | 103 | 0b101111001111100, |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | 0b100111110010111, |
108 | 108 | 0b100101010100000, |
109 | 109 | ], |
110 | - [ // Q |
|
110 | + [// Q |
|
111 | 111 | 0b011010101011111, |
112 | 112 | 0b011000001101000, |
113 | 113 | 0b011111100110001, |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | 0b010111011011010, |
118 | 118 | 0b010101111101101, |
119 | 119 | ], |
120 | - [ // H |
|
120 | + [// H |
|
121 | 121 | 0b001011010001001, |
122 | 122 | 0b001001110111110, |
123 | 123 | 0b001110011100111, |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | */ |
147 | 147 | public function __construct(int $eccLevel){ |
148 | 148 | |
149 | - if((0b11 & $eccLevel) !== $eccLevel){ |
|
149 | + if((0b11&$eccLevel) !== $eccLevel){ |
|
150 | 150 | throw new QRCodeException('invalid ECC level'); |
151 | 151 | } |
152 | 152 |
@@ -231,7 +231,7 @@ |
||
231 | 231 | * |
232 | 232 | * @see \chillerlan\QRCode\QROptions::$imageTransparencyBG |
233 | 233 | * @see https://github.com/chillerlan/php-qrcode/discussions/121 |
234 | - */ |
|
234 | + */ |
|
235 | 235 | protected bool $imageTransparent = true; |
236 | 236 | |
237 | 237 | /** |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | /** |
39 | 39 | * Read count (bits) |
40 | 40 | */ |
41 | - private int $bitsRead = 0; |
|
41 | + private int $bitsRead = 0; |
|
42 | 42 | |
43 | 43 | /** |
44 | 44 | * BitBuffer constructor. |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | $toRead = min($numBits, $bitsLeft); |
125 | 125 | $bitsToNotRead = $bitsLeft - $toRead; |
126 | 126 | $mask = (0xff >> (8 - $toRead)) << $bitsToNotRead; |
127 | - $result = ($this->buffer[$this->bytesRead] & $mask) >> $bitsToNotRead; |
|
127 | + $result = ($this->buffer[$this->bytesRead]&$mask) >> $bitsToNotRead; |
|
128 | 128 | $numBits -= $toRead; |
129 | 129 | $this->bitsRead += $toRead; |
130 | 130 | |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | if($numBits > 0){ |
139 | 139 | |
140 | 140 | while($numBits >= 8){ |
141 | - $result = ($result << 8) | ($this->buffer[$this->bytesRead] & 0xff); |
|
141 | + $result = ($result << 8)|($this->buffer[$this->bytesRead] & 0xff); |
|
142 | 142 | $this->bytesRead++; |
143 | 143 | $numBits -= 8; |
144 | 144 | } |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | if($numBits > 0){ |
148 | 148 | $bitsToNotRead = 8 - $numBits; |
149 | 149 | $mask = (0xff >> $bitsToNotRead) << $bitsToNotRead; |
150 | - $result = ($result << $numBits) | (($this->buffer[$this->bytesRead] & $mask) >> $bitsToNotRead); |
|
150 | + $result = ($result << $numBits)|(($this->buffer[$this->bytesRead]&$mask) >> $bitsToNotRead); |
|
151 | 151 | $this->bitsRead += $numBits; |
152 | 152 | } |
153 | 153 | } |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | $matrix[$y] = []; |
130 | 130 | |
131 | 131 | foreach($row as $x => $val){ |
132 | - $matrix[$y][$x] = ($val & $this::IS_DARK) === $this::IS_DARK; |
|
132 | + $matrix[$y][$x] = ($val&$this::IS_DARK) === $this::IS_DARK; |
|
133 | 133 | } |
134 | 134 | } |
135 | 135 | |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | /** |
154 | 154 | * Returns the current mask pattern |
155 | 155 | */ |
156 | - public function maskPattern():?MaskPattern{ |
|
156 | + public function maskPattern(): ?MaskPattern{ |
|
157 | 157 | return $this->maskPattern; |
158 | 158 | } |
159 | 159 | |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | * false => $M_TYPE |
181 | 181 | */ |
182 | 182 | public function set(int $x, int $y, bool $value, int $M_TYPE):self{ |
183 | - $this->matrix[$y][$x] = $M_TYPE | ($value ? $this::IS_DARK : 0); |
|
183 | + $this->matrix[$y][$x] = $M_TYPE|($value ? $this::IS_DARK : 0); |
|
184 | 184 | |
185 | 185 | return $this; |
186 | 186 | } |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | * true => $value & $M_TYPE === $M_TYPE |
201 | 201 | */ |
202 | 202 | public function checkType(int $x, int $y, int $M_TYPE):bool{ |
203 | - return ($this->matrix[$y][$x] & $M_TYPE) === $M_TYPE; |
|
203 | + return ($this->matrix[$y][$x]&$M_TYPE) === $M_TYPE; |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | /** |
@@ -294,8 +294,8 @@ discard block |
||
294 | 294 | |
295 | 295 | for($c = 0; $c < 3; $c++){ |
296 | 296 | for($i = 0; $i < 8; $i++){ |
297 | - $this->set($h[$c][0] , $h[$c][1] + $i, false, $this::M_SEPARATOR); |
|
298 | - $this->set($v[$c][0] - $i, $v[$c][1] , false, $this::M_SEPARATOR); |
|
297 | + $this->set($h[$c][0], $h[$c][1] + $i, false, $this::M_SEPARATOR); |
|
298 | + $this->set($v[$c][0] - $i, $v[$c][1], false, $this::M_SEPARATOR); |
|
299 | 299 | } |
300 | 300 | } |
301 | 301 | |
@@ -519,7 +519,7 @@ discard block |
||
519 | 519 | foreach($this->matrix as $y => $row){ |
520 | 520 | foreach($row as $x => $val){ |
521 | 521 | // out of bounds, skip |
522 | - if($x < $start || $y < $start ||$x >= $end || $y >= $end){ |
|
522 | + if($x < $start || $y < $start || $x >= $end || $y >= $end){ |
|
523 | 523 | continue; |
524 | 524 | } |
525 | 525 | // a match |
@@ -569,7 +569,7 @@ discard block |
||
569 | 569 | $v = (($data[$byteIndex] >> $bitIndex) & 1) === 1; |
570 | 570 | } |
571 | 571 | |
572 | - $this->matrix[$y][$x] = $this::M_DATA | ($v ? $this::IS_DARK : 0); |
|
572 | + $this->matrix[$y][$x] = $this::M_DATA|($v ? $this::IS_DARK : 0); |
|
573 | 573 | $bitIndex--; |
574 | 574 | |
575 | 575 | if($bitIndex === -1){ |
@@ -582,7 +582,7 @@ discard block |
||
582 | 582 | $y += $inc; |
583 | 583 | |
584 | 584 | if($y < 0 || $this->moduleCount <= $y){ |
585 | - $y -= $inc; |
|
585 | + $y -= $inc; |
|
586 | 586 | $inc = -$inc; |
587 | 587 | |
588 | 588 | break; |
@@ -605,7 +605,7 @@ discard block |
||
605 | 605 | |
606 | 606 | foreach($this->matrix as $y => &$row){ |
607 | 607 | foreach($row as $x => &$val){ |
608 | - if($mask($x, $y) && ($val & $this::M_DATA) === $this::M_DATA){ |
|
608 | + if($mask($x, $y) && ($val&$this::M_DATA) === $this::M_DATA){ |
|
609 | 609 | $val ^= $this::IS_DARK; |
610 | 610 | } |
611 | 611 | } |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | } |
63 | 63 | |
64 | 64 | while($i + 1 < $len){ |
65 | - $c = ((0xff & ord($string[$i])) << 8) | (0xff & ord($string[$i + 1])); |
|
65 | + $c = ((0xff & ord($string[$i])) << 8)|(0xff & ord($string[$i + 1])); |
|
66 | 66 | |
67 | 67 | if(!($c >= 0x8140 && $c <= 0x9ffc) && !($c >= 0xe040 && $c <= 0xebbf)){ |
68 | 68 | return false; |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | $len = strlen($this->data); |
90 | 90 | |
91 | 91 | for($i = 0; $i + 1 < $len; $i += 2){ |
92 | - $c = ((0xff & ord($this->data[$i])) << 8) | (0xff & ord($this->data[$i + 1])); |
|
92 | + $c = ((0xff & ord($this->data[$i])) << 8)|(0xff & ord($this->data[$i + 1])); |
|
93 | 93 | |
94 | 94 | if($c >= 0x8140 && $c <= 0x9ffC){ |
95 | 95 | $c -= 0x8140; |
@@ -128,15 +128,15 @@ discard block |
||
128 | 128 | while($length > 0){ |
129 | 129 | // Each 13 bits encodes a 2-byte character |
130 | 130 | $twoBytes = $bitBuffer->read(13); |
131 | - $assembledTwoBytes = ((int)($twoBytes / 0x0c0) << 8) | ($twoBytes % 0x0c0); |
|
131 | + $assembledTwoBytes = ((int)($twoBytes / 0x0c0) << 8)|($twoBytes % 0x0c0); |
|
132 | 132 | |
133 | 133 | $assembledTwoBytes += ($assembledTwoBytes < 0x01f00) |
134 | 134 | ? 0x08140 // In the 0x8140 to 0x9FFC range |
135 | 135 | : 0x0c140; // In the 0xE040 to 0xEBBF range |
136 | 136 | |
137 | 137 | $buffer[$offset] = chr(0xff & ($assembledTwoBytes >> 8)); |
138 | - $buffer[$offset + 1] = chr(0xff & $assembledTwoBytes); |
|
139 | - $offset += 2; |
|
138 | + $buffer[$offset + 1] = chr(0xff&$assembledTwoBytes); |
|
139 | + $offset += 2; |
|
140 | 140 | $length--; |
141 | 141 | } |
142 | 142 |
@@ -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'); |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | public function flip(int $x, int $y):self{ |
61 | 61 | $offset = $y * $this->rowSize + (int)($x / 0x20); |
62 | 62 | |
63 | - $this->bits[$offset] = ($this->bits[$offset] ^ (1 << ($x & 0x1f))); |
|
63 | + $this->bits[$offset] = ($this->bits[$offset]^(1 << ($x & 0x1f))); |
|
64 | 64 | |
65 | 65 | return $this; |
66 | 66 | } |
@@ -114,14 +114,14 @@ discard block |
||
114 | 114 | /** |
115 | 115 | * |
116 | 116 | */ |
117 | - public function getFormatInfo():?FormatInformation{ |
|
117 | + public function getFormatInfo(): ?FormatInformation{ |
|
118 | 118 | return $this->formatInfo; |
119 | 119 | } |
120 | 120 | |
121 | 121 | /** |
122 | 122 | * |
123 | 123 | */ |
124 | - public function getVersion():?Version{ |
|
124 | + public function getVersion(): ?Version{ |
|
125 | 125 | return $this->version; |
126 | 126 | } |
127 | 127 | |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | ? $this->get($j, $i) |
247 | 247 | : $this->get($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 | /** |
@@ -363,8 +363,8 @@ discard block |
||
363 | 363 | // Should return null, but, some QR codes apparently do not mask this info. |
364 | 364 | // Try again by actually masking the pattern first. |
365 | 365 | $this->formatInfo = $this->doDecodeFormatInformation( |
366 | - $formatInfoBits1 ^ FormatInformation::FORMAT_INFO_MASK_QR, |
|
367 | - $formatInfoBits2 ^ FormatInformation::FORMAT_INFO_MASK_QR |
|
366 | + $formatInfoBits1^FormatInformation::FORMAT_INFO_MASK_QR, |
|
367 | + $formatInfoBits2^FormatInformation::FORMAT_INFO_MASK_QR |
|
368 | 368 | ); |
369 | 369 | |
370 | 370 | if($this->formatInfo !== null){ |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | * @return \chillerlan\QRCode\Common\FormatInformation|null information about the format it specifies, or null |
383 | 383 | * if doesn't seem to match any known pattern |
384 | 384 | */ |
385 | - private function doDecodeFormatInformation(int $maskedFormatInfo1, int $maskedFormatInfo2):?FormatInformation{ |
|
385 | + private function doDecodeFormatInformation(int $maskedFormatInfo1, int $maskedFormatInfo2): ?FormatInformation{ |
|
386 | 386 | // Find the int in FORMAT_INFO_DECODE_LOOKUP with fewest bits differing |
387 | 387 | $bestDifference = PHP_INT_MAX; |
388 | 388 | $bestFormatInfo = 0; |
@@ -478,7 +478,7 @@ discard block |
||
478 | 478 | * |
479 | 479 | * @return \chillerlan\QRCode\Common\Version|null |
480 | 480 | */ |
481 | - private function decodeVersionInformation(int $versionBits):?Version{ |
|
481 | + private function decodeVersionInformation(int $versionBits): ?Version{ |
|
482 | 482 | $bestDifference = PHP_INT_MAX; |
483 | 483 | $bestVersion = 0; |
484 | 484 |