From cbc89f819512049e3307cc8b51f38442f9d0aa68 Mon Sep 17 00:00:00 2001 From: Youssef JLIDAT Date: Fri, 10 May 2024 10:34:01 -0400 Subject: [PATCH 1/3] FIX num_points parameter deprecation in imagepolygon The parameter `num_points` has been deprecated in PHP 8.1 Signed-off-by: Youssef JLIDAT --- src/Renderer/Image.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Renderer/Image.php b/src/Renderer/Image.php index 290d942e..4105c062 100644 --- a/src/Renderer/Image.php +++ b/src/Renderer/Image.php @@ -498,7 +498,10 @@ protected function drawText($text, $size, $position, $font, $color, $alignment = protected function imageFilledPolygonWrapper($image, array $points, $numPoints, $color, $filled) { if (! $filled) { - return imagepolygon($this->resource, $points, $numPoints, $color); + if (PHP_VERSION_ID < 80100) { + return imagepolygon($this->resource, $points, $numPoints, $color); + } + return imagepolygon($this->resource, $points, $color); } if (PHP_VERSION_ID < 80100) { From a835f3ebff105d9f08f7a03d2b07bb06c8f4569c Mon Sep 17 00:00:00 2001 From: Youssef JLIDAT Date: Thu, 16 May 2024 10:48:08 -0400 Subject: [PATCH 2/3] Remove PHP version check in `imagepolygon()` and `imagefilledpolygon()` Signed-off-by: Youssef JLIDAT --- src/Renderer/Image.php | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/Renderer/Image.php b/src/Renderer/Image.php index 4105c062..2f43fbd2 100644 --- a/src/Renderer/Image.php +++ b/src/Renderer/Image.php @@ -39,7 +39,6 @@ use const E_WARNING; use const PHP_MAJOR_VERSION; -use const PHP_VERSION_ID; /** * Class for rendering the barcode as image @@ -397,7 +396,7 @@ protected function drawPolygon($points, $color, $filled = true) $color & 0x0000FF ); - $this->imageFilledPolygonWrapper($this->resource, $newPoints, 4, $allocatedColor, $filled); + $this->imageFilledPolygonWrapper($this->resource, $newPoints, $allocatedColor, $filled); } /** @@ -490,24 +489,16 @@ protected function drawText($text, $size, $position, $font, $color, $alignment = /** * @param GdImage|resource $image * @param array $points - * @param int $numPoints * @param int $color * @param bool $filled * @return bool */ - protected function imageFilledPolygonWrapper($image, array $points, $numPoints, $color, $filled) + protected function imageFilledPolygonWrapper($image, array $points, $color, $filled) { if (! $filled) { - if (PHP_VERSION_ID < 80100) { - return imagepolygon($this->resource, $points, $numPoints, $color); - } return imagepolygon($this->resource, $points, $color); } - if (PHP_VERSION_ID < 80100) { - return imagefilledpolygon($image, $points, $numPoints, $color); - } - return imagefilledpolygon($image, $points, $color); } From 828af4031c0db7ba6cbff8dcd7c35baf100fc2db Mon Sep 17 00:00:00 2001 From: George Steel Date: Thu, 13 Jun 2024 21:20:56 +0100 Subject: [PATCH 3/3] Fix reflection deprecations in tests --- test/FactoryTest.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/test/FactoryTest.php b/test/FactoryTest.php index 1bdaca96..aac9403b 100644 --- a/test/FactoryTest.php +++ b/test/FactoryTest.php @@ -55,12 +55,10 @@ public function setUp(): void $r = new ReflectionClass(Barcode\Barcode::class); $rObjectPlugins = $r->getProperty('objectPlugins'); - $rObjectPlugins->setAccessible(true); - $rObjectPlugins->setValue(null); + $rObjectPlugins->setValue($r, null); $rRendererPlugins = $r->getProperty('rendererPlugins'); - $rRendererPlugins->setAccessible(true); - $rRendererPlugins->setValue(null); + $rRendererPlugins->setValue($r, null); } public function tearDown(): void