diff --git a/src/Common/ECICharset.php b/src/Common/ECICharset.php index 2572b54cd..e1026785f 100644 --- a/src/Common/ECICharset.php +++ b/src/Common/ECICharset.php @@ -3,9 +3,10 @@ * Class ECICharset * * @created 21.01.2021 + * @author ZXing Authors * @author smiley * @copyright 2021 smiley - * @license MIT + * @license Apache-2.0 */ namespace chillerlan\QRCode\Common; diff --git a/src/Common/EccLevel.php b/src/Common/EccLevel.php index 9f4a8d18f..adcfdc1bb 100644 --- a/src/Common/EccLevel.php +++ b/src/Common/EccLevel.php @@ -143,6 +143,9 @@ final class EccLevel{ /** * @param int $eccLevel containing the two bits encoding a QR Code's error correction level * + * @todo: accept string values (PHP8+) + * @see https://github.com/chillerlan/php-qrcode/discussions/160 + * * @throws \chillerlan\QRCode\QRCodeException */ public function __construct(int $eccLevel){ diff --git a/src/Common/Mode.php b/src/Common/Mode.php index aa2a138f2..c226e5b2a 100644 --- a/src/Common/Mode.php +++ b/src/Common/Mode.php @@ -14,7 +14,7 @@ use chillerlan\QRCode\Data\{AlphaNum, Byte, Hanzi, Kanji, Number}; use chillerlan\QRCode\QRCodeException; /** - * ISO 18004:2006, 6.4.1, Tables 2 and 3 + * Data mode information - ISO 18004:2006, 6.4.1, Tables 2 and 3 */ final class Mode{ diff --git a/src/Common/ReedSolomonDecoder.php b/src/Common/ReedSolomonDecoder.php index 0cffbf816..658f825d9 100644 --- a/src/Common/ReedSolomonDecoder.php +++ b/src/Common/ReedSolomonDecoder.php @@ -15,7 +15,7 @@ use chillerlan\QRCode\QRCodeException; use function array_fill, array_reverse, count; /** - * Implements Reed-Solomon decoding, as the name implies. + * Implements Reed-Solomon decoding * * The algorithm will not be explained here, but the following references were helpful * in creating this implementation: diff --git a/src/Common/ReedSolomonEncoder.php b/src/Common/ReedSolomonEncoder.php index d6e2f2219..9c747860c 100644 --- a/src/Common/ReedSolomonEncoder.php +++ b/src/Common/ReedSolomonEncoder.php @@ -13,7 +13,7 @@ namespace chillerlan\QRCode\Common; use function array_fill, array_merge, count, max; /** - * ISO/IEC 18004:2000 Section 8.5 ff + * Reed-Solomon encoding - ISO/IEC 18004:2000 Section 8.5 ff * * @see http://www.thonky.com/qr-code-tutorial/error-correction-coding */ diff --git a/src/Data/Byte.php b/src/Data/Byte.php index 2e0867331..4217deecd 100644 --- a/src/Data/Byte.php +++ b/src/Data/Byte.php @@ -15,7 +15,7 @@ use chillerlan\QRCode\Common\{BitBuffer, Mode}; use function chr, ord; /** - * Byte mode, ISO-8859-1 or UTF-8 + * 8-bit Byte mode, ISO-8859-1 or UTF-8 * * ISO/IEC 18004:2000 Section 8.3.4 * ISO/IEC 18004:2000 Section 8.4.4 diff --git a/src/Data/QRData.php b/src/Data/QRData.php index 705e56920..e0b965715 100644 --- a/src/Data/QRData.php +++ b/src/Data/QRData.php @@ -96,7 +96,7 @@ final class QRData{ * Sets a BitBuffer object * * This can be used instead of setData(), however, the version auto-detection is not available in this case. - * The version needs match the length bits range for the data mode the data has been encoded with, + * The version needs to match the length bits range for the data mode the data has been encoded with, * additionally the bit array needs to contain enough pad bits. * * @throws \chillerlan\QRCode\Data\QRCodeDataException diff --git a/src/Data/QRMatrix.php b/src/Data/QRMatrix.php index 6cfc8176a..eaf255afe 100755 --- a/src/Data/QRMatrix.php +++ b/src/Data/QRMatrix.php @@ -14,7 +14,7 @@ use chillerlan\QRCode\Common\{BitBuffer, EccLevel, MaskPattern, ReedSolomonEncod use function array_fill, count, floor, range; /** - * Holds a numerical representation of the final QR Code; + * Holds an array representation of the final QR Code that contains numerical values for later output modifications; * maps the ECC coded binary data and applies the mask pattern * * @see http://www.thonky.com/qr-code-tutorial/format-version-information diff --git a/src/Decoder/BitMatrix.php b/src/Decoder/BitMatrix.php index c82c39067..36bbb380d 100644 --- a/src/Decoder/BitMatrix.php +++ b/src/Decoder/BitMatrix.php @@ -61,7 +61,7 @@ final class BitMatrix extends QRMatrix{ 0x2BED, // 0010101111101101 ]; - private const FORMAT_INFO_MASK_QR = 0x5412; + private const FORMAT_INFO_MASK_QR = 0x5412; // 0101010000010010 private bool $mirror = false; diff --git a/src/Decoder/LuminanceSourceAbstract.php b/src/Decoder/LuminanceSourceAbstract.php index 13fb8f759..616c5944d 100644 --- a/src/Decoder/LuminanceSourceAbstract.php +++ b/src/Decoder/LuminanceSourceAbstract.php @@ -18,10 +18,7 @@ use function array_slice, array_splice, file_exists, is_file, is_readable, realp /** * The purpose of this class hierarchy is to abstract different bitmap implementations across - * platforms into a standard interface for requesting greyscale luminance values. The interface - * only provides immutable methods; therefore crop and rotation create copies. This is to ensure - * that one Reader does not modify the original luminance source and leave it in an unknown state - * for other Readers in the chain. + * platforms into a standard interface for requesting greyscale luminance values. * * @author dswitkin@google.com (Daniel Switkin) */ diff --git a/src/QRCode.php b/src/QRCode.php index b30c8ee1b..dfc0b39a0 100755 --- a/src/QRCode.php +++ b/src/QRCode.php @@ -164,7 +164,7 @@ class QRCode{ protected SettingsContainerInterface $options; /** - * A collection of one or more data segments of [classname, data] to write + * A collection of one or more data segments of QRDataModeInterface instances to write * * @var \chillerlan\QRCode\Data\QRDataModeInterface[] */ @@ -338,8 +338,10 @@ class QRCode{ * ISO/IEC 18004:2000 8.3.6 - Mixing modes * ISO/IEC 18004:2000 Annex H - Optimisation of bit stream length */ - public function addSegment(QRDataModeInterface $segment):void{ + public function addSegment(QRDataModeInterface $segment):self{ $this->dataSegments[] = $segment; + + return $this; } /** @@ -359,9 +361,7 @@ class QRCode{ * ISO/IEC 18004:2000 8.3.2 - Numeric Mode */ public function addNumericSegment(string $data):self{ - $this->addSegment(new Number($data)); - - return $this; + return $this->addSegment(new Number($data)); } /** @@ -370,9 +370,7 @@ class QRCode{ * ISO/IEC 18004:2000 8.3.3 - Alphanumeric Mode */ public function addAlphaNumSegment(string $data):self{ - $this->addSegment(new AlphaNum($data)); - - return $this; + return $this->addSegment(new AlphaNum($data)); } /** @@ -381,9 +379,7 @@ class QRCode{ * ISO/IEC 18004:2000 8.3.5 - Kanji Mode */ public function addKanjiSegment(string $data):self{ - $this->addSegment(new Kanji($data)); - - return $this; + return $this->addSegment(new Kanji($data)); } /** @@ -392,9 +388,7 @@ class QRCode{ * GBT18284-2000 Hanzi Mode */ public function addHanziSegment(string $data):self{ - $this->addSegment(new Hanzi($data)); - - return $this; + return $this->addSegment(new Hanzi($data)); } /** @@ -403,9 +397,7 @@ class QRCode{ * ISO/IEC 18004:2000 8.3.4 - 8-bit Byte Mode */ public function addByteSegment(string $data):self{ - $this->addSegment(new Byte($data)); - - return $this; + return $this->addSegment(new Byte($data)); } /** @@ -416,9 +408,7 @@ class QRCode{ * ISO/IEC 18004:2000 8.3.1 - Extended Channel Interpretation (ECI) Mode */ public function addEciDesignator(int $encoding):self{ - $this->addSegment(new ECI($encoding)); - - return $this; + return $this->addSegment(new ECI($encoding)); } /** @@ -438,12 +428,11 @@ class QRCode{ // convert the string to the given charset if($eciCharsetName !== null){ $data = mb_convert_encoding($data, $eciCharsetName, mb_internal_encoding()); - $this + + return $this ->addEciDesignator($eciCharset->getID()) ->addByteSegment($data) ; - - return $this; } throw new QRCodeException('unable to add ECI segment'); diff --git a/src/QROptionsTrait.php b/src/QROptionsTrait.php index 47ffe2ed2..9032b1008 100644 --- a/src/QROptionsTrait.php +++ b/src/QROptionsTrait.php @@ -49,6 +49,9 @@ trait QROptionsTrait{ * - M => 15% * - Q => 25% * - H => 30% + * + * @todo: accept string values (PHP8+) + * @see https://github.com/chillerlan/php-qrcode/discussions/160 */ protected int $eccLevel = EccLevel::L;