From c17434429d4de525a8eb8c33af77324e03a14684 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Wed, 17 Mar 2021 15:05:09 +0100 Subject: Return bool from imageinterlace() The function accepts a bool since PHP 8.0, so it should also return a bool to keep things consistent. Furthermore a null return from this functions is not possible. --- ext/gd/gd.c | 2 +- ext/gd/gd.stub.php | 2 +- ext/gd/gd_arginfo.h | 4 ++-- ext/gd/tests/bug77700.phpt | 4 ++-- ext/gd/tests/imageinterlace_basic.phpt | 2 +- ext/gd/tests/imageinterlace_variation1.phpt | 6 +++--- ext/gd/tests/imageinterlace_variation2.phpt | 8 ++++---- 7 files changed, 14 insertions(+), 14 deletions(-) (limited to 'ext/gd') diff --git a/ext/gd/gd.c b/ext/gd/gd.c index b0abecc6f7..46704c60cf 100644 --- a/ext/gd/gd.c +++ b/ext/gd/gd.c @@ -2601,7 +2601,7 @@ PHP_FUNCTION(imageinterlace) gdImageInterlace(im, INT); } - RETURN_LONG(gdImageGetInterlaced(im)); + RETURN_BOOL(gdImageGetInterlaced(im)); } /* }}} */ diff --git a/ext/gd/gd.stub.php b/ext/gd/gd.stub.php index 27290ff4ab..89a3f0e0f3 100644 --- a/ext/gd/gd.stub.php +++ b/ext/gd/gd.stub.php @@ -179,7 +179,7 @@ function imagecolorstotal(GdImage $image): int {} function imagecolortransparent(GdImage $image, ?int $color = null): ?int {} -function imageinterlace(GdImage $image, ?bool $enable = null): ?int {} +function imageinterlace(GdImage $image, ?bool $enable = null): bool {} function imagepolygon(GdImage $image, array $points, int $num_points_or_color, ?int $color = null): bool {} diff --git a/ext/gd/gd_arginfo.h b/ext/gd/gd_arginfo.h index 4baeccace3..ffa8b5565c 100644 --- a/ext/gd/gd_arginfo.h +++ b/ext/gd/gd_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 63898b501cc3ae38585fe0c6f70a9f7865fbee4d */ + * Stub hash: 155175c4f5b60aaed37df2210ae6a5e7f979dae2 */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gd_info, 0, 0, IS_ARRAY, 0) ZEND_END_ARG_INFO() @@ -363,7 +363,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagecolortransparent, 0, 1, IS_ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, color, IS_LONG, 1, "null") ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imageinterlace, 0, 1, IS_LONG, 1) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imageinterlace, 0, 1, _IS_BOOL, 0) ZEND_ARG_OBJ_INFO(0, image, GdImage, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, enable, _IS_BOOL, 1, "null") ZEND_END_ARG_INFO() diff --git a/ext/gd/tests/bug77700.phpt b/ext/gd/tests/bug77700.phpt index 27b93cf0d0..a14a2259eb 100644 --- a/ext/gd/tests/bug77700.phpt +++ b/ext/gd/tests/bug77700.phpt @@ -8,14 +8,14 @@ if (!extension_loaded('gd')) die('skip gd extension not available'); --EXPECT-- -int(1) +bool(true) --CLEAN-- --EXPECT-- -int(0) +bool(false) diff --git a/ext/gd/tests/imageinterlace_variation1.phpt b/ext/gd/tests/imageinterlace_variation1.phpt index d8eb7972fa..477aa9d259 100644 --- a/ext/gd/tests/imageinterlace_variation1.phpt +++ b/ext/gd/tests/imageinterlace_variation1.phpt @@ -12,9 +12,9 @@ if (!extension_loaded("gd")) die("skip GD not present"); $image = imagecreatetruecolor(100, 100); -var_dump(imageinterlace($image, 1)); +var_dump(imageinterlace($image, true)); var_dump(imageinterlace($image)); ?> --EXPECT-- -int(1) -int(1) +bool(true) +bool(true) diff --git a/ext/gd/tests/imageinterlace_variation2.phpt b/ext/gd/tests/imageinterlace_variation2.phpt index f1ee51502d..37370cec03 100644 --- a/ext/gd/tests/imageinterlace_variation2.phpt +++ b/ext/gd/tests/imageinterlace_variation2.phpt @@ -13,12 +13,12 @@ if (!extension_loaded("gd")) die("skip GD not present"); $image = imagecreatetruecolor(100, 100); //setting the interlace bit to on -imageinterlace($image, 1); +imageinterlace($image, true); //setting de interlace bit to off -var_dump(imageinterlace($image, 0)); +var_dump(imageinterlace($image, false)); var_dump(imageinterlace($image)); ?> --EXPECT-- -int(0) -int(0) +bool(false) +bool(false) -- cgit v1.2.1