From d1936de3ba6f732243d7c54e88d58fa686fb1911 Mon Sep 17 00:00:00 2001 From: codemasher Date: Sat, 5 Jun 2021 18:19:55 +0200 Subject: [PATCH] :octocat: change visibility in final classes to private --- src/Common/ECICharset.php | 5 ++++- src/Common/Version.php | 2 +- src/Data/AlphaNum.php | 2 +- src/Data/ECI.php | 2 +- src/Data/MaskPatternTester.php | 10 +++++----- src/Data/Number.php | 2 +- src/Data/QRData.php | 18 +++++++++--------- src/Data/QRMatrix.php | 10 +++++----- src/QRCodeReader.php | 2 +- 9 files changed, 28 insertions(+), 25 deletions(-) diff --git a/src/Common/ECICharset.php b/src/Common/ECICharset.php index 9193c0343..e7e45433d 100644 --- a/src/Common/ECICharset.php +++ b/src/Common/ECICharset.php @@ -13,7 +13,10 @@ namespace chillerlan\QRCode\Common; use InvalidArgumentException; use function array_key_exists; -class ECICharset{ +/** + * + */ +final class ECICharset{ public const CP437 = 0; // Code page 437, DOS Latin US public const ISO_IEC_8859_1_GLI = 1; // GLI encoding with characters 0 to 127 identical to ISO/IEC 646 and characters 128 to 255 identical to ISO 8859-1 diff --git a/src/Common/Version.php b/src/Common/Version.php index 1c0ba45d4..bab6c3fe7 100644 --- a/src/Common/Version.php +++ b/src/Common/Version.php @@ -256,7 +256,7 @@ final class Version{ /** * QR Code version number */ - protected int $version; + private int $version; /** * Version constructor. diff --git a/src/Data/AlphaNum.php b/src/Data/AlphaNum.php index 87291d967..409351cbe 100644 --- a/src/Data/AlphaNum.php +++ b/src/Data/AlphaNum.php @@ -27,7 +27,7 @@ final class AlphaNum extends QRDataModeAbstract{ * * @var int[] */ - protected const CHAR_MAP_ALPHANUM = [ + private const CHAR_MAP_ALPHANUM = [ '0' => 0, '1' => 1, '2' => 2, '3' => 3, '4' => 4, '5' => 5, '6' => 6, '7' => 7, '8' => 8, '9' => 9, 'A' => 10, 'B' => 11, 'C' => 12, 'D' => 13, 'E' => 14, 'F' => 15, 'G' => 16, 'H' => 17, 'I' => 18, 'J' => 19, 'K' => 20, 'L' => 21, 'M' => 22, 'N' => 23, diff --git a/src/Data/ECI.php b/src/Data/ECI.php index 86ebf7fdb..86fe22e0a 100644 --- a/src/Data/ECI.php +++ b/src/Data/ECI.php @@ -24,7 +24,7 @@ final class ECI extends QRDataModeAbstract{ /** * The current ECI encoding id */ - protected int $encoding; + private int $encoding; /** * @inheritDoc diff --git a/src/Data/MaskPatternTester.php b/src/Data/MaskPatternTester.php index 792920b32..942d09244 100644 --- a/src/Data/MaskPatternTester.php +++ b/src/Data/MaskPatternTester.php @@ -27,7 +27,7 @@ final class MaskPatternTester{ /** * The data interface that contains the data matrix to test */ - protected QRData $qrData; + private QRData $qrData; /** * Receives the QRData object @@ -74,7 +74,7 @@ final class MaskPatternTester{ /** * Checks for each group of five or more same-colored modules in a row (or column) */ - protected function testLevel1(array $m, int $size):int{ + private function testLevel1(array $m, int $size):int{ $penalty = 0; foreach($m as $y => $row){ @@ -113,7 +113,7 @@ final class MaskPatternTester{ /** * Checks for each 2x2 area of same-colored modules in the matrix */ - protected function testLevel2(array $m, int $size):int{ + private function testLevel2(array $m, int $size):int{ $penalty = 0; foreach($m as $y => $row){ @@ -144,7 +144,7 @@ final class MaskPatternTester{ /** * Checks if there are patterns that look similar to the finder patterns (1:1:3:1:1 ratio) */ - protected function testLevel3(array $m, int $size):int{ + private function testLevel3(array $m, int $size):int{ $penalties = 0; foreach($m as $y => $row){ @@ -185,7 +185,7 @@ final class MaskPatternTester{ /** * Checks if more than half of the modules are dark or light, with a larger penalty for a larger difference */ - protected function testLevel4(array $m, int $size):float{ + private function testLevel4(array $m, int $size):float{ $count = 0; foreach($m as $y => $row){ diff --git a/src/Data/Number.php b/src/Data/Number.php index d31605826..46fac07a7 100644 --- a/src/Data/Number.php +++ b/src/Data/Number.php @@ -25,7 +25,7 @@ final class Number extends QRDataModeAbstract{ /** * @var int[] */ - protected const CHAR_MAP_NUMBER = [ + private const CHAR_MAP_NUMBER = [ '0' => 0, '1' => 1, '2' => 2, '3' => 3, '4' => 4, '5' => 5, '6' => 6, '7' => 7, '8' => 8, '9' => 9, ]; diff --git a/src/Data/QRData.php b/src/Data/QRData.php index cf6c1d274..a54f78474 100644 --- a/src/Data/QRData.php +++ b/src/Data/QRData.php @@ -26,34 +26,34 @@ final class QRData{ * * @var \chillerlan\Settings\SettingsContainerInterface|\chillerlan\QRCode\QROptions */ - protected SettingsContainerInterface $options; + private SettingsContainerInterface $options; /** * a BitBuffer instance */ - protected BitBuffer $bitBuffer; + private BitBuffer $bitBuffer; /** * an EccLevel instance */ - protected EccLevel $eccLevel; + private EccLevel $eccLevel; /** * current QR Code version */ - protected Version $version; + private Version $version; /** * @var \chillerlan\QRCode\Data\QRDataModeInterface[] */ - protected array $dataSegments = []; + private array $dataSegments = []; /** * Max bits for the current ECC mode * * @var int[] */ - protected array $maxBitsForEcc; + private array $maxBitsForEcc; /** * QRData constructor. @@ -108,7 +108,7 @@ final class QRData{ * * @throws \chillerlan\QRCode\Data\QRCodeDataException */ - protected function estimateTotalBitLength():int{ + private function estimateTotalBitLength():int{ $length = 0; $margin = 0; @@ -142,7 +142,7 @@ final class QRData{ * * @throws \chillerlan\QRCode\Data\QRCodeDataException */ - protected function getMinimumVersion():int{ + private function getMinimumVersion():int{ $total = $this->estimateTotalBitLength(); // guess the version number within the given range @@ -162,7 +162,7 @@ final class QRData{ * * @throws \chillerlan\QRCode\QRCodeException on data overflow */ - protected function writeBitBuffer():void{ + private function writeBitBuffer():void{ $version = $this->version->getVersionNumber(); $MAX_BITS = $this->maxBitsForEcc[$version]; diff --git a/src/Data/QRMatrix.php b/src/Data/QRMatrix.php index 11fd3445e..3fc35675f 100755 --- a/src/Data/QRMatrix.php +++ b/src/Data/QRMatrix.php @@ -55,29 +55,29 @@ final class QRMatrix{ /** * the used mask pattern, set via QRMatrix::mask() */ - protected ?MaskPattern $maskPattern = null; + private ?MaskPattern $maskPattern = null; /** * the size (side length) of the matrix, including quiet zone (if created) */ - protected int $moduleCount; + private int $moduleCount; /** * the actual matrix data array * * @var int[][] */ - protected array $matrix; + private array $matrix; /** * the current ECC level */ - protected EccLevel $eccLevel; + private EccLevel $eccLevel; /** * a Version instance */ - protected Version $version; + private Version $version; /** * QRMatrix constructor. diff --git a/src/QRCodeReader.php b/src/QRCodeReader.php index 6a88b9d0a..d510818f9 100644 --- a/src/QRCodeReader.php +++ b/src/QRCodeReader.php @@ -30,7 +30,7 @@ final class QRCodeReader{ * * @return \chillerlan\QRCode\Decoder\DecoderResult */ - protected function decode($im):DecoderResult{ + private function decode($im):DecoderResult{ $source = $this->useImagickIfAvailable ? new IMagickLuminanceSource($im)