From 4fe97113482863939b83ac1e708b3d7c2b2a5103 Mon Sep 17 00:00:00 2001 From: sistemazul <38798279+sistemazul@users.noreply.github.com> Date: Mon, 15 Sep 2025 11:03:36 -0600 Subject: [PATCH] Fix: Prevent implicit float-to-int conversion in PHP 8.1 when indexing arrays in qrencode.php --- qrcode/qrencode.php | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/qrcode/qrencode.php b/qrcode/qrencode.php index fc909fa..e790e64 100644 --- a/qrcode/qrencode.php +++ b/qrcode/qrencode.php @@ -127,26 +127,25 @@ public function init(array $spec) } //---------------------------------------------------------------------- - public function getCode() + public function getCode() { - $ret; - + $ret = NULL; if($this->count < $this->dataLength) { - $row = $this->count % $this->blocks; - $col = $this->count / $this->blocks; + $row = (int) $this->count % $this->blocks; + $col = intdiv($this->count, $this->blocks); if($col >= $this->rsblocks[0]->dataLength) { $row += $this->b1; } $ret = $this->rsblocks[$row]->data[$col]; } else if($this->count < $this->dataLength + $this->eccLength) { - $row = ($this->count - $this->dataLength) % $this->blocks; - $col = ($this->count - $this->dataLength) / $this->blocks; + $row = (int) (($this->count - $this->dataLength) % $this->blocks); + $col = (int) (($this->count - $this->dataLength) / $this->blocks); $ret = $this->rsblocks[$row]->ecc[$col]; } else { return 0; } $this->count++; - + return $ret; } }