From 144e787b31224d5d30f17b189e4e586e8c318824 Mon Sep 17 00:00:00 2001 From: Sagehen Studio Date: Tue, 1 Aug 2023 07:25:20 -0700 Subject: [PATCH 1/4] Update tcpdf_fonts.php Fixes "use of "self" in callables is deprecated" warning is arising from tcpdf_fonts.php when using PHP >= 8.2 --- include/tcpdf_fonts.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/tcpdf_fonts.php b/include/tcpdf_fonts.php index 30053d3e..c1e2c13c 100644 --- a/include/tcpdf_fonts.php +++ b/include/tcpdf_fonts.php @@ -1780,9 +1780,9 @@ public static function arrUTF8ToUTF16BE($unicode, $setbom=false) { */ public static function UTF8ArrayToUniArray($ta, $isunicode=true) { if ($isunicode) { - return array_map(array('TCPDF_FONTS', 'unichrUnicode'), $ta); + return array_map(self::class . "::unichrUnicode",$ta); } - return array_map(array('TCPDF_FONTS', 'unichrASCII'), $ta); + return array_map(self::class . "::unichrASCII",$ta); } /** @@ -2002,7 +2002,7 @@ 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); - $carr = array_map(array('TCPDF_FONTS', 'uniord'), $chars); + $carr = array_map(self::class . "::uniord",$chars); } else { $chars = str_split($str); $carr = array_map('ord', $chars); From d1ba250ab2805372bd53c722373dba7dbef52a15 Mon Sep 17 00:00:00 2001 From: Sagehen Studio Date: Wed, 2 Aug 2023 12:14:47 -0700 Subject: [PATCH 2/4] Update tcpdf_fonts.php for PHP 5.3-8.2 compatibility PHP 8.2 "use of "self" in callables is deprecated" yet some ways of fixing this breaks for PHP 5.3. This approach works, tested PHP 5.3.29 - 8.2.0 --- include/tcpdf_fonts.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/tcpdf_fonts.php b/include/tcpdf_fonts.php index c1e2c13c..67713cab 100644 --- a/include/tcpdf_fonts.php +++ b/include/tcpdf_fonts.php @@ -1780,9 +1780,9 @@ public static function arrUTF8ToUTF16BE($unicode, $setbom=false) { */ public static function UTF8ArrayToUniArray($ta, $isunicode=true) { if ($isunicode) { - return array_map(self::class . "::unichrUnicode",$ta); + return array_map(array('self','unichrUnicode'),$ta); } - return array_map(self::class . "::unichrASCII",$ta); + return array_map(array('self','unichrUnicode'),$ta); } /** @@ -2002,7 +2002,7 @@ 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); - $carr = array_map(self::class . "::uniord",$chars); + $carr = array_map(array('self','uniord'),$chars); } else { $chars = str_split($str); $carr = array_map('ord', $chars); From 135739a5b888a822545dc44259bedc808046e68f Mon Sep 17 00:00:00 2001 From: Sagehen Studio Date: Wed, 2 Aug 2023 12:58:05 -0700 Subject: [PATCH 3/4] Update tcpdf_fonts.php Spaces added back in before arguments --- include/tcpdf_fonts.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/tcpdf_fonts.php b/include/tcpdf_fonts.php index 67713cab..6d23954c 100644 --- a/include/tcpdf_fonts.php +++ b/include/tcpdf_fonts.php @@ -1780,9 +1780,9 @@ public static function arrUTF8ToUTF16BE($unicode, $setbom=false) { */ public static function UTF8ArrayToUniArray($ta, $isunicode=true) { if ($isunicode) { - return array_map(array('self','unichrUnicode'),$ta); + return array_map(array('self','unichrUnicode'), $ta); } - return array_map(array('self','unichrUnicode'),$ta); + return array_map(array('self','unichrUnicode'), $ta); } /** @@ -2002,7 +2002,7 @@ 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); - $carr = array_map(array('self','uniord'),$chars); + $carr = array_map(array('self','uniord'), $chars); } else { $chars = str_split($str); $carr = array_map('ord', $chars); From 9ee754eb6158508c51b65ff3315e4284ceef6918 Mon Sep 17 00:00:00 2001 From: Sagehen Studio Date: Thu, 3 Aug 2023 08:55:16 -0700 Subject: [PATCH 4/4] Update tcpdf_fonts.php using get_called_class() Maneuvers compatibility of callables inside array_map() between PHP 5.3 and 8.2 - tested. --- include/tcpdf_fonts.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/tcpdf_fonts.php b/include/tcpdf_fonts.php index 6d23954c..a04d5144 100644 --- a/include/tcpdf_fonts.php +++ b/include/tcpdf_fonts.php @@ -1780,9 +1780,9 @@ public static function arrUTF8ToUTF16BE($unicode, $setbom=false) { */ public static function UTF8ArrayToUniArray($ta, $isunicode=true) { if ($isunicode) { - return array_map(array('self','unichrUnicode'), $ta); + return array_map(get_called_class().'::unichrUnicode', $ta); } - return array_map(array('self','unichrUnicode'), $ta); + return array_map(get_called_class().'::unichrASCII', $ta); } /** @@ -2002,7 +2002,7 @@ 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); - $carr = array_map(array('self','uniord'), $chars); + $carr = array_map(get_called_class().'::uniord', $chars); } else { $chars = str_split($str); $carr = array_map('ord', $chars);