Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

php 8+ edge cases fixes #630

Merged
merged 2 commits into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions include/tcpdf_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -1780,7 +1780,7 @@ public static function pregSplit($pattern, $modifiers, $subject, $limit=NULL, $f
if ($ret === false) {
return array();
}
return $ret;
return is_array($ret) ? $ret : array();
}
// preg_split is bugged - try alternative solution
$ret = array();
Expand Down Expand Up @@ -2124,7 +2124,7 @@ public static function _freadint($f) {
* Array of page formats
* measures are calculated in this way: (inches * 72) or (millimeters * 72 / 25.4)
* @public static
*
*
* @var array<string,float[]>
*/
public static $page_formats = array(
Expand Down
4 changes: 3 additions & 1 deletion tcpdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -6409,7 +6409,7 @@ public function Write($h, $txt, $link='', $fill=false, $align='', $ln=false, $st
// calculate maximum width for a single character on string
$chrw = $this->GetArrStringWidth($chars, '', '', 0, true);
array_walk($chrw, array($this, 'getRawCharWidth'));
$maxchwidth = max($chrw);
$maxchwidth = ((is_array($chrw) || $chrw instanceof Countable) && count($chrw) > 0) ? max($chrw) : 0;
nicolaasuni marked this conversation as resolved.
Show resolved Hide resolved
// get array of chars
$uchars = TCPDF_FONTS::UTF8ArrayToUniArray($chars, $this->isunicode);
// get the number of characters
Expand Down Expand Up @@ -6872,6 +6872,8 @@ protected function fitBlock($w, $h, $x, $y, $fitonpage=false) {
}
// resize the block to be contained on the remaining available page or column space
if ($fitonpage) {
// fallback to avoid division by zero
$h = $h == 0 ? 1 : $h;
$ratio_wh = ($w / $h);
if (($y + $h) > $this->PageBreakTrigger) {
$h = $this->PageBreakTrigger - $y;
Expand Down