Skip to content

Commit

Permalink
Merge pull request #24 from ls-youssef-jlidat/fix-imagepolygon-deprec…
Browse files Browse the repository at this point in the history
…ation

FIX `num_points` parameter deprecation in `imagepolygon()`
  • Loading branch information
gsteel authored Jun 13, 2024
2 parents e8e85eb + 828af40 commit a442be8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
12 changes: 3 additions & 9 deletions src/Renderer/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -490,19 +489,14 @@ 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) {
return imagepolygon($this->resource, $points, $numPoints, $color);
}

if (PHP_VERSION_ID < 80100) {
return imagefilledpolygon($image, $points, $numPoints, $color);
return imagepolygon($this->resource, $points, $color);
}

return imagefilledpolygon($image, $points, $color);
Expand Down
6 changes: 2 additions & 4 deletions test/FactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a442be8

Please sign in to comment.