Deprecate $num_points parameter of image(open|filled)polygon

Cf. <https://wiki.php.net/rfc/deprecations_php_8_1#num_points_parameter_of_image_open_filled_polygon>.

Co-authored-by: Máté Kocsis <kocsismate@woohoolabs.com>
Co-authored-by: George Peter Banyard <7906688+Girgias@users.noreply.github.com>

Closes GH-6789.
This commit is contained in:
Christoph M. Becker 2021-03-21 17:47:12 +01:00
parent 4b3615a33f
commit e1285c4aa5
No known key found for this signature in database
GPG Key ID: D66C9593118BCCB6
3 changed files with 9 additions and 1 deletions

View File

@ -370,6 +370,9 @@ PHP 8.1 UPGRADE NOTES
. The filter.default ini setting is deprecated.
RFC: https://wiki.php.net/rfc/deprecations_php_8_1
- GD:
. The $num_points parameter of image(open|filled)polygon has been deprecated.
- Hash:
. The mhash(), mhash_keygen_s2k(), mhash_count(), mhash_get_block_size() and
mhash_get_hash_name() functions are deprecated. Use the hash_*() APIs

View File

@ -2726,6 +2726,8 @@ static void php_imagepolygon(INTERNAL_FUNCTION_PARAMETERS, int filled)
RETURN_THROWS();
}
NPOINTS /= 2;
} else {
php_error_docref(NULL, E_DEPRECATED, "Using the $num_points parameter is deprecated");
}
im = php_gd_libgdimageptr_from_zval_p(IM);

View File

@ -14,6 +14,9 @@ trycatch_dump(
fn () => imagepolygon($g, array(200,10, 200,100, 280,100), 2, $fgnd)
);
?>
--EXPECT--
--EXPECTF--
Deprecated: imagefilledpolygon(): Using the $num_points parameter is deprecated in %s on line %d
!! [ValueError] imagefilledpolygon(): Argument #3 ($num_points_or_color) must be greater than or equal to 3
Deprecated: imagepolygon(): Using the $num_points parameter is deprecated in %s on line %d
!! [ValueError] imagepolygon(): Argument #3 ($num_points_or_color) must be greater than or equal to 3