Skip to content

Commit

Permalink
Fixes for PHP 8.2 in tcpdf_fonts.php - fixes #632 (#633)
Browse files Browse the repository at this point in the history
* Update tcpdf_fonts.php

Fixes "use of "self" in callables is deprecated" warning is arising from tcpdf_fonts.php when using PHP >= 8.2

* 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

* Update tcpdf_fonts.php

Spaces added back in before arguments

* Update tcpdf_fonts.php using get_called_class()

Maneuvers compatibility of callables inside array_map() between PHP 5.3 and 8.2 - tested.

---------

Co-authored-by: Nicola Asuni <nicolaasuni@users.noreply.github.com>
  • Loading branch information
sagehenstudio and nicolaasuni committed Sep 6, 2023
1 parent 7734617 commit 35e4147
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions include/tcpdf_fonts.php
Expand Up @@ -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(get_called_class().'::unichrUnicode', $ta);
}
return array_map(array('TCPDF_FONTS', 'unichrASCII'), $ta);
return array_map(get_called_class().'::unichrASCII', $ta);
}

/**
Expand Down Expand Up @@ -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(get_called_class().'::uniord', $chars);
} else {
$chars = str_split($str);
$carr = array_map('ord', $chars);
Expand Down

0 comments on commit 35e4147

Please sign in to comment.