From 8ad25734660628cfbd32b9e9de7aa497040348ac Mon Sep 17 00:00:00 2001 From: vlakoff <544424+vlakoff@users.noreply.github.com> Date: Sun, 16 Nov 2025 20:46:30 +0100 Subject: [PATCH] fix(encoder): use floor() for explicit truncation in MaskUtil PHP 8.1 introduced warnings for implicit float-to-int conversions when precision is lost. Using floor() makes truncation explicit, aligns with the QR code specification, and removes these warnings. --- src/Encoder/MaskUtil.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Encoder/MaskUtil.php b/src/Encoder/MaskUtil.php index 54a07ba..66f3ff1 100644 --- a/src/Encoder/MaskUtil.php +++ b/src/Encoder/MaskUtil.php @@ -172,7 +172,7 @@ public static function applyMaskPenaltyRule4(ByteMatrix $matrix) : int $numTotalCells = $height * $width; $darkRatio = $numDarkCells / $numTotalCells; - $fixedPercentVariances = (int) (abs($darkRatio - 0.5) * 20); + $fixedPercentVariances = (int) floor(abs($darkRatio - 0.5) * 20); return $fixedPercentVariances * self::N4; }