@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | } |
162 | 162 | |
163 | 163 | $otherToX = (int)($fromX + ($otherToX - $fromX) * $scale); |
164 | - $result += $this->sizeOfBlackWhiteBlackRun((int)$fromX, (int)$fromY, (int)$otherToX, (int)$otherToY); |
|
164 | + $result += $this->sizeOfBlackWhiteBlackRun((int)$fromX, (int)$fromY, (int)$otherToX, (int)$otherToY); |
|
165 | 165 | |
166 | 166 | // Middle pixel is double-counted this way; subtract 1 |
167 | 167 | return $result - 1.0; |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | int $estAlignmentX, |
292 | 292 | int $estAlignmentY, |
293 | 293 | float $allowanceFactor |
294 | - ):?AlignmentPattern{ |
|
294 | + ): ?AlignmentPattern{ |
|
295 | 295 | // Look for an alignment pattern (3 modules in size) around where it should be |
296 | 296 | $dimension = $this->bitMatrix->getDimension(); |
297 | 297 | $allowance = (int)($allowanceFactor * $overallEstModuleSize); |
@@ -59,7 +59,8 @@ |
||
59 | 59 | $estAlignmentY = (int)($topLeft->getY() + $correctionToTopLeft * ($bottomRightY - $topLeft->getY())); |
60 | 60 | |
61 | 61 | // Kind of arbitrary -- expand search radius before giving up |
62 | - for($i = 4; $i <= 16; $i <<= 1){//?????????? |
|
62 | + for($i = 4; $i <= 16; $i <<= 1){ |
|
63 | +//?????????? |
|
63 | 64 | $alignmentPattern = $this->findAlignmentInRegion($moduleSize, $estAlignmentX, $estAlignmentY, (float)$i); |
64 | 65 | |
65 | 66 | if($alignmentPattern !== null){ |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | $eccLevel = $parser->readFormatInformation()->getErrorCorrectionLevel(); |
96 | 96 | |
97 | 97 | // Read raw codewords |
98 | - $rawCodewords = $parser->readCodewords(); |
|
98 | + $rawCodewords = $parser->readCodewords(); |
|
99 | 99 | // Separate into data blocks |
100 | 100 | $dataBlocks = $this->getDataBlocks($rawCodewords, $version, $eccLevel); |
101 | 101 | |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | [$numEccCodewords, $eccBlocks] = $version->getRSBlocks($eccLevel); |
141 | 141 | |
142 | 142 | // Now establish DataBlocks of the appropriate size and number of data codewords |
143 | - $result = [];//new DataBlock[$totalBlocks]; |
|
143 | + $result = []; //new DataBlock[$totalBlocks]; |
|
144 | 144 | $numResultBlocks = 0; |
145 | 145 | |
146 | 146 | foreach($eccBlocks as $blockData){ |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | $codewordsInts = []; |
207 | 207 | |
208 | 208 | foreach($codewordBytes as $i => $codewordByte){ |
209 | - $codewordsInts[$i] = $codewordByte & 0xFF; |
|
209 | + $codewordsInts[$i] = $codewordByte&0xFF; |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | $decoded = (new ReedSolomonDecoder)->decode($codewordsInts, (count($codewordBytes) - $numDataCodewords)); |
@@ -46,7 +46,7 @@ |
||
46 | 46 | $countPixels = count($pixels); |
47 | 47 | |
48 | 48 | for($i = 0; $i < $countPixels; $i += 3){ |
49 | - $this->setLuminancePixel($pixels[$i] & 0xff, $pixels[$i + 1] & 0xff, $pixels[$i + 2] & 0xff); |
|
49 | + $this->setLuminancePixel($pixels[$i]&0xff, $pixels[$i + 1]&0xff, $pixels[$i + 2]&0xff); |
|
50 | 50 | } |
51 | 51 | } |
52 | 52 |
@@ -57,19 +57,19 @@ |
||
57 | 57 | public static function parseValue(BitBuffer $bitBuffer):ECICharset{ |
58 | 58 | $firstByte = $bitBuffer->read(8); |
59 | 59 | |
60 | - if(($firstByte & 0x80) === 0){ |
|
60 | + if(($firstByte&0x80) === 0){ |
|
61 | 61 | // just one byte |
62 | - return new ECICharset($firstByte & 0x7f); |
|
62 | + return new ECICharset($firstByte&0x7f); |
|
63 | 63 | } |
64 | 64 | |
65 | - if(($firstByte & 0xc0) === 0x80){ |
|
65 | + if(($firstByte&0xc0) === 0x80){ |
|
66 | 66 | // two bytes |
67 | - return new ECICharset((($firstByte & 0x3f) << 8) | $bitBuffer->read(8)); |
|
67 | + return new ECICharset((($firstByte&0x3f) << 8)|$bitBuffer->read(8)); |
|
68 | 68 | } |
69 | 69 | |
70 | - if(($firstByte & 0xe0) === 0xC0){ |
|
70 | + if(($firstByte&0xe0) === 0xC0){ |
|
71 | 71 | // three bytes |
72 | - return new ECICharset((($firstByte & 0x1f) << 16) | $bitBuffer->read(16)); |
|
72 | + return new ECICharset((($firstByte&0x1f) << 16)|$bitBuffer->read(16)); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | throw new QRCodeDataException('error decoding ECI value'); |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | $offset = (int)($y * $this->rowSize + ($x / 0x20)); |
38 | 38 | |
39 | 39 | $this->bits[$offset] ??= 0; |
40 | - $this->bits[$offset] |= ($this->bits[$offset] |= 1 << ($x & 0x1f)); |
|
40 | + $this->bits[$offset] |= ($this->bits[$offset] |= 1 << ($x&0x1f)); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | public function flip(int $x, int $y):void{ |
50 | 50 | $offset = $y * $this->rowSize + (int)($x / 0x20); |
51 | 51 | |
52 | - $this->bits[$offset] = ($this->bits[$offset] ^ (1 << ($x & 0x1f))); |
|
52 | + $this->bits[$offset] = ($this->bits[$offset]^(1 << ($x&0x1f))); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | |
85 | 85 | for($x = $left; $x < $right; $x++){ |
86 | 86 | $xOffset = $yOffset + (int)($x / 0x20); |
87 | - $this->bits[$xOffset] = ($this->bits[$xOffset] |= 1 << ($x & 0x1f)); |
|
87 | + $this->bits[$xOffset] = ($this->bits[$xOffset] |= 1 << ($x&0x1f)); |
|
88 | 88 | } |
89 | 89 | } |
90 | 90 | } |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | |
110 | 110 | $this->bits[$offset] ??= 0; |
111 | 111 | |
112 | - return (BitMatrixParser::uRShift($this->bits[$offset], ($x & 0x1f)) & 1) !== 0; |
|
112 | + return (BitMatrixParser::uRShift($this->bits[$offset], ($x&0x1f))&1) !== 0; |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | /** |
@@ -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 | |
@@ -137,13 +137,13 @@ discard block |
||
137 | 137 | if($width >= self::MINIMUM_DIMENSION && $height >= self::MINIMUM_DIMENSION){ |
138 | 138 | $subWidth = $width >> self::BLOCK_SIZE_POWER; |
139 | 139 | |
140 | - if(($width & self::BLOCK_SIZE_MASK) !== 0){ |
|
140 | + if(($width&self::BLOCK_SIZE_MASK) !== 0){ |
|
141 | 141 | $subWidth++; |
142 | 142 | } |
143 | 143 | |
144 | 144 | $subHeight = $height >> self::BLOCK_SIZE_POWER; |
145 | 145 | |
146 | - if(($height & self::BLOCK_SIZE_MASK) !== 0){ |
|
146 | + if(($height&self::BLOCK_SIZE_MASK) !== 0){ |
|
147 | 147 | $subHeight++; |
148 | 148 | } |
149 | 149 | |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | $right = (int)(($width * 4) / 5); |
168 | 168 | |
169 | 169 | for($x = (int)($width / 5); $x < $right; $x++){ |
170 | - $pixel = $localLuminances[(int)$x] & 0xff; |
|
170 | + $pixel = $localLuminances[(int)$x]&0xff; |
|
171 | 171 | $buckets[$pixel >> self::LUMINANCE_SHIFT]++; |
172 | 172 | } |
173 | 173 | } |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | $offset = $y * $width; |
184 | 184 | |
185 | 185 | for($x = 0; $x < $width; $x++){ |
186 | - $pixel = (int)($localLuminances[$offset + $x] & 0xff); |
|
186 | + $pixel = (int)($localLuminances[$offset + $x]&0xff); |
|
187 | 187 | |
188 | 188 | if($pixel < $blackPoint){ |
189 | 189 | $matrix->set($x, $y); |
@@ -230,8 +230,8 @@ discard block |
||
230 | 230 | for($yy = 0, $offset = $yoffset * $width + $xoffset; $yy < self::BLOCK_SIZE; $yy++, $offset += $width){ |
231 | 231 | |
232 | 232 | for($xx = 0; $xx < self::BLOCK_SIZE; $xx++){ |
233 | - $pixel = (int)($luminances[(int)($offset + $xx)]) & 0xff; |
|
234 | - $sum += $pixel; |
|
233 | + $pixel = (int)($luminances[(int)($offset + $xx)])&0xff; |
|
234 | + $sum += $pixel; |
|
235 | 235 | // still looking for good contrast |
236 | 236 | if($pixel < $min){ |
237 | 237 | $min = $pixel; |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | // finish the rest of the rows quickly |
248 | 248 | for($yy++, $offset += $width; $yy < self::BLOCK_SIZE; $yy++, $offset += $width){ |
249 | 249 | for($xx = 0; $xx < self::BLOCK_SIZE; $xx++){ |
250 | - $sum += $luminances[$offset + $xx] & 0xff; |
|
250 | + $sum += $luminances[$offset + $xx]&0xff; |
|
251 | 251 | } |
252 | 252 | } |
253 | 253 | } |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | |
326 | 326 | for($z = -2; $z <= 2; $z++){ |
327 | 327 | $blackRow = $blackPoints[$top + $z]; |
328 | - $sum += $blackRow[$left - 2] + $blackRow[$left - 1] + $blackRow[$left] + $blackRow[$left + 1] + $blackRow[$left + 2]; |
|
328 | + $sum += $blackRow[$left - 2] + $blackRow[$left - 1] + $blackRow[$left] + $blackRow[$left + 1] + $blackRow[$left + 2]; |
|
329 | 329 | } |
330 | 330 | |
331 | 331 | $average = (int)($sum / 25); |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | for($j = 0, $o = $yoffset * $width + $xoffset; $j < self::BLOCK_SIZE; $j++, $o += $width){ |
335 | 335 | for($i = 0; $i < self::BLOCK_SIZE; $i++){ |
336 | 336 | // Comparison needs to be <= so that black == 0 pixels are black even if the threshold is 0. |
337 | - if(($luminances[$o + $i] & 0xff) <= $average){ |
|
337 | + if(($luminances[$o + $i]&0xff) <= $average){ |
|
338 | 338 | $matrix->set($xoffset + $i, $yoffset + $j); |
339 | 339 | } |
340 | 340 | } |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | ? $this->bitMatrix->get($j, $i) |
71 | 71 | : $this->bitMatrix->get($i, $j); |
72 | 72 | |
73 | - return $bit ? ($versionBits << 1) | 0x1 : $versionBits << 1; |
|
73 | + return $bit ? ($versionBits << 1)|0x1 : $versionBits << 1; |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
@@ -189,8 +189,8 @@ discard block |
||
189 | 189 | // Should return null, but, some QR codes apparently do not mask this info. |
190 | 190 | // Try again by actually masking the pattern first. |
191 | 191 | $this->parsedFormatInfo = $this->doDecodeFormatInformation( |
192 | - $formatInfoBits1 ^ FormatInformation::FORMAT_INFO_MASK_QR, |
|
193 | - $formatInfoBits2 ^ FormatInformation::FORMAT_INFO_MASK_QR |
|
192 | + $formatInfoBits1^FormatInformation::FORMAT_INFO_MASK_QR, |
|
193 | + $formatInfoBits2^FormatInformation::FORMAT_INFO_MASK_QR |
|
194 | 194 | ); |
195 | 195 | |
196 | 196 | if($this->parsedFormatInfo !== null){ |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | * @return \chillerlan\QRCode\Common\FormatInformation|null information about the format it specifies, or null |
209 | 209 | * if doesn't seem to match any known pattern |
210 | 210 | */ |
211 | - private function doDecodeFormatInformation(int $maskedFormatInfo1, int $maskedFormatInfo2):?FormatInformation{ |
|
211 | + private function doDecodeFormatInformation(int $maskedFormatInfo1, int $maskedFormatInfo2): ?FormatInformation{ |
|
212 | 212 | // Find the int in FORMAT_INFO_DECODE_LOOKUP with fewest bits differing |
213 | 213 | $bestDifference = PHP_INT_MAX; |
214 | 214 | $bestFormatInfo = 0; |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | * |
306 | 306 | * @return \chillerlan\QRCode\Common\Version|null |
307 | 307 | */ |
308 | - private function decodeVersionInformation(int $versionBits):?Version{ |
|
308 | + private function decodeVersionInformation(int $versionBits): ?Version{ |
|
309 | 309 | $bestDifference = PHP_INT_MAX; |
310 | 310 | $bestVersion = 0; |
311 | 311 | |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | return $a; |
348 | 348 | } |
349 | 349 | |
350 | - return ($a >> $b) & ~((1 << (8 * PHP_INT_SIZE - 1)) >> ($b - 1)); |
|
350 | + return ($a >> $b)&~((1 << (8 * PHP_INT_SIZE - 1)) >> ($b - 1)); |
|
351 | 351 | } |
352 | 352 | |
353 | 353 | /** |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | $count = 0; |
363 | 363 | |
364 | 364 | for($i = 0; $i < 32; $i += 4){ |
365 | - $count += $BITS_SET_IN_HALF_BYTE[self::uRShift($a, $i) & 0x0F]; |
|
365 | + $count += $BITS_SET_IN_HALF_BYTE[self::uRShift($a, $i)&0x0F]; |
|
366 | 366 | } |
367 | 367 | |
368 | 368 | return $count; |
@@ -73,8 +73,8 @@ discard block |
||
73 | 73 | |
74 | 74 | if($file !== null){ |
75 | 75 | return '<!DOCTYPE html>'. |
76 | - '<head><meta charset="UTF-8"><title>QR Code</title></head>'. |
|
77 | - '<body>'.$this->options->eol.$html.'</body>'; |
|
76 | + '<head><meta charset="UTF-8"><title>QR Code</title></head>'. |
|
77 | + '<body>'.$this->options->eol.$html.'</body>'; |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | return $html; |
@@ -89,9 +89,9 @@ discard block |
||
89 | 89 | $matrix = $this->matrix->matrix(); |
90 | 90 | |
91 | 91 | $svg = sprintf($this->svgHeader, $this->options->cssClass, $this->options->svgViewBoxSize ?? $this->moduleCount) |
92 | - .$this->options->eol |
|
93 | - .'<defs>'.$this->options->svgDefs.'</defs>' |
|
94 | - .$this->options->eol; |
|
92 | + .$this->options->eol |
|
93 | + .'<defs>'.$this->options->svgDefs.'</defs>' |
|
94 | + .$this->options->eol; |
|
95 | 95 | |
96 | 96 | foreach($this->moduleValues as $M_TYPE => $value){ |
97 | 97 | $path = ''; |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | // if saving to file, append the correct headers |
146 | 146 | if($file !== null){ |
147 | 147 | return '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">'. |
148 | - $this->options->eol.$svg; |
|
148 | + $this->options->eol.$svg; |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | if($this->options->imageBase64){ |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | $matrix[$y] = []; |
122 | 122 | |
123 | 123 | foreach($row as $x => $val){ |
124 | - $matrix[$y][$x] = ($val & $this::IS_DARK) === $this::IS_DARK; |
|
124 | + $matrix[$y][$x] = ($val&$this::IS_DARK) === $this::IS_DARK; |
|
125 | 125 | } |
126 | 126 | } |
127 | 127 | |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | /** |
146 | 146 | * Returns the current mask pattern |
147 | 147 | */ |
148 | - public function maskPattern():?MaskPattern{ |
|
148 | + public function maskPattern(): ?MaskPattern{ |
|
149 | 149 | return $this->maskPattern; |
150 | 150 | } |
151 | 151 | |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | * false => $M_TYPE |
173 | 173 | */ |
174 | 174 | public function set(int $x, int $y, bool $value, int $M_TYPE):self{ |
175 | - $this->matrix[$y][$x] = $M_TYPE | ($value ? $this::IS_DARK : 0); |
|
175 | + $this->matrix[$y][$x] = $M_TYPE|($value ? $this::IS_DARK : 0); |
|
176 | 176 | |
177 | 177 | return $this; |
178 | 178 | } |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | * true => $value & $M_TYPE === $M_TYPE |
193 | 193 | */ |
194 | 194 | public function checkType(int $x, int $y, int $M_TYPE):bool{ |
195 | - return ($this->matrix[$y][$x] & $M_TYPE) === $M_TYPE; |
|
195 | + return ($this->matrix[$y][$x]&$M_TYPE) === $M_TYPE; |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | /** |
@@ -270,8 +270,8 @@ discard block |
||
270 | 270 | |
271 | 271 | for($c = 0; $c < 3; $c++){ |
272 | 272 | for($i = 0; $i < 8; $i++){ |
273 | - $this->set($h[$c][0] , $h[$c][1] + $i, false, $this::M_SEPARATOR); |
|
274 | - $this->set($v[$c][0] - $i, $v[$c][1] , false, $this::M_SEPARATOR); |
|
273 | + $this->set($h[$c][0], $h[$c][1] + $i, false, $this::M_SEPARATOR); |
|
274 | + $this->set($v[$c][0] - $i, $v[$c][1], false, $this::M_SEPARATOR); |
|
275 | 275 | } |
276 | 276 | } |
277 | 277 | |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | for($i = 0; $i < 18; $i++){ |
346 | 346 | $a = (int)($i / 3); |
347 | 347 | $b = $i % 3 + $this->moduleCount - 8 - 3; |
348 | - $v = !$test && (($bits >> $i) & 1) === 1; |
|
348 | + $v = !$test && (($bits >> $i)&1) === 1; |
|
349 | 349 | |
350 | 350 | $this->set($b, $a, $v, $this::M_VERSION); // ne |
351 | 351 | $this->set($a, $b, $v, $this::M_VERSION); // sw |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | $bits = $this->eccLevel->getformatPattern($maskPattern); |
366 | 366 | |
367 | 367 | for($i = 0; $i < 15; $i++){ |
368 | - $v = !$test && (($bits >> $i) & 1) === 1; |
|
368 | + $v = !$test && (($bits >> $i)&1) === 1; |
|
369 | 369 | |
370 | 370 | if($i < 6){ |
371 | 371 | $this->set(8, $i, $v, $this::M_FORMAT); |
@@ -487,7 +487,7 @@ discard block |
||
487 | 487 | foreach($this->matrix as $y => $row){ |
488 | 488 | foreach($row as $x => $val){ |
489 | 489 | // out of bounds, skip |
490 | - if($x < $start || $y < $start ||$x >= $end || $y >= $end){ |
|
490 | + if($x < $start || $y < $start || $x >= $end || $y >= $end){ |
|
491 | 491 | continue; |
492 | 492 | } |
493 | 493 | // a match |
@@ -531,10 +531,10 @@ discard block |
||
531 | 531 | $v = false; |
532 | 532 | |
533 | 533 | if($byteIndex < $byteCount){ |
534 | - $v = (($data[$byteIndex] >> $bitIndex) & 1) === 1; |
|
534 | + $v = (($data[$byteIndex] >> $bitIndex)&1) === 1; |
|
535 | 535 | } |
536 | 536 | |
537 | - $this->matrix[$y][$x] = $this::M_DATA | ($v ? $this::IS_DARK : 0); |
|
537 | + $this->matrix[$y][$x] = $this::M_DATA|($v ? $this::IS_DARK : 0); |
|
538 | 538 | $bitIndex--; |
539 | 539 | |
540 | 540 | if($bitIndex === -1){ |
@@ -548,7 +548,7 @@ discard block |
||
548 | 548 | $y += $inc; |
549 | 549 | |
550 | 550 | if($y < 0 || $this->moduleCount <= $y){ |
551 | - $y -= $inc; |
|
551 | + $y -= $inc; |
|
552 | 552 | $inc = -$inc; |
553 | 553 | |
554 | 554 | break; |
@@ -571,7 +571,7 @@ discard block |
||
571 | 571 | |
572 | 572 | foreach($this->matrix as $y => &$row){ |
573 | 573 | foreach($row as $x => &$val){ |
574 | - if($mask($x, $y) && ($val & $this::M_DATA) === $this::M_DATA){ |
|
574 | + if($mask($x, $y) && ($val&$this::M_DATA) === $this::M_DATA){ |
|
575 | 575 | $val ^= $this::IS_DARK; |
576 | 576 | } |
577 | 577 | } |