1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
From 534564dda8041e19884eb50b4694a7d5c2638abd Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@remirepo.net>
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);
|