← All changes
|
vendor/tecnickcom/tcpdf/include/barcodes/qrcode.php
+196
-220
2.3.2
→
4.17.0
View file →
| @@ -4,11 +4,11 @@ | ||
| 4 | 4 | // Version : 1.0.010 |
| 5 | 5 | // Begin : 2010-03-22 |
| 6 | 6 | // Last Update : 2012-07-25 |
| 7 | 7 | // Author : Nicola Asuni - Tecnick.com LTD - www.tecnick.com - [email protected] |
| 8 | -// License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html) | |
| 8 | +// License : GNU-LGPL v3 (https://www.gnu.org/copyleft/lesser.html) | |
| 9 | 9 | // ------------------------------------------------------------------- |
| 10 | -// Copyright (C) 2010-2012 Nicola Asuni - Tecnick.com LTD | |
| 10 | +// Copyright (C) 2010-2026 Nicola Asuni - Tecnick.com LTD | |
| 11 | 11 | // |
| 12 | 12 | // This file is part of TCPDF software library. |
| 13 | 13 | // |
| 14 | 14 | // TCPDF is free software: you can redistribute it and/or modify it |
| @@ -21,9 +21,9 @@ | ||
| 21 | 21 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 22 | 22 | // See the GNU Lesser General Public License for more details. |
| 23 | 23 | // |
| 24 | 24 | // You should have received a copy of the GNU Lesser General Public License |
| 25 | -// along with TCPDF. If not, see <http://www.gnu.org/licenses/>. | |
| 25 | +// along with TCPDF. If not, see <https://www.gnu.org/licenses/>. | |
| 26 | 26 | // |
| 27 | 27 | // See LICENSE.TXT file for more information. |
| 28 | 28 | // ------------------------------------------------------------------- |
| 29 | 29 | // |
| @@ -246,34 +246,8 @@ | ||
| 246 | 246 | // ----------------------------------------------------- |
| 247 | 247 | |
| 248 | 248 | } // end of definitions |
| 249 | 249 | |
| 250 | -// #*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*# | |
| 251 | - | |
| 252 | -// for compatibility with PHP4 | |
| 253 | -if (!function_exists('str_split')) { | |
| 254 | - /** | |
| 255 | - * Convert a string to an array (needed for PHP4 compatibility) | |
| 256 | - * @param $string (string) The input string. | |
| 257 | - * @param $split_length (int) Maximum length of the chunk. | |
| 258 | - * @return If the optional split_length parameter is specified, the returned array will be broken down into chunks with each being split_length in length, otherwise each chunk will be one character in length. FALSE is returned if split_length is less than 1. If the split_length length exceeds the length of string , the entire string is returned as the first (and only) array element. | |
| 259 | - */ | |
| 260 | - function str_split($string, $split_length=1) { | |
| 261 | - if ((strlen($string) > $split_length) OR (!$split_length)) { | |
| 262 | - do { | |
| 263 | - $c = strlen($string); | |
| 264 | - $parts[] = substr($string, 0, $split_length); | |
| 265 | - $string = substr($string, $split_length); | |
| 266 | - } while ($string !== false); | |
| 267 | - } else { | |
| 268 | - $parts = array($string); | |
| 269 | - } | |
| 270 | - return $parts; | |
| 271 | - } | |
| 272 | -} | |
| 273 | - | |
| 274 | -// ##################################################### | |
| 275 | - | |
| 276 | 250 | /** |
| 277 | 251 | * @class QRcode |
| 278 | 252 | * Class to create QR-code arrays for TCPDF class. |
| 279 | 253 | * QR Code symbol is a 2D barcode that can be scanned by handy terminals such as a mobile phone with CCD. |
| @@ -630,10 +604,10 @@ | ||
| 630 | 604 | |
| 631 | 605 | /** |
| 632 | 606 | * This is the class constructor. |
| 633 | 607 | * Creates a QRcode object |
| 634 | - * @param $code (string) code to represent using QRcode | |
| 635 | - * @param $eclevel (string) error level: <ul><li>L : About 7% or less errors can be corrected.</li><li>M : About 15% or less errors can be corrected.</li><li>Q : About 25% or less errors can be corrected.</li><li>H : About 30% or less errors can be corrected.</li></ul> | |
| 608 | + * @param string $code code to represent using QRcode | |
| 609 | + * @param string $eclevel error level: <ul><li>L : About 7% or less errors can be corrected.</li><li>M : About 15% or less errors can be corrected.</li><li>Q : About 25% or less errors can be corrected.</li><li>H : About 30% or less errors can be corrected.</li></ul> | |
| 636 | 610 | * @public |
| 637 | 611 | * @since 1.0.000 |
| 638 | 612 | */ |
| 639 | 613 | public function __construct($code, $eclevel = 'L') { |
| @@ -682,9 +656,9 @@ | ||
| 682 | 656 | } |
| 683 | 657 | |
| 684 | 658 | /** |
| 685 | 659 | * Convert the frame in binary form |
| 686 | - * @param $frame (array) array to binarize | |
| 660 | + * @param array $frame array to binarize | |
| 687 | 661 | * @return array frame in binary form |
| 688 | 662 | */ |
| 689 | 663 | protected function binarize($frame) { |
| 690 | 664 | $len = count($frame); |
| @@ -698,9 +672,9 @@ | ||
| 698 | 672 | } |
| 699 | 673 | |
| 700 | 674 | /** |
| 701 | 675 | * Encode the input string to QR code |
| 702 | - * @param $string (string) input string to encode | |
| 676 | + * @param string $string input string to encode | |
| 703 | 677 | */ |
| 704 | 678 | protected function encodeString($string) { |
| 705 | 679 | $this->dataStr = $string; |
| 706 | 680 | if (!$this->casesensitive) { |
| @@ -714,9 +688,9 @@ | ||
| 714 | 688 | } |
| 715 | 689 | |
| 716 | 690 | /** |
| 717 | 691 | * Encode mask |
| 718 | - * @param $mask (int) masking mode | |
| 692 | + * @param int $mask masking mode | |
| 719 | 693 | */ |
| 720 | 694 | protected function encodeMask($mask) { |
| 721 | 695 | $spec = array(0, 0, 0, 0, 0); |
| 722 | 696 | $this->datacode = $this->getByteStream($this->items); |
| @@ -779,10 +753,10 @@ | ||
| 779 | 753 | // FrameFiller |
| 780 | 754 | |
| 781 | 755 | /** |
| 782 | 756 | * Set frame value at specified position |
| 783 | - * @param $at (array) x,y position | |
| 784 | - * @param $val (int) value of the character to set | |
| 757 | + * @param array $at x,y position | |
| 758 | + * @param int $val value of the character to set | |
| 785 | 759 | */ |
| 786 | 760 | protected function setFrameAt($at, $val) { |
| 787 | 761 | $this->frame[$at['y']][$at['x']] = chr($val); |
| 788 | 762 | } |
| @@ -788,9 +762,9 @@ | ||
| 788 | 762 | } |
| 789 | 763 | |
| 790 | 764 | /** |
| 791 | 765 | * Get frame value at specified position |
| 792 | - * @param $at (array) x,y position | |
| 766 | + * @param array $at x,y position | |
| 793 | 767 | * @return value at specified position |
| 794 | 768 | */ |
| 795 | 769 | protected function getFrameAt($at) { |
| 796 | 770 | return ord($this->frame[$at['y']][$at['x']]); |
| @@ -852,10 +826,10 @@ | ||
| 852 | 826 | // QRrawcode |
| 853 | 827 | |
| 854 | 828 | /** |
| 855 | 829 | * Initialize code. |
| 856 | - * @param $spec (array) array of ECC specification | |
| 857 | - * @return 0 in case of success, -1 in case of error | |
| 830 | + * @param array $spec array of ECC specification | |
| 831 | + * @return int 0 in case of success, -1 in case of error | |
| 858 | 832 | */ |
| 859 | 833 | protected function init($spec) { |
| 860 | 834 | $dl = $this->rsDataCodes1($spec); |
| 861 | 835 | $el = $this->rsEccCodes1($spec); |
| @@ -909,16 +883,17 @@ | ||
| 909 | 883 | */ |
| 910 | 884 | protected function getCode() { |
| 911 | 885 | if ($this->count < $this->dataLength) { |
| 912 | 886 | $row = $this->count % $this->blocks; |
| 913 | - $col = $this->count / $this->blocks; | |
| 887 | + $col = (int)($this->count / $this->blocks); | |
| 914 | 888 | if ($col >= $this->rsblocks[0]['dataLength']) { |
| 915 | 889 | $row += $this->b1; |
| 916 | 890 | } |
| 891 | + $row = (int) $row; | |
| 917 | 892 | $ret = $this->rsblocks[$row]['data'][$col]; |
| 918 | 893 | } elseif ($this->count < $this->dataLength + $this->eccLength) { |
| 919 | 894 | $row = ($this->count - $this->dataLength) % $this->blocks; |
| 920 | - $col = ($this->count - $this->dataLength) / $this->blocks; | |
| 895 | + $col = (int)(($this->count - $this->dataLength) / $this->blocks); | |
| 921 | 896 | $ret = $this->rsblocks[$row]['ecc'][$col]; |
| 922 | 897 | } else { |
| 923 | 898 | return 0; |
| 924 | 899 | } |
| @@ -931,12 +906,12 @@ | ||
| 931 | 906 | // QRmask |
| 932 | 907 | |
| 933 | 908 | /** |
| 934 | 909 | * Write Format Information on frame and returns the number of black bits |
| 935 | - * @param $width (int) frame width | |
| 936 | - * @param $frame (array) frame | |
| 937 | - * @param $mask (array) masking mode | |
| 938 | - * @param $level (int) error correction level | |
| 910 | + * @param int $width frame width | |
| 911 | + * @param array $frame frame | |
| 912 | + * @param array $mask masking mode | |
| 913 | + * @param int $level error correction level | |
| 939 | 914 | * @return int blacks |
| 940 | 915 | */ |
| 941 | 916 | protected function writeFormatInformation($width, &$frame, $mask, $level) { |
| 942 | 917 | $blacks = 0; |
| @@ -975,10 +950,10 @@ | ||
| 975 | 950 | } |
| 976 | 951 | |
| 977 | 952 | /** |
| 978 | 953 | * mask0 |
| 979 | - * @param $x (int) X position | |
| 980 | - * @param $y (int) Y position | |
| 954 | + * @param int $x X position | |
| 955 | + * @param int $y Y position | |
| 981 | 956 | * @return int mask |
| 982 | 957 | */ |
| 983 | 958 | protected function mask0($x, $y) { |
| 984 | 959 | return ($x + $y) & 1; |
| @@ -985,10 +960,10 @@ | ||
| 985 | 960 | } |
| 986 | 961 | |
| 987 | 962 | /** |
| 988 | 963 | * mask1 |
| 989 | - * @param $x (int) X position | |
| 990 | - * @param $y (int) Y position | |
| 964 | + * @param int $x X position | |
| 965 | + * @param int $y Y position | |
| 991 | 966 | * @return int mask |
| 992 | 967 | */ |
| 993 | 968 | protected function mask1($x, $y) { |
| 994 | 969 | return ($y & 1); |
| @@ -995,10 +970,10 @@ | ||
| 995 | 970 | } |
| 996 | 971 | |
| 997 | 972 | /** |
| 998 | 973 | * mask2 |
| 999 | - * @param $x (int) X position | |
| 1000 | - * @param $y (int) Y position | |
| 974 | + * @param int $x X position | |
| 975 | + * @param int $y Y position | |
| 1001 | 976 | * @return int mask |
| 1002 | 977 | */ |
| 1003 | 978 | protected function mask2($x, $y) { |
| 1004 | 979 | return ($x % 3); |
| @@ -1005,10 +980,10 @@ | ||
| 1005 | 980 | } |
| 1006 | 981 | |
| 1007 | 982 | /** |
| 1008 | 983 | * mask3 |
| 1009 | - * @param $x (int) X position | |
| 1010 | - * @param $y (int) Y position | |
| 984 | + * @param int $x X position | |
| 985 | + * @param int $y Y position | |
| 1011 | 986 | * @return int mask |
| 1012 | 987 | */ |
| 1013 | 988 | protected function mask3($x, $y) { |
| 1014 | 989 | return ($x + $y) % 3; |
| @@ -1015,10 +990,10 @@ | ||
| 1015 | 990 | } |
| 1016 | 991 | |
| 1017 | 992 | /** |
| 1018 | 993 | * mask4 |
| 1019 | - * @param $x (int) X position | |
| 1020 | - * @param $y (int) Y position | |
| 994 | + * @param int $x X position | |
| 995 | + * @param int $y Y position | |
| 1021 | 996 | * @return int mask |
| 1022 | 997 | */ |
| 1023 | 998 | protected function mask4($x, $y) { |
| 1024 | 999 | return (((int)($y / 2)) + ((int)($x / 3))) & 1; |
| @@ -1025,10 +1000,10 @@ | ||
| 1025 | 1000 | } |
| 1026 | 1001 | |
| 1027 | 1002 | /** |
| 1028 | 1003 | * mask5 |
| 1029 | - * @param $x (int) X position | |
| 1030 | - * @param $y (int) Y position | |
| 1004 | + * @param int $x X position | |
| 1005 | + * @param int $y Y position | |
| 1031 | 1006 | * @return int mask |
| 1032 | 1007 | */ |
| 1033 | 1008 | protected function mask5($x, $y) { |
| 1034 | 1009 | return (($x * $y) & 1) + ($x * $y) % 3; |
| @@ -1035,10 +1010,10 @@ | ||
| 1035 | 1010 | } |
| 1036 | 1011 | |
| 1037 | 1012 | /** |
| 1038 | 1013 | * mask6 |
| 1039 | - * @param $x (int) X position | |
| 1040 | - * @param $y (int) Y position | |
| 1014 | + * @param int $x X position | |
| 1015 | + * @param int $y Y position | |
| 1041 | 1016 | * @return int mask |
| 1042 | 1017 | */ |
| 1043 | 1018 | protected function mask6($x, $y) { |
| 1044 | 1019 | return ((($x * $y) & 1) + ($x * $y) % 3) & 1; |
| @@ -1045,10 +1020,10 @@ | ||
| 1045 | 1020 | } |
| 1046 | 1021 | |
| 1047 | 1022 | /** |
| 1048 | 1023 | * mask7 |
| 1049 | - * @param $x (int) X position | |
| 1050 | - * @param $y (int) Y position | |
| 1024 | + * @param int $x X position | |
| 1025 | + * @param int $y Y position | |
| 1051 | 1026 | * @return int mask |
| 1052 | 1027 | */ |
| 1053 | 1028 | protected function mask7($x, $y) { |
| 1054 | 1029 | return ((($x * $y) % 3) + (($x + $y) & 1)) & 1; |
| @@ -1055,11 +1030,11 @@ | ||
| 1055 | 1030 | } |
| 1056 | 1031 | |
| 1057 | 1032 | /** |
| 1058 | 1033 | * Return bitmask |
| 1059 | - * @param $maskNo (int) mask number | |
| 1060 | - * @param $width (int) width | |
| 1061 | - * @param $frame (array) frame | |
| 1034 | + * @param int $maskNo mask number | |
| 1035 | + * @param int $width width | |
| 1036 | + * @param array $frame frame | |
| 1062 | 1037 | * @return array bitmask |
| 1063 | 1038 | */ |
| 1064 | 1039 | protected function generateMaskNo($maskNo, $width, $frame) { |
| 1065 | 1040 | $bitMask = array_fill(0, $width, array_fill(0, $width, 0)); |
| @@ -1077,19 +1052,19 @@ | ||
| 1077 | 1052 | } |
| 1078 | 1053 | |
| 1079 | 1054 | /** |
| 1080 | 1055 | * makeMaskNo |
| 1081 | - * @param $maskNo (int) | |
| 1082 | - * @param $width (int) | |
| 1083 | - * @param $s (int) | |
| 1084 | - * @param $d (int) | |
| 1085 | - * @param $maskGenOnly (boolean) | |
| 1056 | + * @param int $maskNo | |
| 1057 | + * @param int $width | |
| 1058 | + * @param int $s | |
| 1059 | + * @param int $d | |
| 1060 | + * @param boolean $maskGenOnly | |
| 1086 | 1061 | * @return int b |
| 1087 | 1062 | */ |
| 1088 | 1063 | protected function makeMaskNo($maskNo, $width, $s, &$d, $maskGenOnly=false) { |
| 1089 | 1064 | $b = 0; |
| 1090 | 1065 | $bitMask = array(); |
| 1091 | - $bitMask = $this->generateMaskNo($maskNo, $width, $s, $d); | |
| 1066 | + $bitMask = $this->generateMaskNo($maskNo, $width, $s); | |
| 1092 | 1067 | if ($maskGenOnly) { |
| 1093 | 1068 | return; |
| 1094 | 1069 | } |
| 1095 | 1070 | $d = $s; |
| @@ -1105,12 +1080,12 @@ | ||
| 1105 | 1080 | } |
| 1106 | 1081 | |
| 1107 | 1082 | /** |
| 1108 | 1083 | * makeMask |
| 1109 | - * @param $width (int) | |
| 1110 | - * @param $frame (array) | |
| 1111 | - * @param $maskNo (int) | |
| 1112 | - * @param $level (int) | |
| 1084 | + * @param int $width | |
| 1085 | + * @param array $frame | |
| 1086 | + * @param int $maskNo | |
| 1087 | + * @param int $level | |
| 1113 | 1088 | * @return array mask |
| 1114 | 1089 | */ |
| 1115 | 1090 | protected function makeMask($width, $frame, $maskNo, $level) { |
| 1116 | 1091 | $masked = array_fill(0, $width, str_repeat("\0", $width)); |
| @@ -1120,9 +1095,9 @@ | ||
| 1120 | 1095 | } |
| 1121 | 1096 | |
| 1122 | 1097 | /** |
| 1123 | 1098 | * calcN1N3 |
| 1124 | - * @param $length (int) | |
| 1099 | + * @param int $length | |
| 1125 | 1100 | * @return int demerit |
| 1126 | 1101 | */ |
| 1127 | 1102 | protected function calcN1N3($length) { |
| 1128 | 1103 | $demerit = 0; |
| @@ -1150,10 +1125,10 @@ | ||
| 1150 | 1125 | } |
| 1151 | 1126 | |
| 1152 | 1127 | /** |
| 1153 | 1128 | * evaluateSymbol |
| 1154 | - * @param $width (int) | |
| 1155 | - * @param $frame (array) | |
| 1129 | + * @param int $width | |
| 1130 | + * @param array $frame | |
| 1156 | 1131 | * @return int demerit |
| 1157 | 1132 | */ |
| 1158 | 1133 | protected function evaluateSymbol($width, $frame) { |
| 1159 | 1134 | $head = 0; |
| @@ -1211,11 +1186,11 @@ | ||
| 1211 | 1186 | } |
| 1212 | 1187 | |
| 1213 | 1188 | /** |
| 1214 | 1189 | * mask |
| 1215 | - * @param $width (int) | |
| 1216 | - * @param $frame (array) | |
| 1217 | - * @param $level (int) | |
| 1190 | + * @param int $width | |
| 1191 | + * @param array $frame | |
| 1192 | + * @param int $level | |
| 1218 | 1193 | * @return array best mask |
| 1219 | 1194 | */ |
| 1220 | 1195 | protected function mask($width, $frame, $level) { |
| 1221 | 1196 | $minDemerit = PHP_INT_MAX; |
| @@ -1254,10 +1229,10 @@ | ||
| 1254 | 1229 | // QRsplit |
| 1255 | 1230 | |
| 1256 | 1231 | /** |
| 1257 | 1232 | * Return true if the character at specified position is a number |
| 1258 | - * @param $str (string) string | |
| 1259 | - * @param $pos (int) characted position | |
| 1233 | + * @param string $str string | |
| 1234 | + * @param int $pos characted position | |
| 1260 | 1235 | * @return boolean true of false |
| 1261 | 1236 | */ |
| 1262 | 1237 | protected function isdigitat($str, $pos) { |
| 1263 | 1238 | if ($pos >= strlen($str)) { |
| @@ -1267,10 +1242,10 @@ | ||
| 1267 | 1242 | } |
| 1268 | 1243 | |
| 1269 | 1244 | /** |
| 1270 | 1245 | * Return true if the character at specified position is an alphanumeric character |
| 1271 | - * @param $str (string) string | |
| 1272 | - * @param $pos (int) characted position | |
| 1246 | + * @param string $str string | |
| 1247 | + * @param int $pos characted position | |
| 1273 | 1248 | * @return boolean true of false |
| 1274 | 1249 | */ |
| 1275 | 1250 | protected function isalnumat($str, $pos) { |
| 1276 | 1251 | if ($pos >= strlen($str)) { |
| @@ -1280,9 +1255,9 @@ | ||
| 1280 | 1255 | } |
| 1281 | 1256 | |
| 1282 | 1257 | /** |
| 1283 | 1258 | * identifyMode |
| 1284 | - * @param $pos (int) | |
| 1259 | + * @param int $pos | |
| 1285 | 1260 | * @return int mode |
| 1286 | 1261 | */ |
| 1287 | 1262 | protected function identifyMode($pos) { |
| 1288 | 1263 | if ($pos >= strlen($this->dataStr)) { |
| @@ -1385,8 +1360,9 @@ | ||
| 1385 | 1360 | while($this->identifyMode($p) == QR_MODE_KJ) { |
| 1386 | 1361 | $p += 2; |
| 1387 | 1362 | } |
| 1388 | 1363 | $this->items = $this->appendNewInputItem($this->items, QR_MODE_KJ, $p, str_split($this->dataStr)); |
| 1364 | + $run = $p; | |
| 1389 | 1365 | return $run; |
| 1390 | 1366 | } |
| 1391 | 1367 | |
| 1392 | 1368 | /** |
| @@ -1439,9 +1415,9 @@ | ||
| 1439 | 1415 | } |
| 1440 | 1416 | |
| 1441 | 1417 | /** |
| 1442 | 1418 | * splitString |
| 1443 | - * @return (int) | |
| 1419 | + * @return int | |
| 1444 | 1420 | */ |
| 1445 | 1421 | protected function splitString() { |
| 1446 | 1422 | while (strlen($this->dataStr) > 0) { |
| 1447 | 1423 | $mode = $this->identifyMode(0); |
| @@ -1454,9 +1430,9 @@ | ||
| 1454 | 1430 | $length = $this->eatAn(); |
| 1455 | 1431 | break; |
| 1456 | 1432 | } |
| 1457 | 1433 | case QR_MODE_KJ: { |
| 1458 | - if ($hint == QR_MODE_KJ) { | |
| 1434 | + if ($this->hint == QR_MODE_KJ) { | |
| 1459 | 1435 | $length = $this->eatKanji(); |
| 1460 | 1436 | } else { |
| 1461 | 1437 | $length = $this->eat8(); |
| 1462 | 1438 | } |
| @@ -1484,9 +1460,9 @@ | ||
| 1484 | 1460 | protected function toUpper() { |
| 1485 | 1461 | $stringLen = strlen($this->dataStr); |
| 1486 | 1462 | $p = 0; |
| 1487 | 1463 | while ($p < $stringLen) { |
| 1488 | - $mode = $this->identifyMode(substr($this->dataStr, $p), $this->hint); | |
| 1464 | + $mode = $this->identifyMode(substr($this->dataStr, $p)); | |
| 1489 | 1465 | if ($mode == QR_MODE_KJ) { |
| 1490 | 1466 | $p += 2; |
| 1491 | 1467 | } else { |
| 1492 | 1468 | if ((ord($this->dataStr[$p]) >= ord('a')) AND (ord($this->dataStr[$p]) <= ord('z'))) { |
| @@ -1503,12 +1479,12 @@ | ||
| 1503 | 1479 | // QRinputItem |
| 1504 | 1480 | |
| 1505 | 1481 | /** |
| 1506 | 1482 | * newInputItem |
| 1507 | - * @param $mode (int) | |
| 1508 | - * @param $size (int) | |
| 1509 | - * @param $data (array) | |
| 1510 | - * @param $bstream (array) | |
| 1483 | + * @param int $mode | |
| 1484 | + * @param int $size | |
| 1485 | + * @param array $data | |
| 1486 | + * @param array $bstream | |
| 1511 | 1487 | * @return array input item |
| 1512 | 1488 | */ |
| 1513 | 1489 | protected function newInputItem($mode, $size, $data, $bstream=null) { |
| 1514 | 1490 | $setData = array_slice($data, 0, $size); |
| @@ -1527,10 +1503,10 @@ | ||
| 1527 | 1503 | } |
| 1528 | 1504 | |
| 1529 | 1505 | /** |
| 1530 | 1506 | * encodeModeNum |
| 1531 | - * @param $inputitem (array) | |
| 1532 | - * @param $version (int) | |
| 1507 | + * @param array $inputitem | |
| 1508 | + * @param int $version | |
| 1533 | 1509 | * @return array input item |
| 1534 | 1510 | */ |
| 1535 | 1511 | protected function encodeModeNum($inputitem, $version) { |
| 1536 | 1512 | $words = (int)($inputitem['size'] / 3); |
| @@ -1556,10 +1532,10 @@ | ||
| 1556 | 1532 | } |
| 1557 | 1533 | |
| 1558 | 1534 | /** |
| 1559 | 1535 | * encodeModeAn |
| 1560 | - * @param $inputitem (array) | |
| 1561 | - * @param $version (int) | |
| 1536 | + * @param array $inputitem | |
| 1537 | + * @param int $version | |
| 1562 | 1538 | * @return array input item |
| 1563 | 1539 | */ |
| 1564 | 1540 | protected function encodeModeAn($inputitem, $version) { |
| 1565 | 1541 | $words = (int)($inputitem['size'] / 2); |
| @@ -1579,10 +1555,10 @@ | ||
| 1579 | 1555 | } |
| 1580 | 1556 | |
| 1581 | 1557 | /** |
| 1582 | 1558 | * encodeMode8 |
| 1583 | - * @param $inputitem (array) | |
| 1584 | - * @param $version (int) | |
| 1559 | + * @param array $inputitem | |
| 1560 | + * @param int $version | |
| 1585 | 1561 | * @return array input item |
| 1586 | 1562 | */ |
| 1587 | 1563 | protected function encodeMode8($inputitem, $version) { |
| 1588 | 1564 | $inputitem['bstream'] = array(); |
| @@ -1595,10 +1571,10 @@ | ||
| 1595 | 1571 | } |
| 1596 | 1572 | |
| 1597 | 1573 | /** |
| 1598 | 1574 | * encodeModeKanji |
| 1599 | - * @param $inputitem (array) | |
| 1600 | - * @param $version (int) | |
| 1575 | + * @param array $inputitem | |
| 1576 | + * @param int $version | |
| 1601 | 1577 | * @return array input item |
| 1602 | 1578 | */ |
| 1603 | 1579 | protected function encodeModeKanji($inputitem, $version) { |
| 1604 | 1580 | $inputitem['bstream'] = array(); |
| @@ -1619,9 +1595,9 @@ | ||
| 1619 | 1595 | } |
| 1620 | 1596 | |
| 1621 | 1597 | /** |
| 1622 | 1598 | * encodeModeStructure |
| 1623 | - * @param $inputitem (array) | |
| 1599 | + * @param array $inputitem | |
| 1624 | 1600 | * @return array input item |
| 1625 | 1601 | */ |
| 1626 | 1602 | protected function encodeModeStructure($inputitem) { |
| 1627 | 1603 | $inputitem['bstream'] = array(); |
| @@ -1633,10 +1609,10 @@ | ||
| 1633 | 1609 | } |
| 1634 | 1610 | |
| 1635 | 1611 | /** |
| 1636 | 1612 | * encodeBitStream |
| 1637 | - * @param $inputitem (array) | |
| 1638 | - * @param $version (int) | |
| 1613 | + * @param array $inputitem | |
| 1614 | + * @param int $version | |
| 1639 | 1615 | * @return array input item |
| 1640 | 1616 | */ |
| 1641 | 1617 | protected function encodeBitStream($inputitem, $version) { |
| 1642 | 1618 | $inputitem['bstream'] = array(); |
| @@ -1685,13 +1661,13 @@ | ||
| 1685 | 1661 | |
| 1686 | 1662 | /** |
| 1687 | 1663 | * Append data to an input object. |
| 1688 | 1664 | * The data is copied and appended to the input object. |
| 1689 | - * @param $items (arrray) input items | |
| 1690 | - * @param $mode (int) encoding mode. | |
| 1691 | - * @param $size (int) size of data (byte). | |
| 1692 | - * @param $data (array) array of input data. | |
| 1693 | - * @return items | |
| 1665 | + * @param array $items input items | |
| 1666 | + * @param int $mode encoding mode. | |
| 1667 | + * @param int $size size of data (byte). | |
| 1668 | + * @param array $data array of input data. | |
| 1669 | + * @return array items | |
| 1694 | 1670 | * |
| 1695 | 1671 | */ |
| 1696 | 1672 | protected function appendNewInputItem($items, $mode, $size, $data) { |
| 1697 | 1673 | $newitem = $this->newInputItem($mode, $size, $data); |
| @@ -1702,12 +1678,12 @@ | ||
| 1702 | 1678 | } |
| 1703 | 1679 | |
| 1704 | 1680 | /** |
| 1705 | 1681 | * insertStructuredAppendHeader |
| 1706 | - * @param $items (array) | |
| 1707 | - * @param $size (int) | |
| 1708 | - * @param $index (int) | |
| 1709 | - * @param $parity (int) | |
| 1682 | + * @param array $items | |
| 1683 | + * @param int $size | |
| 1684 | + * @param int $index | |
| 1685 | + * @param int $parity | |
| 1710 | 1686 | * @return array items |
| 1711 | 1687 | */ |
| 1712 | 1688 | protected function insertStructuredAppendHeader($items, $size, $index, $parity) { |
| 1713 | 1689 | if ($size > MAX_STRUCTURED_SYMBOLS) { |
| @@ -1716,9 +1692,9 @@ | ||
| 1716 | 1692 | if (($index <= 0) OR ($index > MAX_STRUCTURED_SYMBOLS)) { |
| 1717 | 1693 | return -1; |
| 1718 | 1694 | } |
| 1719 | 1695 | $buf = array($size, $index, $parity); |
| 1720 | - $entry = $this->newInputItem(QR_MODE_ST, 3, buf); | |
| 1696 | + $entry = $this->newInputItem(QR_MODE_ST, 3, $buf); | |
| 1721 | 1697 | array_unshift($items, $entry); |
| 1722 | 1698 | return $items; |
| 1723 | 1699 | } |
| 1724 | 1700 | |
| @@ -1723,9 +1699,9 @@ | ||
| 1723 | 1699 | } |
| 1724 | 1700 | |
| 1725 | 1701 | /** |
| 1726 | 1702 | * calcParity |
| 1727 | - * @param $items (array) | |
| 1703 | + * @param array $items | |
| 1728 | 1704 | * @return int parity |
| 1729 | 1705 | */ |
| 1730 | 1706 | protected function calcParity($items) { |
| 1731 | 1707 | $parity = 0; |
| @@ -1740,10 +1716,10 @@ | ||
| 1740 | 1716 | } |
| 1741 | 1717 | |
| 1742 | 1718 | /** |
| 1743 | 1719 | * checkModeNum |
| 1744 | - * @param $size (int) | |
| 1745 | - * @param $data (array) | |
| 1720 | + * @param int $size | |
| 1721 | + * @param array $data | |
| 1746 | 1722 | * @return boolean true or false |
| 1747 | 1723 | */ |
| 1748 | 1724 | protected function checkModeNum($size, $data) { |
| 1749 | 1725 | for ($i=0; $i<$size; ++$i) { |
| @@ -1754,11 +1730,11 @@ | ||
| 1754 | 1730 | return true; |
| 1755 | 1731 | } |
| 1756 | 1732 | |
| 1757 | 1733 | /** |
| 1758 | - * Look up the alphabet-numeric convesion table (see JIS X0510:2004, pp.19). | |
| 1759 | - * @param $c (int) character value | |
| 1760 | - * @return value | |
| 1734 | + * Look up the alphabet-numeric conversion table (see JIS X0510:2004, pp.19). | |
| 1735 | + * @param int $c character value | |
| 1736 | + * @return int value | |
| 1761 | 1737 | */ |
| 1762 | 1738 | protected function lookAnTable($c) { |
| 1763 | 1739 | return (($c > 127)?-1:$this->anTable[$c]); |
| 1764 | 1740 | } |
| @@ -1764,10 +1740,10 @@ | ||
| 1764 | 1740 | } |
| 1765 | 1741 | |
| 1766 | 1742 | /** |
| 1767 | 1743 | * checkModeAn |
| 1768 | - * @param $size (int) | |
| 1769 | - * @param $data (array) | |
| 1744 | + * @param int $size | |
| 1745 | + * @param array $data | |
| 1770 | 1746 | * @return boolean true or false |
| 1771 | 1747 | */ |
| 1772 | 1748 | protected function checkModeAn($size, $data) { |
| 1773 | 1749 | for ($i=0; $i<$size; ++$i) { |
| @@ -1779,9 +1755,9 @@ | ||
| 1779 | 1755 | } |
| 1780 | 1756 | |
| 1781 | 1757 | /** |
| 1782 | 1758 | * estimateBitsModeNum |
| 1783 | - * @param $size (int) | |
| 1759 | + * @param int $size | |
| 1784 | 1760 | * @return int number of bits |
| 1785 | 1761 | */ |
| 1786 | 1762 | protected function estimateBitsModeNum($size) { |
| 1787 | 1763 | $w = (int)($size / 3); |
| @@ -1800,9 +1776,9 @@ | ||
| 1800 | 1776 | } |
| 1801 | 1777 | |
| 1802 | 1778 | /** |
| 1803 | 1779 | * estimateBitsModeAn |
| 1804 | - * @param $size (int) | |
| 1780 | + * @param int $size | |
| 1805 | 1781 | * @return int number of bits |
| 1806 | 1782 | */ |
| 1807 | 1783 | protected function estimateBitsModeAn($size) { |
| 1808 | 1784 | $bits = (int)($size * 5.5); // (size / 2 ) * 11 |
| @@ -1813,9 +1789,9 @@ | ||
| 1813 | 1789 | } |
| 1814 | 1790 | |
| 1815 | 1791 | /** |
| 1816 | 1792 | * estimateBitsMode8 |
| 1817 | - * @param $size (int) | |
| 1793 | + * @param int $size | |
| 1818 | 1794 | * @return int number of bits |
| 1819 | 1795 | */ |
| 1820 | 1796 | protected function estimateBitsMode8($size) { |
| 1821 | 1797 | return (int)($size * 8); |
| @@ -1822,9 +1798,9 @@ | ||
| 1822 | 1798 | } |
| 1823 | 1799 | |
| 1824 | 1800 | /** |
| 1825 | 1801 | * estimateBitsModeKanji |
| 1826 | - * @param $size (int) | |
| 1802 | + * @param int $size | |
| 1827 | 1803 | * @return int number of bits |
| 1828 | 1804 | */ |
| 1829 | 1805 | protected function estimateBitsModeKanji($size) { |
| 1830 | 1806 | return (int)($size * 6.5); // (size / 2 ) * 13 |
| @@ -1831,10 +1807,10 @@ | ||
| 1831 | 1807 | } |
| 1832 | 1808 | |
| 1833 | 1809 | /** |
| 1834 | 1810 | * checkModeKanji |
| 1835 | - * @param $size (int) | |
| 1836 | - * @param $data (array) | |
| 1811 | + * @param int $size | |
| 1812 | + * @param array $data | |
| 1837 | 1813 | * @return boolean true or false |
| 1838 | 1814 | */ |
| 1839 | 1815 | protected function checkModeKanji($size, $data) { |
| 1840 | 1816 | if ($size & 1) { |
| @@ -1850,11 +1826,11 @@ | ||
| 1850 | 1826 | } |
| 1851 | 1827 | |
| 1852 | 1828 | /** |
| 1853 | 1829 | * Validate the input data. |
| 1854 | - * @param $mode (int) encoding mode. | |
| 1855 | - * @param $size (int) size of data (byte). | |
| 1856 | - * @param $data (array) data to validate | |
| 1830 | + * @param int $mode encoding mode. | |
| 1831 | + * @param int $size size of data (byte). | |
| 1832 | + * @param array $data data to validate | |
| 1857 | 1833 | * @return boolean true in case of valid data, false otherwise |
| 1858 | 1834 | */ |
| 1859 | 1835 | protected function check($mode, $size, $data) { |
| 1860 | 1836 | if ($size <= 0) { |
| @@ -1884,10 +1860,10 @@ | ||
| 1884 | 1860 | } |
| 1885 | 1861 | |
| 1886 | 1862 | /** |
| 1887 | 1863 | * estimateBitStreamSize |
| 1888 | - * @param $items (array) | |
| 1889 | - * @param $version (int) | |
| 1864 | + * @param array $items | |
| 1865 | + * @param int $version | |
| 1890 | 1866 | * @return int bits |
| 1891 | 1867 | */ |
| 1892 | 1868 | protected function estimateBitStreamSize($items, $version) { |
| 1893 | 1869 | $bits = 0; |
| @@ -1928,9 +1904,9 @@ | ||
| 1928 | 1904 | } |
| 1929 | 1905 | |
| 1930 | 1906 | /** |
| 1931 | 1907 | * estimateVersion |
| 1932 | - * @param $items (array) | |
| 1908 | + * @param array $items | |
| 1933 | 1909 | * @return int version |
| 1934 | 1910 | */ |
| 1935 | 1911 | protected function estimateVersion($items) { |
| 1936 | 1912 | $version = 0; |
| @@ -1947,11 +1923,11 @@ | ||
| 1947 | 1923 | } |
| 1948 | 1924 | |
| 1949 | 1925 | /** |
| 1950 | 1926 | * lengthOfCode |
| 1951 | - * @param $mode (int) | |
| 1952 | - * @param $version (int) | |
| 1953 | - * @param $bits (int) | |
| 1927 | + * @param int $mode | |
| 1928 | + * @param int $version | |
| 1929 | + * @param int $bits | |
| 1954 | 1930 | * @return int size |
| 1955 | 1931 | */ |
| 1956 | 1932 | protected function lengthOfCode($mode, $version, $bits) { |
| 1957 | 1933 | $payload = $bits - 4 - $this->lengthIndicator($mode, $version); |
| @@ -2004,9 +1980,9 @@ | ||
| 2004 | 1980 | } |
| 2005 | 1981 | |
| 2006 | 1982 | /** |
| 2007 | 1983 | * createBitStream |
| 2008 | - * @param $items (array) | |
| 1984 | + * @param array $items | |
| 2009 | 1985 | * @return array of items and total bits |
| 2010 | 1986 | */ |
| 2011 | 1987 | protected function createBitStream($items) { |
| 2012 | 1988 | $total = 0; |
| @@ -2019,9 +1995,9 @@ | ||
| 2019 | 1995 | } |
| 2020 | 1996 | |
| 2021 | 1997 | /** |
| 2022 | 1998 | * convertData |
| 2023 | - * @param $items (array) | |
| 1999 | + * @param array $items | |
| 2024 | 2000 | * @return array items |
| 2025 | 2001 | */ |
| 2026 | 2002 | protected function convertData($items) { |
| 2027 | 2003 | $ver = $this->estimateVersion($items); |
| @@ -2048,9 +2024,9 @@ | ||
| 2048 | 2024 | } |
| 2049 | 2025 | |
| 2050 | 2026 | /** |
| 2051 | 2027 | * Append Padding Bit to bitstream |
| 2052 | - * @param $bstream (array) | |
| 2028 | + * @param array $bstream | |
| 2053 | 2029 | * @return array bitstream |
| 2054 | 2030 | */ |
| 2055 | 2031 | protected function appendPaddingBit($bstream) { |
| 2056 | 2032 | if (is_null($bstream)) { |
| @@ -2081,9 +2057,9 @@ | ||
| 2081 | 2057 | } |
| 2082 | 2058 | |
| 2083 | 2059 | /** |
| 2084 | 2060 | * mergeBitStream |
| 2085 | - * @param $items (array) items | |
| 2061 | + * @param array $items items | |
| 2086 | 2062 | * @return array bitstream |
| 2087 | 2063 | */ |
| 2088 | 2064 | protected function mergeBitStream($items) { |
| 2089 | 2065 | $items = $this->convertData($items); |
| @@ -2098,9 +2074,9 @@ | ||
| 2098 | 2074 | } |
| 2099 | 2075 | |
| 2100 | 2076 | /** |
| 2101 | 2077 | * Returns a stream of bits. |
| 2102 | - * @param $items (int) | |
| 2078 | + * @param int $items | |
| 2103 | 2079 | * @return array padded merged byte stream |
| 2104 | 2080 | */ |
| 2105 | 2081 | protected function getBitStream($items) { |
| 2106 | 2082 | $bstream = $this->mergeBitStream($items); |
| @@ -2108,9 +2084,9 @@ | ||
| 2108 | 2084 | } |
| 2109 | 2085 | |
| 2110 | 2086 | /** |
| 2111 | 2087 | * Pack all bit streams padding bits into a byte array. |
| 2112 | - * @param $items (int) | |
| 2088 | + * @param int $items | |
| 2113 | 2089 | * @return array padded merged byte stream |
| 2114 | 2090 | */ |
| 2115 | 2091 | protected function getByteStream($items) { |
| 2116 | 2092 | $bstream = $this->getBitStream($items); |
| @@ -2122,9 +2098,9 @@ | ||
| 2122 | 2098 | // QRbitstream |
| 2123 | 2099 | |
| 2124 | 2100 | /** |
| 2125 | 2101 | * Return an array with zeros |
| 2126 | - * @param $setLength (int) array size | |
| 2102 | + * @param int $setLength array size | |
| 2127 | 2103 | * @return array |
| 2128 | 2104 | */ |
| 2129 | 2105 | protected function allocate($setLength) { |
| 2130 | 2106 | return array_fill(0, $setLength, 0); |
| @@ -2131,10 +2107,10 @@ | ||
| 2131 | 2107 | } |
| 2132 | 2108 | |
| 2133 | 2109 | /** |
| 2134 | 2110 | * Return new bitstream from number |
| 2135 | - * @param $bits (int) number of bits | |
| 2136 | - * @param $num (int) number | |
| 2111 | + * @param int $bits number of bits | |
| 2112 | + * @param int $num number | |
| 2137 | 2113 | * @return array bitstream |
| 2138 | 2114 | */ |
| 2139 | 2115 | protected function newFromNum($bits, $num) { |
| 2140 | 2116 | $bstream = $this->allocate($bits); |
| @@ -2151,10 +2127,10 @@ | ||
| 2151 | 2127 | } |
| 2152 | 2128 | |
| 2153 | 2129 | /** |
| 2154 | 2130 | * Return new bitstream from bytes |
| 2155 | - * @param $size (int) size | |
| 2156 | - * @param $data (array) bytes | |
| 2131 | + * @param int $size size | |
| 2132 | + * @param array $data bytes | |
| 2157 | 2133 | * @return array bitstream |
| 2158 | 2134 | */ |
| 2159 | 2135 | protected function newFromBytes($size, $data) { |
| 2160 | 2136 | $bstream = $this->allocate($size * 8); |
| @@ -2175,10 +2151,10 @@ | ||
| 2175 | 2151 | } |
| 2176 | 2152 | |
| 2177 | 2153 | /** |
| 2178 | 2154 | * Append one bitstream to another |
| 2179 | - * @param $bitstream (array) original bitstream | |
| 2180 | - * @param $append (array) bitstream to append | |
| 2155 | + * @param array $bitstream original bitstream | |
| 2156 | + * @param array $append bitstream to append | |
| 2181 | 2157 | * @return array bitstream |
| 2182 | 2158 | */ |
| 2183 | 2159 | protected function appendBitstream($bitstream, $append) { |
| 2184 | 2160 | if ((!is_array($append)) OR (count($append) == 0)) { |
| @@ -2191,11 +2167,11 @@ | ||
| 2191 | 2167 | } |
| 2192 | 2168 | |
| 2193 | 2169 | /** |
| 2194 | 2170 | * Append one bitstream created from number to another |
| 2195 | - * @param $bitstream (array) original bitstream | |
| 2196 | - * @param $bits (int) number of bits | |
| 2197 | - * @param $num (int) number | |
| 2171 | + * @param array $bitstream original bitstream | |
| 2172 | + * @param int $bits number of bits | |
| 2173 | + * @param int $num number | |
| 2198 | 2174 | * @return array bitstream |
| 2199 | 2175 | */ |
| 2200 | 2176 | protected function appendNum($bitstream, $bits, $num) { |
| 2201 | 2177 | if ($bits == 0) { |
| @@ -2206,11 +2182,11 @@ | ||
| 2206 | 2182 | } |
| 2207 | 2183 | |
| 2208 | 2184 | /** |
| 2209 | 2185 | * Append one bitstream created from bytes to another |
| 2210 | - * @param $bitstream (array) original bitstream | |
| 2211 | - * @param $size (int) size | |
| 2212 | - * @param $data (array) bytes | |
| 2186 | + * @param array $bitstream original bitstream | |
| 2187 | + * @param int $size size | |
| 2188 | + * @param array $data bytes | |
| 2213 | 2189 | * @return array bitstream |
| 2214 | 2190 | */ |
| 2215 | 2191 | protected function appendBytes($bitstream, $size, $data) { |
| 2216 | 2192 | if ($size == 0) { |
| @@ -2221,9 +2197,9 @@ | ||
| 2221 | 2197 | } |
| 2222 | 2198 | |
| 2223 | 2199 | /** |
| 2224 | 2200 | * Convert bitstream to bytes |
| 2225 | - * @param $bstream (array) original bitstream | |
| 2201 | + * @param array $bstream original bitstream | |
| 2226 | 2202 | * @return array of bytes |
| 2227 | 2203 | */ |
| 2228 | 2204 | protected function bitstreamToByte($bstream) { |
| 2229 | 2205 | if (is_null($bstream)) { |
| @@ -2262,13 +2238,13 @@ | ||
| 2262 | 2238 | // QRspec |
| 2263 | 2239 | |
| 2264 | 2240 | /** |
| 2265 | 2241 | * Replace a value on the array at the specified position |
| 2266 | - * @param $srctab (array) | |
| 2267 | - * @param $x (int) X position | |
| 2268 | - * @param $y (int) Y position | |
| 2269 | - * @param $repl (string) value to replace | |
| 2270 | - * @param $replLen (int) length of the repl string | |
| 2242 | + * @param array $srctab | |
| 2243 | + * @param int $x X position | |
| 2244 | + * @param int $y Y position | |
| 2245 | + * @param string $repl value to replace | |
| 2246 | + * @param int $replLen length of the repl string | |
| 2271 | 2247 | * @return array srctab |
| 2272 | 2248 | */ |
| 2273 | 2249 | protected function qrstrset($srctab, $x, $y, $repl, $replLen=false) { |
| 2274 | 2250 | $srctab[$y] = substr_replace($srctab[$y], ($replLen !== false)?substr($repl,0,$replLen):$repl, $x, ($replLen !== false)?$replLen:strlen($repl)); |
| @@ -2276,10 +2252,10 @@ | ||
| 2276 | 2252 | } |
| 2277 | 2253 | |
| 2278 | 2254 | /** |
| 2279 | 2255 | * Return maximum data code length (bytes) for the version. |
| 2280 | - * @param $version (int) version | |
| 2281 | - * @param $level (int) error correction level | |
| 2256 | + * @param int $version version | |
| 2257 | + * @param int $level error correction level | |
| 2282 | 2258 | * @return int maximum size (bytes) |
| 2283 | 2259 | */ |
| 2284 | 2260 | protected function getDataLength($version, $level) { |
| 2285 | 2261 | return $this->capacity[$version][QRCAP_WORDS] - $this->capacity[$version][QRCAP_EC][$level]; |
| @@ -2286,10 +2262,10 @@ | ||
| 2286 | 2262 | } |
| 2287 | 2263 | |
| 2288 | 2264 | /** |
| 2289 | 2265 | * Return maximum error correction code length (bytes) for the version. |
| 2290 | - * @param $version (int) version | |
| 2291 | - * @param $level (int) error correction level | |
| 2266 | + * @param int $version version | |
| 2267 | + * @param int $level error correction level | |
| 2292 | 2268 | * @return int ECC size (bytes) |
| 2293 | 2269 | */ |
| 2294 | 2270 | protected function getECCLength($version, $level){ |
| 2295 | 2271 | return $this->capacity[$version][QRCAP_EC][$level]; |
| @@ -2296,9 +2272,9 @@ | ||
| 2296 | 2272 | } |
| 2297 | 2273 | |
| 2298 | 2274 | /** |
| 2299 | 2275 | * Return the width of the symbol for the version. |
| 2300 | - * @param $version (int) version | |
| 2276 | + * @param int $version version | |
| 2301 | 2277 | * @return int width |
| 2302 | 2278 | */ |
| 2303 | 2279 | protected function getWidth($version) { |
| 2304 | 2280 | return $this->capacity[$version][QRCAP_WIDTH]; |
| @@ -2305,9 +2281,9 @@ | ||
| 2305 | 2281 | } |
| 2306 | 2282 | |
| 2307 | 2283 | /** |
| 2308 | 2284 | * Return the numer of remainder bits. |
| 2309 | - * @param $version (int) version | |
| 2285 | + * @param int $version version | |
| 2310 | 2286 | * @return int number of remainder bits |
| 2311 | 2287 | */ |
| 2312 | 2288 | protected function getRemainder($version) { |
| 2313 | 2289 | return $this->capacity[$version][QRCAP_REMINDER]; |
| @@ -2314,10 +2290,10 @@ | ||
| 2314 | 2290 | } |
| 2315 | 2291 | |
| 2316 | 2292 | /** |
| 2317 | 2293 | * Return a version number that satisfies the input code length. |
| 2318 | - * @param $size (int) input code length (bytes) | |
| 2319 | - * @param $level (int) error correction level | |
| 2294 | + * @param int $size input code length (bytes) | |
| 2295 | + * @param int $level error correction level | |
| 2320 | 2296 | * @return int version number |
| 2321 | 2297 | */ |
| 2322 | 2298 | protected function getMinimumVersion($size, $level) { |
| 2323 | 2299 | for ($i = 1; $i <= QRSPEC_VERSION_MAX; ++$i) { |
| @@ -2331,10 +2307,10 @@ | ||
| 2331 | 2307 | } |
| 2332 | 2308 | |
| 2333 | 2309 | /** |
| 2334 | 2310 | * Return the size of length indicator for the mode and version. |
| 2335 | - * @param $mode (int) encoding mode | |
| 2336 | - * @param $version (int) version | |
| 2311 | + * @param int $mode encoding mode | |
| 2312 | + * @param int $version version | |
| 2337 | 2313 | * @return int the size of the appropriate length indicator (bits). |
| 2338 | 2314 | */ |
| 2339 | 2315 | protected function lengthIndicator($mode, $version) { |
| 2340 | 2316 | if ($mode == QR_MODE_ST) { |
| @@ -2351,10 +2327,10 @@ | ||
| 2351 | 2327 | } |
| 2352 | 2328 | |
| 2353 | 2329 | /** |
| 2354 | 2330 | * Return the maximum length for the mode and version. |
| 2355 | - * @param $mode (int) encoding mode | |
| 2356 | - * @param $version (int) version | |
| 2331 | + * @param int $mode encoding mode | |
| 2332 | + * @param int $version version | |
| 2357 | 2333 | * @return int the maximum length (bytes) |
| 2358 | 2334 | */ |
| 2359 | 2335 | protected function maximumWords($mode, $version) { |
| 2360 | 2336 | if ($mode == QR_MODE_ST) { |
| @@ -2376,11 +2352,11 @@ | ||
| 2376 | 2352 | } |
| 2377 | 2353 | |
| 2378 | 2354 | /** |
| 2379 | 2355 | * Return an array of ECC specification. |
| 2380 | - * @param $version (int) version | |
| 2381 | - * @param $level (int) error correction level | |
| 2382 | - * @param $spec (array) an array of ECC specification contains as following: {# of type1 blocks, # of data code, # of ecc code, # of type2 blocks, # of data code} | |
| 2356 | + * @param int $version version | |
| 2357 | + * @param int $level error correction level | |
| 2358 | + * @param array $spec an array of ECC specification contains as following: {# of type1 blocks, # of data code, # of ecc code, # of type2 blocks, # of data code} | |
| 2383 | 2359 | * @return array spec |
| 2384 | 2360 | */ |
| 2385 | 2361 | protected function getEccSpec($version, $level, $spec) { |
| 2386 | 2362 | if (count($spec) < 5) { |
| @@ -2407,11 +2383,11 @@ | ||
| 2407 | 2383 | } |
| 2408 | 2384 | |
| 2409 | 2385 | /** |
| 2410 | 2386 | * Put an alignment marker. |
| 2411 | - * @param $frame (array) frame | |
| 2412 | - * @param $ox (int) X center coordinate of the pattern | |
| 2413 | - * @param $oy (int) Y center coordinate of the pattern | |
| 2387 | + * @param array $frame frame | |
| 2388 | + * @param int $ox X center coordinate of the pattern | |
| 2389 | + * @param int $oy Y center coordinate of the pattern | |
| 2414 | 2390 | * @return array frame |
| 2415 | 2391 | */ |
| 2416 | 2392 | protected function putAlignmentMarker($frame, $ox, $oy) { |
| 2417 | 2393 | $finder = array( |
| @@ -2430,11 +2406,11 @@ | ||
| 2430 | 2406 | } |
| 2431 | 2407 | |
| 2432 | 2408 | /** |
| 2433 | 2409 | * Put an alignment pattern. |
| 2434 | - * @param $version (int) version | |
| 2435 | - * @param $frame (array) frame | |
| 2436 | - * @param $width (int) width | |
| 2410 | + * @param int $version version | |
| 2411 | + * @param array $frame frame | |
| 2412 | + * @param int $width width | |
| 2437 | 2413 | * @return array frame |
| 2438 | 2414 | */ |
| 2439 | 2415 | protected function putAlignmentPattern($version, $frame, $width) { |
| 2440 | 2416 | if ($version < 2) { |
| @@ -2472,10 +2448,10 @@ | ||
| 2472 | 2448 | } |
| 2473 | 2449 | |
| 2474 | 2450 | /** |
| 2475 | 2451 | * Return BCH encoded version information pattern that is used for the symbol of version 7 or greater. Use lower 18 bits. |
| 2476 | - * @param $version (int) version | |
| 2477 | - * @return BCH encoded version information pattern | |
| 2452 | + * @param int $version version | |
| 2453 | + * @return string BCH encoded version information pattern | |
| 2478 | 2454 | */ |
| 2479 | 2455 | protected function getVersionPattern($version) { |
| 2480 | 2456 | if (($version < 7) OR ($version > QRSPEC_VERSION_MAX)) { |
| 2481 | 2457 | return 0; |
| @@ -2484,11 +2460,11 @@ | ||
| 2484 | 2460 | } |
| 2485 | 2461 | |
| 2486 | 2462 | /** |
| 2487 | 2463 | * Return BCH encoded format information pattern. |
| 2488 | - * @param $mask (array) | |
| 2489 | - * @param $level (int) error correction level | |
| 2490 | - * @return BCH encoded format information pattern | |
| 2464 | + * @param array $mask | |
| 2465 | + * @param int $level error correction level | |
| 2466 | + * @return string BCH encoded format information pattern | |
| 2491 | 2467 | */ |
| 2492 | 2468 | protected function getFormatInfo($mask, $level) { |
| 2493 | 2469 | if (($mask < 0) OR ($mask > 7)) { |
| 2494 | 2470 | return 0; |
| @@ -2500,11 +2476,11 @@ | ||
| 2500 | 2476 | } |
| 2501 | 2477 | |
| 2502 | 2478 | /** |
| 2503 | 2479 | * Put a finder pattern. |
| 2504 | - * @param $frame (array) frame | |
| 2505 | - * @param $ox (int) X center coordinate of the pattern | |
| 2506 | - * @param $oy (int) Y center coordinate of the pattern | |
| 2480 | + * @param array $frame frame | |
| 2481 | + * @param int $ox X center coordinate of the pattern | |
| 2482 | + * @param int $oy Y center coordinate of the pattern | |
| 2507 | 2483 | * @return array frame |
| 2508 | 2484 | */ |
| 2509 | 2485 | protected function putFinderPattern($frame, $ox, $oy) { |
| 2510 | 2486 | $finder = array( |
| @@ -2523,10 +2499,10 @@ | ||
| 2523 | 2499 | } |
| 2524 | 2500 | |
| 2525 | 2501 | /** |
| 2526 | 2502 | * Return a copy of initialized frame. |
| 2527 | - * @param $version (int) version | |
| 2528 | - * @return Array of unsigned char. | |
| 2503 | + * @param int $version version | |
| 2504 | + * @return array array of unsigned char. | |
| 2529 | 2505 | */ |
| 2530 | 2506 | protected function createFrame($version) { |
| 2531 | 2507 | $width = $this->capacity[$version][QRCAP_WIDTH]; |
| 2532 | 2508 | $frameLine = str_repeat ("\0", $width); |
| @@ -2588,10 +2564,10 @@ | ||
| 2588 | 2564 | } |
| 2589 | 2565 | |
| 2590 | 2566 | /** |
| 2591 | 2567 | * Set new frame for the specified version. |
| 2592 | - * @param $version (int) version | |
| 2593 | - * @return Array of unsigned char. | |
| 2568 | + * @param int $version version | |
| 2569 | + * @return array array of unsigned char. | |
| 2594 | 2570 | */ |
| 2595 | 2571 | protected function newFrame($version) { |
| 2596 | 2572 | if (($version < 1) OR ($version > QRSPEC_VERSION_MAX)) { |
| 2597 | 2573 | return NULL; |
| @@ -2606,9 +2582,9 @@ | ||
| 2606 | 2582 | } |
| 2607 | 2583 | |
| 2608 | 2584 | /** |
| 2609 | 2585 | * Return block number 0 |
| 2610 | - * @param $spec (array) | |
| 2586 | + * @param array $spec | |
| 2611 | 2587 | * @return int value |
| 2612 | 2588 | */ |
| 2613 | 2589 | protected function rsBlockNum($spec) { |
| 2614 | 2590 | return ($spec[0] + $spec[3]); |
| @@ -2615,9 +2591,9 @@ | ||
| 2615 | 2591 | } |
| 2616 | 2592 | |
| 2617 | 2593 | /** |
| 2618 | 2594 | * Return block number 1 |
| 2619 | - * @param $spec (array) | |
| 2595 | + * @param array $spec | |
| 2620 | 2596 | * @return int value |
| 2621 | 2597 | */ |
| 2622 | 2598 | protected function rsBlockNum1($spec) { |
| 2623 | 2599 | return $spec[0]; |
| @@ -2624,9 +2600,9 @@ | ||
| 2624 | 2600 | } |
| 2625 | 2601 | |
| 2626 | 2602 | /** |
| 2627 | 2603 | * Return data codes 1 |
| 2628 | - * @param $spec (array) | |
| 2604 | + * @param array $spec | |
| 2629 | 2605 | * @return int value |
| 2630 | 2606 | */ |
| 2631 | 2607 | protected function rsDataCodes1($spec) { |
| 2632 | 2608 | return $spec[1]; |
| @@ -2633,9 +2609,9 @@ | ||
| 2633 | 2609 | } |
| 2634 | 2610 | |
| 2635 | 2611 | /** |
| 2636 | 2612 | * Return ecc codes 1 |
| 2637 | - * @param $spec (array) | |
| 2613 | + * @param array $spec | |
| 2638 | 2614 | * @return int value |
| 2639 | 2615 | */ |
| 2640 | 2616 | protected function rsEccCodes1($spec) { |
| 2641 | 2617 | return $spec[2]; |
| @@ -2642,9 +2618,9 @@ | ||
| 2642 | 2618 | } |
| 2643 | 2619 | |
| 2644 | 2620 | /** |
| 2645 | 2621 | * Return block number 2 |
| 2646 | - * @param $spec (array) | |
| 2622 | + * @param array $spec | |
| 2647 | 2623 | * @return int value |
| 2648 | 2624 | */ |
| 2649 | 2625 | protected function rsBlockNum2($spec) { |
| 2650 | 2626 | return $spec[3]; |
| @@ -2651,9 +2627,9 @@ | ||
| 2651 | 2627 | } |
| 2652 | 2628 | |
| 2653 | 2629 | /** |
| 2654 | 2630 | * Return data codes 2 |
| 2655 | - * @param $spec (array) | |
| 2631 | + * @param array $spec | |
| 2656 | 2632 | * @return int value |
| 2657 | 2633 | */ |
| 2658 | 2634 | protected function rsDataCodes2($spec) { |
| 2659 | 2635 | return $spec[4]; |
| @@ -2660,9 +2636,9 @@ | ||
| 2660 | 2636 | } |
| 2661 | 2637 | |
| 2662 | 2638 | /** |
| 2663 | 2639 | * Return ecc codes 2 |
| 2664 | - * @param $spec (array) | |
| 2640 | + * @param array $spec | |
| 2665 | 2641 | * @return int value |
| 2666 | 2642 | */ |
| 2667 | 2643 | protected function rsEccCodes2($spec) { |
| 2668 | 2644 | return $spec[2]; |
| @@ -2669,9 +2645,9 @@ | ||
| 2669 | 2645 | } |
| 2670 | 2646 | |
| 2671 | 2647 | /** |
| 2672 | 2648 | * Return data length |
| 2673 | - * @param $spec (array) | |
| 2649 | + * @param array $spec | |
| 2674 | 2650 | * @return int value |
| 2675 | 2651 | */ |
| 2676 | 2652 | protected function rsDataLength($spec) { |
| 2677 | 2653 | return ($spec[0] * $spec[1]) + ($spec[3] * $spec[4]); |
| @@ -2678,9 +2654,9 @@ | ||
| 2678 | 2654 | } |
| 2679 | 2655 | |
| 2680 | 2656 | /** |
| 2681 | 2657 | * Return ecc length |
| 2682 | - * @param $spec (array) | |
| 2658 | + * @param array $spec | |
| 2683 | 2659 | * @return int value |
| 2684 | 2660 | */ |
| 2685 | 2661 | protected function rsEccLength($spec) { |
| 2686 | 2662 | return ($spec[0] + $spec[3]) * $spec[2]; |
| @@ -2691,14 +2667,14 @@ | ||
| 2691 | 2667 | // QRrs |
| 2692 | 2668 | |
| 2693 | 2669 | /** |
| 2694 | 2670 | * Initialize a Reed-Solomon codec and add it to existing rsitems |
| 2695 | - * @param $symsize (int) symbol size, bits | |
| 2696 | - * @param $gfpoly (int) Field generator polynomial coefficients | |
| 2697 | - * @param $fcr (int) first root of RS code generator polynomial, index form | |
| 2698 | - * @param $prim (int) primitive element to generate polynomial roots | |
| 2699 | - * @param $nroots (int) RS code generator polynomial degree (number of roots) | |
| 2700 | - * @param $pad (int) padding bytes at front of shortened block | |
| 2671 | + * @param int $symsize symbol size, bits | |
| 2672 | + * @param int $gfpoly Field generator polynomial coefficients | |
| 2673 | + * @param int $fcr first root of RS code generator polynomial, index form | |
| 2674 | + * @param int $prim primitive element to generate polynomial roots | |
| 2675 | + * @param int $nroots RS code generator polynomial degree (number of roots) | |
| 2676 | + * @param int $pad padding bytes at front of shortened block | |
| 2701 | 2677 | * @return array Array of RS values:<ul><li>mm = Bits per symbol;</li><li>nn = Symbols per block;</li><li>alpha_to = log lookup table array;</li><li>index_of = Antilog lookup table array;</li><li>genpoly = Generator polynomial array;</li><li>nroots = Number of generator;</li><li>roots = number of parity symbols;</li><li>fcr = First consecutive root, index form;</li><li>prim = Primitive element, index form;</li><li>iprim = prim-th root of 1, index form;</li><li>pad = Padding bytes in shortened block;</li><li>gfpoly</ul>. |
| 2702 | 2678 | */ |
| 2703 | 2679 | protected function init_rs($symsize, $gfpoly, $fcr, $prim, $nroots, $pad) { |
| 2704 | 2680 | foreach ($this->rsitems as $rs) { |
| @@ -2718,10 +2694,10 @@ | ||
| 2718 | 2694 | // QRrsItem |
| 2719 | 2695 | |
| 2720 | 2696 | /** |
| 2721 | 2697 | * modnn |
| 2722 | - * @param $rs (array) RS values | |
| 2723 | - * @param $x (int) X position | |
| 2698 | + * @param array $rs RS values | |
| 2699 | + * @param int $x X position | |
| 2724 | 2700 | * @return int X osition |
| 2725 | 2701 | */ |
| 2726 | 2702 | protected function modnn($rs, $x) { |
| 2727 | 2703 | while ($x >= $rs['nn']) { |
| @@ -2732,14 +2708,14 @@ | ||
| 2732 | 2708 | } |
| 2733 | 2709 | |
| 2734 | 2710 | /** |
| 2735 | 2711 | * Initialize a Reed-Solomon codec and returns an array of values. |
| 2736 | - * @param $symsize (int) symbol size, bits | |
| 2737 | - * @param $gfpoly (int) Field generator polynomial coefficients | |
| 2738 | - * @param $fcr (int) first root of RS code generator polynomial, index form | |
| 2739 | - * @param $prim (int) primitive element to generate polynomial roots | |
| 2740 | - * @param $nroots (int) RS code generator polynomial degree (number of roots) | |
| 2741 | - * @param $pad (int) padding bytes at front of shortened block | |
| 2712 | + * @param int $symsize symbol size, bits | |
| 2713 | + * @param int $gfpoly Field generator polynomial coefficients | |
| 2714 | + * @param int $fcr first root of RS code generator polynomial, index form | |
| 2715 | + * @param int $prim primitive element to generate polynomial roots | |
| 2716 | + * @param int $nroots RS code generator polynomial degree (number of roots) | |
| 2717 | + * @param int $pad padding bytes at front of shortened block | |
| 2742 | 2718 | * @return array Array of RS values:<ul><li>mm = Bits per symbol;</li><li>nn = Symbols per block;</li><li>alpha_to = log lookup table array;</li><li>index_of = Antilog lookup table array;</li><li>genpoly = Generator polynomial array;</li><li>nroots = Number of generator;</li><li>roots = number of parity symbols;</li><li>fcr = First consecutive root, index form;</li><li>prim = Primitive element, index form;</li><li>iprim = prim-th root of 1, index form;</li><li>pad = Padding bytes in shortened block;</li><li>gfpoly</ul>. |
| 2743 | 2719 | */ |
| 2744 | 2720 | protected function init_rs_char($symsize, $gfpoly, $fcr, $prim, $nroots, $pad) { |
| 2745 | 2721 | // Based on Reed solomon encoder by Phil Karn, KA9Q (GNU-LGPLv2) |
| @@ -2819,11 +2795,11 @@ | ||
| 2819 | 2795 | } |
| 2820 | 2796 | |
| 2821 | 2797 | /** |
| 2822 | 2798 | * Encode a Reed-Solomon codec and returns the parity array |
| 2823 | - * @param $rs (array) RS values | |
| 2824 | - * @param $data (array) data | |
| 2825 | - * @param $parity (array) parity | |
| 2799 | + * @param array $rs RS values | |
| 2800 | + * @param array $data data | |
| 2801 | + * @param array $parity parity | |
| 2826 | 2802 | * @return parity array |
| 2827 | 2803 | */ |
| 2828 | 2804 | protected function encode_rs_char($rs, $data, $parity) { |
| 2829 | 2805 | $MM =& $rs['mm']; // bits per symbol |