Skip to content

Commit 94931d8

Browse files
committed
:octocat: type hints for class constants
1 parent 408f463 commit 94931d8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+165
-224
lines changed

examples/svgModuleJitter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
*/
2727
class ModuleJitterSVGoutput extends QRMarkupSVG{
2828

29-
protected const ROUND_PRECISION = 5;
29+
protected const int ROUND_PRECISION = 5;
3030

3131
protected readonly float $sideLength;
3232

src/Common/ECICharset.php

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -20,44 +20,44 @@
2020
*/
2121
final class ECICharset{
2222

23-
public const CP437 = 0; // Code page 437, DOS Latin US
24-
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
25-
public const CP437_WO_GLI = 2; // An equivalent code table to CP437, without the return-to-GLI 0 logic
26-
public const ISO_IEC_8859_1 = 3; // Latin-1 (Default)
27-
public const ISO_IEC_8859_2 = 4; // Latin-2
28-
public const ISO_IEC_8859_3 = 5; // Latin-3
29-
public const ISO_IEC_8859_4 = 6; // Latin-4
30-
public const ISO_IEC_8859_5 = 7; // Latin/Cyrillic
31-
public const ISO_IEC_8859_6 = 8; // Latin/Arabic
32-
public const ISO_IEC_8859_7 = 9; // Latin/Greek
33-
public const ISO_IEC_8859_8 = 10; // Latin/Hebrew
34-
public const ISO_IEC_8859_9 = 11; // Latin-5
35-
public const ISO_IEC_8859_10 = 12; // Latin-6
36-
public const ISO_IEC_8859_11 = 13; // Latin/Thai
23+
public const int CP437 = 0; // Code page 437, DOS Latin US
24+
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
25+
public const int CP437_WO_GLI = 2; // An equivalent code table to CP437, without the return-to-GLI 0 logic
26+
public const int ISO_IEC_8859_1 = 3; // Latin-1 (Default)
27+
public const int ISO_IEC_8859_2 = 4; // Latin-2
28+
public const int ISO_IEC_8859_3 = 5; // Latin-3
29+
public const int ISO_IEC_8859_4 = 6; // Latin-4
30+
public const int ISO_IEC_8859_5 = 7; // Latin/Cyrillic
31+
public const int ISO_IEC_8859_6 = 8; // Latin/Arabic
32+
public const int ISO_IEC_8859_7 = 9; // Latin/Greek
33+
public const int ISO_IEC_8859_8 = 10; // Latin/Hebrew
34+
public const int ISO_IEC_8859_9 = 11; // Latin-5
35+
public const int ISO_IEC_8859_10 = 12; // Latin-6
36+
public const int ISO_IEC_8859_11 = 13; // Latin/Thai
3737
// 14 reserved
38-
public const ISO_IEC_8859_13 = 15; // Latin-7 (Baltic Rim)
39-
public const ISO_IEC_8859_14 = 16; // Latin-8 (Celtic)
40-
public const ISO_IEC_8859_15 = 17; // Latin-9
41-
public const ISO_IEC_8859_16 = 18; // Latin-10
38+
public const int ISO_IEC_8859_13 = 15; // Latin-7 (Baltic Rim)
39+
public const int ISO_IEC_8859_14 = 16; // Latin-8 (Celtic)
40+
public const int ISO_IEC_8859_15 = 17; // Latin-9
41+
public const int ISO_IEC_8859_16 = 18; // Latin-10
4242
// 19 reserved
43-
public const SHIFT_JIS = 20; // JIS X 0208 Annex 1 + JIS X 0201
44-
public const WINDOWS_1250_LATIN_2 = 21; // Superset of Latin-2, Central Europe
45-
public const WINDOWS_1251_CYRILLIC = 22; // Latin/Cyrillic
46-
public const WINDOWS_1252_LATIN_1 = 23; // Superset of Latin-1
47-
public const WINDOWS_1256_ARABIC = 24;
48-
public const ISO_IEC_10646_UCS_2 = 25; // High order byte first (UTF-16BE)
49-
public const ISO_IEC_10646_UTF_8 = 26; // UTF-8
50-
public const ISO_IEC_646_1991 = 27; // International Reference Version of ISO 7-bit coded character set (US-ASCII)
51-
public const BIG5 = 28; // Big 5 (Taiwan) Chinese Character Set
52-
public const GB18030 = 29; // GB (PRC) Chinese Character Set
53-
public const EUC_KR = 30; // Korean Character Set
43+
public const int SHIFT_JIS = 20; // JIS X 0208 Annex 1 + JIS X 0201
44+
public const int WINDOWS_1250_LATIN_2 = 21; // Superset of Latin-2, Central Europe
45+
public const int WINDOWS_1251_CYRILLIC = 22; // Latin/Cyrillic
46+
public const int WINDOWS_1252_LATIN_1 = 23; // Superset of Latin-1
47+
public const int WINDOWS_1256_ARABIC = 24;
48+
public const int ISO_IEC_10646_UCS_2 = 25; // High order byte first (UTF-16BE)
49+
public const int ISO_IEC_10646_UTF_8 = 26; // UTF-8
50+
public const int ISO_IEC_646_1991 = 27; // International Reference Version of ISO 7-bit coded character set (US-ASCII)
51+
public const int BIG5 = 28; // Big 5 (Taiwan) Chinese Character Set
52+
public const int GB18030 = 29; // GB (PRC) Chinese Character Set
53+
public const int EUC_KR = 30; // Korean Character Set
5454

5555
/**
5656
* map of charset id -> name
5757
*
5858
* @see \mb_list_encodings()
5959
*/
60-
public const MB_ENCODINGS = [
60+
public const array MB_ENCODINGS = [
6161
self::CP437 => null,
6262
self::ISO_IEC_8859_1_GLI => null,
6363
self::CP437_WO_GLI => null,

src/Common/EccLevel.php

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,17 @@ final class EccLevel{
2121

2222
// ISO/IEC 18004:2000 Tables 12, 25
2323

24-
/** @var int */
25-
public const L = 0b01; // 7%.
26-
/** @var int */
27-
public const M = 0b00; // 15%.
28-
/** @var int */
29-
public const Q = 0b11; // 25%.
30-
/** @var int */
31-
public const H = 0b10; // 30%.
24+
public const int L = 0b01; // 7%.
25+
public const int M = 0b00; // 15%.
26+
public const int Q = 0b11; // 25%.
27+
public const int H = 0b10; // 30%.
3228

3329
/**
3430
* ISO/IEC 18004:2000 Tables 7-11 - Number of symbol characters and input data capacity for versions 1 to 40
3531
*
3632
* @var int[][]
3733
*/
38-
private const MAX_BITS = [
34+
private const array MAX_BITS = [
3935
// [ L, M, Q, H] // v => modules
4036
[ 0, 0, 0, 0], // 0 => will be ignored, index starts at 1
4137
[ 152, 128, 104, 72], // 1 => 21
@@ -87,7 +83,7 @@ final class EccLevel{
8783
*
8884
* @var int[][]
8985
*/
90-
private const FORMAT_PATTERN = [
86+
private const array FORMAT_PATTERN = [
9187
[ // L
9288
0b111011111000100,
9389
0b111001011110011,

src/Common/GF256.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ final class GF256{
3535
*/
3636
# private int $primitive = 0x011D;
3737

38-
private const logTable = [
38+
private const array logTable = [
3939
0, // the first value is never returned, index starts at 1
4040
0, 1, 25, 2, 50, 26, 198, 3, 223, 51, 238, 27, 104, 199, 75,
4141
4, 100, 224, 14, 52, 141, 239, 129, 28, 193, 105, 248, 200, 8, 76, 113,
@@ -55,7 +55,7 @@ final class GF256{
5555
79, 174, 213, 233, 230, 231, 173, 232, 116, 214, 244, 234, 168, 80, 88, 175,
5656
];
5757

58-
private const expTable = [
58+
private const array expTable = [
5959
1, 2, 4, 8, 16, 32, 64, 128, 29, 58, 116, 232, 205, 135, 19, 38,
6060
76, 152, 45, 90, 180, 117, 234, 201, 143, 3, 6, 12, 24, 48, 96, 192,
6161
157, 39, 78, 156, 37, 74, 148, 53, 106, 212, 181, 119, 238, 193, 159, 35,

src/Common/MaskPattern.php

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,22 @@ final class MaskPattern{
2828

2929
/**
3030
* @see \chillerlan\QRCode\QROptionsTrait::$maskPattern
31-
*
32-
* @var int
3331
*/
34-
public const AUTO = -1;
32+
public const int AUTO = -1;
3533

36-
public const PATTERN_000 = 0b000;
37-
public const PATTERN_001 = 0b001;
38-
public const PATTERN_010 = 0b010;
39-
public const PATTERN_011 = 0b011;
40-
public const PATTERN_100 = 0b100;
41-
public const PATTERN_101 = 0b101;
42-
public const PATTERN_110 = 0b110;
43-
public const PATTERN_111 = 0b111;
34+
public const int PATTERN_000 = 0b000;
35+
public const int PATTERN_001 = 0b001;
36+
public const int PATTERN_010 = 0b010;
37+
public const int PATTERN_011 = 0b011;
38+
public const int PATTERN_100 = 0b100;
39+
public const int PATTERN_101 = 0b101;
40+
public const int PATTERN_110 = 0b110;
41+
public const int PATTERN_111 = 0b111;
4442

4543
/**
4644
* @var int[]
4745
*/
48-
public const PATTERNS = [
46+
public const array PATTERNS = [
4947
self::PATTERN_000,
5048
self::PATTERN_001,
5149
self::PATTERN_010,
@@ -61,10 +59,10 @@ final class MaskPattern{
6159
*
6260
* ISO/IEC 18004:2000 Section 8.8.1 - Table 24
6361
*/
64-
private const PENALTY_N1 = 3;
65-
private const PENALTY_N2 = 3;
66-
private const PENALTY_N3 = 40;
67-
private const PENALTY_N4 = 10;
62+
private const int PENALTY_N1 = 3;
63+
private const int PENALTY_N2 = 3;
64+
private const int PENALTY_N3 = 40;
65+
private const int PENALTY_N4 = 10;
6866

6967
/**
7068
* The current mask pattern value (0-7)

src/Common/Mode.php

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -21,33 +21,23 @@ final class Mode{
2121

2222
// ISO/IEC 18004:2000 Table 2
2323

24-
/** @var int */
25-
public const TERMINATOR = 0b0000;
26-
/** @var int */
27-
public const NUMBER = 0b0001;
28-
/** @var int */
29-
public const ALPHANUM = 0b0010;
30-
/** @var int */
31-
public const BYTE = 0b0100;
32-
/** @var int */
33-
public const KANJI = 0b1000;
34-
/** @var int */
35-
public const HANZI = 0b1101;
36-
/** @var int */
37-
public const STRCTURED_APPEND = 0b0011;
38-
/** @var int */
39-
public const FNC1_FIRST = 0b0101;
40-
/** @var int */
41-
public const FNC1_SECOND = 0b1001;
42-
/** @var int */
43-
public const ECI = 0b0111;
24+
public const int TERMINATOR = 0b0000;
25+
public const int NUMBER = 0b0001;
26+
public const int ALPHANUM = 0b0010;
27+
public const int BYTE = 0b0100;
28+
public const int KANJI = 0b1000;
29+
public const int HANZI = 0b1101;
30+
public const int STRCTURED_APPEND = 0b0011;
31+
public const int FNC1_FIRST = 0b0101;
32+
public const int FNC1_SECOND = 0b1001;
33+
public const int ECI = 0b0111;
4434

4535
/**
4636
* mode length bits for the version breakpoints 1-9, 10-26 and 27-40
4737
*
4838
* ISO/IEC 18004:2000 Table 3 - Number of bits in Character Count Indicator
4939
*/
50-
public const LENGTH_BITS = [
40+
public const array LENGTH_BITS = [
5141
self::NUMBER => [10, 12, 14],
5242
self::ALPHANUM => [ 9, 11, 13],
5343
self::BYTE => [ 8, 16, 16],
@@ -61,7 +51,7 @@ final class Mode{
6151
*
6252
* @var array<int, string>
6353
*/
64-
public const INTERFACES = [
54+
public const array INTERFACES = [
6555
self::NUMBER => Number::class,
6656
self::ALPHANUM => AlphaNum::class,
6757
self::KANJI => Kanji::class,

src/Common/Version.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,8 @@ final class Version{
2222
* Enable version auto detection
2323
*
2424
* @see \chillerlan\QRCode\QROptionsTrait::$version
25-
*
26-
* @var int
2725
*/
28-
public const AUTO = -1;
26+
public const int AUTO = -1;
2927

3028
/**
3129
* 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{
3432
*
3533
* @var int[][]
3634
*/
37-
private const ALIGNMENT_PATTERN = [
35+
private const array ALIGNMENT_PATTERN = [
3836
1 => [],
3937
2 => [6, 18],
4038
3 => [6, 22],
@@ -84,7 +82,7 @@ final class Version{
8482
*
8583
* @var int[]
8684
*/
87-
private const VERSION_PATTERN = [
85+
private const array VERSION_PATTERN = [
8886
7 => 0b000111110010010100,
8987
8 => 0b001000010110111100,
9088
9 => 0b001001101010011001,
@@ -126,7 +124,7 @@ final class Version{
126124
*
127125
* @see http://www.thonky.com/qr-code-tutorial/error-correction-table
128126
*/
129-
private const RSBLOCKS = [
127+
private const array RSBLOCKS = [
130128
1 => [[ 7, [[ 1, 19], [ 0, 0]]], [10, [[ 1, 16], [ 0, 0]]], [13, [[ 1, 13], [ 0, 0]]], [17, [[ 1, 9], [ 0, 0]]]],
131129
2 => [[10, [[ 1, 34], [ 0, 0]]], [16, [[ 1, 28], [ 0, 0]]], [22, [[ 1, 22], [ 0, 0]]], [28, [[ 1, 16], [ 0, 0]]]],
132130
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{
172170
/**
173171
* ISO/IEC 18004:2000 Table 1 - Data capacity of all versions of QR Code
174172
*/
175-
private const TOTAL_CODEWORDS = [
173+
private const array TOTAL_CODEWORDS = [
176174
1 => 26,
177175
2 => 44,
178176
3 => 70,

src/Data/AlphaNum.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,10 @@ final class AlphaNum extends QRDataModeAbstract{
2424

2525
/**
2626
* ISO/IEC 18004:2000 Table 5
27-
*
28-
* @var string
2927
*/
30-
private const CHAR_MAP = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:';
28+
private const string CHAR_MAP = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:';
3129

32-
public const DATAMODE = Mode::ALPHANUM;
30+
public const int DATAMODE = Mode::ALPHANUM;
3331

3432
public function getLengthInBits():int{
3533
return (int)ceil($this->getCharCount() * (11 / 2));

src/Data/Byte.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*/
2323
final class Byte extends QRDataModeAbstract{
2424

25-
public const DATAMODE = Mode::BYTE;
25+
public const int DATAMODE = Mode::BYTE;
2626

2727
public function getLengthInBits():int{
2828
return ($this->getCharCount() * 8);

src/Data/ECI.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
*/
2424
final class ECI extends QRDataModeAbstract{
2525

26-
public const DATAMODE = Mode::ECI;
26+
public const int DATAMODE = Mode::ECI;
2727

2828
/**
2929
* The current ECI encoding id (default to UTF-8)

0 commit comments

Comments
 (0)