Skip to content

Commit b987af3

Browse files
authored
remove warning, Deprecated: Implicit conversion from float to int loses precision in PHP 8.2 (#847)
1 parent 6d5b83a commit b987af3

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/Image/Point.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ final class Point implements PointInterface
3838
*/
3939
public function __construct($x, $y)
4040
{
41+
if (!is_numeric($x) || !is_numeric($y)) {
42+
throw new InvalidArgumentException('x or y must be numeric');
43+
}
44+
45+
$x = (int) round((float) $x);
46+
$y = (int) round((float) $y);
47+
4148
if ($x < 0 || $y < 0) {
4249
throw new InvalidArgumentException(sprintf('A coordinate cannot be positioned outside of a bounding box (x: %s, y: %s given)', $x, $y));
4350
}

0 commit comments

Comments
 (0)