mirror of
https://github.com/chillerlan/php-qrcode.git
synced 2026-10-10 13:55:53 +00:00
:octocat: switch phan for phpstan (see #277)
This commit is contained in:
@@ -47,6 +47,7 @@ final class Binarizer{
|
||||
private const LUMINANCE_BUCKETS = 32;
|
||||
|
||||
private LuminanceSourceInterface $source;
|
||||
/** @var int[] */
|
||||
private array $luminances;
|
||||
|
||||
/**
|
||||
@@ -58,6 +59,7 @@ final class Binarizer{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int[] $buckets
|
||||
* @throws \chillerlan\QRCode\Decoder\QRCodeDecoderException
|
||||
*/
|
||||
private function estimateBlackPoint(array $buckets):int{
|
||||
@@ -204,6 +206,8 @@ final class Binarizer{
|
||||
* See the following thread for a discussion of this algorithm:
|
||||
*
|
||||
* @see http://groups.google.com/group/zxing/browse_thread/thread/d06efa2c35a7ddc0
|
||||
*
|
||||
* @return float[][]
|
||||
*/
|
||||
private function calculateBlackPoints(int $subWidth, int $subHeight, int $width, int $height):array{
|
||||
$blackPoints = array_fill(0, $subHeight, array_fill(0, $subWidth, 0));
|
||||
|
||||
@@ -105,6 +105,7 @@ final class BitMatrix extends QRMatrix{
|
||||
* correct order in order to reconstruct the codewords bytes contained within the
|
||||
* QR Code. Throws if the exact number of bytes expected is not read.
|
||||
*
|
||||
* @return int[]
|
||||
* @throws \chillerlan\QRCode\Decoder\QRCodeDecoderException
|
||||
*/
|
||||
public function readCodewords():array{
|
||||
@@ -362,7 +363,6 @@ final class BitMatrix extends QRMatrix{
|
||||
|
||||
// Otherwise see if this is the closest to a real version info bit string
|
||||
// we have seen so far
|
||||
/** @phan-suppress-next-line PhanTypeMismatchArgumentNullable ($targetVersionPattern is never null here) */
|
||||
$bitsDifference = $this->numBitsDiffering($versionBits, $targetVersionPattern);
|
||||
|
||||
if($bitsDifference < $bestDifference){
|
||||
|
||||
@@ -40,6 +40,8 @@ final class DecoderResult{
|
||||
|
||||
/**
|
||||
* DecoderResult constructor.
|
||||
*
|
||||
* @phpstan-param array<string, mixed> $properties
|
||||
*/
|
||||
public function __construct(iterable|null $properties = null){
|
||||
|
||||
|
||||
@@ -47,6 +47,8 @@ final class ReedSolomonDecoder{
|
||||
|
||||
/**
|
||||
* Error-correct and copy data blocks together into a stream of bytes
|
||||
*
|
||||
* @param int[] $rawCodewords
|
||||
*/
|
||||
public function decode(array $rawCodewords):BitBuffer{
|
||||
$dataBlocks = $this->deinterleaveRawBytes($rawCodewords);
|
||||
@@ -69,6 +71,8 @@ final class ReedSolomonDecoder{
|
||||
* method will separate the data into original blocks.
|
||||
*
|
||||
* @throws \chillerlan\QRCode\Decoder\QRCodeDecoderException
|
||||
*
|
||||
* @param int[] $rawCodewords
|
||||
*/
|
||||
private function deinterleaveRawBytes(array $rawCodewords):array{
|
||||
// Figure out the number and size of data blocks used by this version and
|
||||
@@ -87,7 +91,6 @@ final class ReedSolomonDecoder{
|
||||
|
||||
// All blocks have the same amount of data, except that the last n
|
||||
// (where n may be 0) have 1 more byte. Figure out where these start.
|
||||
/** @phan-suppress-next-line PhanTypePossiblyInvalidDimOffset */
|
||||
$shorterBlocksTotalCodewords = count($result[0][1]);
|
||||
$longerBlocksStartAt = (count($result) - 1);
|
||||
|
||||
@@ -120,7 +123,6 @@ final class ReedSolomonDecoder{
|
||||
}
|
||||
|
||||
// Now add in error correction blocks
|
||||
/** @phan-suppress-next-line PhanTypePossiblyInvalidDimOffset */
|
||||
$max = count($result[0][1]);
|
||||
|
||||
for($i = $shorterBlocksNumDataCodewords; $i < $max; $i++){
|
||||
@@ -137,6 +139,9 @@ final class ReedSolomonDecoder{
|
||||
/**
|
||||
* Given data and error-correction codewords received, possibly corrupted by errors, attempts to
|
||||
* correct the errors in-place using Reed-Solomon error correction.
|
||||
*
|
||||
* @param int[] $codewordBytes
|
||||
* @return int[]
|
||||
*/
|
||||
private function correctErrors(array $codewordBytes, int $numDataCodewords):array{
|
||||
// First read into an array of ints
|
||||
@@ -162,7 +167,7 @@ final class ReedSolomonDecoder{
|
||||
* codewords. Really, this means it uses Reed-Solomon to detect and correct errors, in-place,
|
||||
* in the input.
|
||||
*
|
||||
* @param array $received data and error-correction codewords
|
||||
* @param int[] $received data and error-correction codewords
|
||||
* @param int $numEccCodewords number of error-correction codewords available
|
||||
*
|
||||
* @return int[]
|
||||
@@ -255,6 +260,7 @@ final class ReedSolomonDecoder{
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int[]
|
||||
* @throws \chillerlan\QRCode\Decoder\QRCodeDecoderException
|
||||
*/
|
||||
private function findErrorLocations(GenericGFPoly $errorLocator):array{
|
||||
@@ -283,7 +289,8 @@ final class ReedSolomonDecoder{
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param int[] $errorLocations
|
||||
* @return int[]
|
||||
*/
|
||||
private function findErrorMagnitudes(GenericGFPoly $errorEvaluator, array $errorLocations):array{
|
||||
// This is directly applying Forney's Formula
|
||||
|
||||
Reference in New Issue
Block a user