@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | return $a; |
28 | 28 | } |
29 | 29 | |
30 | - return ($a >> $b) & ~((1 << (8 * PHP_INT_SIZE - 1)) >> ($b - 1)); |
|
30 | + return ($a >> $b)&~((1 << (8 * PHP_INT_SIZE - 1)) >> ($b - 1)); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | function numBitsDiffering(int $a, int $b):int{ |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | $count = 0; |
40 | 40 | |
41 | 41 | for($i = 0; $i < 32; $i += 4){ |
42 | - $count += $BITS_SET_IN_HALF_BYTE[uRShift($a, $i) & 0x0F]; |
|
42 | + $count += $BITS_SET_IN_HALF_BYTE[uRShift($a, $i)&0x0F]; |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | return $count; |
@@ -179,7 +179,7 @@ |
||
179 | 179 | // Above should work but fails on some Apple and Linux JDKs due to a Hotspot bug. |
180 | 180 | // Below is a funny-looking workaround from Steven Parkes |
181 | 181 | $term = GF256::multiply($errorLocations[$j], $xiInverse); |
182 | - $denominator = GF256::multiply($denominator, (($term & 0x1) === 0 ? $term | 1 : $term & ~1)); |
|
182 | + $denominator = GF256::multiply($denominator, (($term&0x1) === 0 ? $term|1 : $term&~1)); |
|
183 | 183 | } |
184 | 184 | } |
185 | 185 |
@@ -143,7 +143,8 @@ |
||
143 | 143 | // This is a direct application of Chien's search |
144 | 144 | $numErrors = $errorLocator->getDegree(); |
145 | 145 | |
146 | - if($numErrors === 1){ // shortcut |
|
146 | + if($numErrors === 1){ |
|
147 | +// shortcut |
|
147 | 148 | return [$errorLocator->getCoefficient(1)]; |
148 | 149 | } |
149 | 150 |
@@ -45,14 +45,14 @@ discard block |
||
45 | 45 | 18 => [6, 30, 56, 82], |
46 | 46 | 19 => [6, 30, 58, 86], |
47 | 47 | 20 => [6, 34, 62, 90], |
48 | - 21 => [6, 28, 50, 72, 94], |
|
49 | - 22 => [6, 26, 50, 74, 98], |
|
48 | + 21 => [6, 28, 50, 72, 94], |
|
49 | + 22 => [6, 26, 50, 74, 98], |
|
50 | 50 | 23 => [6, 30, 54, 78, 102], |
51 | 51 | 24 => [6, 28, 54, 80, 106], |
52 | 52 | 25 => [6, 32, 58, 84, 110], |
53 | 53 | 26 => [6, 30, 58, 86, 114], |
54 | 54 | 27 => [6, 34, 62, 90, 118], |
55 | - 28 => [6, 26, 50, 74, 98, 122], |
|
55 | + 28 => [6, 26, 50, 74, 98, 122], |
|
56 | 56 | 29 => [6, 30, 54, 78, 102, 126], |
57 | 57 | 30 => [6, 26, 52, 78, 104, 130], |
58 | 58 | 31 => [6, 30, 56, 82, 108, 134], |
@@ -118,48 +118,48 @@ discard block |
||
118 | 118 | * |
119 | 119 | * @var int [][][] |
120 | 120 | */ |
121 | - private const MAX_LENGTH =[ |
|
121 | + private const MAX_LENGTH = [ |
|
122 | 122 | // v => [NUMERIC => [L, M, Q, H ], ALPHANUM => [L, M, Q, H], BINARY => [L, M, Q, H ], KANJI => [L, M, Q, H ]] |
123 | - 1 => [[ 41, 34, 27, 17], [ 25, 20, 16, 10], [ 17, 14, 11, 7], [ 10, 8, 7, 4]], |
|
124 | - 2 => [[ 77, 63, 48, 34], [ 47, 38, 29, 20], [ 32, 26, 20, 14], [ 20, 16, 12, 8]], |
|
125 | - 3 => [[ 127, 101, 77, 58], [ 77, 61, 47, 35], [ 53, 42, 32, 24], [ 32, 26, 20, 15]], |
|
126 | - 4 => [[ 187, 149, 111, 82], [ 114, 90, 67, 50], [ 78, 62, 46, 34], [ 48, 38, 28, 21]], |
|
127 | - 5 => [[ 255, 202, 144, 106], [ 154, 122, 87, 64], [ 106, 84, 60, 44], [ 65, 52, 37, 27]], |
|
128 | - 6 => [[ 322, 255, 178, 139], [ 195, 154, 108, 84], [ 134, 106, 74, 58], [ 82, 65, 45, 36]], |
|
129 | - 7 => [[ 370, 293, 207, 154], [ 224, 178, 125, 93], [ 154, 122, 86, 64], [ 95, 75, 53, 39]], |
|
130 | - 8 => [[ 461, 365, 259, 202], [ 279, 221, 157, 122], [ 192, 152, 108, 84], [ 118, 93, 66, 52]], |
|
131 | - 9 => [[ 552, 432, 312, 235], [ 335, 262, 189, 143], [ 230, 180, 130, 98], [ 141, 111, 80, 60]], |
|
132 | - 10 => [[ 652, 513, 364, 288], [ 395, 311, 221, 174], [ 271, 213, 151, 119], [ 167, 131, 93, 74]], |
|
133 | - 11 => [[ 772, 604, 427, 331], [ 468, 366, 259, 200], [ 321, 251, 177, 137], [ 198, 155, 109, 85]], |
|
134 | - 12 => [[ 883, 691, 489, 374], [ 535, 419, 296, 227], [ 367, 287, 203, 155], [ 226, 177, 125, 96]], |
|
135 | - 13 => [[1022, 796, 580, 427], [ 619, 483, 352, 259], [ 425, 331, 241, 177], [ 262, 204, 149, 109]], |
|
136 | - 14 => [[1101, 871, 621, 468], [ 667, 528, 376, 283], [ 458, 362, 258, 194], [ 282, 223, 159, 120]], |
|
137 | - 15 => [[1250, 991, 703, 530], [ 758, 600, 426, 321], [ 520, 412, 292, 220], [ 320, 254, 180, 136]], |
|
138 | - 16 => [[1408, 1082, 775, 602], [ 854, 656, 470, 365], [ 586, 450, 322, 250], [ 361, 277, 198, 154]], |
|
139 | - 17 => [[1548, 1212, 876, 674], [ 938, 734, 531, 408], [ 644, 504, 364, 280], [ 397, 310, 224, 173]], |
|
140 | - 18 => [[1725, 1346, 948, 746], [1046, 816, 574, 452], [ 718, 560, 394, 310], [ 442, 345, 243, 191]], |
|
141 | - 19 => [[1903, 1500, 1063, 813], [1153, 909, 644, 493], [ 792, 624, 442, 338], [ 488, 384, 272, 208]], |
|
142 | - 20 => [[2061, 1600, 1159, 919], [1249, 970, 702, 557], [ 858, 666, 482, 382], [ 528, 410, 297, 235]], |
|
143 | - 21 => [[2232, 1708, 1224, 969], [1352, 1035, 742, 587], [ 929, 711, 509, 403], [ 572, 438, 314, 248]], |
|
144 | - 22 => [[2409, 1872, 1358, 1056], [1460, 1134, 823, 640], [1003, 779, 565, 439], [ 618, 480, 348, 270]], |
|
145 | - 23 => [[2620, 2059, 1468, 1108], [1588, 1248, 890, 672], [1091, 857, 611, 461], [ 672, 528, 376, 284]], |
|
146 | - 24 => [[2812, 2188, 1588, 1228], [1704, 1326, 963, 744], [1171, 911, 661, 511], [ 721, 561, 407, 315]], |
|
147 | - 25 => [[3057, 2395, 1718, 1286], [1853, 1451, 1041, 779], [1273, 997, 715, 535], [ 784, 614, 440, 330]], |
|
148 | - 26 => [[3283, 2544, 1804, 1425], [1990, 1542, 1094, 864], [1367, 1059, 751, 593], [ 842, 652, 462, 365]], |
|
149 | - 27 => [[3517, 2701, 1933, 1501], [2132, 1637, 1172, 910], [1465, 1125, 805, 625], [ 902, 692, 496, 385]], |
|
150 | - 28 => [[3669, 2857, 2085, 1581], [2223, 1732, 1263, 958], [1528, 1190, 868, 658], [ 940, 732, 534, 405]], |
|
151 | - 29 => [[3909, 3035, 2181, 1677], [2369, 1839, 1322, 1016], [1628, 1264, 908, 698], [1002, 778, 559, 430]], |
|
152 | - 30 => [[4158, 3289, 2358, 1782], [2520, 1994, 1429, 1080], [1732, 1370, 982, 742], [1066, 843, 604, 457]], |
|
153 | - 31 => [[4417, 3486, 2473, 1897], [2677, 2113, 1499, 1150], [1840, 1452, 1030, 790], [1132, 894, 634, 486]], |
|
154 | - 32 => [[4686, 3693, 2670, 2022], [2840, 2238, 1618, 1226], [1952, 1538, 1112, 842], [1201, 947, 684, 518]], |
|
155 | - 33 => [[4965, 3909, 2805, 2157], [3009, 2369, 1700, 1307], [2068, 1628, 1168, 898], [1273, 1002, 719, 553]], |
|
156 | - 34 => [[5253, 4134, 2949, 2301], [3183, 2506, 1787, 1394], [2188, 1722, 1228, 958], [1347, 1060, 756, 590]], |
|
157 | - 35 => [[5529, 4343, 3081, 2361], [3351, 2632, 1867, 1431], [2303, 1809, 1283, 983], [1417, 1113, 790, 605]], |
|
158 | - 36 => [[5836, 4588, 3244, 2524], [3537, 2780, 1966, 1530], [2431, 1911, 1351, 1051], [1496, 1176, 832, 647]], |
|
159 | - 37 => [[6153, 4775, 3417, 2625], [3729, 2894, 2071, 1591], [2563, 1989, 1423, 1093], [1577, 1224, 876, 673]], |
|
160 | - 38 => [[6479, 5039, 3599, 2735], [3927, 3054, 2181, 1658], [2699, 2099, 1499, 1139], [1661, 1292, 923, 701]], |
|
161 | - 39 => [[6743, 5313, 3791, 2927], [4087, 3220, 2298, 1774], [2809, 2213, 1579, 1219], [1729, 1362, 972, 750]], |
|
162 | - 40 => [[7089, 5596, 3993, 3057], [4296, 3391, 2420, 1852], [2953, 2331, 1663, 1273], [1817, 1435, 1024, 784]], |
|
123 | + 1 => [[41, 34, 27, 17], [25, 20, 16, 10], [17, 14, 11, 7], [10, 8, 7, 4]], |
|
124 | + 2 => [[77, 63, 48, 34], [47, 38, 29, 20], [32, 26, 20, 14], [20, 16, 12, 8]], |
|
125 | + 3 => [[127, 101, 77, 58], [77, 61, 47, 35], [53, 42, 32, 24], [32, 26, 20, 15]], |
|
126 | + 4 => [[187, 149, 111, 82], [114, 90, 67, 50], [78, 62, 46, 34], [48, 38, 28, 21]], |
|
127 | + 5 => [[255, 202, 144, 106], [154, 122, 87, 64], [106, 84, 60, 44], [65, 52, 37, 27]], |
|
128 | + 6 => [[322, 255, 178, 139], [195, 154, 108, 84], [134, 106, 74, 58], [82, 65, 45, 36]], |
|
129 | + 7 => [[370, 293, 207, 154], [224, 178, 125, 93], [154, 122, 86, 64], [95, 75, 53, 39]], |
|
130 | + 8 => [[461, 365, 259, 202], [279, 221, 157, 122], [192, 152, 108, 84], [118, 93, 66, 52]], |
|
131 | + 9 => [[552, 432, 312, 235], [335, 262, 189, 143], [230, 180, 130, 98], [141, 111, 80, 60]], |
|
132 | + 10 => [[652, 513, 364, 288], [395, 311, 221, 174], [271, 213, 151, 119], [167, 131, 93, 74]], |
|
133 | + 11 => [[772, 604, 427, 331], [468, 366, 259, 200], [321, 251, 177, 137], [198, 155, 109, 85]], |
|
134 | + 12 => [[883, 691, 489, 374], [535, 419, 296, 227], [367, 287, 203, 155], [226, 177, 125, 96]], |
|
135 | + 13 => [[1022, 796, 580, 427], [619, 483, 352, 259], [425, 331, 241, 177], [262, 204, 149, 109]], |
|
136 | + 14 => [[1101, 871, 621, 468], [667, 528, 376, 283], [458, 362, 258, 194], [282, 223, 159, 120]], |
|
137 | + 15 => [[1250, 991, 703, 530], [758, 600, 426, 321], [520, 412, 292, 220], [320, 254, 180, 136]], |
|
138 | + 16 => [[1408, 1082, 775, 602], [854, 656, 470, 365], [586, 450, 322, 250], [361, 277, 198, 154]], |
|
139 | + 17 => [[1548, 1212, 876, 674], [938, 734, 531, 408], [644, 504, 364, 280], [397, 310, 224, 173]], |
|
140 | + 18 => [[1725, 1346, 948, 746], [1046, 816, 574, 452], [718, 560, 394, 310], [442, 345, 243, 191]], |
|
141 | + 19 => [[1903, 1500, 1063, 813], [1153, 909, 644, 493], [792, 624, 442, 338], [488, 384, 272, 208]], |
|
142 | + 20 => [[2061, 1600, 1159, 919], [1249, 970, 702, 557], [858, 666, 482, 382], [528, 410, 297, 235]], |
|
143 | + 21 => [[2232, 1708, 1224, 969], [1352, 1035, 742, 587], [929, 711, 509, 403], [572, 438, 314, 248]], |
|
144 | + 22 => [[2409, 1872, 1358, 1056], [1460, 1134, 823, 640], [1003, 779, 565, 439], [618, 480, 348, 270]], |
|
145 | + 23 => [[2620, 2059, 1468, 1108], [1588, 1248, 890, 672], [1091, 857, 611, 461], [672, 528, 376, 284]], |
|
146 | + 24 => [[2812, 2188, 1588, 1228], [1704, 1326, 963, 744], [1171, 911, 661, 511], [721, 561, 407, 315]], |
|
147 | + 25 => [[3057, 2395, 1718, 1286], [1853, 1451, 1041, 779], [1273, 997, 715, 535], [784, 614, 440, 330]], |
|
148 | + 26 => [[3283, 2544, 1804, 1425], [1990, 1542, 1094, 864], [1367, 1059, 751, 593], [842, 652, 462, 365]], |
|
149 | + 27 => [[3517, 2701, 1933, 1501], [2132, 1637, 1172, 910], [1465, 1125, 805, 625], [902, 692, 496, 385]], |
|
150 | + 28 => [[3669, 2857, 2085, 1581], [2223, 1732, 1263, 958], [1528, 1190, 868, 658], [940, 732, 534, 405]], |
|
151 | + 29 => [[3909, 3035, 2181, 1677], [2369, 1839, 1322, 1016], [1628, 1264, 908, 698], [1002, 778, 559, 430]], |
|
152 | + 30 => [[4158, 3289, 2358, 1782], [2520, 1994, 1429, 1080], [1732, 1370, 982, 742], [1066, 843, 604, 457]], |
|
153 | + 31 => [[4417, 3486, 2473, 1897], [2677, 2113, 1499, 1150], [1840, 1452, 1030, 790], [1132, 894, 634, 486]], |
|
154 | + 32 => [[4686, 3693, 2670, 2022], [2840, 2238, 1618, 1226], [1952, 1538, 1112, 842], [1201, 947, 684, 518]], |
|
155 | + 33 => [[4965, 3909, 2805, 2157], [3009, 2369, 1700, 1307], [2068, 1628, 1168, 898], [1273, 1002, 719, 553]], |
|
156 | + 34 => [[5253, 4134, 2949, 2301], [3183, 2506, 1787, 1394], [2188, 1722, 1228, 958], [1347, 1060, 756, 590]], |
|
157 | + 35 => [[5529, 4343, 3081, 2361], [3351, 2632, 1867, 1431], [2303, 1809, 1283, 983], [1417, 1113, 790, 605]], |
|
158 | + 36 => [[5836, 4588, 3244, 2524], [3537, 2780, 1966, 1530], [2431, 1911, 1351, 1051], [1496, 1176, 832, 647]], |
|
159 | + 37 => [[6153, 4775, 3417, 2625], [3729, 2894, 2071, 1591], [2563, 1989, 1423, 1093], [1577, 1224, 876, 673]], |
|
160 | + 38 => [[6479, 5039, 3599, 2735], [3927, 3054, 2181, 1658], [2699, 2099, 1499, 1139], [1661, 1292, 923, 701]], |
|
161 | + 39 => [[6743, 5313, 3791, 2927], [4087, 3220, 2298, 1774], [2809, 2213, 1579, 1219], [1729, 1362, 972, 750]], |
|
162 | + 40 => [[7089, 5596, 3993, 3057], [4296, 3391, 2420, 1852], [2953, 2331, 1663, 1273], [1817, 1435, 1024, 784]], |
|
163 | 163 | ]; |
164 | 164 | |
165 | 165 | /** |
@@ -168,46 +168,46 @@ discard block |
||
168 | 168 | * @see http://www.thonky.com/qr-code-tutorial/error-correction-table |
169 | 169 | */ |
170 | 170 | private const RSBLOCKS = [ |
171 | - 1 => [[ 7, [[ 1, 19], [ 0, 0]]], [10, [[ 1, 16], [ 0, 0]]], [13, [[ 1, 13], [ 0, 0]]], [17, [[ 1, 9], [ 0, 0]]]], |
|
172 | - 2 => [[10, [[ 1, 34], [ 0, 0]]], [16, [[ 1, 28], [ 0, 0]]], [22, [[ 1, 22], [ 0, 0]]], [28, [[ 1, 16], [ 0, 0]]]], |
|
173 | - 3 => [[15, [[ 1, 55], [ 0, 0]]], [26, [[ 1, 44], [ 0, 0]]], [18, [[ 2, 17], [ 0, 0]]], [22, [[ 2, 13], [ 0, 0]]]], |
|
174 | - 4 => [[20, [[ 1, 80], [ 0, 0]]], [18, [[ 2, 32], [ 0, 0]]], [26, [[ 2, 24], [ 0, 0]]], [16, [[ 4, 9], [ 0, 0]]]], |
|
175 | - 5 => [[26, [[ 1, 108], [ 0, 0]]], [24, [[ 2, 43], [ 0, 0]]], [18, [[ 2, 15], [ 2, 16]]], [22, [[ 2, 11], [ 2, 12]]]], |
|
176 | - 6 => [[18, [[ 2, 68], [ 0, 0]]], [16, [[ 4, 27], [ 0, 0]]], [24, [[ 4, 19], [ 0, 0]]], [28, [[ 4, 15], [ 0, 0]]]], |
|
177 | - 7 => [[20, [[ 2, 78], [ 0, 0]]], [18, [[ 4, 31], [ 0, 0]]], [18, [[ 2, 14], [ 4, 15]]], [26, [[ 4, 13], [ 1, 14]]]], |
|
178 | - 8 => [[24, [[ 2, 97], [ 0, 0]]], [22, [[ 2, 38], [ 2, 39]]], [22, [[ 4, 18], [ 2, 19]]], [26, [[ 4, 14], [ 2, 15]]]], |
|
179 | - 9 => [[30, [[ 2, 116], [ 0, 0]]], [22, [[ 3, 36], [ 2, 37]]], [20, [[ 4, 16], [ 4, 17]]], [24, [[ 4, 12], [ 4, 13]]]], |
|
180 | - 10 => [[18, [[ 2, 68], [ 2, 69]]], [26, [[ 4, 43], [ 1, 44]]], [24, [[ 6, 19], [ 2, 20]]], [28, [[ 6, 15], [ 2, 16]]]], |
|
181 | - 11 => [[20, [[ 4, 81], [ 0, 0]]], [30, [[ 1, 50], [ 4, 51]]], [28, [[ 4, 22], [ 4, 23]]], [24, [[ 3, 12], [ 8, 13]]]], |
|
182 | - 12 => [[24, [[ 2, 92], [ 2, 93]]], [22, [[ 6, 36], [ 2, 37]]], [26, [[ 4, 20], [ 6, 21]]], [28, [[ 7, 14], [ 4, 15]]]], |
|
183 | - 13 => [[26, [[ 4, 107], [ 0, 0]]], [22, [[ 8, 37], [ 1, 38]]], [24, [[ 8, 20], [ 4, 21]]], [22, [[12, 11], [ 4, 12]]]], |
|
184 | - 14 => [[30, [[ 3, 115], [ 1, 116]]], [24, [[ 4, 40], [ 5, 41]]], [20, [[11, 16], [ 5, 17]]], [24, [[11, 12], [ 5, 13]]]], |
|
185 | - 15 => [[22, [[ 5, 87], [ 1, 88]]], [24, [[ 5, 41], [ 5, 42]]], [30, [[ 5, 24], [ 7, 25]]], [24, [[11, 12], [ 7, 13]]]], |
|
186 | - 16 => [[24, [[ 5, 98], [ 1, 99]]], [28, [[ 7, 45], [ 3, 46]]], [24, [[15, 19], [ 2, 20]]], [30, [[ 3, 15], [13, 16]]]], |
|
187 | - 17 => [[28, [[ 1, 107], [ 5, 108]]], [28, [[10, 46], [ 1, 47]]], [28, [[ 1, 22], [15, 23]]], [28, [[ 2, 14], [17, 15]]]], |
|
188 | - 18 => [[30, [[ 5, 120], [ 1, 121]]], [26, [[ 9, 43], [ 4, 44]]], [28, [[17, 22], [ 1, 23]]], [28, [[ 2, 14], [19, 15]]]], |
|
189 | - 19 => [[28, [[ 3, 113], [ 4, 114]]], [26, [[ 3, 44], [11, 45]]], [26, [[17, 21], [ 4, 22]]], [26, [[ 9, 13], [16, 14]]]], |
|
190 | - 20 => [[28, [[ 3, 107], [ 5, 108]]], [26, [[ 3, 41], [13, 42]]], [30, [[15, 24], [ 5, 25]]], [28, [[15, 15], [10, 16]]]], |
|
191 | - 21 => [[28, [[ 4, 116], [ 4, 117]]], [26, [[17, 42], [ 0, 0]]], [28, [[17, 22], [ 6, 23]]], [30, [[19, 16], [ 6, 17]]]], |
|
192 | - 22 => [[28, [[ 2, 111], [ 7, 112]]], [28, [[17, 46], [ 0, 0]]], [30, [[ 7, 24], [16, 25]]], [24, [[34, 13], [ 0, 0]]]], |
|
193 | - 23 => [[30, [[ 4, 121], [ 5, 122]]], [28, [[ 4, 47], [14, 48]]], [30, [[11, 24], [14, 25]]], [30, [[16, 15], [14, 16]]]], |
|
194 | - 24 => [[30, [[ 6, 117], [ 4, 118]]], [28, [[ 6, 45], [14, 46]]], [30, [[11, 24], [16, 25]]], [30, [[30, 16], [ 2, 17]]]], |
|
195 | - 25 => [[26, [[ 8, 106], [ 4, 107]]], [28, [[ 8, 47], [13, 48]]], [30, [[ 7, 24], [22, 25]]], [30, [[22, 15], [13, 16]]]], |
|
196 | - 26 => [[28, [[10, 114], [ 2, 115]]], [28, [[19, 46], [ 4, 47]]], [28, [[28, 22], [ 6, 23]]], [30, [[33, 16], [ 4, 17]]]], |
|
197 | - 27 => [[30, [[ 8, 122], [ 4, 123]]], [28, [[22, 45], [ 3, 46]]], [30, [[ 8, 23], [26, 24]]], [30, [[12, 15], [28, 16]]]], |
|
198 | - 28 => [[30, [[ 3, 117], [10, 118]]], [28, [[ 3, 45], [23, 46]]], [30, [[ 4, 24], [31, 25]]], [30, [[11, 15], [31, 16]]]], |
|
199 | - 29 => [[30, [[ 7, 116], [ 7, 117]]], [28, [[21, 45], [ 7, 46]]], [30, [[ 1, 23], [37, 24]]], [30, [[19, 15], [26, 16]]]], |
|
200 | - 30 => [[30, [[ 5, 115], [10, 116]]], [28, [[19, 47], [10, 48]]], [30, [[15, 24], [25, 25]]], [30, [[23, 15], [25, 16]]]], |
|
201 | - 31 => [[30, [[13, 115], [ 3, 116]]], [28, [[ 2, 46], [29, 47]]], [30, [[42, 24], [ 1, 25]]], [30, [[23, 15], [28, 16]]]], |
|
202 | - 32 => [[30, [[17, 115], [ 0, 0]]], [28, [[10, 46], [23, 47]]], [30, [[10, 24], [35, 25]]], [30, [[19, 15], [35, 16]]]], |
|
203 | - 33 => [[30, [[17, 115], [ 1, 116]]], [28, [[14, 46], [21, 47]]], [30, [[29, 24], [19, 25]]], [30, [[11, 15], [46, 16]]]], |
|
204 | - 34 => [[30, [[13, 115], [ 6, 116]]], [28, [[14, 46], [23, 47]]], [30, [[44, 24], [ 7, 25]]], [30, [[59, 16], [ 1, 17]]]], |
|
205 | - 35 => [[30, [[12, 121], [ 7, 122]]], [28, [[12, 47], [26, 48]]], [30, [[39, 24], [14, 25]]], [30, [[22, 15], [41, 16]]]], |
|
206 | - 36 => [[30, [[ 6, 121], [14, 122]]], [28, [[ 6, 47], [34, 48]]], [30, [[46, 24], [10, 25]]], [30, [[ 2, 15], [64, 16]]]], |
|
207 | - 37 => [[30, [[17, 122], [ 4, 123]]], [28, [[29, 46], [14, 47]]], [30, [[49, 24], [10, 25]]], [30, [[24, 15], [46, 16]]]], |
|
208 | - 38 => [[30, [[ 4, 122], [18, 123]]], [28, [[13, 46], [32, 47]]], [30, [[48, 24], [14, 25]]], [30, [[42, 15], [32, 16]]]], |
|
209 | - 39 => [[30, [[20, 117], [ 4, 118]]], [28, [[40, 47], [ 7, 48]]], [30, [[43, 24], [22, 25]]], [30, [[10, 15], [67, 16]]]], |
|
210 | - 40 => [[30, [[19, 118], [ 6, 119]]], [28, [[18, 47], [31, 48]]], [30, [[34, 24], [34, 25]]], [30, [[20, 15], [61, 16]]]], |
|
171 | + 1 => [[7, [[1, 19], [0, 0]]], [10, [[1, 16], [0, 0]]], [13, [[1, 13], [0, 0]]], [17, [[1, 9], [0, 0]]]], |
|
172 | + 2 => [[10, [[1, 34], [0, 0]]], [16, [[1, 28], [0, 0]]], [22, [[1, 22], [0, 0]]], [28, [[1, 16], [0, 0]]]], |
|
173 | + 3 => [[15, [[1, 55], [0, 0]]], [26, [[1, 44], [0, 0]]], [18, [[2, 17], [0, 0]]], [22, [[2, 13], [0, 0]]]], |
|
174 | + 4 => [[20, [[1, 80], [0, 0]]], [18, [[2, 32], [0, 0]]], [26, [[2, 24], [0, 0]]], [16, [[4, 9], [0, 0]]]], |
|
175 | + 5 => [[26, [[1, 108], [0, 0]]], [24, [[2, 43], [0, 0]]], [18, [[2, 15], [2, 16]]], [22, [[2, 11], [2, 12]]]], |
|
176 | + 6 => [[18, [[2, 68], [0, 0]]], [16, [[4, 27], [0, 0]]], [24, [[4, 19], [0, 0]]], [28, [[4, 15], [0, 0]]]], |
|
177 | + 7 => [[20, [[2, 78], [0, 0]]], [18, [[4, 31], [0, 0]]], [18, [[2, 14], [4, 15]]], [26, [[4, 13], [1, 14]]]], |
|
178 | + 8 => [[24, [[2, 97], [0, 0]]], [22, [[2, 38], [2, 39]]], [22, [[4, 18], [2, 19]]], [26, [[4, 14], [2, 15]]]], |
|
179 | + 9 => [[30, [[2, 116], [0, 0]]], [22, [[3, 36], [2, 37]]], [20, [[4, 16], [4, 17]]], [24, [[4, 12], [4, 13]]]], |
|
180 | + 10 => [[18, [[2, 68], [2, 69]]], [26, [[4, 43], [1, 44]]], [24, [[6, 19], [2, 20]]], [28, [[6, 15], [2, 16]]]], |
|
181 | + 11 => [[20, [[4, 81], [0, 0]]], [30, [[1, 50], [4, 51]]], [28, [[4, 22], [4, 23]]], [24, [[3, 12], [8, 13]]]], |
|
182 | + 12 => [[24, [[2, 92], [2, 93]]], [22, [[6, 36], [2, 37]]], [26, [[4, 20], [6, 21]]], [28, [[7, 14], [4, 15]]]], |
|
183 | + 13 => [[26, [[4, 107], [0, 0]]], [22, [[8, 37], [1, 38]]], [24, [[8, 20], [4, 21]]], [22, [[12, 11], [4, 12]]]], |
|
184 | + 14 => [[30, [[3, 115], [1, 116]]], [24, [[4, 40], [5, 41]]], [20, [[11, 16], [5, 17]]], [24, [[11, 12], [5, 13]]]], |
|
185 | + 15 => [[22, [[5, 87], [1, 88]]], [24, [[5, 41], [5, 42]]], [30, [[5, 24], [7, 25]]], [24, [[11, 12], [7, 13]]]], |
|
186 | + 16 => [[24, [[5, 98], [1, 99]]], [28, [[7, 45], [3, 46]]], [24, [[15, 19], [2, 20]]], [30, [[3, 15], [13, 16]]]], |
|
187 | + 17 => [[28, [[1, 107], [5, 108]]], [28, [[10, 46], [1, 47]]], [28, [[1, 22], [15, 23]]], [28, [[2, 14], [17, 15]]]], |
|
188 | + 18 => [[30, [[5, 120], [1, 121]]], [26, [[9, 43], [4, 44]]], [28, [[17, 22], [1, 23]]], [28, [[2, 14], [19, 15]]]], |
|
189 | + 19 => [[28, [[3, 113], [4, 114]]], [26, [[3, 44], [11, 45]]], [26, [[17, 21], [4, 22]]], [26, [[9, 13], [16, 14]]]], |
|
190 | + 20 => [[28, [[3, 107], [5, 108]]], [26, [[3, 41], [13, 42]]], [30, [[15, 24], [5, 25]]], [28, [[15, 15], [10, 16]]]], |
|
191 | + 21 => [[28, [[4, 116], [4, 117]]], [26, [[17, 42], [0, 0]]], [28, [[17, 22], [6, 23]]], [30, [[19, 16], [6, 17]]]], |
|
192 | + 22 => [[28, [[2, 111], [7, 112]]], [28, [[17, 46], [0, 0]]], [30, [[7, 24], [16, 25]]], [24, [[34, 13], [0, 0]]]], |
|
193 | + 23 => [[30, [[4, 121], [5, 122]]], [28, [[4, 47], [14, 48]]], [30, [[11, 24], [14, 25]]], [30, [[16, 15], [14, 16]]]], |
|
194 | + 24 => [[30, [[6, 117], [4, 118]]], [28, [[6, 45], [14, 46]]], [30, [[11, 24], [16, 25]]], [30, [[30, 16], [2, 17]]]], |
|
195 | + 25 => [[26, [[8, 106], [4, 107]]], [28, [[8, 47], [13, 48]]], [30, [[7, 24], [22, 25]]], [30, [[22, 15], [13, 16]]]], |
|
196 | + 26 => [[28, [[10, 114], [2, 115]]], [28, [[19, 46], [4, 47]]], [28, [[28, 22], [6, 23]]], [30, [[33, 16], [4, 17]]]], |
|
197 | + 27 => [[30, [[8, 122], [4, 123]]], [28, [[22, 45], [3, 46]]], [30, [[8, 23], [26, 24]]], [30, [[12, 15], [28, 16]]]], |
|
198 | + 28 => [[30, [[3, 117], [10, 118]]], [28, [[3, 45], [23, 46]]], [30, [[4, 24], [31, 25]]], [30, [[11, 15], [31, 16]]]], |
|
199 | + 29 => [[30, [[7, 116], [7, 117]]], [28, [[21, 45], [7, 46]]], [30, [[1, 23], [37, 24]]], [30, [[19, 15], [26, 16]]]], |
|
200 | + 30 => [[30, [[5, 115], [10, 116]]], [28, [[19, 47], [10, 48]]], [30, [[15, 24], [25, 25]]], [30, [[23, 15], [25, 16]]]], |
|
201 | + 31 => [[30, [[13, 115], [3, 116]]], [28, [[2, 46], [29, 47]]], [30, [[42, 24], [1, 25]]], [30, [[23, 15], [28, 16]]]], |
|
202 | + 32 => [[30, [[17, 115], [0, 0]]], [28, [[10, 46], [23, 47]]], [30, [[10, 24], [35, 25]]], [30, [[19, 15], [35, 16]]]], |
|
203 | + 33 => [[30, [[17, 115], [1, 116]]], [28, [[14, 46], [21, 47]]], [30, [[29, 24], [19, 25]]], [30, [[11, 15], [46, 16]]]], |
|
204 | + 34 => [[30, [[13, 115], [6, 116]]], [28, [[14, 46], [23, 47]]], [30, [[44, 24], [7, 25]]], [30, [[59, 16], [1, 17]]]], |
|
205 | + 35 => [[30, [[12, 121], [7, 122]]], [28, [[12, 47], [26, 48]]], [30, [[39, 24], [14, 25]]], [30, [[22, 15], [41, 16]]]], |
|
206 | + 36 => [[30, [[6, 121], [14, 122]]], [28, [[6, 47], [34, 48]]], [30, [[46, 24], [10, 25]]], [30, [[2, 15], [64, 16]]]], |
|
207 | + 37 => [[30, [[17, 122], [4, 123]]], [28, [[29, 46], [14, 47]]], [30, [[49, 24], [10, 25]]], [30, [[24, 15], [46, 16]]]], |
|
208 | + 38 => [[30, [[4, 122], [18, 123]]], [28, [[13, 46], [32, 47]]], [30, [[48, 24], [14, 25]]], [30, [[42, 15], [32, 16]]]], |
|
209 | + 39 => [[30, [[20, 117], [4, 118]]], [28, [[40, 47], [7, 48]]], [30, [[43, 24], [22, 25]]], [30, [[10, 15], [67, 16]]]], |
|
210 | + 40 => [[30, [[19, 118], [6, 119]]], [28, [[18, 47], [31, 48]]], [30, [[34, 24], [34, 25]]], [30, [[20, 15], [61, 16]]]], |
|
211 | 211 | ]; |
212 | 212 | |
213 | 213 | private const TOTAL_CODEWORDS = [ |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | /** |
290 | 290 | * the version pattern for the given version |
291 | 291 | */ |
292 | - public function getVersionPattern():?int{ |
|
292 | + public function getVersionPattern(): ?int{ |
|
293 | 293 | return self::VERSION_PATTERN[$this->version] ?? null; |
294 | 294 | } |
295 | 295 | |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | /** |
306 | 306 | * the maximum character count for the given $mode and $eccLevel |
307 | 307 | */ |
308 | - public function getMaxLengthForMode(int $mode, EccLevel $eccLevel):?int{ |
|
308 | + public function getMaxLengthForMode(int $mode, EccLevel $eccLevel): ?int{ |
|
309 | 309 | return self::MAX_LENGTH[$this->version][Mode::DATA_MODES[$mode]][$eccLevel->getOrdinal()] ?? null; |
310 | 310 | } |
311 | 311 |
@@ -66,8 +66,8 @@ |
||
66 | 66 | private int $dataMask; |
67 | 67 | |
68 | 68 | public function __construct(int $formatInfo){ |
69 | - $this->errorCorrectionLevel = ($formatInfo >> 3) & 0x03; // Bits 3,4 |
|
70 | - $this->dataMask = ($formatInfo & 0x07); // Bottom 3 bits |
|
69 | + $this->errorCorrectionLevel = ($formatInfo >> 3)&0x03; // Bits 3,4 |
|
70 | + $this->dataMask = ($formatInfo&0x07); // Bottom 3 bits |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | public function getErrorCorrectionLevel():EccLevel{ |
@@ -152,7 +152,8 @@ |
||
152 | 152 | } |
153 | 153 | } |
154 | 154 | } |
155 | - catch(Exception $aioobe){//ArrayIndexOutOfBoundsException |
|
155 | + catch(Exception $aioobe){ |
|
156 | +//ArrayIndexOutOfBoundsException |
|
156 | 157 | // This feels wrong, but, sometimes if the finder patterns are misidentified, the resulting |
157 | 158 | // transform gets "twisted" such that it maps a straight line of points to a set of points |
158 | 159 | // whose endpoints are in bounds, but others are not. There is probably some mathematical |
@@ -580,7 +580,7 @@ |
||
580 | 580 | $this->hasSkipped = true; |
581 | 581 | |
582 | 582 | return (int)((abs($firstConfirmedCenter->getX() - $center->getX()) - |
583 | - abs($firstConfirmedCenter->getY() - $center->getY())) / 2); |
|
583 | + abs($firstConfirmedCenter->getY() - $center->getY())) / 2); |
|
584 | 584 | } |
585 | 585 | } |
586 | 586 | } |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | // Black pixel |
79 | 79 | if($this->bitMatrix->get($j, $i)){ |
80 | 80 | // Counting white pixels |
81 | - if(($currentState & 1) === 1){ |
|
81 | + if(($currentState&1) === 1){ |
|
82 | 82 | $currentState++; |
83 | 83 | } |
84 | 84 | |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | // White pixel |
88 | 88 | else{ |
89 | 89 | // Counting black pixels |
90 | - if(($currentState & 1) === 0){ |
|
90 | + if(($currentState&1) === 0){ |
|
91 | 91 | // A winner? |
92 | 92 | if($currentState === 4){ |
93 | 93 | // Yes |
@@ -339,7 +339,7 @@ discard block |
||
339 | 339 | * |
340 | 340 | * @return float|null vertical center of finder pattern, or null if not found |
341 | 341 | */ |
342 | - private function crossCheckVertical(int $startI, int $centerJ, int $maxCount, int $originalStateCountTotal):?float{ |
|
342 | + private function crossCheckVertical(int $startI, int $centerJ, int $maxCount, int $originalStateCountTotal): ?float{ |
|
343 | 343 | $maxI = $this->bitMatrix->getDimension(); |
344 | 344 | $stateCount = $this->getCrossCheckStateCount(); |
345 | 345 | |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | * except it reads horizontally instead of vertically. This is used to cross-cross |
423 | 423 | * check a vertical cross check and locate the real center of the alignment pattern.</p> |
424 | 424 | */ |
425 | - private function crossCheckHorizontal(int $startJ, int $centerI, int $maxCount, int $originalStateCountTotal):?float{ |
|
425 | + private function crossCheckHorizontal(int $startJ, int $centerI, int $maxCount, int $originalStateCountTotal): ?float{ |
|
426 | 426 | $maxJ = $this->bitMatrix->getDimension(); |
427 | 427 | $stateCount = $this->getCrossCheckStateCount(); |
428 | 428 |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | * |
62 | 62 | * @return \chillerlan\QRCode\Detector\AlignmentPattern|null |
63 | 63 | */ |
64 | - public function find(int $startX, int $startY, int $width, int $height):?AlignmentPattern{ |
|
64 | + public function find(int $startX, int $startY, int $width, int $height): ?AlignmentPattern{ |
|
65 | 65 | $maxJ = $startX + $width; |
66 | 66 | $middleI = $startY + ($height / 2); |
67 | 67 | $stateCount = []; |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | // this tracks the number of black/white/black modules seen so far |
71 | 71 | for($iGen = 0; $iGen < $height; $iGen++){ |
72 | 72 | // Search from middle outwards |
73 | - $i = (int)($middleI + (($iGen & 0x01) === 0 ? ($iGen + 1) / 2 : -(($iGen + 1) / 2))); |
|
73 | + $i = (int)($middleI + (($iGen&0x01) === 0 ? ($iGen + 1) / 2 : -(($iGen + 1) / 2))); |
|
74 | 74 | $stateCount[0] = 0; |
75 | 75 | $stateCount[1] = 0; |
76 | 76 | $stateCount[2] = 0; |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | * |
178 | 178 | * @return \chillerlan\QRCode\Detector\AlignmentPattern|null if we have found the same pattern twice, or null if not |
179 | 179 | */ |
180 | - private function handlePossibleCenter(array $stateCount, int $i, int $j):?AlignmentPattern{ |
|
180 | + private function handlePossibleCenter(array $stateCount, int $i, int $j): ?AlignmentPattern{ |
|
181 | 181 | $stateCountTotal = $stateCount[0] + $stateCount[1] + $stateCount[2]; |
182 | 182 | $centerJ = $this->centerFromEnd($stateCount, $j); |
183 | 183 | $centerI = $this->crossCheckVertical($i, (int)$centerJ, 2 * $stateCount[1], $stateCountTotal); |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | * |
227 | 227 | * @return float|null vertical center of alignment pattern, or null if not found |
228 | 228 | */ |
229 | - private function crossCheckVertical(int $startI, int $centerJ, int $maxCount, int $originalStateCountTotal):?float{ |
|
229 | + private function crossCheckVertical(int $startI, int $centerJ, int $maxCount, int $originalStateCountTotal): ?float{ |
|
230 | 230 | $maxI = $this->bitMatrix->getDimension(); |
231 | 231 | $stateCount = $this->crossCheckStateCount; |
232 | 232 | $stateCount[0] = 0; |
@@ -88,7 +88,8 @@ |
||
88 | 88 | |
89 | 89 | if($this->bitMatrix->get($j, $i)){ |
90 | 90 | // Black pixel |
91 | - if($currentState === 1){ // Counting black pixels |
|
91 | + if($currentState === 1){ |
|
92 | +// Counting black pixels |
|
92 | 93 | $stateCount[$currentState]++; |
93 | 94 | } |
94 | 95 | // Counting white pixels |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | } |
162 | 162 | |
163 | 163 | $otherToX = (int)($fromX + ($otherToX - $fromX) * $scale); |
164 | - $result += $this->sizeOfBlackWhiteBlackRun((int)$fromX, (int)$fromY, (int)$otherToX, (int)$otherToY); |
|
164 | + $result += $this->sizeOfBlackWhiteBlackRun((int)$fromX, (int)$fromY, (int)$otherToX, (int)$otherToY); |
|
165 | 165 | |
166 | 166 | // Middle pixel is double-counted this way; subtract 1 |
167 | 167 | return $result - 1.0; |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | int $estAlignmentX, |
292 | 292 | int $estAlignmentY, |
293 | 293 | float $allowanceFactor |
294 | - ):?AlignmentPattern{ |
|
294 | + ): ?AlignmentPattern{ |
|
295 | 295 | // Look for an alignment pattern (3 modules in size) around where it should be |
296 | 296 | $dimension = $this->bitMatrix->getDimension(); |
297 | 297 | $allowance = (int)($allowanceFactor * $overallEstModuleSize); |
@@ -59,7 +59,8 @@ |
||
59 | 59 | $estAlignmentY = (int)($topLeft->getY() + $correctionToTopLeft * ($bottomRightY - $topLeft->getY())); |
60 | 60 | |
61 | 61 | // Kind of arbitrary -- expand search radius before giving up |
62 | - for($i = 4; $i <= 16; $i <<= 1){//?????????? |
|
62 | + for($i = 4; $i <= 16; $i <<= 1){ |
|
63 | +//?????????? |
|
63 | 64 | $alignmentPattern = $this->findAlignmentInRegion($moduleSize, $estAlignmentX, $estAlignmentY, (float)$i); |
64 | 65 | |
65 | 66 | if($alignmentPattern !== null){ |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | $offset = (int)($y * $this->rowSize + ($x / 0x20)); |
39 | 39 | |
40 | 40 | $this->bits[$offset] ??= 0; |
41 | - $this->bits[$offset] |= ($this->bits[$offset] |= 1 << ($x & 0x1f)); |
|
41 | + $this->bits[$offset] |= ($this->bits[$offset] |= 1 << ($x&0x1f)); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | public function flip(int $x, int $y):void{ |
51 | 51 | $offset = $y * $this->rowSize + (int)($x / 0x20); |
52 | 52 | |
53 | - $this->bits[$offset] = ($this->bits[$offset] ^ (1 << ($x & 0x1f))); |
|
53 | + $this->bits[$offset] = ($this->bits[$offset]^(1 << ($x&0x1f))); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | |
86 | 86 | for($x = $left; $x < $right; $x++){ |
87 | 87 | $xOffset = $yOffset + (int)($x / 0x20); |
88 | - $this->bits[$xOffset] = ($this->bits[$xOffset] |= 1 << ($x & 0x1f)); |
|
88 | + $this->bits[$xOffset] = ($this->bits[$xOffset] |= 1 << ($x&0x1f)); |
|
89 | 89 | } |
90 | 90 | } |
91 | 91 | } |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | |
111 | 111 | $this->bits[$offset] ??= 0; |
112 | 112 | |
113 | - return (uRShift($this->bits[$offset], ($x & 0x1f)) & 1) !== 0; |
|
113 | + return (uRShift($this->bits[$offset], ($x&0x1f))&1) !== 0; |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | /** |