]> granicus.if.org Git - php/commitdiff
Return bool from imageinterlace()
authorNikita Popov <nikita.ppv@gmail.com>
Wed, 17 Mar 2021 14:05:09 +0000 (15:05 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Wed, 17 Mar 2021 14:05:09 +0000 (15:05 +0100)
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
ext/gd/gd.stub.php
ext/gd/gd_arginfo.h
ext/gd/tests/bug77700.phpt
ext/gd/tests/imageinterlace_basic.phpt
ext/gd/tests/imageinterlace_variation1.phpt
ext/gd/tests/imageinterlace_variation2.phpt

index b0abecc6f7282e29e3f983762e1c9fba7843cc1a..46704c60cfd044a7d05e7bb8ae9a1be1dcb0148d 100644 (file)
@@ -2601,7 +2601,7 @@ PHP_FUNCTION(imageinterlace)
                gdImageInterlace(im, INT);
        }
 
-       RETURN_LONG(gdImageGetInterlaced(im));
+       RETURN_BOOL(gdImageGetInterlaced(im));
 }
 /* }}} */
 
index 27290ff4aba61d4f1165e51c57c398a868928609..89a3f0e0f387b7a333e631e7790257ffac760462 100644 (file)
@@ -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 {}
 
index 4baeccace3583d152b418880f4bf82e64dd0df93..ffa8b5565cd7a94ee88ec8ad6897e967ae4239bd 100644 (file)
@@ -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()
index 27b93cf0d041dbeccc05b770b12214856961565f..a14a2259ebc6d47a616e60743d53b1e81c7c5246 100644 (file)
@@ -8,14 +8,14 @@ if (!extension_loaded('gd')) die('skip gd extension not available');
 <?php
 $im = imagecreatetruecolor(10, 10);
 imagefilledrectangle($im, 0, 0, 9, 9, imagecolorallocate($im, 255, 255, 255));
-imageinterlace($im, 1);
+imageinterlace($im, true);
 imagegif($im, __DIR__ . 'bug77700.gif');
 
 $im = imagecreatefromgif(__DIR__ . 'bug77700.gif');
 var_dump(imageinterlace($im));
 ?>
 --EXPECT--
-int(1)
+bool(true)
 --CLEAN--
 <?php
 unlink(__DIR__ . 'bug77700.gif');
index 62d99bcf91eb35094260b3853b194c652751a33b..5ea674e60619e2c5c333a16b0dd729f324593409 100644 (file)
@@ -14,4 +14,4 @@ $image = imagecreatetruecolor(100, 100);
 var_dump(imageinterlace($image));
 ?>
 --EXPECT--
-int(0)
+bool(false)
index d8eb7972fa18a7356cfd6e6d2e17702602214271..477aa9d259a1a667ede8938e1f347a93007c0ff6 100644 (file)
@@ -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)
index f1ee51502df6fcc6c1c6ae631d25497ca337db82..37370cec03ebd6df7354d2bf888152433d1404cf 100644 (file)
@@ -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)