From 8ca359a5f1266daff6f6fa88a31f4e321a4fa5cf Mon Sep 17 00:00:00 2001 From: fusionate Date: Thu, 1 Jun 2023 22:53:58 +0000 Subject: [PATCH] TCPDF: Update for PHP 8.1 --- resources/tcpdf/include/tcpdf_fonts.php | 34 ++++++++++++------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/resources/tcpdf/include/tcpdf_fonts.php b/resources/tcpdf/include/tcpdf_fonts.php index 2337b93251..29a189e61a 100644 --- a/resources/tcpdf/include/tcpdf_fonts.php +++ b/resources/tcpdf/include/tcpdf_fonts.php @@ -1995,8 +1995,8 @@ class TCPDF_FONTS { * @author Nicola Asuni * @public static */ - public static function UTF8StringToArray($str, $isunicode=true, &$currentfont) { - if ($isunicode) { + public static function UTF8StringToArray($str, $isunicode, &$currentfont) { + if ($isunicode == true) { // requires PCRE unicode support turned on $chars = TCPDF_STATIC::pregSplit('//','u', $str, -1, PREG_SPLIT_NO_EMPTY); $carr = array_map(array('TCPDF_FONTS', 'uniord'), $chars); @@ -2021,8 +2021,8 @@ class TCPDF_FONTS { * @since 3.2.000 (2008-06-23) * @public static */ - public static function UTF8ToLatin1($str, $isunicode=true, &$currentfont) { - $unicode = self::UTF8StringToArray($str, $isunicode, $currentfont); // array containing UTF-8 unicode values + public static function UTF8ToLatin1($str, $isunicode, &$currentfont) { + $unicode = self::UTF8StringToArray($str, $isunicode ?? true, $currentfont); // array containing UTF-8 unicode values return self::UTF8ArrToLatin1($unicode); } @@ -2037,12 +2037,12 @@ class TCPDF_FONTS { * @since 1.53.0.TC005 (2005-01-05) * @public static */ - public static function UTF8ToUTF16BE($str, $setbom=false, $isunicode=true, &$currentfont) { - if (!$isunicode) { + public static function UTF8ToUTF16BE($str, $setbom, $isunicode, &$currentfont) { + if (!$isunicode ?? true) { return $str; // string is not in unicode } $unicode = self::UTF8StringToArray($str, $isunicode, $currentfont); // array containing UTF-8 unicode values - return self::arrUTF8ToUTF16BE($unicode, $setbom); + return self::arrUTF8ToUTF16BE($unicode, $setbom ?? false); } /** @@ -2057,8 +2057,8 @@ class TCPDF_FONTS { * @since 2.1.000 (2008-01-08) * @public static */ - public static function utf8StrRev($str, $setbom=false, $forcertl=false, $isunicode=true, &$currentfont) { - return self::utf8StrArrRev(self::UTF8StringToArray($str, $isunicode, $currentfont), $str, $setbom, $forcertl, $isunicode, $currentfont); + public static function utf8StrRev($str, $setbom, $forcertl, $isunicode, &$currentfont) { + return self::utf8StrArrRev(self::UTF8StringToArray($str, $isunicode, $currentfont), $str, $setbom ?? false, $forcertl ?? false, $isunicode ?? true, $currentfont); } /** @@ -2074,8 +2074,8 @@ 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) { - return self::arrUTF8ToUTF16BE(self::utf8Bidi($arr, $str, $forcertl, $isunicode, $currentfont), $setbom); + public static function utf8StrArrRev($arr, $str, $setbom, $forcertl, $isunicode, &$currentfont) { + return self::arrUTF8ToUTF16BE(self::utf8Bidi($arr, $str ?? '', $forcertl ?? false, $isunicode ?? true, $currentfont), $setbom ?? false); } /** @@ -2090,14 +2090,14 @@ class TCPDF_FONTS { * @since 2.4.000 (2008-03-06) * @public static */ - public static function utf8Bidi($ta, $str='', $forcertl=false, $isunicode=true, &$currentfont) { + public static function utf8Bidi($ta, $str, $forcertl, $isunicode, &$currentfont) { // paragraph embedding level $pel = 0; // max level $maxlevel = 0; - if (TCPDF_STATIC::empty_string($str)) { + if (TCPDF_STATIC::empty_string($str ?? '')) { // create string from array - $str = self::UTF8ArrSubString($ta, '', '', $isunicode); + $str = self::UTF8ArrSubString($ta, '', '', $isunicode ?? true); } // check if string contains arabic text if (preg_match(TCPDF_FONT_DATA::$uni_RE_PATTERN_ARABIC, $str)) { @@ -2106,16 +2106,16 @@ class TCPDF_FONTS { $arabic = false; } // check if string contains RTL text - if (!($forcertl OR $arabic OR preg_match(TCPDF_FONT_DATA::$uni_RE_PATTERN_RTL, $str))) { + if (!($forcertl ?? false OR $arabic OR preg_match(TCPDF_FONT_DATA::$uni_RE_PATTERN_RTL, $str))) { return $ta; } // get number of chars $numchars = count($ta); - if ($forcertl == 'R') { + if ($forcertl ?? false == 'R') { $pel = 1; - } elseif ($forcertl == 'L') { + } elseif ($forcertl ?? false == 'L') { $pel = 0; } else { // P2. In each paragraph, find the first character of type L, AL, or R.