@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | [$numEccCodewords, $eccBlocks] = $version->getRSBlocks($eccLevel); |
| 128 | 128 | |
| 129 | 129 | // Now establish DataBlocks of the appropriate size and number of data codewords |
| 130 | - $result = [];//new DataBlock[$totalBlocks]; |
|
| 130 | + $result = []; //new DataBlock[$totalBlocks]; |
|
| 131 | 131 | $numResultBlocks = 0; |
| 132 | 132 | |
| 133 | 133 | foreach($eccBlocks as $blockData){ |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | $codewordsInts = []; |
| 196 | 196 | |
| 197 | 197 | foreach($codewordBytes as $i => $codewordByte){ |
| 198 | - $codewordsInts[$i] = $codewordByte & 0xFF; |
|
| 198 | + $codewordsInts[$i] = $codewordByte&0xFF; |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | $decoded = (new ReedSolomonDecoder)->decode($codewordsInts, (count($codewordBytes) - $numDataCodewords)); |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | $offset = (int)($y * $this->rowSize + ($x / 0x20)); |
| 48 | 48 | |
| 49 | 49 | $this->bits[$offset] ??= 0; |
| 50 | - $this->bits[$offset] |= ($this->bits[$offset] |= 1 << ($x & 0x1f)); |
|
| 50 | + $this->bits[$offset] |= ($this->bits[$offset] |= 1 << ($x&0x1f)); |
|
| 51 | 51 | |
| 52 | 52 | return $this; |
| 53 | 53 | } |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | public function flip(int $x, int $y):self{ |
| 62 | 62 | $offset = $y * $this->rowSize + (int)($x / 0x20); |
| 63 | 63 | |
| 64 | - $this->bits[$offset] = ($this->bits[$offset] ^ (1 << ($x & 0x1f))); |
|
| 64 | + $this->bits[$offset] = ($this->bits[$offset]^(1 << ($x&0x1f))); |
|
| 65 | 65 | |
| 66 | 66 | return $this; |
| 67 | 67 | } |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | |
| 99 | 99 | for($x = $left; $x < $right; $x++){ |
| 100 | 100 | $xOffset = $yOffset + (int)($x / 0x20); |
| 101 | - $this->bits[$xOffset] = ($this->bits[$xOffset] |= 1 << ($x & 0x1f)); |
|
| 101 | + $this->bits[$xOffset] = ($this->bits[$xOffset] |= 1 << ($x&0x1f)); |
|
| 102 | 102 | } |
| 103 | 103 | } |
| 104 | 104 | |
@@ -115,14 +115,14 @@ discard block |
||
| 115 | 115 | /** |
| 116 | 116 | * |
| 117 | 117 | */ |
| 118 | - public function getFormatInfo():?FormatInformation{ |
|
| 118 | + public function getFormatInfo(): ?FormatInformation{ |
|
| 119 | 119 | return $this->formatInfo; |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | /** |
| 123 | 123 | * |
| 124 | 124 | */ |
| 125 | - public function getVersion():?Version{ |
|
| 125 | + public function getVersion(): ?Version{ |
|
| 126 | 126 | return $this->version; |
| 127 | 127 | } |
| 128 | 128 | |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | |
| 140 | 140 | $this->bits[$offset] ??= 0; |
| 141 | 141 | |
| 142 | - return ($this->uRShift($this->bits[$offset], ($x & 0x1f)) & 1) !== 0; |
|
| 142 | + return ($this->uRShift($this->bits[$offset], ($x&0x1f))&1) !== 0; |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | /** |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | ? $this->get($j, $i) |
| 248 | 248 | : $this->get($i, $j); |
| 249 | 249 | |
| 250 | - return $bit ? ($versionBits << 1) | 0x1 : $versionBits << 1; |
|
| 250 | + return $bit ? ($versionBits << 1)|0x1 : $versionBits << 1; |
|
| 251 | 251 | } |
| 252 | 252 | |
| 253 | 253 | /** |
@@ -364,8 +364,8 @@ discard block |
||
| 364 | 364 | // Should return null, but, some QR codes apparently do not mask this info. |
| 365 | 365 | // Try again by actually masking the pattern first. |
| 366 | 366 | $this->formatInfo = $this->doDecodeFormatInformation( |
| 367 | - $formatInfoBits1 ^ FormatInformation::FORMAT_INFO_MASK_QR, |
|
| 368 | - $formatInfoBits2 ^ FormatInformation::FORMAT_INFO_MASK_QR |
|
| 367 | + $formatInfoBits1^FormatInformation::FORMAT_INFO_MASK_QR, |
|
| 368 | + $formatInfoBits2^FormatInformation::FORMAT_INFO_MASK_QR |
|
| 369 | 369 | ); |
| 370 | 370 | |
| 371 | 371 | if($this->formatInfo !== null){ |
@@ -383,7 +383,7 @@ discard block |
||
| 383 | 383 | * @return \chillerlan\QRCode\Common\FormatInformation|null information about the format it specifies, or null |
| 384 | 384 | * if doesn't seem to match any known pattern |
| 385 | 385 | */ |
| 386 | - private function doDecodeFormatInformation(int $maskedFormatInfo1, int $maskedFormatInfo2):?FormatInformation{ |
|
| 386 | + private function doDecodeFormatInformation(int $maskedFormatInfo1, int $maskedFormatInfo2): ?FormatInformation{ |
|
| 387 | 387 | // Find the int in FORMAT_INFO_DECODE_LOOKUP with fewest bits differing |
| 388 | 388 | $bestDifference = PHP_INT_MAX; |
| 389 | 389 | $bestFormatInfo = 0; |
@@ -479,7 +479,7 @@ discard block |
||
| 479 | 479 | * |
| 480 | 480 | * @return \chillerlan\QRCode\Common\Version|null |
| 481 | 481 | */ |
| 482 | - private function decodeVersionInformation(int $versionBits):?Version{ |
|
| 482 | + private function decodeVersionInformation(int $versionBits): ?Version{ |
|
| 483 | 483 | $bestDifference = PHP_INT_MAX; |
| 484 | 484 | $bestVersion = 0; |
| 485 | 485 | |
@@ -521,7 +521,7 @@ discard block |
||
| 521 | 521 | return $a; |
| 522 | 522 | } |
| 523 | 523 | |
| 524 | - return ($a >> $b) & ~((1 << (8 * PHP_INT_SIZE - 1)) >> ($b - 1)); |
|
| 524 | + return ($a >> $b)&~((1 << (8 * PHP_INT_SIZE - 1)) >> ($b - 1)); |
|
| 525 | 525 | } |
| 526 | 526 | |
| 527 | 527 | /** |
@@ -536,7 +536,7 @@ discard block |
||
| 536 | 536 | $count = 0; |
| 537 | 537 | |
| 538 | 538 | for($i = 0; $i < 32; $i += 4){ |
| 539 | - $count += $BITS_SET_IN_HALF_BYTE[$this->uRShift($a, $i) & 0x0F]; |
|
| 539 | + $count += $BITS_SET_IN_HALF_BYTE[$this->uRShift($a, $i)&0x0F]; |
|
| 540 | 540 | } |
| 541 | 541 | |
| 542 | 542 | return $count; |
@@ -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 | /** |
@@ -280,8 +280,8 @@ discard block |
||
| 280 | 280 | |
| 281 | 281 | for($c = 0; $c < 3; $c++){ |
| 282 | 282 | for($i = 0; $i < 8; $i++){ |
| 283 | - $this->set($h[$c][0] , $h[$c][1] + $i, false, $this::M_SEPARATOR); |
|
| 284 | - $this->set($v[$c][0] - $i, $v[$c][1] , false, $this::M_SEPARATOR); |
|
| 283 | + $this->set($h[$c][0], $h[$c][1] + $i, false, $this::M_SEPARATOR); |
|
| 284 | + $this->set($v[$c][0] - $i, $v[$c][1], false, $this::M_SEPARATOR); |
|
| 285 | 285 | } |
| 286 | 286 | } |
| 287 | 287 | |
@@ -355,7 +355,7 @@ discard block |
||
| 355 | 355 | for($i = 0; $i < 18; $i++){ |
| 356 | 356 | $a = (int)($i / 3); |
| 357 | 357 | $b = $i % 3 + $this->moduleCount - 8 - 3; |
| 358 | - $v = (($bits >> $i) & 1) === 1; |
|
| 358 | + $v = (($bits >> $i)&1) === 1; |
|
| 359 | 359 | |
| 360 | 360 | $this->set($b, $a, $v, $this::M_VERSION); // ne |
| 361 | 361 | $this->set($a, $b, $v, $this::M_VERSION); // sw |
@@ -375,7 +375,7 @@ discard block |
||
| 375 | 375 | $bits = $this->eccLevel->getformatPattern($maskPattern); |
| 376 | 376 | |
| 377 | 377 | for($i = 0; $i < 15; $i++){ |
| 378 | - $v = (($bits >> $i) & 1) === 1; |
|
| 378 | + $v = (($bits >> $i)&1) === 1; |
|
| 379 | 379 | |
| 380 | 380 | if($i < 6){ |
| 381 | 381 | $this->set(8, $i, $v, $this::M_FORMAT); |
@@ -495,7 +495,7 @@ discard block |
||
| 495 | 495 | foreach($this->matrix as $y => $row){ |
| 496 | 496 | foreach($row as $x => $val){ |
| 497 | 497 | // out of bounds, skip |
| 498 | - if($x < $start || $y < $start ||$x >= $end || $y >= $end){ |
|
| 498 | + if($x < $start || $y < $start || $x >= $end || $y >= $end){ |
|
| 499 | 499 | continue; |
| 500 | 500 | } |
| 501 | 501 | // a match |
@@ -542,10 +542,10 @@ discard block |
||
| 542 | 542 | $v = false; |
| 543 | 543 | |
| 544 | 544 | if($byteIndex < $byteCount){ |
| 545 | - $v = (($data[$byteIndex] >> $bitIndex) & 1) === 1; |
|
| 545 | + $v = (($data[$byteIndex] >> $bitIndex)&1) === 1; |
|
| 546 | 546 | } |
| 547 | 547 | |
| 548 | - $this->matrix[$y][$x] = $this::M_DATA | ($v ? $this::IS_DARK : 0); |
|
| 548 | + $this->matrix[$y][$x] = $this::M_DATA|($v ? $this::IS_DARK : 0); |
|
| 549 | 549 | $bitIndex--; |
| 550 | 550 | |
| 551 | 551 | if($bitIndex === -1){ |
@@ -558,7 +558,7 @@ discard block |
||
| 558 | 558 | $y += $inc; |
| 559 | 559 | |
| 560 | 560 | if($y < 0 || $this->moduleCount <= $y){ |
| 561 | - $y -= $inc; |
|
| 561 | + $y -= $inc; |
|
| 562 | 562 | $inc = -$inc; |
| 563 | 563 | |
| 564 | 564 | break; |
@@ -581,7 +581,7 @@ discard block |
||
| 581 | 581 | |
| 582 | 582 | foreach($this->matrix as $y => &$row){ |
| 583 | 583 | foreach($row as $x => &$val){ |
| 584 | - if($mask($x, $y) && ($val & $this::M_DATA) === $this::M_DATA){ |
|
| 584 | + if($mask($x, $y) && ($val&$this::M_DATA) === $this::M_DATA){ |
|
| 585 | 585 | $val ^= $this::IS_DARK; |
| 586 | 586 | } |
| 587 | 587 | } |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | */ |
| 59 | 59 | public function __construct(int $maskPattern){ |
| 60 | 60 | |
| 61 | - if((0b111 & $maskPattern) !== $maskPattern){ |
|
| 61 | + if((0b111&$maskPattern) !== $maskPattern){ |
|
| 62 | 62 | throw new QRCodeException('invalid mask pattern'); |
| 63 | 63 | } |
| 64 | 64 | |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | $penalty += 3 + ($numSameBitCells - 5); |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | - $numSameBitCells = 1; // Include the cell itself. |
|
| 152 | + $numSameBitCells = 1; // Include the cell itself. |
|
| 153 | 153 | $prevBit = $bit; |
| 154 | 154 | } |
| 155 | 155 | } |