diff --git a/examples/svgModuleJitter.php b/examples/svgModuleJitter.php index e3aa38a90..cdb4020f2 100644 --- a/examples/svgModuleJitter.php +++ b/examples/svgModuleJitter.php @@ -26,7 +26,7 @@ require_once __DIR__.'/../vendor/autoload.php'; */ class ModuleJitterSVGoutput extends QRMarkupSVG{ - protected const ROUND_PRECISION = 5; + protected const int ROUND_PRECISION = 5; protected readonly float $sideLength; diff --git a/src/Common/ECICharset.php b/src/Common/ECICharset.php index d6f78b743..72ab66426 100644 --- a/src/Common/ECICharset.php +++ b/src/Common/ECICharset.php @@ -20,44 +20,44 @@ use function sprintf; */ 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 - public const CP437_WO_GLI = 2; // An equivalent code table to CP437, without the return-to-GLI 0 logic - public const ISO_IEC_8859_1 = 3; // Latin-1 (Default) - public const ISO_IEC_8859_2 = 4; // Latin-2 - public const ISO_IEC_8859_3 = 5; // Latin-3 - public const ISO_IEC_8859_4 = 6; // Latin-4 - public const ISO_IEC_8859_5 = 7; // Latin/Cyrillic - public const ISO_IEC_8859_6 = 8; // Latin/Arabic - public const ISO_IEC_8859_7 = 9; // Latin/Greek - public const ISO_IEC_8859_8 = 10; // Latin/Hebrew - public const ISO_IEC_8859_9 = 11; // Latin-5 - public const ISO_IEC_8859_10 = 12; // Latin-6 - public const ISO_IEC_8859_11 = 13; // Latin/Thai + public const int CP437 = 0; // Code page 437, DOS Latin US + public const int 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 + public const int CP437_WO_GLI = 2; // An equivalent code table to CP437, without the return-to-GLI 0 logic + public const int ISO_IEC_8859_1 = 3; // Latin-1 (Default) + public const int ISO_IEC_8859_2 = 4; // Latin-2 + public const int ISO_IEC_8859_3 = 5; // Latin-3 + public const int ISO_IEC_8859_4 = 6; // Latin-4 + public const int ISO_IEC_8859_5 = 7; // Latin/Cyrillic + public const int ISO_IEC_8859_6 = 8; // Latin/Arabic + public const int ISO_IEC_8859_7 = 9; // Latin/Greek + public const int ISO_IEC_8859_8 = 10; // Latin/Hebrew + public const int ISO_IEC_8859_9 = 11; // Latin-5 + public const int ISO_IEC_8859_10 = 12; // Latin-6 + public const int ISO_IEC_8859_11 = 13; // Latin/Thai // 14 reserved - public const ISO_IEC_8859_13 = 15; // Latin-7 (Baltic Rim) - public const ISO_IEC_8859_14 = 16; // Latin-8 (Celtic) - public const ISO_IEC_8859_15 = 17; // Latin-9 - public const ISO_IEC_8859_16 = 18; // Latin-10 + public const int ISO_IEC_8859_13 = 15; // Latin-7 (Baltic Rim) + public const int ISO_IEC_8859_14 = 16; // Latin-8 (Celtic) + public const int ISO_IEC_8859_15 = 17; // Latin-9 + public const int ISO_IEC_8859_16 = 18; // Latin-10 // 19 reserved - public const SHIFT_JIS = 20; // JIS X 0208 Annex 1 + JIS X 0201 - public const WINDOWS_1250_LATIN_2 = 21; // Superset of Latin-2, Central Europe - public const WINDOWS_1251_CYRILLIC = 22; // Latin/Cyrillic - public const WINDOWS_1252_LATIN_1 = 23; // Superset of Latin-1 - public const WINDOWS_1256_ARABIC = 24; - public const ISO_IEC_10646_UCS_2 = 25; // High order byte first (UTF-16BE) - public const ISO_IEC_10646_UTF_8 = 26; // UTF-8 - public const ISO_IEC_646_1991 = 27; // International Reference Version of ISO 7-bit coded character set (US-ASCII) - public const BIG5 = 28; // Big 5 (Taiwan) Chinese Character Set - public const GB18030 = 29; // GB (PRC) Chinese Character Set - public const EUC_KR = 30; // Korean Character Set + public const int SHIFT_JIS = 20; // JIS X 0208 Annex 1 + JIS X 0201 + public const int WINDOWS_1250_LATIN_2 = 21; // Superset of Latin-2, Central Europe + public const int WINDOWS_1251_CYRILLIC = 22; // Latin/Cyrillic + public const int WINDOWS_1252_LATIN_1 = 23; // Superset of Latin-1 + public const int WINDOWS_1256_ARABIC = 24; + public const int ISO_IEC_10646_UCS_2 = 25; // High order byte first (UTF-16BE) + public const int ISO_IEC_10646_UTF_8 = 26; // UTF-8 + public const int ISO_IEC_646_1991 = 27; // International Reference Version of ISO 7-bit coded character set (US-ASCII) + public const int BIG5 = 28; // Big 5 (Taiwan) Chinese Character Set + public const int GB18030 = 29; // GB (PRC) Chinese Character Set + public const int EUC_KR = 30; // Korean Character Set /** * map of charset id -> name * * @see \mb_list_encodings() */ - public const MB_ENCODINGS = [ + public const array MB_ENCODINGS = [ self::CP437 => null, self::ISO_IEC_8859_1_GLI => null, self::CP437_WO_GLI => null, diff --git a/src/Common/EccLevel.php b/src/Common/EccLevel.php index ae7720433..1e525e0eb 100644 --- a/src/Common/EccLevel.php +++ b/src/Common/EccLevel.php @@ -21,21 +21,17 @@ final class EccLevel{ // ISO/IEC 18004:2000 Tables 12, 25 - /** @var int */ - public const L = 0b01; // 7%. - /** @var int */ - public const M = 0b00; // 15%. - /** @var int */ - public const Q = 0b11; // 25%. - /** @var int */ - public const H = 0b10; // 30%. + public const int L = 0b01; // 7%. + public const int M = 0b00; // 15%. + public const int Q = 0b11; // 25%. + public const int H = 0b10; // 30%. /** * ISO/IEC 18004:2000 Tables 7-11 - Number of symbol characters and input data capacity for versions 1 to 40 * * @var int[][] */ - private const MAX_BITS = [ + private const array MAX_BITS = [ // [ L, M, Q, H] // v => modules [ 0, 0, 0, 0], // 0 => will be ignored, index starts at 1 [ 152, 128, 104, 72], // 1 => 21 @@ -87,7 +83,7 @@ final class EccLevel{ * * @var int[][] */ - private const FORMAT_PATTERN = [ + private const array FORMAT_PATTERN = [ [ // L 0b111011111000100, 0b111001011110011, diff --git a/src/Common/GF256.php b/src/Common/GF256.php index f3e4fd5ee..f8deec0e7 100644 --- a/src/Common/GF256.php +++ b/src/Common/GF256.php @@ -35,7 +35,7 @@ final class GF256{ */ # private int $primitive = 0x011D; - private const logTable = [ + private const array logTable = [ 0, // the first value is never returned, index starts at 1 0, 1, 25, 2, 50, 26, 198, 3, 223, 51, 238, 27, 104, 199, 75, 4, 100, 224, 14, 52, 141, 239, 129, 28, 193, 105, 248, 200, 8, 76, 113, @@ -55,7 +55,7 @@ final class GF256{ 79, 174, 213, 233, 230, 231, 173, 232, 116, 214, 244, 234, 168, 80, 88, 175, ]; - private const expTable = [ + private const array expTable = [ 1, 2, 4, 8, 16, 32, 64, 128, 29, 58, 116, 232, 205, 135, 19, 38, 76, 152, 45, 90, 180, 117, 234, 201, 143, 3, 6, 12, 24, 48, 96, 192, 157, 39, 78, 156, 37, 74, 148, 53, 106, 212, 181, 119, 238, 193, 159, 35, diff --git a/src/Common/MaskPattern.php b/src/Common/MaskPattern.php index 106fc5922..832a6bf4b 100644 --- a/src/Common/MaskPattern.php +++ b/src/Common/MaskPattern.php @@ -28,24 +28,22 @@ final class MaskPattern{ /** * @see \chillerlan\QRCode\QROptionsTrait::$maskPattern - * - * @var int */ - public const AUTO = -1; + public const int AUTO = -1; - public const PATTERN_000 = 0b000; - public const PATTERN_001 = 0b001; - public const PATTERN_010 = 0b010; - public const PATTERN_011 = 0b011; - public const PATTERN_100 = 0b100; - public const PATTERN_101 = 0b101; - public const PATTERN_110 = 0b110; - public const PATTERN_111 = 0b111; + public const int PATTERN_000 = 0b000; + public const int PATTERN_001 = 0b001; + public const int PATTERN_010 = 0b010; + public const int PATTERN_011 = 0b011; + public const int PATTERN_100 = 0b100; + public const int PATTERN_101 = 0b101; + public const int PATTERN_110 = 0b110; + public const int PATTERN_111 = 0b111; /** * @var int[] */ - public const PATTERNS = [ + public const array PATTERNS = [ self::PATTERN_000, self::PATTERN_001, self::PATTERN_010, @@ -61,10 +59,10 @@ final class MaskPattern{ * * ISO/IEC 18004:2000 Section 8.8.1 - Table 24 */ - private const PENALTY_N1 = 3; - private const PENALTY_N2 = 3; - private const PENALTY_N3 = 40; - private const PENALTY_N4 = 10; + private const int PENALTY_N1 = 3; + private const int PENALTY_N2 = 3; + private const int PENALTY_N3 = 40; + private const int PENALTY_N4 = 10; /** * The current mask pattern value (0-7) diff --git a/src/Common/Mode.php b/src/Common/Mode.php index e3847f98f..f1a9780fa 100644 --- a/src/Common/Mode.php +++ b/src/Common/Mode.php @@ -21,33 +21,23 @@ final class Mode{ // ISO/IEC 18004:2000 Table 2 - /** @var int */ - public const TERMINATOR = 0b0000; - /** @var int */ - public const NUMBER = 0b0001; - /** @var int */ - public const ALPHANUM = 0b0010; - /** @var int */ - public const BYTE = 0b0100; - /** @var int */ - public const KANJI = 0b1000; - /** @var int */ - public const HANZI = 0b1101; - /** @var int */ - public const STRCTURED_APPEND = 0b0011; - /** @var int */ - public const FNC1_FIRST = 0b0101; - /** @var int */ - public const FNC1_SECOND = 0b1001; - /** @var int */ - public const ECI = 0b0111; + public const int TERMINATOR = 0b0000; + public const int NUMBER = 0b0001; + public const int ALPHANUM = 0b0010; + public const int BYTE = 0b0100; + public const int KANJI = 0b1000; + public const int HANZI = 0b1101; + public const int STRCTURED_APPEND = 0b0011; + public const int FNC1_FIRST = 0b0101; + public const int FNC1_SECOND = 0b1001; + public const int ECI = 0b0111; /** * mode length bits for the version breakpoints 1-9, 10-26 and 27-40 * * ISO/IEC 18004:2000 Table 3 - Number of bits in Character Count Indicator */ - public const LENGTH_BITS = [ + public const array LENGTH_BITS = [ self::NUMBER => [10, 12, 14], self::ALPHANUM => [ 9, 11, 13], self::BYTE => [ 8, 16, 16], @@ -61,7 +51,7 @@ final class Mode{ * * @var array */ - public const INTERFACES = [ + public const array INTERFACES = [ self::NUMBER => Number::class, self::ALPHANUM => AlphaNum::class, self::KANJI => Kanji::class, diff --git a/src/Common/Version.php b/src/Common/Version.php index 7c5938527..bfc4f1126 100644 --- a/src/Common/Version.php +++ b/src/Common/Version.php @@ -22,10 +22,8 @@ final class Version{ * Enable version auto detection * * @see \chillerlan\QRCode\QROptionsTrait::$version - * - * @var int */ - public const AUTO = -1; + public const int AUTO = -1; /** * ISO/IEC 18004:2000 Annex E, Table E.1 - Row/column coordinates of center module of Alignment Patterns @@ -34,7 +32,7 @@ final class Version{ * * @var int[][] */ - private const ALIGNMENT_PATTERN = [ + private const array ALIGNMENT_PATTERN = [ 1 => [], 2 => [6, 18], 3 => [6, 22], @@ -84,7 +82,7 @@ final class Version{ * * @var int[] */ - private const VERSION_PATTERN = [ + private const array VERSION_PATTERN = [ 7 => 0b000111110010010100, 8 => 0b001000010110111100, 9 => 0b001001101010011001, @@ -126,7 +124,7 @@ final class Version{ * * @see http://www.thonky.com/qr-code-tutorial/error-correction-table */ - private const RSBLOCKS = [ + private const array RSBLOCKS = [ 1 => [[ 7, [[ 1, 19], [ 0, 0]]], [10, [[ 1, 16], [ 0, 0]]], [13, [[ 1, 13], [ 0, 0]]], [17, [[ 1, 9], [ 0, 0]]]], 2 => [[10, [[ 1, 34], [ 0, 0]]], [16, [[ 1, 28], [ 0, 0]]], [22, [[ 1, 22], [ 0, 0]]], [28, [[ 1, 16], [ 0, 0]]]], 3 => [[15, [[ 1, 55], [ 0, 0]]], [26, [[ 1, 44], [ 0, 0]]], [18, [[ 2, 17], [ 0, 0]]], [22, [[ 2, 13], [ 0, 0]]]], @@ -172,7 +170,7 @@ final class Version{ /** * ISO/IEC 18004:2000 Table 1 - Data capacity of all versions of QR Code */ - private const TOTAL_CODEWORDS = [ + private const array TOTAL_CODEWORDS = [ 1 => 26, 2 => 44, 3 => 70, diff --git a/src/Data/AlphaNum.php b/src/Data/AlphaNum.php index e3d355427..2edb1df77 100644 --- a/src/Data/AlphaNum.php +++ b/src/Data/AlphaNum.php @@ -24,12 +24,10 @@ final class AlphaNum extends QRDataModeAbstract{ /** * ISO/IEC 18004:2000 Table 5 - * - * @var string */ - private const CHAR_MAP = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:'; + private const string CHAR_MAP = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:'; - public const DATAMODE = Mode::ALPHANUM; + public const int DATAMODE = Mode::ALPHANUM; public function getLengthInBits():int{ return (int)ceil($this->getCharCount() * (11 / 2)); diff --git a/src/Data/Byte.php b/src/Data/Byte.php index 69f7279d1..354824aa3 100644 --- a/src/Data/Byte.php +++ b/src/Data/Byte.php @@ -22,7 +22,7 @@ use function chr, ord; */ final class Byte extends QRDataModeAbstract{ - public const DATAMODE = Mode::BYTE; + public const int DATAMODE = Mode::BYTE; public function getLengthInBits():int{ return ($this->getCharCount() * 8); diff --git a/src/Data/ECI.php b/src/Data/ECI.php index 34f96e547..bac131dac 100644 --- a/src/Data/ECI.php +++ b/src/Data/ECI.php @@ -23,7 +23,7 @@ use function mb_convert_encoding, mb_detect_encoding, mb_internal_encoding, spri */ final class ECI extends QRDataModeAbstract{ - public const DATAMODE = Mode::ECI; + public const int DATAMODE = Mode::ECI; /** * The current ECI encoding id (default to UTF-8) diff --git a/src/Data/Hanzi.php b/src/Data/Hanzi.php index 48d19429a..b1f9bf899 100644 --- a/src/Data/Hanzi.php +++ b/src/Data/Hanzi.php @@ -32,19 +32,15 @@ final class Hanzi extends QRDataModeAbstract{ /** * possible values: GB2312, GB18030 - * - * @var string */ - public const ENCODING = 'GB18030'; + public const string ENCODING = 'GB18030'; /** * @todo: other subsets??? - * - * @var int */ - public const GB2312_SUBSET = 0b0001; + public const int GB2312_SUBSET = 0b0001; - public const DATAMODE = Mode::HANZI; + public const int DATAMODE = Mode::HANZI; protected function getCharCount():int{ return mb_strlen($this->data, self::ENCODING); diff --git a/src/Data/Kanji.php b/src/Data/Kanji.php index 1e657b342..8ba9d20c1 100644 --- a/src/Data/Kanji.php +++ b/src/Data/Kanji.php @@ -32,12 +32,10 @@ final class Kanji extends QRDataModeAbstract{ * possible values: SJIS, SJIS-2004 * * SJIS-2004 may produce errors in PHP < 8 - * - * @var string */ - public const ENCODING = 'SJIS'; + public const string ENCODING = 'SJIS'; - public const DATAMODE = Mode::KANJI; + public const int DATAMODE = Mode::KANJI; protected function getCharCount():int{ return mb_strlen($this->data, self::ENCODING); diff --git a/src/Data/Number.php b/src/Data/Number.php index dda98494b..08a8dcd29 100644 --- a/src/Data/Number.php +++ b/src/Data/Number.php @@ -22,7 +22,7 @@ use function ceil, intdiv, preg_match, substr, unpack; */ final class Number extends QRDataModeAbstract{ - public const DATAMODE = Mode::NUMBER; + public const int DATAMODE = Mode::NUMBER; public function getLengthInBits():int{ return (int)ceil($this->getCharCount() * (10 / 3)); diff --git a/src/Data/QRDataModeInterface.php b/src/Data/QRDataModeInterface.php index 0f9f38598..07508fb71 100644 --- a/src/Data/QRDataModeInterface.php +++ b/src/Data/QRDataModeInterface.php @@ -23,10 +23,9 @@ interface QRDataModeInterface{ * * Note: do not call this constant from the interface, but rather from one of the child classes * - * @var int * @see \chillerlan\QRCode\Common\Mode */ - public const DATAMODE = -1; + public const int DATAMODE = -1; /** * retruns the length in bits of the data string diff --git a/src/Data/QRMatrix.php b/src/Data/QRMatrix.php index e338d8208..160e8af08 100755 --- a/src/Data/QRMatrix.php +++ b/src/Data/QRMatrix.php @@ -22,73 +22,41 @@ use function array_fill, array_map, array_reverse, count, intdiv; */ class QRMatrix{ - /* - * special values - */ + /* special values */ - /** @var int */ - public const IS_DARK = 0b100000000000; - /** @var int */ - public const M_NULL = 0b000000000000; - /** @var int */ - public const M_LOGO = 0b001000000000; - /** @var int */ - public const M_LOGO_DARK = 0b101000000000; + final public const int IS_DARK = 0b100000000000; + final public const int M_NULL = 0b000000000000; + final public const int M_LOGO = 0b001000000000; + final public const int M_LOGO_DARK = 0b101000000000; - /* - * light values - */ + /* light values */ - /** @var int */ - public const M_DATA = 0b000000000010; - /** @var int */ - public const M_FINDER = 0b000000000100; - /** @var int */ - public const M_SEPARATOR = 0b000000001000; - /** @var int */ - public const M_ALIGNMENT = 0b000000010000; - /** @var int */ - public const M_TIMING = 0b000000100000; - /** @var int */ - public const M_FORMAT = 0b000001000000; - /** @var int */ - public const M_VERSION = 0b000010000000; - /** @var int */ - public const M_QUIETZONE = 0b000100000000; + final public const int M_DATA = 0b000000000010; + final public const int M_FINDER = 0b000000000100; + final public const int M_SEPARATOR = 0b000000001000; + final public const int M_ALIGNMENT = 0b000000010000; + final public const int M_TIMING = 0b000000100000; + final public const int M_FORMAT = 0b000001000000; + final public const int M_VERSION = 0b000010000000; + final public const int M_QUIETZONE = 0b000100000000; - /* - * dark values - */ + /* dark values */ - /** @var int */ - public const M_DARKMODULE = 0b100000000001; - /** @var int */ - public const M_DATA_DARK = 0b100000000010; - /** @var int */ - public const M_FINDER_DARK = 0b100000000100; - /** @var int */ - public const M_ALIGNMENT_DARK = 0b100000010000; - /** @var int */ - public const M_TIMING_DARK = 0b100000100000; - /** @var int */ - public const M_FORMAT_DARK = 0b100001000000; - /** @var int */ - public const M_VERSION_DARK = 0b100010000000; - /** @var int */ - public const M_FINDER_DOT = 0b110000000000; + final public const int M_DARKMODULE = 0b100000000001; + final public const int M_DATA_DARK = 0b100000000010; + final public const int M_FINDER_DARK = 0b100000000100; + final public const int M_ALIGNMENT_DARK = 0b100000010000; + final public const int M_TIMING_DARK = 0b100000100000; + final public const int M_FORMAT_DARK = 0b100001000000; + final public const int M_VERSION_DARK = 0b100010000000; + final public const int M_FINDER_DOT = 0b110000000000; - /* - * values used for reversed reflectance - */ + /* values used for reversed reflectance */ - /** @var int */ - public const M_DARKMODULE_LIGHT = 0b000000000001; - /** @var int */ - public const M_FINDER_DOT_LIGHT = 0b010000000000; - /** @var int */ - public const M_SEPARATOR_DARK = 0b100000001000; - /** @var int */ - public const M_QUIETZONE_DARK = 0b100100000000; + final public const int M_DARKMODULE_LIGHT = 0b000000000001; + final public const int M_FINDER_DOT_LIGHT = 0b010000000000; + final public const int M_SEPARATOR_DARK = 0b100000001000; + final public const int M_QUIETZONE_DARK = 0b100100000000; /** * Map of flag => coord @@ -97,7 +65,7 @@ class QRMatrix{ * * @var int[][] */ - protected const neighbours = [ + final protected const array neighbours = [ 0b00000001 => [-1, -1], 0b00000010 => [ 0, -1], 0b00000100 => [ 1, -1], diff --git a/src/Decoder/Binarizer.php b/src/Decoder/Binarizer.php index c035cdded..48ec9ff3f 100644 --- a/src/Decoder/Binarizer.php +++ b/src/Decoder/Binarizer.php @@ -37,15 +37,15 @@ final class Binarizer{ // This class uses 5x5 blocks to compute local luminance, where each block is 8x8 pixels. // So this is the smallest dimension in each axis we can accept. - private const BLOCK_SIZE_POWER = 3; - private const BLOCK_SIZE = 8; // ...0100...00 - private const BLOCK_SIZE_MASK = 7; // ...0011...11 - private const MINIMUM_DIMENSION = 40; - private const MIN_DYNAMIC_RANGE = 24; + private const int BLOCK_SIZE_POWER = 3; + private const int BLOCK_SIZE = 8; // ...0100...00 + private const int BLOCK_SIZE_MASK = 7; // ...0011...11 + private const int MINIMUM_DIMENSION = 40; + private const int MIN_DYNAMIC_RANGE = 24; -# private const LUMINANCE_BITS = 5; - private const LUMINANCE_SHIFT = 3; - private const LUMINANCE_BUCKETS = 32; +# private const int LUMINANCE_BITS = 5; + private const int LUMINANCE_SHIFT = 3; + private const int LUMINANCE_BUCKETS = 32; private LuminanceSourceInterface $source; /** @var int[] */ diff --git a/src/Decoder/BitMatrix.php b/src/Decoder/BitMatrix.php index c1072f859..b262bbbf4 100644 --- a/src/Decoder/BitMatrix.php +++ b/src/Decoder/BitMatrix.php @@ -27,7 +27,7 @@ final class BitMatrix extends QRMatrix{ * * [data bits, sequence after masking] */ - private const DECODE_LOOKUP = [ + private const array DECODE_LOOKUP = [ 0x5412, // 0101010000010010 0x5125, // 0101000100100101 0x5E7C, // 0101111001111100 @@ -62,7 +62,7 @@ final class BitMatrix extends QRMatrix{ 0x2BED, // 0010101111101101 ]; - private const FORMAT_INFO_MASK_QR = 0x5412; // 0101010000010010 + private const int FORMAT_INFO_MASK_QR = 0x5412; // 0101010000010010 /** * This flag has effect only on the copyVersionBit() method. diff --git a/src/Detector/FinderPatternFinder.php b/src/Detector/FinderPatternFinder.php index 222f9e5ca..ca594ee83 100644 --- a/src/Detector/FinderPatternFinder.php +++ b/src/Detector/FinderPatternFinder.php @@ -26,11 +26,11 @@ use const PHP_FLOAT_MAX; */ final class FinderPatternFinder{ - private const MIN_SKIP = 2; - private const MAX_MODULES = 177; // 1 pixel/module times 3 modules/center - private const CENTER_QUORUM = 2; // support up to version 10 for mobile clients + private const int MIN_SKIP = 2; + private const int MAX_MODULES = 177; // 1 pixel/module times 3 modules/center + private const int CENTER_QUORUM = 2; // support up to version 10 for mobile clients /** @var int[] */ - private const crossCheckStateCount = [0, 0, 0, 0, 0]; + private const array crossCheckStateCount = [0, 0, 0, 0, 0]; private BitMatrix $matrix; /** @var \chillerlan\QRCode\Detector\FinderPattern[] */ private array $possibleCenters; diff --git a/src/Output/QREps.php b/src/Output/QREps.php index 5a6cf5885..6d418086d 100644 --- a/src/Output/QREps.php +++ b/src/Output/QREps.php @@ -23,7 +23,7 @@ use function array_values, count, date, implode, is_array, is_numeric, max, min, */ class QREps extends QROutputAbstract{ - final public const MIME_TYPE = 'application/postscript'; + final public const string MIME_TYPE = 'application/postscript'; public static function moduleValueIsValid(mixed $value):bool{ diff --git a/src/Output/QRFpdf.php b/src/Output/QRFpdf.php index 23438952a..8ee105cb3 100644 --- a/src/Output/QRFpdf.php +++ b/src/Output/QRFpdf.php @@ -28,7 +28,7 @@ use function class_exists; class QRFpdf extends QROutputAbstract{ use RGBArrayModuleValueTrait; - final public const MIME_TYPE = 'application/pdf'; + final public const string MIME_TYPE = 'application/pdf'; /** @var int[]|null */ protected array|null $prevColor = null; diff --git a/src/Output/QRGdImageAVIF.php b/src/Output/QRGdImageAVIF.php index d002ec72a..8b9db3d24 100644 --- a/src/Output/QRGdImageAVIF.php +++ b/src/Output/QRGdImageAVIF.php @@ -22,7 +22,7 @@ use function imageavif; */ class QRGdImageAVIF extends QRGdImage{ - final public const MIME_TYPE = 'image/avif'; + final public const string MIME_TYPE = 'image/avif'; /** * @throws \chillerlan\QRCode\Output\QRCodeOutputException diff --git a/src/Output/QRGdImageBMP.php b/src/Output/QRGdImageBMP.php index d3110b37f..abea060a8 100644 --- a/src/Output/QRGdImageBMP.php +++ b/src/Output/QRGdImageBMP.php @@ -22,7 +22,7 @@ use function imagebmp; */ class QRGdImageBMP extends QRGdImage{ - final public const MIME_TYPE = 'image/bmp'; + final public const string MIME_TYPE = 'image/bmp'; /** * @throws \chillerlan\QRCode\Output\QRCodeOutputException diff --git a/src/Output/QRGdImageGIF.php b/src/Output/QRGdImageGIF.php index 574d9d0b6..e210f7b68 100644 --- a/src/Output/QRGdImageGIF.php +++ b/src/Output/QRGdImageGIF.php @@ -22,7 +22,7 @@ use function imagegif; */ class QRGdImageGIF extends QRGdImage{ - final public const MIME_TYPE = 'image/gif'; + final public const string MIME_TYPE = 'image/gif'; /** * @throws \chillerlan\QRCode\Output\QRCodeOutputException diff --git a/src/Output/QRGdImageJPEG.php b/src/Output/QRGdImageJPEG.php index f6f40b34b..b1b0cceee 100644 --- a/src/Output/QRGdImageJPEG.php +++ b/src/Output/QRGdImageJPEG.php @@ -22,7 +22,7 @@ use function imagejpeg; */ class QRGdImageJPEG extends QRGdImage{ - final public const MIME_TYPE = 'image/jpg'; + final public const string MIME_TYPE = 'image/jpg'; protected function setTransparencyColor():int{ // noop - transparency is not supported diff --git a/src/Output/QRGdImagePNG.php b/src/Output/QRGdImagePNG.php index 73ebeb114..7f1bdc54a 100644 --- a/src/Output/QRGdImagePNG.php +++ b/src/Output/QRGdImagePNG.php @@ -22,7 +22,7 @@ use function imagepng, max, min; */ class QRGdImagePNG extends QRGdImage{ - final public const MIME_TYPE = 'image/png'; + final public const string MIME_TYPE = 'image/png'; protected function getQuality():int{ return max(-1, min(9, $this->options->quality)); diff --git a/src/Output/QRGdImageWEBP.php b/src/Output/QRGdImageWEBP.php index 995bead18..1ce802841 100644 --- a/src/Output/QRGdImageWEBP.php +++ b/src/Output/QRGdImageWEBP.php @@ -22,7 +22,7 @@ use function imagewebp; */ class QRGdImageWEBP extends QRGdImage{ - final public const MIME_TYPE = 'image/webp'; + final public const string MIME_TYPE = 'image/webp'; /** * @throws \chillerlan\QRCode\Output\QRCodeOutputException diff --git a/src/Output/QRMarkupHTML.php b/src/Output/QRMarkupHTML.php index f12e77886..11a0d2058 100644 --- a/src/Output/QRMarkupHTML.php +++ b/src/Output/QRMarkupHTML.php @@ -18,7 +18,7 @@ use function implode, sprintf; */ class QRMarkupHTML extends QRMarkup{ - final public const MIME_TYPE = 'text/html'; + final public const string MIME_TYPE = 'text/html'; protected function createMarkup(bool $saveToFile):string{ $rows = []; diff --git a/src/Output/QRMarkupSVG.php b/src/Output/QRMarkupSVG.php index 37b734d17..217776824 100644 --- a/src/Output/QRMarkupSVG.php +++ b/src/Output/QRMarkupSVG.php @@ -26,7 +26,7 @@ use function array_chunk, implode, is_string, preg_match, sprintf, trim; */ class QRMarkupSVG extends QRMarkup{ - final public const MIME_TYPE = 'image/svg+xml'; + final public const string MIME_TYPE = 'image/svg+xml'; /** * @todo: XSS proof diff --git a/src/Output/QRMarkupXML.php b/src/Output/QRMarkupXML.php index 6d78a2a8e..1e946dd97 100644 --- a/src/Output/QRMarkupXML.php +++ b/src/Output/QRMarkupXML.php @@ -22,8 +22,8 @@ use function sprintf; */ class QRMarkupXML extends QRMarkup{ - final public const MIME_TYPE = 'application/xml'; - final public const SCHEMA = 'https://raw.githubusercontent.com/chillerlan/php-qrcode/main/src/Output/qrcode.schema.xsd'; + final public const string MIME_TYPE = 'application/xml'; + final public const string SCHEMA = 'https://raw.githubusercontent.com/chillerlan/php-qrcode/main/src/Output/qrcode.schema.xsd'; protected DOMDocument $dom; diff --git a/src/Output/QROutputInterface.php b/src/Output/QROutputInterface.php index 44d68225b..ebd156405 100644 --- a/src/Output/QROutputInterface.php +++ b/src/Output/QROutputInterface.php @@ -24,7 +24,7 @@ interface QROutputInterface{ * @var string[] * @see https://github.com/chillerlan/php-qrcode/issues/223 */ - public const MODES = [ + final public const array MODES = [ QREps::class, QRFpdf::class, QRGdImageAVIF::class, @@ -47,7 +47,7 @@ interface QROutputInterface{ * * @var bool[] */ - public const DEFAULT_MODULE_VALUES = [ + final public const array DEFAULT_MODULE_VALUES = [ // light QRMatrix::M_NULL => false, QRMatrix::M_DARKMODULE_LIGHT => false, @@ -80,7 +80,7 @@ interface QROutputInterface{ * * @var string[] */ - public const LAYERNAMES = [ + final public const array LAYERNAMES = [ // light QRMatrix::M_NULL => 'null', QRMatrix::M_DARKMODULE_LIGHT => 'darkmodule-light', @@ -114,7 +114,7 @@ interface QROutputInterface{ * @var string * @see \chillerlan\QRCode\Output\QROutputAbstract::toBase64DataURI() */ - public const MIME_TYPE = ''; + public const string MIME_TYPE = ''; /** * Determines whether the given value is valid diff --git a/src/Output/QRStringJSON.php b/src/Output/QRStringJSON.php index a0274ef03..1803531d7 100644 --- a/src/Output/QRStringJSON.php +++ b/src/Output/QRStringJSON.php @@ -26,8 +26,8 @@ use function json_encode; class QRStringJSON extends QROutputAbstract{ use CssColorModuleValueTrait; - final public const MIME_TYPE = 'application/json'; - final public const SCHEMA = 'https://raw.githubusercontent.com/chillerlan/php-qrcode/main/src/Output/qrcode.schema.json'; + final public const string MIME_TYPE = 'application/json'; + final public const string SCHEMA = 'https://raw.githubusercontent.com/chillerlan/php-qrcode/main/src/Output/qrcode.schema.json'; /** * @inheritDoc diff --git a/src/Output/QRStringText.php b/src/Output/QRStringText.php index d8e244d01..af2d99c7a 100644 --- a/src/Output/QRStringText.php +++ b/src/Output/QRStringText.php @@ -18,7 +18,7 @@ use function array_map, implode, is_string, max, min, sprintf; */ class QRStringText extends QROutputAbstract{ - final public const MIME_TYPE = 'text/plain'; + final public const string MIME_TYPE = 'text/plain'; public static function moduleValueIsValid(mixed $value):bool{ return is_string($value); diff --git a/tests/Data/AlphaNumTest.php b/tests/Data/AlphaNumTest.php index 43296510a..a3d30544e 100644 --- a/tests/Data/AlphaNumTest.php +++ b/tests/Data/AlphaNumTest.php @@ -18,7 +18,7 @@ use chillerlan\QRCode\Data\{AlphaNum, QRDataModeInterface}; */ final class AlphaNumTest extends DataInterfaceTestAbstract{ - protected const testData = '0 $%*+-./:'; + protected const string testData = '0 $%*+-./:'; protected static function getDataModeInterface(string $data):QRDataModeInterface{ return new AlphaNum($data); diff --git a/tests/Data/ByteTest.php b/tests/Data/ByteTest.php index fc4d8a663..f6649dfac 100644 --- a/tests/Data/ByteTest.php +++ b/tests/Data/ByteTest.php @@ -19,7 +19,7 @@ use PHPUnit\Framework\Attributes\Test; */ final class ByteTest extends DataInterfaceTestAbstract{ - protected const testData = '[¯\_(ツ)_/¯]'; + protected const string testData = '[¯\_(ツ)_/¯]'; protected static function getDataModeInterface(string $data):QRDataModeInterface{ return new Byte($data); diff --git a/tests/Data/DataInterfaceTestAbstract.php b/tests/Data/DataInterfaceTestAbstract.php index ab73471b5..4af387dbd 100644 --- a/tests/Data/DataInterfaceTestAbstract.php +++ b/tests/Data/DataInterfaceTestAbstract.php @@ -30,7 +30,7 @@ abstract class DataInterfaceTestAbstract extends TestCase{ protected QRData $QRData; protected QRDataModeInterface $dataMode; - protected const testData = ''; + protected const string testData = ''; protected function setUp():void{ $this->QRData = new QRData(new QROptions); diff --git a/tests/Data/ECITest.php b/tests/Data/ECITest.php index 2a5711986..366508b65 100644 --- a/tests/Data/ECITest.php +++ b/tests/Data/ECITest.php @@ -25,7 +25,7 @@ final class ECITest extends TestCase{ private QRData $QRData; private int $testCharset = ECICharset::GB18030; - private const testData = '无可奈何燃花作香'; + private const string testData = '无可奈何燃花作香'; protected function setUp():void{ $this->QRData = new QRData(new QROptions); diff --git a/tests/Data/HanziTest.php b/tests/Data/HanziTest.php index b034ed83f..dd9229a00 100644 --- a/tests/Data/HanziTest.php +++ b/tests/Data/HanziTest.php @@ -21,7 +21,7 @@ use function bin2hex, chr, defined, sprintf; */ final class HanziTest extends DataInterfaceTestAbstract{ - protected const testData = '无可奈何燃花作香'; + protected const string testData = '无可奈何燃花作香'; protected static function getDataModeInterface(string $data):QRDataModeInterface{ return new Hanzi($data); diff --git a/tests/Data/KanjiTest.php b/tests/Data/KanjiTest.php index 4771daa22..d7ad84c33 100644 --- a/tests/Data/KanjiTest.php +++ b/tests/Data/KanjiTest.php @@ -21,7 +21,7 @@ use function bin2hex, chr, defined, sprintf; */ final class KanjiTest extends DataInterfaceTestAbstract{ - protected const testData = '漂う花の香り'; + protected const string testData = '漂う花の香り'; protected static function getDataModeInterface(string $data):QRDataModeInterface{ return new Kanji($data); diff --git a/tests/Data/NumberTest.php b/tests/Data/NumberTest.php index abfa66116..3d9dc7b82 100644 --- a/tests/Data/NumberTest.php +++ b/tests/Data/NumberTest.php @@ -18,7 +18,7 @@ use chillerlan\QRCode\Data\{Number, QRDataModeInterface}; */ final class NumberTest extends DataInterfaceTestAbstract{ - protected const testData = '0123456789'; + protected const string testData = '0123456789'; protected static function getDataModeInterface(string $data):QRDataModeInterface{ return new Number($data); diff --git a/tests/Data/QRMatrixTest.php b/tests/Data/QRMatrixTest.php index 2f5d997dc..09c81d577 100755 --- a/tests/Data/QRMatrixTest.php +++ b/tests/Data/QRMatrixTest.php @@ -25,7 +25,7 @@ use Generator; final class QRMatrixTest extends TestCase{ use QRMatrixDebugTrait; - private const version = 40; + private const int version = 40; private QRMatrix $matrix; /** diff --git a/tests/Output/QROutputTestAbstract.php b/tests/Output/QROutputTestAbstract.php index 8b85a4d49..f326afb88 100644 --- a/tests/Output/QROutputTestAbstract.php +++ b/tests/Output/QROutputTestAbstract.php @@ -31,7 +31,7 @@ abstract class QROutputTestAbstract extends TestCase{ protected QROutputInterface $outputInterface; protected QRMatrix $matrix; - protected const buildDir = 'output-test'; + protected const string buildDir = 'output-test'; /** * Attempts to create a directory under /.build and instances several required objects diff --git a/tests/QRCodeReaderTestAbstract.php b/tests/QRCodeReaderTestAbstract.php index 16995e0a6..bd299a2b4 100644 --- a/tests/QRCodeReaderTestAbstract.php +++ b/tests/QRCodeReaderTestAbstract.php @@ -32,7 +32,7 @@ abstract class QRCodeReaderTestAbstract extends TestCase{ use QRMaxLengthTrait, QRMatrixDebugTrait; /** @see https://www.bobrosslipsum.com/ */ - protected const loremipsum = 'Just let this happen. We just let this flow right out of our minds. ' + final protected const string loremipsum = 'Just let this happen. We just let this flow right out of our minds. ' .'Anyone can paint. We touch the canvas, the canvas takes what it wants. From all of us here, ' .'I want to wish you happy painting and God bless, my friends. A tree cannot be straight if it has a crooked trunk. ' .'You have to make almighty decisions when you\'re the creator. I guess that would be considered a UFO. ' @@ -40,7 +40,7 @@ abstract class QRCodeReaderTestAbstract extends TestCase{ .'They say everything looks better with odd numbers of things. But sometimes I put even numbers—just ' .'to upset the critics. We\'ll lay all these little funky little things in there. '; - protected const samplesDir = __DIR__.'/samples/'; + protected const string samplesDir = __DIR__.'/samples/'; protected SettingsContainerInterface|QROptions $options; diff --git a/tests/QRCodeTest.php b/tests/QRCodeTest.php index 5b3e3cb74..67ba9de42 100755 --- a/tests/QRCodeTest.php +++ b/tests/QRCodeTest.php @@ -28,7 +28,7 @@ final class QRCodeTest extends TestCase{ private QRCode $qrcode; private QROptions $options; - private const buildDir = 'output-test'; + private const string buildDir = 'output-test'; /** * invoke test instances diff --git a/tests/Traits/BuildDirTrait.php b/tests/Traits/BuildDirTrait.php index ba6b59b67..efc66d14f 100644 --- a/tests/Traits/BuildDirTrait.php +++ b/tests/Traits/BuildDirTrait.php @@ -19,7 +19,7 @@ use function dirname, file_exists, file_get_contents, is_file, mkdir, realpath, */ trait BuildDirTrait{ - protected const _buildDir = __DIR__.'/../../.build/'; + protected const string _buildDir = __DIR__.'/../../.build/'; /** * returns the full raw path to the build dir diff --git a/tests/Traits/QRMaxLengthTrait.php b/tests/Traits/QRMaxLengthTrait.php index 05a79e11c..5db20f2dd 100644 --- a/tests/Traits/QRMaxLengthTrait.php +++ b/tests/Traits/QRMaxLengthTrait.php @@ -26,7 +26,7 @@ trait QRMaxLengthTrait{ * * @var int[][][] */ - protected const MAX_LENGTH = [ + final protected const array MAX_LENGTH = [ // v => [NUMERIC => [L, M, Q, H ], ALPHANUM => [L, M, Q, H], BINARY => [L, M, Q, H ], KANJI => [L, M, Q, H ]] 1 => [[ 41, 34, 27, 17], [ 25, 20, 16, 10], [ 17, 14, 11, 7], [ 10, 8, 7, 4]], 2 => [[ 77, 63, 48, 34], [ 47, 38, 29, 20], [ 32, 26, 20, 14], [ 20, 16, 12, 8]],