Skip to content

Commit

Permalink
Fix php8 warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Franck ALARY committed Aug 6, 2023
1 parent bd17e2a commit b53cdce
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ private function convertPosX($posX, int $width = 0): int
case static::ALIGN_LEFT:
return 0;
case static::ALIGN_CENTER:
return $this->width / 2 - $width / 2;
return \round($this->width / 2 - $width / 2);
case static::ALIGN_RIGHT:
return $this->width - $width;
}
Expand All @@ -400,7 +400,7 @@ private function convertPosY($posY, int $height = 0): int
case static::ALIGN_TOP:
return 0;
case static::ALIGN_MIDDLE:
return $this->height / 2 - $height / 2;
return \round($this->height / 2 - $height / 2);
case static::ALIGN_BOTTOM:
return $this->height - $height;
}
Expand Down Expand Up @@ -960,7 +960,7 @@ public function writeTextAndGetBoundingBox(string $string, string $fontPath, flo
private function imagettftextWithSpacing($image, float $size, float $angle, float $x, float $y, int $color, string $font, string $text, float $spacing = 0)
{
if ($spacing == 0) {
return \imagettftext($image, $size, $angle, $x, $y, $color, $font, $text);
return \imagettftext($image, $size, $angle, \round($x), \round($y), $color, $font, $text);
} else {
$length = \mb_strlen($text);

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

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

Expand Down

0 comments on commit b53cdce

Please sign in to comment.