Skip to content

Commit

Permalink
remove warning, Deprecated: Implicit conversion from float to int los…
Browse files Browse the repository at this point in the history
…es precision in PHP 8.2 (#847)
  • Loading branch information
anovsiradj committed Jun 6, 2023
1 parent 6d5b83a commit b987af3
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Image/Point.php
Expand Up @@ -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));
}
Expand Down

0 comments on commit b987af3

Please sign in to comment.