From e5c11046f83eeddd90aa4a7f2041dc0b6e5d4bbe Mon Sep 17 00:00:00 2001 From: Marc van Tilburg Date: Wed, 3 Mar 2021 10:13:36 +0100 Subject: [PATCH] PHP 8 (deprecation) fixes --- include/barcodes/pdf417.php | 2 +- include/barcodes/qrcode.php | 3 ++- include/tcpdf_colors.php | 2 +- include/tcpdf_fonts.php | 18 ++++++++++-------- include/tcpdf_static.php | 6 +++--- tcpdf_barcodes_1d.php | 8 ++++---- 6 files changed, 21 insertions(+), 18 deletions(-) diff --git a/include/barcodes/pdf417.php b/include/barcodes/pdf417.php index 9a58a21..65381dc 100644 --- a/include/barcodes/pdf417.php +++ b/include/barcodes/pdf417.php @@ -740,6 +740,7 @@ class PDF417 { * @protected */ protected function getErrorCorrectionLevel($ecl, $numcw) { + $maxecl = 8; // starting error level // check for automatic levels if (($ecl < 0) OR ($ecl > 8)) { if ($numcw < 41) { @@ -755,7 +756,6 @@ class PDF417 { } } // get maximum correction level - $maxecl = 8; // starting error level $maxerrsize = (928 - $numcw); // available codewords for error while ($maxecl > 0) { $errsize = (2 << $ecl); diff --git a/include/barcodes/qrcode.php b/include/barcodes/qrcode.php index 7ef2759..a9a2124 100644 --- a/include/barcodes/qrcode.php +++ b/include/barcodes/qrcode.php @@ -1386,6 +1386,7 @@ class QRcode { $p += 2; } $this->items = $this->appendNewInputItem($this->items, QR_MODE_KJ, $p, str_split($this->dataStr)); + $run = $p; return $run; } @@ -1455,7 +1456,7 @@ class QRcode { break; } case QR_MODE_KJ: { - if ($hint == QR_MODE_KJ) { + if ($this->hint == QR_MODE_KJ) { $length = $this->eatKanji(); } else { $length = $this->eat8(); diff --git a/include/tcpdf_colors.php b/include/tcpdf_colors.php index 27fb7af..f9fc3fc 100644 --- a/include/tcpdf_colors.php +++ b/include/tcpdf_colors.php @@ -449,7 +449,7 @@ class TCPDF_COLORS { } if (!in_array($color, self::$jscolor)) { // default transparent color - $color = $jscolor[0]; + $color = self::$jscolor[0]; } return 'color.'.$color; } diff --git a/include/tcpdf_fonts.php b/include/tcpdf_fonts.php index 4f5bcf3..bd1cc77 100644 --- a/include/tcpdf_fonts.php +++ b/include/tcpdf_fonts.php @@ -557,6 +557,7 @@ class TCPDF_FONTS { $numGlyphs = TCPDF_STATIC::_getUSHORT($font, $offset); // ---------- get CIDToGIDMap ---------- $ctg = array(); + $c = 0; foreach ($encodingTables as $enctable) { // get only specified Platform ID and Encoding ID if (($enctable['platformID'] == $platid) AND ($enctable['encodingID'] == $encid)) { @@ -956,6 +957,7 @@ class TCPDF_FONTS { // sfnt version must be 0x00010000 for TrueType version 1.0. return $font; } + $c = 0; $offset += 4; // get number of tables $numTables = TCPDF_STATIC::_getUSHORT($font, $offset); @@ -1883,7 +1885,7 @@ class TCPDF_FONTS { * Converts UTF-8 character to integer value.
* Uses the getUniord() method if the value is not cached. * @param $uch (string) character string to process. - * @return integer Unicode value + * @return int Unicode value * @public static */ public static function uniord($uch) { @@ -1922,7 +1924,7 @@ class TCPDF_FONTS { * --------------------------------------------------------------------- * * @param $uch (string) character string to process. - * @return integer Unicode value + * @return int Unicode value * @author Nicola Asuni * @public static */ @@ -1995,7 +1997,7 @@ class TCPDF_FONTS { * @author Nicola Asuni * @public static */ - public static function UTF8StringToArray($str, $isunicode=true, &$currentfont=array()) { + public static function UTF8StringToArray($str, $isunicode, &$currentfont) { if ($isunicode) { // requires PCRE unicode support turned on $chars = TCPDF_STATIC::pregSplit('//','u', $str, -1, PREG_SPLIT_NO_EMPTY); @@ -2021,7 +2023,7 @@ class TCPDF_FONTS { * @since 3.2.000 (2008-06-23) * @public static */ - public static function UTF8ToLatin1($str, $isunicode=true, &$currentfont=array()) { + public static function UTF8ToLatin1($str, $isunicode, &$currentfont) { $unicode = self::UTF8StringToArray($str, $isunicode, $currentfont); // array containing UTF-8 unicode values return self::UTF8ArrToLatin1($unicode); } @@ -2037,7 +2039,7 @@ class TCPDF_FONTS { * @since 1.53.0.TC005 (2005-01-05) * @public static */ - public static function UTF8ToUTF16BE($str, $setbom=false, $isunicode=true, &$currentfont=array()) { + public static function UTF8ToUTF16BE($str, $setbom, $isunicode, &$currentfont) { if (!$isunicode) { return $str; // string is not in unicode } @@ -2057,7 +2059,7 @@ class TCPDF_FONTS { * @since 2.1.000 (2008-01-08) * @public static */ - public static function utf8StrRev($str, $setbom=false, $forcertl=false, $isunicode=true, &$currentfont=array()) { + public static function utf8StrRev($str, $setbom, $forcertl, $isunicode, &$currentfont) { return self::utf8StrArrRev(self::UTF8StringToArray($str, $isunicode, $currentfont), $str, $setbom, $forcertl, $isunicode, $currentfont); } @@ -2074,7 +2076,7 @@ class TCPDF_FONTS { * @since 4.9.000 (2010-03-27) * @public static */ - public static function utf8StrArrRev($arr, $str='', $setbom=false, $forcertl=false, $isunicode=true, &$currentfont=array()) { + public static function utf8StrArrRev($arr, $str, $setbom, $forcertl, $isunicode, &$currentfont) { return self::arrUTF8ToUTF16BE(self::utf8Bidi($arr, $str, $forcertl, $isunicode, $currentfont), $setbom); } @@ -2090,7 +2092,7 @@ class TCPDF_FONTS { * @since 2.4.000 (2008-03-06) * @public static */ - public static function utf8Bidi($ta, $str='', $forcertl=false, $isunicode=true, &$currentfont=array()) { + public static function utf8Bidi($ta, $str, $forcertl, $isunicode, &$currentfont) { // paragraph embedding level $pel = 0; // max level diff --git a/include/tcpdf_static.php b/include/tcpdf_static.php index 56ea082..6985b09 100644 --- a/include/tcpdf_static.php +++ b/include/tcpdf_static.php @@ -276,7 +276,7 @@ class TCPDF_STATIC { /** * Determine whether a string is empty. * @param $str (string) string to be checked - * @return boolean true if string is empty + * @return bool true if string is empty * @since 4.5.044 (2009-04-16) * @public static */ @@ -1136,7 +1136,7 @@ class TCPDF_STATIC { * @see setHtmlVSpace() * @public static */ - public static function fixHTMLCode($html, $default_css='', $tagvs='', $tidy_options='', &$tagvspaces=array()) { + public static function fixHTMLCode($html, $default_css, $tagvs, $tidy_options, &$tagvspaces) { // configure parameters for HTML Tidy if ($tidy_options === '') { $tidy_options = array ( @@ -2507,7 +2507,7 @@ class TCPDF_STATIC { * @since 5.0.010 (2010-05-17) * @public static */ - public static function setPageBoxes($page, $type, $llx, $lly, $urx, $ury, $points=false, $k=1, $pagedim=array()) { + public static function setPageBoxes($page, $type, $llx, $lly, $urx, $ury, $points, $k, $pagedim=array()) { if (!isset($pagedim[$page])) { // initialize array $pagedim[$page] = array(); diff --git a/tcpdf_barcodes_1d.php b/tcpdf_barcodes_1d.php index 78bfc5b..2b94afc 100644 --- a/tcpdf_barcodes_1d.php +++ b/tcpdf_barcodes_1d.php @@ -938,7 +938,7 @@ class TCPDFBarcode { } else { $t = false; // space } - $w = $seq[$j]; + $w = (float)$seq[$j]; $bararray['bcode'][$k] = array('t' => $t, 'w' => $w, 'h' => 1, 'p' => 0); $bararray['maxw'] += $w; ++$k; @@ -1271,7 +1271,7 @@ class TCPDFBarcode { } else { $t = false; // space } - $w = $seq[$j]; + $w = (float)$seq[$j]; $bararray['bcode'][] = array('t' => $t, 'w' => $w, 'h' => 1, 'p' => 0); $bararray['maxw'] += $w; } @@ -1856,7 +1856,7 @@ class TCPDFBarcode { } else { $t = false; // space } - $w = $seq[$j]; + $w = (float)$seq[$j]; $bararray['bcode'][$k] = array('t' => $t, 'w' => $w, 'h' => 1, 'p' => 0); $bararray['maxw'] += $w; ++$k; @@ -1947,7 +1947,7 @@ class TCPDFBarcode { } else { $t = false; // space } - $w = $seq[$j]; + $w = (float)$seq[$j]; $bararray['bcode'][$k] = array('t' => $t, 'w' => $w, 'h' => 1, 'p' => 0); $bararray['maxw'] += $w; ++$k;