@@ -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'); |
@@ -105,7 +105,7 @@ |
||
| 105 | 105 | [$numEccCodewords, $eccBlocks] = $this->version->getRSBlocks($this->eccLevel); |
| 106 | 106 | |
| 107 | 107 | // Now establish DataBlocks of the appropriate size and number of data codewords |
| 108 | - $result = [];//new DataBlock[$totalBlocks]; |
|
| 108 | + $result = []; //new DataBlock[$totalBlocks]; |
|
| 109 | 109 | $numResultBlocks = 0; |
| 110 | 110 | |
| 111 | 111 | foreach($eccBlocks as $blockData){ |
@@ -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->size(); |
| 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->size(); |
| 419 | 419 | $stateCount = $this->getCrossCheckStateCount(); |
| 420 | 420 | |
@@ -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->size(); |
| 282 | 282 | $allowance = (int)($allowanceFactor * $overallEstModuleSize); |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | public function __construct(BitMatrix $matrix, float $moduleSize){ |
| 45 | 45 | $this->matrix = $matrix; |
| 46 | 46 | $this->moduleSize = $moduleSize; |
| 47 | - $this->possibleCenters = []; |
|
| 47 | + $this->possibleCenters = []; |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | /** |
@@ -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->matrix->size(); |
| 228 | 228 | $stateCount = []; |
| 229 | 229 | $stateCount[0] = 0; |
@@ -222,8 +222,8 @@ discard block |
||
| 222 | 222 | // Should return null, but, some QR codes apparently do not mask this info. |
| 223 | 223 | // Try again by actually masking the pattern first. |
| 224 | 224 | $formatInfo = $this->doDecodeFormatInformation( |
| 225 | - $formatInfoBits1 ^ $this::FORMAT_INFO_MASK_QR, |
|
| 226 | - $formatInfoBits2 ^ $this::FORMAT_INFO_MASK_QR |
|
| 225 | + $formatInfoBits1^$this::FORMAT_INFO_MASK_QR, |
|
| 226 | + $formatInfoBits2^$this::FORMAT_INFO_MASK_QR |
|
| 227 | 227 | ); |
| 228 | 228 | |
| 229 | 229 | // still nothing??? |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | ? $this->check($j, $i) |
| 249 | 249 | : $this->check($i, $j); |
| 250 | 250 | |
| 251 | - return $bit ? ($versionBits << 1) | 0x1 : $versionBits << 1; |
|
| 251 | + return $bit ? ($versionBits << 1)|0x1 : $versionBits << 1; |
|
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | /** |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | * |
| 259 | 259 | * @return int|null information about the format it specifies, or null if doesn't seem to match any known pattern |
| 260 | 260 | */ |
| 261 | - private function doDecodeFormatInformation(int $maskedFormatInfo1, int $maskedFormatInfo2):?int{ |
|
| 261 | + private function doDecodeFormatInformation(int $maskedFormatInfo1, int $maskedFormatInfo2): ?int{ |
|
| 262 | 262 | // Find the int in FORMAT_INFO_DECODE_LOOKUP with fewest bits differing |
| 263 | 263 | $bestDifference = PHP_INT_MAX; |
| 264 | 264 | $bestFormatInfo = 0; |
@@ -354,7 +354,7 @@ discard block |
||
| 354 | 354 | /** |
| 355 | 355 | * |
| 356 | 356 | */ |
| 357 | - private function decodeVersionInformation(int $versionBits):?Version{ |
|
| 357 | + private function decodeVersionInformation(int $versionBits): ?Version{ |
|
| 358 | 358 | $bestDifference = PHP_INT_MAX; |
| 359 | 359 | $bestVersion = 0; |
| 360 | 360 | |
@@ -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 | |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | |
| 235 | 235 | for($xx = 0; $xx < self::BLOCK_SIZE; $xx++){ |
| 236 | 236 | $pixel = (int)($this->luminances[(int)($offset + $xx)]) & 0xff; |
| 237 | - $sum += $pixel; |
|
| 237 | + $sum += $pixel; |
|
| 238 | 238 | // still looking for good contrast |
| 239 | 239 | if($pixel < $min){ |
| 240 | 240 | $min = $pixel; |
@@ -59,13 +59,13 @@ discard block |
||
| 59 | 59 | */ |
| 60 | 60 | protected const neighbours = [ |
| 61 | 61 | 0b00000001 => [-1, -1], |
| 62 | - 0b00000010 => [ 0, -1], |
|
| 63 | - 0b00000100 => [ 1, -1], |
|
| 64 | - 0b00001000 => [ 1, 0], |
|
| 65 | - 0b00010000 => [ 1, 1], |
|
| 66 | - 0b00100000 => [ 0, 1], |
|
| 67 | - 0b01000000 => [-1, 1], |
|
| 68 | - 0b10000000 => [-1, 0] |
|
| 62 | + 0b00000010 => [0, -1], |
|
| 63 | + 0b00000100 => [1, -1], |
|
| 64 | + 0b00001000 => [1, 0], |
|
| 65 | + 0b00010000 => [1, 1], |
|
| 66 | + 0b00100000 => [0, 1], |
|
| 67 | + 0b01000000 => [-1, 1], |
|
| 68 | + 0b10000000 => [-1, 0] |
|
| 69 | 69 | ]; |
| 70 | 70 | |
| 71 | 71 | /** |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | $matrix[$y] = []; |
| 139 | 139 | |
| 140 | 140 | foreach($row as $x => $val){ |
| 141 | - $matrix[$y][$x] = ($val & $this::IS_DARK) === $this::IS_DARK; |
|
| 141 | + $matrix[$y][$x] = ($val&$this::IS_DARK) === $this::IS_DARK; |
|
| 142 | 142 | } |
| 143 | 143 | } |
| 144 | 144 | |
@@ -148,21 +148,21 @@ discard block |
||
| 148 | 148 | /** |
| 149 | 149 | * Returns the current version number |
| 150 | 150 | */ |
| 151 | - public function version():?Version{ |
|
| 151 | + public function version(): ?Version{ |
|
| 152 | 152 | return $this->version; |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | /** |
| 156 | 156 | * Returns the current ECC level |
| 157 | 157 | */ |
| 158 | - public function eccLevel():?EccLevel{ |
|
| 158 | + public function eccLevel(): ?EccLevel{ |
|
| 159 | 159 | return $this->eccLevel; |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | /** |
| 163 | 163 | * Returns the current mask pattern |
| 164 | 164 | */ |
| 165 | - public function maskPattern():?MaskPattern{ |
|
| 165 | + public function maskPattern(): ?MaskPattern{ |
|
| 166 | 166 | return $this->maskPattern; |
| 167 | 167 | } |
| 168 | 168 | |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | public function set(int $x, int $y, bool $value, int $M_TYPE):self{ |
| 197 | 197 | |
| 198 | 198 | if(isset($this->matrix[$y][$x])){ |
| 199 | - $this->matrix[$y][$x] = $M_TYPE | ($value ? $this::IS_DARK : 0); |
|
| 199 | + $this->matrix[$y][$x] = $M_TYPE|($value ? $this::IS_DARK : 0); |
|
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | return $this; |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | return false; |
| 226 | 226 | } |
| 227 | 227 | |
| 228 | - return ($this->matrix[$y][$x] & $M_TYPE) === $M_TYPE; |
|
| 228 | + return ($this->matrix[$y][$x]&$M_TYPE) === $M_TYPE; |
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | /** |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | [$ix, $iy] = $coord; |
| 271 | 271 | |
| 272 | 272 | // check if the field is the same type |
| 273 | - if($M_TYPE_VALUE !== null && ($this->get($x + $ix, $y + $iy) | $this::IS_DARK) !== ($M_TYPE_VALUE | $this::IS_DARK)){ |
|
| 273 | + if($M_TYPE_VALUE !== null && ($this->get($x + $ix, $y + $iy)|$this::IS_DARK) !== ($M_TYPE_VALUE|$this::IS_DARK)){ |
|
| 274 | 274 | continue; |
| 275 | 275 | } |
| 276 | 276 | |
@@ -349,8 +349,8 @@ discard block |
||
| 349 | 349 | |
| 350 | 350 | for($c = 0; $c < 3; $c++){ |
| 351 | 351 | for($i = 0; $i < 8; $i++){ |
| 352 | - $this->set($h[$c][0] , $h[$c][1] + $i, false, $this::M_SEPARATOR); |
|
| 353 | - $this->set($v[$c][0] - $i, $v[$c][1] , false, $this::M_SEPARATOR); |
|
| 352 | + $this->set($h[$c][0], $h[$c][1] + $i, false, $this::M_SEPARATOR); |
|
| 353 | + $this->set($v[$c][0] - $i, $v[$c][1], false, $this::M_SEPARATOR); |
|
| 354 | 354 | } |
| 355 | 355 | } |
| 356 | 356 | |
@@ -574,7 +574,7 @@ discard block |
||
| 574 | 574 | foreach($this->matrix as $y => $row){ |
| 575 | 575 | foreach($row as $x => $val){ |
| 576 | 576 | // out of bounds, skip |
| 577 | - if($x < $start || $y < $start ||$x >= $end || $y >= $end){ |
|
| 577 | + if($x < $start || $y < $start || $x >= $end || $y >= $end){ |
|
| 578 | 578 | continue; |
| 579 | 579 | } |
| 580 | 580 | // a match |
@@ -642,7 +642,7 @@ discard block |
||
| 642 | 642 | |
| 643 | 643 | foreach($this->matrix as $y => $row){ |
| 644 | 644 | foreach($row as $x => $val){ |
| 645 | - if($mask($x, $y) && ($val & $this::M_DATA) === $this::M_DATA){ |
|
| 645 | + if($mask($x, $y) && ($val&$this::M_DATA) === $this::M_DATA){ |
|
| 646 | 646 | $this->flip($x, $y); |
| 647 | 647 | } |
| 648 | 648 | } |
@@ -116,7 +116,7 @@ |
||
| 116 | 116 | |
| 117 | 117 | // scale down to the expected size |
| 118 | 118 | if($this->options->drawCircularModules && $this->options->scale <= 20){ |
| 119 | - $this->image = imagescale($this->image, $this->length/10, $this->length/10, IMG_BILINEAR_FIXED); |
|
| 119 | + $this->image = imagescale($this->image, $this->length / 10, $this->length / 10, IMG_BILINEAR_FIXED); |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | if($this->options->returnResource){ |