← All changes
|
vendor/tecnickcom/tcpdf/include/barcodes/pdf417.php
+24
-24
2.3.1
→
4.17.0
View file →
| @@ -4,11 +4,11 @@ | ||
| 4 | 4 | // Version : 1.0.005 |
| 5 | 5 | // Begin : 2010-06-03 |
| 6 | 6 | // Last Update : 2014-04-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-2013 Nicola Asuni - Tecnick.com LTD | |
| 10 | +// Copyright (C) 2010-2013 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 | // |
| @@ -522,12 +522,12 @@ | ||
| 522 | 522 | |
| 523 | 523 | /** |
| 524 | 524 | * This is the class constructor. |
| 525 | 525 | * Creates a PDF417 object |
| 526 | - * @param $code (string) code to represent using PDF417 | |
| 527 | - * @param $ecl (int) error correction level (0-8); default -1 = automatic correction level | |
| 528 | - * @param $aspectratio (float) the width to height of the symbol (excluding quiet zones) | |
| 529 | - * @param $macro (array) information for macro block | |
| 526 | + * @param string $code code to represent using PDF417 | |
| 527 | + * @param int $ecl error correction level (0-8); default -1 = automatic correction level | |
| 528 | + * @param float $aspectratio the width to height of the symbol (excluding quiet zones) | |
| 529 | + * @param array $macro information for macro block | |
| 530 | 530 | * @public |
| 531 | 531 | */ |
| 532 | 532 | public function __construct($code, $ecl=-1, $aspectratio=2, $macro=array()) { |
| 533 | 533 | $barcode_array = array(); |
| @@ -733,14 +733,15 @@ | ||
| 733 | 733 | } |
| 734 | 734 | |
| 735 | 735 | /** |
| 736 | 736 | * Returns the error correction level (0-8) to be used |
| 737 | - * @param $ecl (int) error correction level | |
| 738 | - * @param $numcw (int) number of data codewords | |
| 737 | + * @param int $ecl error correction level | |
| 738 | + * @param int $numcw number of data codewords | |
| 739 | 739 | * @return int error correction level |
| 740 | 740 | * @protected |
| 741 | 741 | */ |
| 742 | 742 | protected function getErrorCorrectionLevel($ecl, $numcw) { |
| 743 | + $maxecl = 8; // starting error level | |
| 743 | 744 | // check for automatic levels |
| 744 | 745 | if (($ecl < 0) OR ($ecl > 8)) { |
| 745 | 746 | if ($numcw < 41) { |
| 746 | 747 | $ecl = 2; |
| @@ -754,9 +755,8 @@ | ||
| 754 | 755 | $ecl = $maxecl; |
| 755 | 756 | } |
| 756 | 757 | } |
| 757 | 758 | // get maximum correction level |
| 758 | - $maxecl = 8; // starting error level | |
| 759 | 759 | $maxerrsize = (928 - $numcw); // available codewords for error |
| 760 | 760 | while ($maxecl > 0) { |
| 761 | 761 | $errsize = (2 << $ecl); |
| 762 | 762 | if ($maxerrsize >= $errsize) { |
| @@ -771,10 +771,10 @@ | ||
| 771 | 771 | } |
| 772 | 772 | |
| 773 | 773 | /** |
| 774 | 774 | * Returns the error correction codewords |
| 775 | - * @param $cw (array) array of codewords including Symbol Length Descriptor and pad | |
| 776 | - * @param $ecl (int) error correction level 0-8 | |
| 775 | + * @param array $cw array of codewords including Symbol Length Descriptor and pad | |
| 776 | + * @param int $ecl error correction level 0-8 | |
| 777 | 777 | * @return array of error correction codewords |
| 778 | 778 | * @protected |
| 779 | 779 | */ |
| 780 | 780 | protected function getErrorCorrection($cw, $ecl) { |
| @@ -808,10 +808,10 @@ | ||
| 808 | 808 | } |
| 809 | 809 | |
| 810 | 810 | /** |
| 811 | 811 | * Create array of sequences from input |
| 812 | - * @param $code (string) code | |
| 813 | - * @return bidimensional array containing characters and classification | |
| 812 | + * @param string $code code | |
| 813 | + * @return array bi-dimensional array containing characters and classification | |
| 814 | 814 | * @protected |
| 815 | 815 | */ |
| 816 | 816 | protected function getInputSequences($code) { |
| 817 | 817 | $sequence_array = array(); // array to be returned |
| @@ -863,11 +863,11 @@ | ||
| 863 | 863 | } |
| 864 | 864 | |
| 865 | 865 | /** |
| 866 | 866 | * Compact data by mode. |
| 867 | - * @param $mode (int) compaction mode number | |
| 868 | - * @param $code (string) data to compact | |
| 869 | - * @param $addmode (boolean) if true add the mode codeword at first position | |
| 867 | + * @param int $mode compaction mode number | |
| 868 | + * @param string $code data to compact | |
| 869 | + * @param boolean $addmode if true add the mode codeword at first position | |
| 870 | 870 | * @return array of codewords |
| 871 | 871 | * @protected |
| 872 | 872 | */ |
| 873 | 873 | protected function getCompaction($mode, $code, $addmode=true) { |
| @@ -877,9 +877,9 @@ | ||
| 877 | 877 | $submode = 0; // default Alpha sub-mode |
| 878 | 878 | $txtarr = array(); // array of characters and sub-mode switching characters |
| 879 | 879 | $codelen = strlen($code); |
| 880 | 880 | for ($i = 0; $i < $codelen; ++$i) { |
| 881 | - $chval = ord($code{$i}); | |
| 881 | + $chval = ord($code[$i]); | |
| 882 | 882 | if (($k = array_search($chval, $this->textsubmodes[$submode])) !== false) { |
| 883 | 883 | // we are on the same sub-mode |
| 884 | 884 | $txtarr[] = $k; |
| 885 | 885 | } else { |
| @@ -887,9 +887,9 @@ | ||
| 887 | 887 | for ($s = 0; $s < 4; ++$s) { |
| 888 | 888 | // search new sub-mode |
| 889 | 889 | if (($s != $submode) AND (($k = array_search($chval, $this->textsubmodes[$s])) !== false)) { |
| 890 | 890 | // $s is the new submode |
| 891 | - if (((($i + 1) == $codelen) OR ((($i + 1) < $codelen) AND (array_search(ord($code{($i + 1)}), $this->textsubmodes[$submode]) !== false))) AND (($s == 3) OR (($s == 0) AND ($submode == 1)))) { | |
| 891 | + if (((($i + 1) == $codelen) OR ((($i + 1) < $codelen) AND (array_search(ord($code[($i + 1)]), $this->textsubmodes[$submode]) !== false))) AND (($s == 3) OR (($s == 0) AND ($submode == 1)))) { | |
| 892 | 892 | // shift (temporary change only for this char) |
| 893 | 893 | if ($s == 3) { |
| 894 | 894 | // shift to puntuaction |
| 895 | 895 | $txtarr[] = 29; |
| @@ -942,10 +942,10 @@ | ||
| 942 | 942 | $t = bcadd($t, ''.ord($code[5])); |
| 943 | 943 | // tmp array for the 6 bytes block |
| 944 | 944 | $cw6 = array(); |
| 945 | 945 | do { |
| 946 | - $d = bcmod($t, '900'); | |
| 947 | - $t = bcdiv($t, '900'); | |
| 946 | + $d = bcmod($t, '900', 0); | |
| 947 | + $t = bcdiv($t, '900', 0); | |
| 948 | 948 | // prepend the value to the beginning of the array |
| 949 | 949 | array_unshift($cw6, $d); |
| 950 | 950 | } while ($t != '0'); |
| 951 | 951 | // append the result array at the end |
| @@ -951,9 +951,9 @@ | ||
| 951 | 951 | // append the result array at the end |
| 952 | 952 | $cw = array_merge($cw, $cw6); |
| 953 | 953 | } else { |
| 954 | 954 | for ($i = 0; $i < $sublen; ++$i) { |
| 955 | - $cw[] = ord($code{$i}); | |
| 955 | + $cw[] = ord($code[$i]); | |
| 956 | 956 | } |
| 957 | 957 | } |
| 958 | 958 | $code = $rest; |
| 959 | 959 | } |
| @@ -968,10 +968,10 @@ | ||
| 968 | 968 | $rest = ''; |
| 969 | 969 | } |
| 970 | 970 | $t = '1'.$code; |
| 971 | 971 | do { |
| 972 | - $d = bcmod($t, '900'); | |
| 973 | - $t = bcdiv($t, '900'); | |
| 972 | + $d = bcmod($t, '900', 0); | |
| 973 | + $t = bcdiv($t, '900', 0); | |
| 974 | 974 | array_unshift($cw, $d); |
| 975 | 975 | } while ($t != '0'); |
| 976 | 976 | $code = $rest; |
| 977 | 977 | } |