diff --git a/src/Common/ECICharset.php b/src/Common/ECICharset.php index e7e45433d..9f12bc71c 100644 --- a/src/Common/ECICharset.php +++ b/src/Common/ECICharset.php @@ -89,6 +89,9 @@ final class ECICharset{ private int $charsetID; + /** + * + */ public function __construct(int $charsetID){ if(!array_key_exists($charsetID, self::MB_ENCODINGS)){ @@ -98,10 +101,16 @@ final class ECICharset{ $this->charsetID = $charsetID; } + /** + * + */ public function getID():int{ return $this->charsetID; } + /** + * + */ public function getName():?string{ return self::MB_ENCODINGS[$this->charsetID]; } diff --git a/src/Common/FormatInformation.php b/src/Common/FormatInformation.php index 4f409fc8f..da46ff055 100644 --- a/src/Common/FormatInformation.php +++ b/src/Common/FormatInformation.php @@ -65,15 +65,24 @@ final class FormatInformation{ private int $errorCorrectionLevel; private int $dataMask; + /** + * + */ public function __construct(int $formatInfo){ $this->errorCorrectionLevel = ($formatInfo >> 3) & 0x03; // Bits 3,4 $this->dataMask = ($formatInfo & 0x07); // Bottom 3 bits } + /** + * + */ public function getErrorCorrectionLevel():EccLevel{ return new EccLevel($this->errorCorrectionLevel); } + /** + * + */ public function getDataMask():MaskPattern{ return new MaskPattern($this->dataMask); } diff --git a/src/Common/GenericGFPoly.php b/src/Common/GenericGFPoly.php index 353a7380d..98962356e 100644 --- a/src/Common/GenericGFPoly.php +++ b/src/Common/GenericGFPoly.php @@ -117,9 +117,7 @@ final class GenericGFPoly{ } /** - * @param \chillerlan\QRCode\Common\GenericGFPoly $other * - * @return \chillerlan\QRCode\Common\GenericGFPoly */ public function multiply(GenericGFPoly $other):self{ @@ -139,8 +137,6 @@ final class GenericGFPoly{ } /** - * @param \chillerlan\QRCode\Common\GenericGFPoly $other - * * @return \chillerlan\QRCode\Common\GenericGFPoly[] [quotient, remainder] */ public function divide(GenericGFPoly $other):array{ @@ -167,9 +163,7 @@ final class GenericGFPoly{ } /** - * @param int $scalar * - * @return \chillerlan\QRCode\Common\GenericGFPoly */ public function multiplyInt(int $scalar):self{ @@ -191,10 +185,7 @@ final class GenericGFPoly{ } /** - * @param int $degree - * @param int $coefficient * - * @return \chillerlan\QRCode\Common\GenericGFPoly */ public function multiplyByMonomial(int $degree, int $coefficient):self{ @@ -216,9 +207,7 @@ final class GenericGFPoly{ } /** - * @param \chillerlan\QRCode\Common\GenericGFPoly $other * - * @return \chillerlan\QRCode\Common\GenericGFPoly */ public function mod(GenericGFPoly $other):self{ @@ -236,9 +225,7 @@ final class GenericGFPoly{ } /** - * @param \chillerlan\QRCode\Common\GenericGFPoly $other * - * @return \chillerlan\QRCode\Common\GenericGFPoly */ public function addOrSubtract(GenericGFPoly $other):self{ diff --git a/src/Common/ReedSolomonDecoder.php b/src/Common/ReedSolomonDecoder.php index 943973860..213f06179 100644 --- a/src/Common/ReedSolomonDecoder.php +++ b/src/Common/ReedSolomonDecoder.php @@ -164,6 +164,9 @@ final class ReedSolomonDecoder{ return $result; } + /** + * + */ private function findErrorMagnitudes(GenericGFPoly $errorEvaluator, array $errorLocations):array{ // This is directly applying Forney's Formula $s = count($errorLocations); diff --git a/src/Common/Version.php b/src/Common/Version.php index 3efcb44a8..84d112e62 100644 --- a/src/Common/Version.php +++ b/src/Common/Version.php @@ -330,5 +330,4 @@ final class Version{ return self::TOTAL_CODEWORDS[$this->version]; } - } diff --git a/src/Data/Kanji.php b/src/Data/Kanji.php index e37604cf0..e9664d4a4 100644 --- a/src/Data/Kanji.php +++ b/src/Data/Kanji.php @@ -24,6 +24,9 @@ final class Kanji extends QRDataModeAbstract{ protected static int $datamode = Mode::DATA_KANJI; + /** + * + */ public function __construct(string $data){ parent::__construct($data); diff --git a/src/Decoder/Binarizer.php b/src/Decoder/Binarizer.php index 7173b5add..c83322dfe 100644 --- a/src/Decoder/Binarizer.php +++ b/src/Decoder/Binarizer.php @@ -47,6 +47,9 @@ final class Binarizer{ private LuminanceSource $source; + /** + * + */ public function __construct(LuminanceSource $source){ $this->source = $source; } @@ -154,6 +157,9 @@ final class Binarizer{ return $this->getHistogramBlackMatrix($width, $height); } + /** + * + */ public function getHistogramBlackMatrix(int $width, int $height):BitMatrix{ $matrix = new BitMatrix(max($width, $height)); diff --git a/src/Decoder/BitMatrix.php b/src/Decoder/BitMatrix.php index 0f3b902fa..4863d8e1f 100644 --- a/src/Decoder/BitMatrix.php +++ b/src/Decoder/BitMatrix.php @@ -15,12 +15,18 @@ use chillerlan\QRCode\Common\{MaskPattern, Version}; use InvalidArgumentException; use function array_fill, count; +/** + * + */ final class BitMatrix{ private int $dimension; private int $rowSize; private array $bits; + /** + * + */ public function __construct(int $dimension){ $this->dimension = $dimension; $this->rowSize = ((int)(($this->dimension + 0x1f) / 0x20)); diff --git a/src/Decoder/BitMatrixParser.php b/src/Decoder/BitMatrixParser.php index da9f26666..24ae15f94 100644 --- a/src/Decoder/BitMatrixParser.php +++ b/src/Decoder/BitMatrixParser.php @@ -61,6 +61,9 @@ final class BitMatrixParser{ $this->bitMatrix->mirror(); } + /** + * + */ private function copyBit(int $i, int $j, int $versionBits):int{ $bit = $this->mirror @@ -335,6 +338,9 @@ final class BitMatrixParser{ return null; } + /** + * + */ public static function uRShift(int $a, int $b):int{ if($b === 0){ @@ -344,6 +350,9 @@ final class BitMatrixParser{ return ($a >> $b) & ~((1 << (8 * PHP_INT_SIZE - 1)) >> ($b - 1)); } + /** + * + */ private static function numBitsDiffering(int $a, int $b):int{ // a now has a 1 bit exactly where its bit differs with b's $a ^= $b; diff --git a/src/Decoder/DecoderResult.php b/src/Decoder/DecoderResult.php index fb61802e1..e46655838 100644 --- a/src/Decoder/DecoderResult.php +++ b/src/Decoder/DecoderResult.php @@ -29,6 +29,9 @@ final class DecoderResult{ private int $structuredAppendParity; private int $structuredAppendSequenceNumber; + /** + * + */ public function __construct( array $rawBytes, string $text, @@ -59,26 +62,44 @@ final class DecoderResult{ return $this->text; } + /** + * + */ public function __toString():string{ return $this->text; } + /** + * + */ public function getVersion():Version{ return $this->version; } + /** + * + */ public function getEccLevel():EccLevel{ return $this->eccLevel; } + /** + * + */ public function hasStructuredAppend():bool{ return $this->structuredAppendParity >= 0 && $this->structuredAppendSequenceNumber >= 0; } + /** + * + */ public function getStructuredAppendParity():int{ return $this->structuredAppendParity; } + /** + * + */ public function getStructuredAppendSequenceNumber():int{ return $this->structuredAppendSequenceNumber; } diff --git a/src/Decoder/GDLuminanceSource.php b/src/Decoder/GDLuminanceSource.php index e0a787c4c..ec53da3a2 100644 --- a/src/Decoder/GDLuminanceSource.php +++ b/src/Decoder/GDLuminanceSource.php @@ -52,6 +52,9 @@ final class GDLuminanceSource extends LuminanceSource{ $this->setLuminancePixels(); } + /** + * + */ private function setLuminancePixels():void{ for($j = 0; $j < $this->height; $j++){ for($i = 0; $i < $this->width; $i++){ diff --git a/src/Decoder/IMagickLuminanceSource.php b/src/Decoder/IMagickLuminanceSource.php index 15efb6448..d0106eeb9 100644 --- a/src/Decoder/IMagickLuminanceSource.php +++ b/src/Decoder/IMagickLuminanceSource.php @@ -39,6 +39,9 @@ final class IMagickLuminanceSource extends LuminanceSource{ $this->setLuminancePixels(); } + /** + * + */ private function setLuminancePixels():void{ $this->imagick->setImageColorspace(Imagick::COLORSPACE_GRAY); $pixels = $this->imagick->exportImagePixels(1, 1, $this->width, $this->height, 'RGB', Imagick::PIXEL_CHAR); diff --git a/src/Decoder/LuminanceSource.php b/src/Decoder/LuminanceSource.php index 5ed658b97..8dc8fb513 100644 --- a/src/Decoder/LuminanceSource.php +++ b/src/Decoder/LuminanceSource.php @@ -29,6 +29,9 @@ abstract class LuminanceSource{ protected int $width; protected int $height; + /** + * + */ public function __construct(int $width, int $height){ $this->width = $width; $this->height = $height; diff --git a/src/Detector/FinderPattern.php b/src/Detector/FinderPattern.php index 5ea8814a6..89339ce10 100644 --- a/src/Detector/FinderPattern.php +++ b/src/Detector/FinderPattern.php @@ -24,12 +24,18 @@ final class FinderPattern extends ResultPoint{ private int $count; + /** + * + */ public function __construct(float $posX, float $posY, float $estimatedModuleSize, int $count = null){ parent::__construct($posX, $posY, $estimatedModuleSize); $this->count = $count ?? 1; } + /** + * + */ public function getCount():int{ return $this->count; } @@ -66,6 +72,9 @@ final class FinderPattern extends ResultPoint{ ); } + /** + * + */ private static function squaredDistance(float $aX, float $aY, float $bX, float $bY):float{ $xDiff = $aX - $bX; $yDiff = $aY - $bY; @@ -73,6 +82,9 @@ final class FinderPattern extends ResultPoint{ return $xDiff * $xDiff + $yDiff * $yDiff; } + /** + * + */ public static function distance(float $aX, float $aY, float $bX, float $bY):float{ return sqrt(self::squaredDistance($aX, $aY, $bX, $bY)); } diff --git a/src/Detector/FinderPatternFinder.php b/src/Detector/FinderPatternFinder.php index 6cd188c96..251868647 100644 --- a/src/Detector/FinderPatternFinder.php +++ b/src/Detector/FinderPatternFinder.php @@ -187,8 +187,6 @@ final class FinderPatternFinder{ * figures the location of the center of this run. * * @param int[] $stateCount - * - * @return float */ private function centerFromEnd(array $stateCount, int $end):float{ return (float)(($end - $stateCount[4] - $stateCount[3]) - $stateCount[2] / 2.0); @@ -196,8 +194,6 @@ final class FinderPatternFinder{ /** * @param int[] $stateCount - * - * @return bool */ private function foundPatternCross(array $stateCount):bool{ // Allow less than 50% variance from 1-1-3-1-1 proportions @@ -206,8 +202,6 @@ final class FinderPatternFinder{ /** * @param int[] $stateCount - * - * @return bool */ private function foundPatternDiagonal(array $stateCount):bool{ // Allow less than 75% variance from 1-1-3-1-1 proportions diff --git a/src/Detector/PerspectiveTransform.php b/src/Detector/PerspectiveTransform.php index 6a0813c09..87c93d7c6 100644 --- a/src/Detector/PerspectiveTransform.php +++ b/src/Detector/PerspectiveTransform.php @@ -32,6 +32,9 @@ final class PerspectiveTransform{ private float $a32; private float $a33; + /** + * + */ private function set( float $a11, float $a21, float $a31, float $a12, float $a22, float $a32, @@ -50,6 +53,9 @@ final class PerspectiveTransform{ return $this; } + /** + * + */ public function quadrilateralToQuadrilateral( float $x0, float $y0, float $x1, float $y1, float $x2, float $y2, float $x3, float $y3, float $x0p, float $y0p, float $x1p, float $y1p, float $x2p, float $y2p, float $x3p, float $y3p @@ -59,6 +65,9 @@ final class PerspectiveTransform{ ->times($this->quadrilateralToSquare($x0, $y0, $x1, $y1, $x2, $y2, $x3, $y3)); } + /** + * + */ private function quadrilateralToSquare( float $x0, float $y0, float $x1, float $y1, float $x2, float $y2, float $x3, float $y3 @@ -69,6 +78,9 @@ final class PerspectiveTransform{ ->buildAdjoint(); } + /** + * + */ private function buildAdjoint():self{ // Adjoint is the transpose of the cofactor matrix: return $this->set( @@ -84,6 +96,9 @@ final class PerspectiveTransform{ ); } + /** + * + */ private function squareToQuadrilateral( float $x0, float $y0, float $x1, float $y1, float $x2, float $y2, float $x3, float $y3 @@ -111,6 +126,9 @@ final class PerspectiveTransform{ ); } + /** + * + */ private function times(PerspectiveTransform $other):self{ return $this->set( $this->a11 * $other->a11 + $this->a21 * $other->a12 + $this->a31 * $other->a13, @@ -125,6 +143,9 @@ final class PerspectiveTransform{ ); } + /** + * + */ public function transformPoints(array &$xValues, array &$yValues = null):void{ $max = count($xValues); diff --git a/src/Detector/ResultPoint.php b/src/Detector/ResultPoint.php index 4d69116b1..5cc17116f 100644 --- a/src/Detector/ResultPoint.php +++ b/src/Detector/ResultPoint.php @@ -25,20 +25,32 @@ abstract class ResultPoint{ protected float $y; protected float $estimatedModuleSize; + /** + * + */ public function __construct(float $x, float $y, float $estimatedModuleSize){ $this->x = $x; $this->y = $y; $this->estimatedModuleSize = $estimatedModuleSize; } + /** + * + */ public function getX():float{ return $this->x; } + /** + * + */ public function getY():float{ return $this->y; } + /** + * + */ public function getEstimatedModuleSize():float{ return $this->estimatedModuleSize; } diff --git a/src/QRCodeReader.php b/src/QRCodeReader.php index d510818f9..8e50eb1b0 100644 --- a/src/QRCodeReader.php +++ b/src/QRCodeReader.php @@ -17,10 +17,16 @@ use Imagick, InvalidArgumentException; use chillerlan\QRCode\Decoder\{Decoder, DecoderResult, GDLuminanceSource, IMagickLuminanceSource}; use function extension_loaded, file_exists, file_get_contents, imagecreatefromstring, is_file, is_readable; +/** + * + */ final class QRCodeReader{ private bool $useImagickIfAvailable; + /** + * + */ public function __construct(bool $useImagickIfAvailable = true){ $this->useImagickIfAvailable = $useImagickIfAvailable && extension_loaded('imagick'); }