From 0c866231e083c4a818584f9f10604ade81d84665 Mon Sep 17 00:00:00 2001 From: ADmad Date: Wed, 3 Mar 2021 18:32:27 +0530 Subject: [PATCH] Bump up psalm to level 4. Intervention functions like resize(), resizeCanvas() only accept int values hence float values are rounded where necessary. --- psalm.xml | 2 +- src/Manipulators/Border.php | 20 ++++++++++---------- src/Manipulators/Helpers/Dimension.php | 4 ++-- src/Manipulators/Orientation.php | 2 +- src/Manipulators/Size.php | 10 +++++----- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/psalm.xml b/psalm.xml index 8dc065a2..3e4e3d08 100644 --- a/psalm.xml +++ b/psalm.xml @@ -1,6 +1,6 @@ rectangle( - $width / 2, - $width / 2, - $image->width() - ($width / 2), - $image->height() - ($width / 2), + (int) round($width / 2), + (int) round($width / 2), + (int) round($image->width() - ($width / 2)), + (int) round($image->height() - ($width / 2)), function ($draw) use ($width, $color) { $draw->border($width, $color); } @@ -161,12 +161,12 @@ public function runShrink(Image $image, $width, $color) { return $image ->resize( - $image->width() - ($width * 2), - $image->height() - ($width * 2) + (int) round($image->width() - ($width * 2)), + (int) round($image->height() - ($width * 2)) ) ->resizeCanvas( - $width * 2, - $width * 2, + (int) round($width * 2), + (int) round($width * 2), 'center', true, $color @@ -185,8 +185,8 @@ public function runShrink(Image $image, $width, $color) public function runExpand(Image $image, $width, $color) { return $image->resizeCanvas( - $width * 2, - $width * 2, + (int) round($width * 2), + (int) round($width * 2), 'center', true, $color diff --git a/src/Manipulators/Helpers/Dimension.php b/src/Manipulators/Helpers/Dimension.php index 83b8b1a3..ac9fda4b 100644 --- a/src/Manipulators/Helpers/Dimension.php +++ b/src/Manipulators/Helpers/Dimension.php @@ -16,7 +16,7 @@ class Dimension /** * The device pixel ratio. * - * @var int + * @var float */ protected $dpr; @@ -24,7 +24,7 @@ class Dimension * Create dimension helper instance. * * @param Image $image The source image. - * @param int $dpr The device pixel ratio. + * @param float $dpr The device pixel ratio. */ public function __construct(Image $image, $dpr = 1) { diff --git a/src/Manipulators/Orientation.php b/src/Manipulators/Orientation.php index 4466adb0..231cbebe 100644 --- a/src/Manipulators/Orientation.php +++ b/src/Manipulators/Orientation.php @@ -24,7 +24,7 @@ public function run(Image $image) return $image->orientate(); } - return $image->rotate($orientation); + return $image->rotate((float) $orientation); } /** diff --git a/src/Manipulators/Size.php b/src/Manipulators/Size.php index f8915a26..68493634 100644 --- a/src/Manipulators/Size.php +++ b/src/Manipulators/Size.php @@ -183,9 +183,9 @@ public function resolveMissingDimensions(Image $image, $width, $height) /** * Apply the device pixel ratio. * - * @param int $width The target image width. - * @param int $height The target image height. - * @param int $dpr The device pixel ratio. + * @param int $width The target image width. + * @param int $height The target image height. + * @param float $dpr The device pixel ratio. * * @return int[] The modified width and height. */ @@ -195,8 +195,8 @@ public function applyDpr($width, $height, $dpr) $height = $height * $dpr; return [ - (int) $width, - (int) $height, + (int) round($width), + (int) round($height), ]; }