Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX num_points parameter deprecation in imagepolygon() #24

Merged
merged 3 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading