@@ -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 | /** |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | ? $this->bitMatrix->get($j, $i) |
| 68 | 68 | : $this->bitMatrix->get($i, $j); |
| 69 | 69 | |
| 70 | - return $bit ? ($versionBits << 1) | 0x1 : $versionBits << 1; |
|
| 70 | + return $bit ? ($versionBits << 1)|0x1 : $versionBits << 1; |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | /** |
@@ -186,8 +186,8 @@ discard block |
||
| 186 | 186 | // Should return null, but, some QR codes apparently do not mask this info. |
| 187 | 187 | // Try again by actually masking the pattern first. |
| 188 | 188 | $this->parsedFormatInfo = $this->doDecodeFormatInformation( |
| 189 | - $formatInfoBits1 ^ FormatInformation::MASK_QR, |
|
| 190 | - $formatInfoBits2 ^ FormatInformation::MASK_QR |
|
| 189 | + $formatInfoBits1^FormatInformation::MASK_QR, |
|
| 190 | + $formatInfoBits2^FormatInformation::MASK_QR |
|
| 191 | 191 | ); |
| 192 | 192 | |
| 193 | 193 | if($this->parsedFormatInfo !== null){ |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | * @return \chillerlan\QRCode\Common\FormatInformation|null information about the format it specifies, or null |
| 206 | 206 | * if doesn't seem to match any known pattern |
| 207 | 207 | */ |
| 208 | - private function doDecodeFormatInformation(int $maskedFormatInfo1, int $maskedFormatInfo2):?FormatInformation{ |
|
| 208 | + private function doDecodeFormatInformation(int $maskedFormatInfo1, int $maskedFormatInfo2): ?FormatInformation{ |
|
| 209 | 209 | // Find the int in FORMAT_INFO_DECODE_LOOKUP with fewest bits differing |
| 210 | 210 | $bestDifference = PHP_INT_MAX; |
| 211 | 211 | $bestFormatInfo = 0; |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | * |
| 303 | 303 | * @return \chillerlan\QRCode\Common\Version|null |
| 304 | 304 | */ |
| 305 | - private function decodeVersionInformation(int $versionBits):?Version{ |
|
| 305 | + private function decodeVersionInformation(int $versionBits): ?Version{ |
|
| 306 | 306 | $bestDifference = PHP_INT_MAX; |
| 307 | 307 | $bestVersion = 0; |
| 308 | 308 | |
@@ -341,7 +341,7 @@ discard block |
||
| 341 | 341 | return $a; |
| 342 | 342 | } |
| 343 | 343 | |
| 344 | - return ($a >> $b) & ~((1 << (8 * PHP_INT_SIZE - 1)) >> ($b - 1)); |
|
| 344 | + return ($a >> $b)&~((1 << (8 * PHP_INT_SIZE - 1)) >> ($b - 1)); |
|
| 345 | 345 | } |
| 346 | 346 | |
| 347 | 347 | private static function numBitsDiffering(int $a, int $b):int{ |
@@ -353,7 +353,7 @@ discard block |
||
| 353 | 353 | $count = 0; |
| 354 | 354 | |
| 355 | 355 | for($i = 0; $i < 32; $i += 4){ |
| 356 | - $count += $BITS_SET_IN_HALF_BYTE[self::uRShift($a, $i) & 0x0F]; |
|
| 356 | + $count += $BITS_SET_IN_HALF_BYTE[self::uRShift($a, $i)&0x0F]; |
|
| 357 | 357 | } |
| 358 | 358 | |
| 359 | 359 | return $count; |
@@ -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 | } |