From 95cac35fdd5097fb987b522138537847fd7d5a79 Mon Sep 17 00:00:00 2001 From: codemasher Date: Mon, 25 Jan 2021 01:09:32 +0100 Subject: [PATCH] :fire_engine: phan happy --- src/Decoder/BitMatrixParser.php | 12 +++++++++--- src/Decoder/Decoder.php | 2 ++ src/Decoder/GDLuminanceSource.php | 8 +++----- src/Decoder/IMagickLuminanceSource.php | 2 +- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/Decoder/BitMatrixParser.php b/src/Decoder/BitMatrixParser.php index 190b7ff82..f56165cca 100644 --- a/src/Decoder/BitMatrixParser.php +++ b/src/Decoder/BitMatrixParser.php @@ -47,7 +47,7 @@ final class BitMatrixParser{ * {@link #readVersion()}. Before proceeding with {@link #readCodewords()} the * {@link #mirror()} method should be called. * - * @param bool mirror Whether to read version and format information mirrored. + * @param bool $mirror Whether to read version and format information mirrored. */ public function setMirror(bool $mirror):void{ $this->parsedVersion = null; @@ -203,8 +203,8 @@ final class BitMatrixParser{ * @param int $maskedFormatInfo2 second copy of same info; both are checked at the same time * to establish best match * - * @return \chillerlan\QRCode\Common\FormatInformation information about the format it specifies, or {@code null} - * if doesn't seem to match any known pattern + * @return \chillerlan\QRCode\Common\FormatInformation|null information about the format it specifies, or null + * if doesn't seem to match any known pattern */ private function doDecodeFormatInformation(int $maskedFormatInfo1, int $maskedFormatInfo2):?FormatInformation{ // Find the int in FORMAT_INFO_DECODE_LOOKUP with fewest bits differing @@ -298,6 +298,11 @@ final class BitMatrixParser{ throw new RuntimeException('failed to read version'); } + /** + * @param int $versionBits + * + * @return \chillerlan\QRCode\Common\Version|null + */ private function decodeVersionInformation(int $versionBits):?Version{ $bestDifference = PHP_INT_MAX; $bestVersion = 0; @@ -313,6 +318,7 @@ final class BitMatrixParser{ // 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 = numBitsDiffering($versionBits, $targetVersionPattern); if($bitsDifference < $bestDifference){ diff --git a/src/Decoder/Decoder.php b/src/Decoder/Decoder.php index f50f43ef1..d38f33818 100644 --- a/src/Decoder/Decoder.php +++ b/src/Decoder/Decoder.php @@ -153,6 +153,7 @@ final class Decoder{ // 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; @@ -185,6 +186,7 @@ final class Decoder{ } // Now add in error correction blocks + /** @phan-suppress-next-line PhanTypePossiblyInvalidDimOffset */ $max = count($result[0][1]); for($i = $shorterBlocksNumDataCodewords; $i < $max; $i++){ diff --git a/src/Decoder/GDLuminanceSource.php b/src/Decoder/GDLuminanceSource.php index 710887aae..787d3cb35 100644 --- a/src/Decoder/GDLuminanceSource.php +++ b/src/Decoder/GDLuminanceSource.php @@ -8,7 +8,7 @@ * @copyright 2021 Smiley * @license Apache-2.0 * - * @noinspection PhpComposerExtensionStubsInspection + * @noinspection PhpComposerExtensionStubsInspection */ namespace chillerlan\QRCode\Decoder; @@ -39,11 +39,9 @@ final class GDLuminanceSource extends LuminanceSource{ */ public function __construct($gdImage){ - /** - * @noinspection PhpElementIsNotAvailableInCurrentPhpVersionInspection - * @phan-suppress PhanUndeclaredClassInstanceof - */ + /** @noinspection PhpElementIsNotAvailableInCurrentPhpVersionInspection, PhpFullyQualifiedNameUsageInspection */ if( + /** @phan-suppress-next-line PhanUndeclaredClassInstanceof */ (PHP_MAJOR_VERSION >= 8 && !$gdImage instanceof \GdImage) || (PHP_MAJOR_VERSION < 8 && (!is_resource($gdImage) || get_resource_type($gdImage) !== 'gd')) ){ diff --git a/src/Decoder/IMagickLuminanceSource.php b/src/Decoder/IMagickLuminanceSource.php index c2f71231c..15efb6448 100644 --- a/src/Decoder/IMagickLuminanceSource.php +++ b/src/Decoder/IMagickLuminanceSource.php @@ -13,7 +13,7 @@ namespace chillerlan\QRCode\Decoder; -use Imagick, InvalidArgumentException; +use Imagick; use function count; /**