Jelajahi Sumber

TCPDF: Update for PHP 8.1

fusionate 2 tahun lalu
induk
melakukan
1173c5a4a6
1 mengubah file dengan 17 tambahan dan 17 penghapusan
  1. 17 17
      resources/tcpdf/include/tcpdf_fonts.php

+ 17 - 17
resources/tcpdf/include/tcpdf_fonts.php

@@ -1995,8 +1995,8 @@ class TCPDF_FONTS {
 	 * @author Nicola Asuni
 	 * @author Nicola Asuni
 	 * @public static
 	 * @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
 			// requires PCRE unicode support turned on
 			$chars = TCPDF_STATIC::pregSplit('//','u', $str, -1, PREG_SPLIT_NO_EMPTY);
 			$chars = TCPDF_STATIC::pregSplit('//','u', $str, -1, PREG_SPLIT_NO_EMPTY);
 			$carr = array_map(array('TCPDF_FONTS', 'uniord'), $chars);
 			$carr = array_map(array('TCPDF_FONTS', 'uniord'), $chars);
@@ -2021,8 +2021,8 @@ class TCPDF_FONTS {
 	 * @since 3.2.000 (2008-06-23)
 	 * @since 3.2.000 (2008-06-23)
 	 * @public static
 	 * @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);
 		return self::UTF8ArrToLatin1($unicode);
 	}
 	}
 
 
@@ -2037,12 +2037,12 @@ class TCPDF_FONTS {
 	 * @since 1.53.0.TC005 (2005-01-05)
 	 * @since 1.53.0.TC005 (2005-01-05)
 	 * @public static
 	 * @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
 			return $str; // string is not in unicode
 		}
 		}
 		$unicode = self::UTF8StringToArray($str, $isunicode, $currentfont); // array containing UTF-8 unicode values
 		$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)
 	 * @since 2.1.000 (2008-01-08)
 	 * @public static
 	 * @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)
 	 * @since 4.9.000 (2010-03-27)
 	 * @public static
 	 * @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)
 	 * @since 2.4.000 (2008-03-06)
 	 * @public static
 	 * @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
 		// paragraph embedding level
 		$pel = 0;
 		$pel = 0;
 		// max level
 		// max level
 		$maxlevel = 0;
 		$maxlevel = 0;
-		if (TCPDF_STATIC::empty_string($str)) {
+		if (TCPDF_STATIC::empty_string($str ?? '')) {
 			// create string from array
 			// create string from array
-			$str = self::UTF8ArrSubString($ta, '', '', $isunicode);
+			$str = self::UTF8ArrSubString($ta, '', '', $isunicode ?? true);
 		}
 		}
 		// check if string contains arabic text
 		// check if string contains arabic text
 		if (preg_match(TCPDF_FONT_DATA::$uni_RE_PATTERN_ARABIC, $str)) {
 		if (preg_match(TCPDF_FONT_DATA::$uni_RE_PATTERN_ARABIC, $str)) {
@@ -2106,16 +2106,16 @@ class TCPDF_FONTS {
 			$arabic = false;
 			$arabic = false;
 		}
 		}
 		// check if string contains RTL text
 		// 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;
 			return $ta;
 		}
 		}
 
 
 		// get number of chars
 		// get number of chars
 		$numchars = count($ta);
 		$numchars = count($ta);
 
 
-		if ($forcertl == 'R') {
+		if ($forcertl ?? false == 'R') {
 			$pel = 1;
 			$pel = 1;
-		} elseif ($forcertl == 'L') {
+		} elseif ($forcertl ?? false == 'L') {
 			$pel = 0;
 			$pel = 0;
 		} else {
 		} else {
 			// P2. In each paragraph, find the first character of type L, AL, or R.
 			// P2. In each paragraph, find the first character of type L, AL, or R.