From 534564dda8041e19884eb50b4694a7d5c2638abd Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Mon, 30 Nov 2020 09:01:24 +0100 Subject: [PATCH] fix for PHP 8 --- composer.json | 2 +- lib/GDLuminanceSource.php | 6 +++--- lib/QrReader.php | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 9187ebd..ba76df8 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ "php": ">=5.6" }, "require-dev": { - "phpunit/phpunit": "^9.0" + "phpunit/phpunit": "^5.7 | ^7.5 | ^8.0 | ^9.0" }, "autoload": { "psr-4": { diff --git a/lib/GDLuminanceSource.php b/lib/GDLuminanceSource.php index 526df82..f1f808c 100644 --- a/lib/GDLuminanceSource.php +++ b/lib/GDLuminanceSource.php @@ -52,7 +52,7 @@ public function GDLuminanceSource($gdImage, $width, $height) $this->dataHeight = $height; $this->left = 0; $this->top = 0; - $this->$gdImage = $gdImage; + $this->gdImage = $gdImage; // In order to measure pure decoding speed, we convert the entire image to a greyscale array @@ -65,8 +65,8 @@ public function GDLuminanceSource($gdImage, $width, $height) for ($j = 0; $j < $height; $j++) { for ($i = 0; $i < $width; $i++) { - $argb = imagecolorat($this->$gdImage, $i, $j); - $pixel = imagecolorsforindex($this->$gdImage, $argb); + $argb = imagecolorat($this->gdImage, $i, $j); + $pixel = imagecolorsforindex($this->gdImage, $argb); $r = $pixel['red']; $g = $pixel['green']; $b = $pixel['blue']; diff --git a/lib/QrReader.php b/lib/QrReader.php index 200f910..b7dd1ea 100644 --- a/lib/QrReader.php +++ b/lib/QrReader.php @@ -62,7 +62,7 @@ public function __construct($imgSource, $sourceType = QrReader::SOURCE_TYPE_FILE $height = $im->getImageHeight(); $source = new IMagickLuminanceSource($im, $width, $height); } else { - if (!is_resource($im)) { + if (!is_resource($im) && !is_object($im)) { throw new \InvalidArgumentException('Invalid image source.'); } $width = imagesx($im);