Skip to content

Commit b53cdce

Browse files
committed
Fix php8 warnings
1 parent bd17e2a commit b53cdce

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/Image.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ private function convertPosX($posX, int $width = 0): int
380380
case static::ALIGN_LEFT:
381381
return 0;
382382
case static::ALIGN_CENTER:
383-
return $this->width / 2 - $width / 2;
383+
return \round($this->width / 2 - $width / 2);
384384
case static::ALIGN_RIGHT:
385385
return $this->width - $width;
386386
}
@@ -400,7 +400,7 @@ private function convertPosY($posY, int $height = 0): int
400400
case static::ALIGN_TOP:
401401
return 0;
402402
case static::ALIGN_MIDDLE:
403-
return $this->height / 2 - $height / 2;
403+
return \round($this->height / 2 - $height / 2);
404404
case static::ALIGN_BOTTOM:
405405
return $this->height - $height;
406406
}
@@ -960,7 +960,7 @@ public function writeTextAndGetBoundingBox(string $string, string $fontPath, flo
960960
private function imagettftextWithSpacing($image, float $size, float $angle, float $x, float $y, int $color, string $font, string $text, float $spacing = 0)
961961
{
962962
if ($spacing == 0) {
963-
return \imagettftext($image, $size, $angle, $x, $y, $color, $font, $text);
963+
return \imagettftext($image, $size, $angle, \round($x), \round($y), $color, $font, $text);
964964
} else {
965965
$length = \mb_strlen($text);
966966

@@ -975,7 +975,7 @@ private function imagettftextWithSpacing($image, float $size, float $angle, floa
975975

976976
for ($i = 0; $i < $length; ++$i) {
977977
$char = \mb_substr($text, $i, 1);
978-
\imagettftext($image, $size, $angle, $letterPos['x'], $letterPos['y'], $color, $font, $char);
978+
\imagettftext($image, $size, $angle, \round($letterPos['x']), \round($letterPos['y']), $color, $font, $char);
979979
$bbox = \imagettfbbox($size, 0, $font, $char);
980980
$letterPos = Geometry2D::getDstXY($letterPos['x'], $letterPos['y'], $angle, $spacing + $bbox[2]);
981981

0 commit comments

Comments
 (0)