From 66466432db7eff982ba351d72bad46d98404f301 Mon Sep 17 00:00:00 2001 From: codemasher Date: Wed, 19 Feb 2020 15:53:29 +0100 Subject: [PATCH] :shower: some docblocks/fixes --- src/Data/Kanji.php | 5 +---- src/Data/QRDataAbstract.php | 25 +++++++------------------ src/Data/QRDataInterface.php | 8 ++++++-- src/Output/QRImage.php | 6 ++---- src/Output/QRImagick.php | 6 ++---- src/Output/QRMarkup.php | 2 +- src/Output/QROutputAbstract.php | 8 +++++--- src/Output/QROutputInterface.php | 2 ++ src/Output/QRString.php | 2 +- src/QRCode.php | 2 +- src/QROptionsTrait.php | 16 ++++++++++++++-- 11 files changed, 42 insertions(+), 40 deletions(-) diff --git a/src/Data/Kanji.php b/src/Data/Kanji.php index 9faf4fc54..ce600d4ff 100644 --- a/src/Data/Kanji.php +++ b/src/Data/Kanji.php @@ -39,10 +39,7 @@ class Kanji extends QRDataAbstract{ } /** - * @param string $data - * - * @return void - * @throws \chillerlan\QRCode\Data\QRCodeDataException + * @inheritdoc */ protected function write(string $data):void{ $len = strlen($data); diff --git a/src/Data/QRDataAbstract.php b/src/Data/QRDataAbstract.php index d4c66936d..f52767e38 100644 --- a/src/Data/QRDataAbstract.php +++ b/src/Data/QRDataAbstract.php @@ -86,7 +86,7 @@ abstract class QRDataAbstract implements QRDataInterface{ * QRDataInterface constructor. * * @param \chillerlan\Settings\SettingsContainerInterface $options - * @param string|null $data + * @param string|null $data */ public function __construct(SettingsContainerInterface $options, string $data = null){ $this->options = $options; @@ -97,11 +97,7 @@ abstract class QRDataAbstract implements QRDataInterface{ } /** - * Sets the data string (internally called by the constructor) - * - * @param string $data - * - * @return \chillerlan\QRCode\Data\QRDataInterface + * @inheritDoc */ public function setData(string $data):QRDataInterface{ @@ -123,17 +119,10 @@ abstract class QRDataAbstract implements QRDataInterface{ } /** - * returns a fresh matrix object with the data written for the given $maskPattern - * - * @param int $maskPattern - * @param bool|null $test - * - * @return \chillerlan\QRCode\Data\QRMatrix + * @inheritDoc */ public function initMatrix(int $maskPattern, bool $test = null):QRMatrix{ - $matrix = new QRMatrix($this->version, $this->options->eccLevel); - - return $matrix + return (new QRMatrix($this->version, $this->options->eccLevel)) ->setFinderPattern() ->setSeparators() ->setAlignmentPattern() @@ -196,6 +185,8 @@ abstract class QRDataAbstract implements QRDataInterface{ } /** + * writes the actual data string to the BitBuffer + * * @see \chillerlan\QRCode\Data\QRDataAbstract::writeBitBuffer() * * @param string $data @@ -205,7 +196,7 @@ abstract class QRDataAbstract implements QRDataInterface{ abstract protected function write(string $data):void; /** - * writes the string data to the BitBuffer + * creates a BitBuffer and writes the string data to it * * @param string $data * @@ -262,8 +253,6 @@ abstract class QRDataAbstract implements QRDataInterface{ /** * ECC masking * - * @see \chillerlan\QRCode\Data\QRDataAbstract::writeBitBuffer() - * * @link http://www.thonky.com/qr-code-tutorial/error-correction-coding * * @return array diff --git a/src/Data/QRDataInterface.php b/src/Data/QRDataInterface.php index 9b5c49505..14479afee 100644 --- a/src/Data/QRDataInterface.php +++ b/src/Data/QRDataInterface.php @@ -166,6 +166,8 @@ interface QRDataInterface{ ]; /** + * Sets the data string (internally called by the constructor) + * * @param string $data * * @return \chillerlan\QRCode\Data\QRDataInterface @@ -173,8 +175,10 @@ interface QRDataInterface{ public function setData(string $data):QRDataInterface; /** - * @param int $maskPattern - * @param bool $test + * returns a fresh matrix object with the data written for the given $maskPattern + * + * @param int $maskPattern + * @param bool|null $test * * @return \chillerlan\QRCode\Data\QRMatrix */ diff --git a/src/Output/QRImage.php b/src/Output/QRImage.php index 4d8576117..09156f5ff 100644 --- a/src/Output/QRImage.php +++ b/src/Output/QRImage.php @@ -43,7 +43,7 @@ class QRImage extends QROutputAbstract{ protected $image; /** - * @return void + * @inheritDoc */ protected function setModuleValues():void{ @@ -64,9 +64,7 @@ class QRImage extends QROutputAbstract{ } /** - * @param string|null $file - * - * @return string + * @inheritDoc */ public function dump(string $file = null):string{ $this->image = imagecreatetruecolor($this->length, $this->length); diff --git a/src/Output/QRImagick.php b/src/Output/QRImagick.php index 6fa8a1a16..bd4507dfa 100644 --- a/src/Output/QRImagick.php +++ b/src/Output/QRImagick.php @@ -25,7 +25,7 @@ use function is_string; class QRImagick extends QROutputAbstract{ /** - * @return void + * @inheritDoc */ protected function setModuleValues():void{ @@ -44,9 +44,7 @@ class QRImagick extends QROutputAbstract{ } /** - * @param string|null $file - * - * @return string + * @inheritDoc */ public function dump(string $file = null):string{ $file = $file ?? $this->options->cachefile; diff --git a/src/Output/QRMarkup.php b/src/Output/QRMarkup.php index 4472d34c0..11d5ec510 100644 --- a/src/Output/QRMarkup.php +++ b/src/Output/QRMarkup.php @@ -34,7 +34,7 @@ class QRMarkup extends QROutputAbstract{ protected $svgHeader = ''; /** - * @return void + * @inheritDoc */ protected function setModuleValues():void{ diff --git a/src/Output/QROutputAbstract.php b/src/Output/QROutputAbstract.php index 05c909e82..4ec47de24 100644 --- a/src/Output/QROutputAbstract.php +++ b/src/Output/QROutputAbstract.php @@ -92,7 +92,10 @@ abstract class QROutputAbstract implements QROutputInterface{ abstract protected function setModuleValues():void; /** + * saves the qr data to a file + * * @see file_put_contents() + * @see \chillerlan\QRCode\QROptions::cachefile * * @param string $data * @param string $file @@ -110,11 +113,10 @@ abstract class QROutputAbstract implements QROutputInterface{ } /** - * @param string|null $file - * - * @return string|mixed + * @inheritDoc */ public function dump(string $file = null){ + // call the built-in output method $data = call_user_func([$this, $this->outputMode ?? $this->defaultMode]); $file = $file ?? $this->options->cachefile; diff --git a/src/Output/QROutputInterface.php b/src/Output/QROutputInterface.php index 3cff7001b..415d2cfe4 100644 --- a/src/Output/QROutputInterface.php +++ b/src/Output/QROutputInterface.php @@ -42,6 +42,8 @@ interface QROutputInterface{ ]; /** + * generates the output, optionally dumps it to a file, and returns it + * * @param string|null $file * * @return mixed diff --git a/src/Output/QRString.php b/src/Output/QRString.php index 85507cde2..ba8d83675 100644 --- a/src/Output/QRString.php +++ b/src/Output/QRString.php @@ -27,7 +27,7 @@ class QRString extends QROutputAbstract{ protected $defaultMode = QRCode::OUTPUT_STRING_TEXT; /** - * @return void + * @inheritDoc */ protected function setModuleValues():void{ diff --git a/src/QRCode.php b/src/QRCode.php index 790736927..d9b471df0 100755 --- a/src/QRCode.php +++ b/src/QRCode.php @@ -91,7 +91,7 @@ class QRCode{ ]; /** - * @var \chillerlan\QRCode\QROptions + * @var \chillerlan\QRCode\QROptions|\chillerlan\Settings\SettingsContainerInterface */ protected $options; diff --git a/src/QROptionsTrait.php b/src/QROptionsTrait.php index 4d4f84497..d653144a1 100644 --- a/src/QROptionsTrait.php +++ b/src/QROptionsTrait.php @@ -55,7 +55,7 @@ trait QROptionsTrait{ /** * Mask Pattern to use * - * [0...7] or QRCode::MASK_PATTERN_AUTO + * [0...7] or QRCode::MASK_PATTERN_AUTO * * @var int */ @@ -69,7 +69,7 @@ trait QROptionsTrait{ protected $addQuietzone = true; /** - * Size of the quiet zone + * Size of the quiet zone * * internally clamped to [0 ... $moduleCount / 2], defaults to 4 modules * @@ -268,6 +268,8 @@ trait QROptionsTrait{ } /** + * sets the minimum version number + * * @param int $version * * @return void @@ -277,6 +279,8 @@ trait QROptionsTrait{ } /** + * sets the maximum version number + * * @param int $version * * @return void @@ -286,6 +290,8 @@ trait QROptionsTrait{ } /** + * sets the error correction level + * * @param int $eccLevel * * @return void @@ -301,6 +307,8 @@ trait QROptionsTrait{ } /** + * sets/clamps the mask pattern + * * @param int $maskPattern * * @return void @@ -314,6 +322,8 @@ trait QROptionsTrait{ } /** + * sets the transparency background color + * * @param mixed $imageTransparencyBG * * @return void @@ -343,6 +353,8 @@ trait QROptionsTrait{ } /** + * sets/clamps the version number + * * @param int $version * * @return void