@@ -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 = []; |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | * |
| 175 | 175 | * @return \chillerlan\QRCode\Detector\AlignmentPattern|null if we have found the same pattern twice, or null if not |
| 176 | 176 | */ |
| 177 | - private function handlePossibleCenter(array $stateCount, int $i, int $j):?AlignmentPattern{ |
|
| 177 | + private function handlePossibleCenter(array $stateCount, int $i, int $j): ?AlignmentPattern{ |
|
| 178 | 178 | $stateCountTotal = $stateCount[0] + $stateCount[1] + $stateCount[2]; |
| 179 | 179 | $centerJ = $this->centerFromEnd($stateCount, $j); |
| 180 | 180 | $centerI = $this->crossCheckVertical($i, (int)$centerJ, 2 * $stateCount[1], $stateCountTotal); |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | * |
| 224 | 224 | * @return float|null vertical center of alignment pattern, or null if not found |
| 225 | 225 | */ |
| 226 | - private function crossCheckVertical(int $startI, int $centerJ, int $maxCount, int $originalStateCountTotal):?float{ |
|
| 226 | + private function crossCheckVertical(int $startI, int $centerJ, int $maxCount, int $originalStateCountTotal): ?float{ |
|
| 227 | 227 | $maxI = $this->bitMatrix->getDimension(); |
| 228 | 228 | $stateCount = []; |
| 229 | 229 | $stateCount[0] = 0; |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | * |
| 330 | 330 | * @return float|null vertical center of finder pattern, or null if not found |
| 331 | 331 | */ |
| 332 | - private function crossCheckVertical(int $startI, int $centerJ, int $maxCount, int $originalStateCountTotal):?float{ |
|
| 332 | + private function crossCheckVertical(int $startI, int $centerJ, int $maxCount, int $originalStateCountTotal): ?float{ |
|
| 333 | 333 | $maxI = $this->bitMatrix->getDimension(); |
| 334 | 334 | $stateCount = $this->getCrossCheckStateCount(); |
| 335 | 335 | |
@@ -412,7 +412,7 @@ discard block |
||
| 412 | 412 | * except it reads horizontally instead of vertically. This is used to cross-cross |
| 413 | 413 | * check a vertical cross check and locate the real center of the alignment pattern. |
| 414 | 414 | */ |
| 415 | - private function crossCheckHorizontal(int $startJ, int $centerI, int $maxCount, int $originalStateCountTotal):?float{ |
|
| 415 | + private function crossCheckHorizontal(int $startJ, int $centerI, int $maxCount, int $originalStateCountTotal): ?float{ |
|
| 416 | 416 | $maxJ = $this->bitMatrix->getDimension(); |
| 417 | 417 | $stateCount = $this->getCrossCheckStateCount(); |
| 418 | 418 | |
@@ -178,7 +178,7 @@ |
||
| 178 | 178 | // Above should work but fails on some Apple and Linux JDKs due to a Hotspot bug. |
| 179 | 179 | // Below is a funny-looking workaround from Steven Parkes |
| 180 | 180 | $term = GF256::multiply($errorLocations[$j], $xiInverse); |
| 181 | - $denominator = GF256::multiply($denominator, (($term & 0x1) === 0 ? $term | 1 : $term & ~1)); |
|
| 181 | + $denominator = GF256::multiply($denominator, (($term & 0x1) === 0 ? $term|1 : $term & ~1)); |
|
| 182 | 182 | } |
| 183 | 183 | } |
| 184 | 184 | |
@@ -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 | |
@@ -35,8 +35,8 @@ discard block |
||
| 35 | 35 | // This class uses 5x5 blocks to compute local luminance, where each block is 8x8 pixels. |
| 36 | 36 | // So this is the smallest dimension in each axis we can accept. |
| 37 | 37 | private const BLOCK_SIZE_POWER = 3; |
| 38 | - private const BLOCK_SIZE = 8; // ...0100...00 |
|
| 39 | - private const BLOCK_SIZE_MASK = 7; // ...0011...11 |
|
| 38 | + private const BLOCK_SIZE = 8; // ...0100...00 |
|
| 39 | + private const BLOCK_SIZE_MASK = 7; // ...0011...11 |
|
| 40 | 40 | private const MINIMUM_DIMENSION = 40; |
| 41 | 41 | private const MIN_DYNAMIC_RANGE = 24; |
| 42 | 42 | |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | |
| 237 | 237 | for($xx = 0; $xx < self::BLOCK_SIZE; $xx++){ |
| 238 | 238 | $pixel = (int)($luminances[(int)($offset + $xx)]) & 0xff; |
| 239 | - $sum += $pixel; |
|
| 239 | + $sum += $pixel; |
|
| 240 | 240 | // still looking for good contrast |
| 241 | 241 | if($pixel < $min){ |
| 242 | 242 | $min = $pixel; |
@@ -330,7 +330,7 @@ discard block |
||
| 330 | 330 | |
| 331 | 331 | for($z = -2; $z <= 2; $z++){ |
| 332 | 332 | $blackRow = $blackPoints[$top + $z]; |
| 333 | - $sum += $blackRow[$left - 2] + $blackRow[$left - 1] + $blackRow[$left] + $blackRow[$left + 1] + $blackRow[$left + 2]; |
|
| 333 | + $sum += $blackRow[$left - 2] + $blackRow[$left - 1] + $blackRow[$left] + $blackRow[$left + 1] + $blackRow[$left + 2]; |
|
| 334 | 334 | } |
| 335 | 335 | |
| 336 | 336 | $average = (int)($sum / 25); |