From b987af31043bf99729d8f8e44b30130e38c56010 Mon Sep 17 00:00:00 2001 From: MDMCDC Date: Tue, 6 Jun 2023 15:44:02 +0700 Subject: [PATCH] remove warning, Deprecated: Implicit conversion from float to int loses precision in PHP 8.2 (#847) --- src/Image/Point.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Image/Point.php b/src/Image/Point.php index 6119b0ee1..abac86ca2 100644 --- a/src/Image/Point.php +++ b/src/Image/Point.php @@ -38,6 +38,13 @@ final class Point implements PointInterface */ public function __construct($x, $y) { + if (!is_numeric($x) || !is_numeric($y)) { + throw new InvalidArgumentException('x or y must be numeric'); + } + + $x = (int) round((float) $x); + $y = (int) round((float) $y); + if ($x < 0 || $y < 0) { throw new InvalidArgumentException(sprintf('A coordinate cannot be positioned outside of a bounding box (x: %s, y: %s given)', $x, $y)); }