Skip to content

Commit 8bcaaa3

Browse files
committed
Fix some imagecolor*() return types
These functions either return always a valid color, or `-1` on failure, but never `false`. Closes GH-7041.
1 parent 25e2471 commit 8bcaaa3

File tree

2 files changed

+24
-13
lines changed

2 files changed

+24
-13
lines changed

ext/gd/gd.stub.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ function imagelayereffect(GdImage $image, int $effect): bool {}
3636

3737
function imagecolorallocatealpha(GdImage $image, int $red, int $green, int $blue, int $alpha): int|false {}
3838

39-
function imagecolorresolvealpha(GdImage $image, int $red, int $green, int $blue, int $alpha): int|false {}
39+
function imagecolorresolvealpha(GdImage $image, int $red, int $green, int $blue, int $alpha): int {}
4040

41-
function imagecolorclosestalpha(GdImage $image, int $red, int $green, int $blue, int $alpha): int|false {}
41+
function imagecolorclosestalpha(GdImage $image, int $red, int $green, int $blue, int $alpha): int {}
4242

4343
function imagecolorexactalpha(GdImage $image, int $red, int $green, int $blue, int $alpha): int|false {}
4444

@@ -141,15 +141,15 @@ function imagepalettecopy(GdImage $dst, GdImage $src): void {}
141141

142142
function imagecolorat(GdImage $image, int $x, int $y): int|false {}
143143

144-
function imagecolorclosest(GdImage $image, int $red, int $green, int $blue): int|false {}
144+
function imagecolorclosest(GdImage $image, int $red, int $green, int $blue): int {}
145145

146-
function imagecolorclosesthwb(GdImage $image, int $red, int $green, int $blue): int|false {}
146+
function imagecolorclosesthwb(GdImage $image, int $red, int $green, int $blue): int {}
147147

148148
function imagecolordeallocate(GdImage $image, int $color): bool {}
149149

150-
function imagecolorresolve(GdImage $image, int $red, int $green, int $blue): int|false {}
150+
function imagecolorresolve(GdImage $image, int $red, int $green, int $blue): int {}
151151

152-
function imagecolorexact(GdImage $image, int $red, int $green, int $blue): int|false {}
152+
function imagecolorexact(GdImage $image, int $red, int $green, int $blue): int {}
153153

154154
function imagecolorset(GdImage $image, int $color, int $red, int $green, int $blue, int $alpha = 0): ?bool {}
155155

ext/gd/gd_arginfo.h

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: ef2df95a30077f088ccfa9b02341385f77caaa64 */
2+
* Stub hash: 4efa17e2238f259e359b8f64967677c0ac2abfdb */
33

44
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gd_info, 0, 0, IS_ARRAY, 0)
55
ZEND_END_ARG_INFO()
@@ -81,9 +81,15 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imagecolorallocatealpha, 0, 5, M
8181
ZEND_ARG_TYPE_INFO(0, alpha, IS_LONG, 0)
8282
ZEND_END_ARG_INFO()
8383

84-
#define arginfo_imagecolorresolvealpha arginfo_imagecolorallocatealpha
84+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagecolorresolvealpha, 0, 5, IS_LONG, 0)
85+
ZEND_ARG_OBJ_INFO(0, image, GdImage, 0)
86+
ZEND_ARG_TYPE_INFO(0, red, IS_LONG, 0)
87+
ZEND_ARG_TYPE_INFO(0, green, IS_LONG, 0)
88+
ZEND_ARG_TYPE_INFO(0, blue, IS_LONG, 0)
89+
ZEND_ARG_TYPE_INFO(0, alpha, IS_LONG, 0)
90+
ZEND_END_ARG_INFO()
8591

86-
#define arginfo_imagecolorclosestalpha arginfo_imagecolorallocatealpha
92+
#define arginfo_imagecolorclosestalpha arginfo_imagecolorresolvealpha
8793

8894
#define arginfo_imagecolorexactalpha arginfo_imagecolorallocatealpha
8995

@@ -276,18 +282,23 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imagecolorat, 0, 3, MAY_BE_LONG|
276282
ZEND_ARG_TYPE_INFO(0, y, IS_LONG, 0)
277283
ZEND_END_ARG_INFO()
278284

279-
#define arginfo_imagecolorclosest arginfo_imagecolorallocate
285+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagecolorclosest, 0, 4, IS_LONG, 0)
286+
ZEND_ARG_OBJ_INFO(0, image, GdImage, 0)
287+
ZEND_ARG_TYPE_INFO(0, red, IS_LONG, 0)
288+
ZEND_ARG_TYPE_INFO(0, green, IS_LONG, 0)
289+
ZEND_ARG_TYPE_INFO(0, blue, IS_LONG, 0)
290+
ZEND_END_ARG_INFO()
280291

281-
#define arginfo_imagecolorclosesthwb arginfo_imagecolorallocate
292+
#define arginfo_imagecolorclosesthwb arginfo_imagecolorclosest
282293

283294
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagecolordeallocate, 0, 2, _IS_BOOL, 0)
284295
ZEND_ARG_OBJ_INFO(0, image, GdImage, 0)
285296
ZEND_ARG_TYPE_INFO(0, color, IS_LONG, 0)
286297
ZEND_END_ARG_INFO()
287298

288-
#define arginfo_imagecolorresolve arginfo_imagecolorallocate
299+
#define arginfo_imagecolorresolve arginfo_imagecolorclosest
289300

290-
#define arginfo_imagecolorexact arginfo_imagecolorallocate
301+
#define arginfo_imagecolorexact arginfo_imagecolorclosest
291302

292303
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagecolorset, 0, 5, _IS_BOOL, 1)
293304
ZEND_ARG_OBJ_INFO(0, image, GdImage, 0)

0 commit comments

Comments
 (0)