-
-
Save krakjoe/9cb036e3dfae225c1eafcd4db2efab88 to your computer and use it in GitHub Desktop.
gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/ext/gd/gd.c b/ext/gd/gd.c | |
index 4f93d62c51..26da367544 100644 | |
--- a/ext/gd/gd.c | |
+++ b/ext/gd/gd.c | |
@@ -55,10 +55,10 @@ | |
# include <X11/xpm.h> | |
#endif | |
-# include "gd_compat.h" | |
+#include "gd_compat.h" | |
-static int le_gd, le_gd_font; | |
+static int le_gd_font; | |
#include <gd.h> | |
#include <gd_errors.h> | |
@@ -68,6 +68,11 @@ static int le_gd, le_gd_font; | |
#include <gdfontl.h> /* 4 Large font */ | |
#include <gdfontg.h> /* 5 Giant font */ | |
+typedef struct _php_gd_image_object { | |
+ gdImagePtr image; | |
+ zend_object std; | |
+} php_gd_image_object; | |
+ | |
#if defined(HAVE_GD_FREETYPE) && defined(HAVE_GD_BUNDLED) | |
# include <ft2build.h> | |
# include FT_FREETYPE_H | |
@@ -306,14 +311,6 @@ PHP_INI_BEGIN() | |
PHP_INI_END() | |
/* }}} */ | |
-/* {{{ php_free_gd_image | |
- */ | |
-static void php_free_gd_image(zend_resource *rsrc) | |
-{ | |
- gdImageDestroy((gdImagePtr) rsrc->ptr); | |
-} | |
-/* }}} */ | |
- | |
/* {{{ php_free_gd_font | |
*/ | |
static void php_free_gd_font(zend_resource *rsrc) | |
@@ -351,13 +348,77 @@ void php_gd_error_method(int type, const char *format, va_list args) | |
} | |
/* }}} */ | |
+static zend_object_handlers php_gd_image_object_handlers; | |
+ | |
+static const zend_function_entry php_gd_image_methods[] = { | |
+ PHP_FE_END | |
+}; | |
+ | |
+static zend_always_inline php_gd_image_object* php_gd_image_object_fetch(zend_object *obj) { | |
+ return (php_gd_image_object*) (((char*) obj) - XtOffsetOf(php_gd_image_object, std)); | |
+} | |
+ | |
+static zend_always_inline gdImagePtr php_gd_image_object_from(zval *zv) { | |
+ php_gd_image_object *object = | |
+ php_gd_image_object_fetch(Z_OBJ_P(zv)); | |
+ | |
+ return object->image; | |
+} | |
+ | |
+void* php_gd_image_object_cast(zval *zv) { | |
+ return php_gd_image_object_from(zv); | |
+} | |
+ | |
+static zend_object* php_gd_image_object_create(zend_class_entry *class_type) { | |
+ php_gd_image_object* intern = emalloc(sizeof(php_gd_image_object) + zend_object_properties_size(class_type)); | |
+ memset(intern, 0, sizeof(php_gd_image_object)); | |
+ | |
+ zend_object_std_init(&intern->std, class_type); | |
+ object_properties_init(&intern->std, class_type); | |
+ intern->std.handlers = &php_gd_image_object_handlers; | |
+ | |
+ return &intern->std; | |
+}; | |
+ | |
+static void php_gd_image_object_free(zend_object *intern) { | |
+ php_gd_image_object* object = | |
+ php_gd_image_object_fetch(intern); | |
+ | |
+ gdImageDestroy(object->image); | |
+ | |
+ zend_object_std_dtor(intern); | |
+}; | |
+ | |
+static zend_object* php_gd_image_object_construct(zval *val, gdImagePtr image) { | |
+ php_gd_image_object *object; | |
+ | |
+ object_init_ex(val, php_gd_image_ce); | |
+ | |
+ object = php_gd_image_object_fetch(Z_OBJ_P(val)); | |
+ object->image = image; | |
+ | |
+ return &object->std; | |
+} | |
+ | |
/* {{{ PHP_MINIT_FUNCTION | |
*/ | |
PHP_MINIT_FUNCTION(gd) | |
{ | |
- le_gd = zend_register_list_destructors_ex(php_free_gd_image, NULL, "gd", module_number); | |
+ zend_class_entry ce; | |
+ | |
le_gd_font = zend_register_list_destructors_ex(php_free_gd_font, NULL, "gd font", module_number); | |
+ INIT_CLASS_ENTRY(ce, "GdImage", php_gd_image_methods); | |
+ | |
+ php_gd_image_ce = zend_register_internal_class(&ce); | |
+ php_gd_image_ce->ce_flags |= ZEND_ACC_FINAL; | |
+ php_gd_image_ce->create_object = php_gd_image_object_create; | |
+ | |
+ memcpy(&php_gd_image_object_handlers, &std_object_handlers, sizeof(zend_object_handlers)); | |
+ php_gd_image_object_handlers.clone_obj = NULL; | |
+ php_gd_image_object_handlers.free_obj = php_gd_image_object_free; | |
+ php_gd_image_object_handlers.offset = XtOffsetOf(php_gd_image_object, std); | |
+ | |
#if defined(HAVE_GD_FREETYPE) && defined(HAVE_GD_BUNDLED) | |
gdFontCacheMutexSetup(); | |
#endif | |
@@ -665,13 +726,6 @@ PHP_FUNCTION(gd_info) | |
} | |
/* }}} */ | |
-/* Need this for cpdf. See also comment in file.c php3i_get_le_fp() */ | |
-PHP_GD_API int phpi_get_le_gd(void) | |
-{ | |
- return le_gd; | |
-} | |
-/* }}} */ | |
- | |
#define FLIPWORD(a) (((a & 0xff000000) >> 24) | ((a & 0x00ff0000) >> 8) | ((a & 0x0000ff00) << 8) | ((a & 0x000000ff) << 24)) | |
/* {{{ proto int imageloadfont(string filename) | |
@@ -788,13 +842,11 @@ PHP_FUNCTION(imagesetstyle) | |
int index = 0; | |
uint32_t num_styles; | |
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ra", &IM, &styles) == FAILURE) { | |
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "Oa", &IM, php_gd_image_ce, &styles) == FAILURE) { | |
return; | |
} | |
- if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
+ im = php_gd_image_object_from(IM); | |
num_styles = zend_hash_num_elements(Z_ARRVAL_P(styles)); | |
if (num_styles == 0) { | |
@@ -844,7 +896,7 @@ PHP_FUNCTION(imagecreatetruecolor) | |
RETURN_FALSE; | |
} | |
- RETURN_RES(zend_register_resource(im, le_gd)); | |
+ php_gd_image_object_construct(return_value, im); | |
} | |
/* }}} */ | |
@@ -855,13 +907,11 @@ PHP_FUNCTION(imageistruecolor) | |
zval *IM; | |
gdImagePtr im; | |
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &IM) == FAILURE) { | |
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &IM, php_gd_image_ce) == FAILURE) { | |
return; | |
} | |
- if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
+ im = php_gd_image_object_from(IM); | |
RETURN_BOOL(im->trueColor); | |
} | |
@@ -876,13 +926,11 @@ PHP_FUNCTION(imagetruecolortopalette) | |
zend_long ncolors; | |
gdImagePtr im; | |
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rbl", &IM, &dither, &ncolors) == FAILURE) { | |
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "Obl", &IM, php_gd_image_ce, &dither, &ncolors) == FAILURE) { | |
return; | |
} | |
- if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
+ im = php_gd_image_object_from(IM); | |
if (ncolors <= 0 || ZEND_LONG_INT_OVFL(ncolors)) { | |
zend_value_error("Number of colors has to be greater than zero and no more than %d", INT_MAX); | |
@@ -905,13 +953,11 @@ PHP_FUNCTION(imagepalettetotruecolor) | |
zval *IM; | |
gdImagePtr im; | |
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &IM) == FAILURE) { | |
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &IM, php_gd_image_ce) == FAILURE) { | |
return; | |
} | |
- if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
+ im = php_gd_image_object_from(IM); | |
if (gdImagePaletteToTrueColor(im) == 0) { | |
RETURN_FALSE; | |
@@ -929,16 +975,12 @@ PHP_FUNCTION(imagecolormatch) | |
gdImagePtr im1, im2; | |
int result; | |
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rr", &IM1, &IM2) == FAILURE) { | |
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "OO", &IM1, php_gd_image_ce, &IM2, php_gd_image_ce) == FAILURE) { | |
return; | |
} | |
- if ((im1 = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM1), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
- if ((im2 = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM2), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
+ im1 = php_gd_image_object_from(IM1); | |
+ im2 = php_gd_image_object_from(IM2); | |
result = gdImageColorMatch(im1, im2); | |
switch (result) { | |
@@ -972,13 +1014,11 @@ PHP_FUNCTION(imagesetthickness) | |
zend_long thick; | |
gdImagePtr im; | |
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rl", &IM, &thick) == FAILURE) { | |
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "Ol", &IM, php_gd_image_ce, &thick) == FAILURE) { | |
return; | |
} | |
- if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
+ im = php_gd_image_object_from(IM); | |
gdImageSetThickness(im, thick); | |
@@ -994,13 +1034,11 @@ PHP_FUNCTION(imagefilledellipse) | |
zend_long cx, cy, w, h, color; | |
gdImagePtr im; | |
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rlllll", &IM, &cx, &cy, &w, &h, &color) == FAILURE) { | |
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "Olllll", &IM, php_gd_image_ce, &cx, &cy, &w, &h, &color) == FAILURE) { | |
return; | |
} | |
- if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
+ im = php_gd_image_object_from(IM); | |
gdImageFilledEllipse(im, cx, cy, w, h, color); | |
@@ -1017,13 +1055,11 @@ PHP_FUNCTION(imagefilledarc) | |
gdImagePtr im; | |
int e, st; | |
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rllllllll", &IM, &cx, &cy, &w, &h, &ST, &E, &col, &style) == FAILURE) { | |
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "Ollllllll", &IM, php_gd_image_ce, &cx, &cy, &w, &h, &ST, &E, &col, &style) == FAILURE) { | |
return; | |
} | |
- if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
+ im = php_gd_image_object_from(IM); | |
e = E; | |
if (e < 0) { | |
@@ -1049,13 +1085,11 @@ PHP_FUNCTION(imagealphablending) | |
zend_bool blend; | |
gdImagePtr im; | |
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rb", &IM, &blend) == FAILURE) { | |
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "Ob", &IM, php_gd_image_ce, &blend) == FAILURE) { | |
return; | |
} | |
- if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
+ im = php_gd_image_object_from(IM); | |
gdImageAlphaBlending(im, blend); | |
@@ -1071,13 +1105,11 @@ PHP_FUNCTION(imagesavealpha) | |
zend_bool save; | |
gdImagePtr im; | |
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rb", &IM, &save) == FAILURE) { | |
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "Ob", &IM, php_gd_image_ce, &save) == FAILURE) { | |
return; | |
} | |
- if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
+ im = php_gd_image_object_from(IM); | |
gdImageSaveAlpha(im, save); | |
@@ -1093,13 +1125,11 @@ PHP_FUNCTION(imagelayereffect) | |
zend_long effect; | |
gdImagePtr im; | |
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rl", &IM, &effect) == FAILURE) { | |
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "Ol", &IM, php_gd_image_ce, &effect) == FAILURE) { | |
return; | |
} | |
- if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
+ im = php_gd_image_object_from(IM); | |
gdImageAlphaBlending(im, effect); | |
@@ -1122,13 +1152,11 @@ PHP_FUNCTION(imagecolorallocatealpha) | |
gdImagePtr im; | |
int ct = (-1); | |
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rllll", &IM, &red, &green, &blue, &alpha) == FAILURE) { | |
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "Ollll", &IM, php_gd_image_ce, &red, &green, &blue, &alpha) == FAILURE) { | |
return; | |
} | |
- if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
+ im = php_gd_image_object_from(IM); | |
CHECK_RGBA_RANGE(red, Red); | |
CHECK_RGBA_RANGE(green, Green); | |
@@ -1151,13 +1179,11 @@ PHP_FUNCTION(imagecolorresolvealpha) | |
zend_long red, green, blue, alpha; | |
gdImagePtr im; | |
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rllll", &IM, &red, &green, &blue, &alpha) == FAILURE) { | |
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "Ollll", &IM, php_gd_image_ce, &red, &green, &blue, &alpha) == FAILURE) { | |
return; | |
} | |
- if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
+ im = php_gd_image_object_from(IM); | |
CHECK_RGBA_RANGE(red, Red); | |
CHECK_RGBA_RANGE(green, Green); | |
@@ -1176,13 +1202,11 @@ PHP_FUNCTION(imagecolorclosestalpha) | |
zend_long red, green, blue, alpha; | |
gdImagePtr im; | |
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rllll", &IM, &red, &green, &blue, &alpha) == FAILURE) { | |
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "Ollll", &IM, php_gd_image_ce, &red, &green, &blue, &alpha) == FAILURE) { | |
return; | |
} | |
- if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
+ im = php_gd_image_object_from(IM); | |
CHECK_RGBA_RANGE(red, Red); | |
CHECK_RGBA_RANGE(green, Green); | |
@@ -1201,13 +1225,11 @@ PHP_FUNCTION(imagecolorexactalpha) | |
zend_long red, green, blue, alpha; | |
gdImagePtr im; | |
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rllll", &IM, &red, &green, &blue, &alpha) == FAILURE) { | |
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "Ollll", &IM, php_gd_image_ce, &red, &green, &blue, &alpha) == FAILURE) { | |
return; | |
} | |
- if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
+ im = php_gd_image_object_from(IM); | |
CHECK_RGBA_RANGE(red, Red); | |
CHECK_RGBA_RANGE(green, Green); | |
@@ -1227,17 +1249,12 @@ PHP_FUNCTION(imagecopyresampled) | |
gdImagePtr im_dst, im_src; | |
int srcH, srcW, dstH, dstW, srcY, srcX, dstY, dstX; | |
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rrllllllll", &DIM, &SIM, &DX, &DY, &SX, &SY, &DW, &DH, &SW, &SH) == FAILURE) { | |
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "OOllllllll", &DIM, php_gd_image_ce, &SIM, php_gd_image_ce, &DX, &DY, &SX, &SY, &DW, &DH, &SW, &SH) == FAILURE) { | |
return; | |
} | |
- if ((im_dst = (gdImagePtr)zend_fetch_resource(Z_RES_P(DIM), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
- | |
- if ((im_src = (gdImagePtr)zend_fetch_resource(Z_RES_P(SIM), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
+ im_src = php_gd_image_object_from(SIM); | |
+ im_dst = php_gd_image_object_from(DIM); | |
srcX = SX; | |
srcY = SY; | |
@@ -1319,9 +1336,9 @@ PHP_FUNCTION(imagegrabwindow) | |
if (!im) { | |
RETURN_FALSE; | |
- } else { | |
- RETURN_RES(zend_register_resource(im, le_gd)); | |
} | |
+ | |
+ php_gd_image_object_construct(return_value, im); | |
} | |
/* }}} */ | |
@@ -1376,9 +1393,9 @@ PHP_FUNCTION(imagegrabscreen) | |
if (!im) { | |
RETURN_FALSE; | |
- } else { | |
- RETURN_RES(zend_register_resource(im, le_gd)); | |
} | |
+ | |
+ php_gd_image_object_construct(return_value, im); | |
} | |
/* }}} */ | |
#endif /* PHP_WIN32 */ | |
@@ -1393,21 +1410,18 @@ PHP_FUNCTION(imagerotate) | |
zend_long color; | |
zend_long ignoretransparent = 0; | |
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rdl|l", &SIM, °rees, &color, &ignoretransparent) == FAILURE) { | |
- return; | |
- } | |
- | |
- if ((im_src = (gdImagePtr)zend_fetch_resource(Z_RES_P(SIM), "Image", le_gd)) == NULL) { | |
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "Odl|l", &SIM, php_gd_image_ce, °rees, &color, &ignoretransparent) == FAILURE) { | |
return; | |
} | |
+ im_src = php_gd_image_object_from(SIM); | |
im_dst = gdImageRotateInterpolated(im_src, (const float)degrees, color); | |
- if (im_dst != NULL) { | |
- RETURN_RES(zend_register_resource(im_dst, le_gd)); | |
- } else { | |
+ if (im_dst == NULL) { | |
RETURN_FALSE; | |
} | |
+ | |
+ php_gd_image_object_construct(return_value, im_dst); | |
} | |
/* }}} */ | |
@@ -1418,17 +1432,12 @@ PHP_FUNCTION(imagesettile) | |
zval *IM, *TILE; | |
gdImagePtr im, tile; | |
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rr", &IM, &TILE) == FAILURE) { | |
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "OO", &IM, php_gd_image_ce, &TILE, php_gd_image_ce) == FAILURE) { | |
return; | |
} | |
- if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
- | |
- if ((tile = (gdImagePtr)zend_fetch_resource(Z_RES_P(TILE), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
+ im = php_gd_image_object_from(IM); | |
+ tile = php_gd_image_object_from(TILE); | |
gdImageSetTile(im, tile); | |
@@ -1443,17 +1452,12 @@ PHP_FUNCTION(imagesetbrush) | |
zval *IM, *TILE; | |
gdImagePtr im, tile; | |
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rr", &IM, &TILE) == FAILURE) { | |
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "OO", &IM, php_gd_image_ce, &TILE, php_gd_image_ce) == FAILURE) { | |
return; | |
} | |
- if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
- | |
- if ((tile = (gdImagePtr)zend_fetch_resource(Z_RES_P(TILE), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
+ im = php_gd_image_object_from(IM); | |
+ tile = php_gd_image_object_from(TILE); | |
gdImageSetBrush(im, tile); | |
@@ -1488,7 +1492,7 @@ PHP_FUNCTION(imagecreate) | |
RETURN_FALSE; | |
} | |
- RETURN_RES(zend_register_resource(im, le_gd)); | |
+ php_gd_image_object_construct(return_value, im); | |
} | |
/* }}} */ | |
@@ -1688,7 +1692,7 @@ PHP_FUNCTION(imagecreatefromstring) | |
RETURN_FALSE; | |
} | |
- RETURN_RES(zend_register_resource(im, le_gd)); | |
+ php_gd_image_object_construct(return_value, im); | |
} | |
/* }}} */ | |
@@ -1805,7 +1809,7 @@ static void _php_image_create_from(INTERNAL_FUNCTION_PARAMETERS, int image_type, | |
/* register_im: */ | |
if (im) { | |
- RETVAL_RES(zend_register_resource(im, le_gd)); | |
+ RETVAL_OBJ(php_gd_image_object_construct(return_value, im)); | |
php_stream_close(stream); | |
return; | |
} | |
@@ -1942,13 +1946,11 @@ static void _php_image_output(INTERNAL_FUNCTION_PARAMETERS, int image_type, char | |
/* The quality parameter for gd2 stands for chunk size */ | |
- if (zend_parse_parameters(argc, "r|pll", &imgind, &file, &file_len, &quality, &type) == FAILURE) { | |
+ if (zend_parse_parameters(argc, "O|pll", &imgind, php_gd_image_ce, &file, &file_len, &quality, &type) == FAILURE) { | |
return; | |
} | |
- if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(imgind), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
+ im = php_gd_image_object_from(imgind); | |
if (argc > 1) { | |
fn = file; | |
@@ -2125,22 +2127,16 @@ PHP_FUNCTION(imagebmp) | |
#endif | |
/* {{{ proto bool imagedestroy(resource im) | |
- Destroy an image */ | |
+ Destroy an image - No effect as of PHP 8.0 */ | |
PHP_FUNCTION(imagedestroy) | |
{ | |
+ /* This function used to free the resource, as resources are no longer used, it does nothing */ | |
zval *IM; | |
- gdImagePtr im; | |
- | |
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &IM) == FAILURE) { | |
+ | |
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &IM, php_gd_image_ce) == FAILURE) { | |
return; | |
} | |
- if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
- | |
- zend_list_close(Z_RES_P(IM)); | |
- | |
RETURN_TRUE; | |
} | |
/* }}} */ | |
@@ -2154,13 +2150,11 @@ PHP_FUNCTION(imagecolorallocate) | |
gdImagePtr im; | |
int ct = (-1); | |
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rlll", &IM, &red, &green, &blue) == FAILURE) { | |
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "Olll", &IM, php_gd_image_ce, &red, &green, &blue) == FAILURE) { | |
return; | |
} | |
- if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
+ im = php_gd_image_object_from(IM); | |
CHECK_RGBA_RANGE(red, Red); | |
CHECK_RGBA_RANGE(green, Green); | |
@@ -2181,17 +2175,12 @@ PHP_FUNCTION(imagepalettecopy) | |
zval *dstim, *srcim; | |
gdImagePtr dst, src; | |
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rr", &dstim, &srcim) == FAILURE) { | |
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "OO", &dstim, php_gd_image_ce, &srcim, php_gd_image_ce) == FAILURE) { | |
return; | |
} | |
- if ((dst = (gdImagePtr)zend_fetch_resource(Z_RES_P(dstim), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
- | |
- if ((src = (gdImagePtr)zend_fetch_resource(Z_RES_P(srcim), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
+ src = php_gd_image_object_from(srcim); | |
+ dst = php_gd_image_object_from(dstim); | |
gdImagePaletteCopy(dst, src); | |
} | |
@@ -2206,14 +2195,12 @@ PHP_FUNCTION(imagecolorat) | |
gdImagePtr im; | |
ZEND_PARSE_PARAMETERS_START(3, 3) | |
- Z_PARAM_RESOURCE(IM) | |
+ Z_PARAM_OBJECT_OF_CLASS(IM, php_gd_image_ce) | |
Z_PARAM_LONG(x) | |
Z_PARAM_LONG(y) | |
ZEND_PARSE_PARAMETERS_END(); | |
- if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
+ im = php_gd_image_object_from(IM); | |
if (gdImageTrueColor(im)) { | |
if (im->tpixels && gdImageBoundsSafe(im, x, y)) { | |
@@ -2241,13 +2228,11 @@ PHP_FUNCTION(imagecolorclosest) | |
zend_long red, green, blue; | |
gdImagePtr im; | |
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rlll", &IM, &red, &green, &blue) == FAILURE) { | |
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "Olll", &IM, php_gd_image_ce, &red, &green, &blue) == FAILURE) { | |
return; | |
} | |
- if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
+ im = php_gd_image_object_from(IM); | |
CHECK_RGBA_RANGE(red, Red); | |
CHECK_RGBA_RANGE(green, Green); | |
@@ -2265,13 +2250,11 @@ PHP_FUNCTION(imagecolorclosesthwb) | |
zend_long red, green, blue; | |
gdImagePtr im; | |
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rlll", &IM, &red, &green, &blue) == FAILURE) { | |
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "Olll", &IM, php_gd_image_ce, &red, &green, &blue) == FAILURE) { | |
return; | |
} | |
- if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
+ im = php_gd_image_object_from(IM); | |
CHECK_RGBA_RANGE(red, Red); | |
CHECK_RGBA_RANGE(green, Green); | |
@@ -2290,13 +2273,11 @@ PHP_FUNCTION(imagecolordeallocate) | |
int col; | |
gdImagePtr im; | |
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rl", &IM, &index) == FAILURE) { | |
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "Ol", &IM, php_gd_image_ce, &index) == FAILURE) { | |
return; | |
} | |
- if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
+ im = php_gd_image_object_from(IM); | |
/* We can return right away for a truecolor image as deallocating colours is meaningless here */ | |
if (gdImageTrueColor(im)) { | |
@@ -2309,8 +2290,8 @@ PHP_FUNCTION(imagecolordeallocate) | |
gdImageColorDeallocate(im, col); | |
RETURN_TRUE; | |
} else { | |
- php_error_docref(NULL, E_WARNING, "Color index %d out of range", col); | |
- RETURN_FALSE; | |
+ zend_value_error("Color index %d out of range", col); | |
+ return; | |
} | |
} | |
/* }}} */ | |
@@ -2323,13 +2304,11 @@ PHP_FUNCTION(imagecolorresolve) | |
zend_long red, green, blue; | |
gdImagePtr im; | |
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rlll", &IM, &red, &green, &blue) == FAILURE) { | |
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "Olll", &IM, php_gd_image_ce, &red, &green, &blue) == FAILURE) { | |
return; | |
} | |
- if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
+ im = php_gd_image_object_from(IM); | |
CHECK_RGBA_RANGE(red, Red); | |
CHECK_RGBA_RANGE(green, Green); | |
@@ -2347,13 +2326,11 @@ PHP_FUNCTION(imagecolorexact) | |
zend_long red, green, blue; | |
gdImagePtr im; | |
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rlll", &IM, &red, &green, &blue) == FAILURE) { | |
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "Olll", &IM, php_gd_image_ce, &red, &green, &blue) == FAILURE) { | |
return; | |
} | |
- if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
+ im = php_gd_image_object_from(IM); | |
CHECK_RGBA_RANGE(red, Red); | |
CHECK_RGBA_RANGE(green, Green); | |
@@ -2372,13 +2349,11 @@ PHP_FUNCTION(imagecolorset) | |
int col; | |
gdImagePtr im; | |
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rllll|l", &IM, &color, &red, &green, &blue, &alpha) == FAILURE) { | |
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "Ollll|l", &IM, php_gd_image_ce, &color, &red, &green, &blue, &alpha) == FAILURE) { | |
return; | |
} | |
- if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
+ im = php_gd_image_object_from(IM); | |
CHECK_RGBA_RANGE(red, Red); | |
CHECK_RGBA_RANGE(green, Green); | |
@@ -2407,13 +2382,11 @@ PHP_FUNCTION(imagecolorsforindex) | |
int col; | |
gdImagePtr im; | |
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rl", &IM, &index) == FAILURE) { | |
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "Ol", &IM, php_gd_image_ce, &index) == FAILURE) { | |
return; | |
} | |
- if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
+ im = php_gd_image_object_from(IM); | |
col = index; | |
@@ -2440,7 +2413,7 @@ PHP_FUNCTION(imagegammacorrect) | |
int i; | |
double input, output, gamma; | |
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rdd", &IM, &input, &output) == FAILURE) { | |
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "Odd", &IM, php_gd_image_ce, &input, &output) == FAILURE) { | |
return; | |
} | |
@@ -2451,9 +2424,7 @@ PHP_FUNCTION(imagegammacorrect) | |
gamma = input / output; | |
- if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
+ im = php_gd_image_object_from(IM); | |
if (gdImageTrueColor(im)) { | |
int x, y, c; | |
@@ -2493,15 +2464,13 @@ PHP_FUNCTION(imagesetpixel) | |
gdImagePtr im; | |
ZEND_PARSE_PARAMETERS_START(4, 4) | |
- Z_PARAM_RESOURCE(IM) | |
+ Z_PARAM_OBJECT_OF_CLASS(IM, php_gd_image_ce) | |
Z_PARAM_LONG(x) | |
Z_PARAM_LONG(y) | |
Z_PARAM_LONG(col) | |
ZEND_PARSE_PARAMETERS_END(); | |
- if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
+ im = php_gd_image_object_from(IM); | |
gdImageSetPixel(im, x, y, col); | |
RETURN_TRUE; | |
@@ -2516,13 +2485,11 @@ PHP_FUNCTION(imageline) | |
zend_long x1, y1, x2, y2, col; | |
gdImagePtr im; | |
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rlllll", &IM, &x1, &y1, &x2, &y2, &col) == FAILURE) { | |
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "Olllll", &IM, php_gd_image_ce, &x1, &y1, &x2, &y2, &col) == FAILURE) { | |
return; | |
} | |
- if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
+ im = php_gd_image_object_from(IM); | |
if (im->AA) { | |
gdImageSetAntiAliased(im, col); | |
@@ -2541,13 +2508,11 @@ PHP_FUNCTION(imagedashedline) | |
zend_long x1, y1, x2, y2, col; | |
gdImagePtr im; | |
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rlllll", &IM, &x1, &y1, &x2, &y2, &col) == FAILURE) { | |
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "Olllll", &IM, php_gd_image_ce, &x1, &y1, &x2, &y2, &col) == FAILURE) { | |
return; | |
} | |
- if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
+ im = php_gd_image_object_from(IM); | |
gdImageDashedLine(im, x1, y1, x2, y2, col); | |
RETURN_TRUE; | |
@@ -2562,13 +2527,11 @@ PHP_FUNCTION(imagerectangle) | |
zend_long x1, y1, x2, y2, col; | |
gdImagePtr im; | |
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rlllll", &IM, &x1, &y1, &x2, &y2, &col) == FAILURE) { | |
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "Olllll", &IM, php_gd_image_ce, &x1, &y1, &x2, &y2, &col) == FAILURE) { | |
return; | |
} | |
- if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
+ im = php_gd_image_object_from(IM); | |
gdImageRectangle(im, x1, y1, x2, y2, col); | |
RETURN_TRUE; | |
@@ -2583,13 +2546,11 @@ PHP_FUNCTION(imagefilledrectangle) | |
zend_long x1, y1, x2, y2, col; | |
gdImagePtr im; | |
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rlllll", &IM, &x1, &y1, &x2, &y2, &col) == FAILURE) { | |
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "Olllll", &IM, php_gd_image_ce, &x1, &y1, &x2, &y2, &col) == FAILURE) { | |
return; | |
} | |
- if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
+ im = php_gd_image_object_from(IM); | |
gdImageFilledRectangle(im, x1, y1, x2, y2, col); | |
RETURN_TRUE; | |
} | |
@@ -2604,13 +2565,11 @@ PHP_FUNCTION(imagearc) | |
gdImagePtr im; | |
int e, st; | |
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rlllllll", &IM, &cx, &cy, &w, &h, &ST, &E, &col) == FAILURE) { | |
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "Olllllll", &IM, php_gd_image_ce, &cx, &cy, &w, &h, &ST, &E, &col) == FAILURE) { | |
return; | |
} | |
- if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
+ im = php_gd_image_object_from(IM); | |
e = E; | |
if (e < 0) { | |
@@ -2635,13 +2594,11 @@ PHP_FUNCTION(imageellipse) | |
zend_long cx, cy, w, h, color; | |
gdImagePtr im; | |
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rlllll", &IM, &cx, &cy, &w, &h, &color) == FAILURE) { | |
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "Olllll", &IM, php_gd_image_ce, &cx, &cy, &w, &h, &color) == FAILURE) { | |
return; | |
} | |
- if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
+ im = php_gd_image_object_from(IM); | |
gdImageEllipse(im, cx, cy, w, h, color); | |
RETURN_TRUE; | |
@@ -2656,13 +2613,11 @@ PHP_FUNCTION(imagefilltoborder) | |
zend_long x, y, border, col; | |
gdImagePtr im; | |
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rllll", &IM, &x, &y, &border, &col) == FAILURE) { | |
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "Ollll", &IM, php_gd_image_ce, &x, &y, &border, &col) == FAILURE) { | |
return; | |
} | |
- if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
+ im = php_gd_image_object_from(IM); | |
gdImageFillToBorder(im, x, y, border, col); | |
RETURN_TRUE; | |
@@ -2677,13 +2632,11 @@ PHP_FUNCTION(imagefill) | |
zend_long x, y, col; | |
gdImagePtr im; | |
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rlll", &IM, &x, &y, &col) == FAILURE) { | |
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "Olll", &IM, php_gd_image_ce, &x, &y, &col) == FAILURE) { | |
return; | |
} | |
- if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
+ im = php_gd_image_object_from(IM); | |
gdImageFill(im, x, y, col); | |
RETURN_TRUE; | |
@@ -2697,13 +2650,11 @@ PHP_FUNCTION(imagecolorstotal) | |
zval *IM; | |
gdImagePtr im; | |
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &IM) == FAILURE) { | |
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &IM, php_gd_image_ce) == FAILURE) { | |
return; | |
} | |
- if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
+ im = php_gd_image_object_from(IM); | |
RETURN_LONG(gdImageColorsTotal(im)); | |
} | |
@@ -2718,13 +2669,11 @@ PHP_FUNCTION(imagecolortransparent) | |
gdImagePtr im; | |
int argc = ZEND_NUM_ARGS(); | |
- if (zend_parse_parameters(argc, "r|l", &IM, &COL) == FAILURE) { | |
+ if (zend_parse_parameters(argc, "O|l", &IM, php_gd_image_ce, &COL) == FAILURE) { | |
return; | |
} | |
- if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
+ im = php_gd_image_object_from(IM); | |
if (argc > 1) { | |
gdImageColorTransparent(im, COL); | |
@@ -2743,13 +2692,11 @@ PHP_FUNCTION(imageinterlace) | |
zend_long INT = 0; | |
gdImagePtr im; | |
- if (zend_parse_parameters(argc, "r|l", &IM, &INT) == FAILURE) { | |
+ if (zend_parse_parameters(argc, "O|l", &IM, php_gd_image_ce, &INT) == FAILURE) { | |
return; | |
} | |
- if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
+ im = php_gd_image_object_from(IM); | |
if (argc > 1) { | |
gdImageInterlace(im, INT); | |
@@ -2773,13 +2720,11 @@ static void php_imagepolygon(INTERNAL_FUNCTION_PARAMETERS, int filled) | |
gdPointPtr points; | |
int npoints, col, nelem, i; | |
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rall", &IM, &POINTS, &NPOINTS, &COL) == FAILURE) { | |
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "Oall", &IM, php_gd_image_ce, &POINTS, &NPOINTS, &COL) == FAILURE) { | |
return; | |
} | |
- if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
+ im = php_gd_image_object_from(IM); | |
npoints = NPOINTS; | |
col = COL; | |
@@ -2974,13 +2919,11 @@ static void php_imagechar(INTERNAL_FUNCTION_PARAMETERS, int mode) | |
unsigned char *str = NULL; | |
gdFontPtr font; | |
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rlllsl", &IM, &SIZE, &X, &Y, &C, &C_len, &COL) == FAILURE) { | |
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "Olllsl", &IM, php_gd_image_ce, &SIZE, &X, &Y, &C, &C_len, &COL) == FAILURE) { | |
return; | |
} | |
- if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
+ im = php_gd_image_object_from(IM); | |
col = COL; | |
@@ -3067,17 +3010,12 @@ PHP_FUNCTION(imagecopy) | |
gdImagePtr im_dst, im_src; | |
int srcH, srcW, srcY, srcX, dstY, dstX; | |
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rrllllll", &DIM, &SIM, &DX, &DY, &SX, &SY, &SW, &SH) == FAILURE) { | |
- return; | |
- } | |
- | |
- if ((im_dst = (gdImagePtr)zend_fetch_resource(Z_RES_P(DIM), "Image", le_gd)) == NULL) { | |
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "OOllllll", &DIM, php_gd_image_ce, &SIM, php_gd_image_ce, &DX, &DY, &SX, &SY, &SW, &SH) == FAILURE) { | |
return; | |
} | |
- if ((im_src = (gdImagePtr)zend_fetch_resource(Z_RES_P(SIM), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
+ im_dst = php_gd_image_object_from(DIM); | |
+ im_src = php_gd_image_object_from(SIM); | |
srcX = SX; | |
srcY = SY; | |
@@ -3100,17 +3038,12 @@ PHP_FUNCTION(imagecopymerge) | |
gdImagePtr im_dst, im_src; | |
int srcH, srcW, srcY, srcX, dstY, dstX, pct; | |
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rrlllllll", &DIM, &SIM, &DX, &DY, &SX, &SY, &SW, &SH, &PCT) == FAILURE) { | |
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "OOlllllll", &DIM, php_gd_image_ce, &SIM, php_gd_image_ce, &DX, &DY, &SX, &SY, &SW, &SH, &PCT) == FAILURE) { | |
return; | |
} | |
- if ((im_dst = (gdImagePtr)zend_fetch_resource(Z_RES_P(DIM), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
- | |
- if ((im_src = (gdImagePtr)zend_fetch_resource(Z_RES_P(SIM), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
+ im_src = php_gd_image_object_from(SIM); | |
+ im_dst = php_gd_image_object_from(DIM); | |
srcX = SX; | |
srcY = SY; | |
@@ -3134,18 +3067,13 @@ PHP_FUNCTION(imagecopymergegray) | |
gdImagePtr im_dst, im_src; | |
int srcH, srcW, srcY, srcX, dstY, dstX, pct; | |
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rrlllllll", &DIM, &SIM, &DX, &DY, &SX, &SY, &SW, &SH, &PCT) == FAILURE) { | |
- return; | |
- } | |
- | |
- if ((im_dst = (gdImagePtr)zend_fetch_resource(Z_RES_P(DIM), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
- | |
- if ((im_src = (gdImagePtr)zend_fetch_resource(Z_RES_P(SIM), "Image", le_gd)) == NULL) { | |
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "OOlllllll", &DIM, php_gd_image_ce, &SIM, php_gd_image_ce, &DX, &DY, &SX, &SY, &SW, &SH, &PCT) == FAILURE) { | |
return; | |
} | |
+ im_src = php_gd_image_object_from(SIM); | |
+ im_dst = php_gd_image_object_from(DIM); | |
+ | |
srcX = SX; | |
srcY = SY; | |
srcH = SH; | |
@@ -3168,18 +3096,13 @@ PHP_FUNCTION(imagecopyresized) | |
gdImagePtr im_dst, im_src; | |
int srcH, srcW, dstH, dstW, srcY, srcX, dstY, dstX; | |
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rrllllllll", &DIM, &SIM, &DX, &DY, &SX, &SY, &DW, &DH, &SW, &SH) == FAILURE) { | |
- return; | |
- } | |
- | |
- if ((im_dst = (gdImagePtr)zend_fetch_resource(Z_RES_P(DIM), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
- | |
- if ((im_src = (gdImagePtr)zend_fetch_resource(Z_RES_P(SIM), "Image", le_gd)) == NULL) { | |
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "OOllllllll", &DIM, php_gd_image_ce, &SIM, php_gd_image_ce, &DX, &DY, &SX, &SY, &DW, &DH, &SW, &SH) == FAILURE) { | |
return; | |
} | |
+ im_src = php_gd_image_object_from(SIM); | |
+ im_dst = php_gd_image_object_from(DIM); | |
+ | |
srcX = SX; | |
srcY = SY; | |
srcH = SH; | |
@@ -3190,7 +3113,7 @@ PHP_FUNCTION(imagecopyresized) | |
dstW = DW; | |
if (dstW <= 0 || dstH <= 0 || srcW <= 0 || srcH <= 0) { | |
- php_error_docref(NULL, E_WARNING, "Invalid image dimensions"); | |
+ zend_value_error("Invalid image dimensions"); | |
RETURN_FALSE; | |
} | |
@@ -3206,13 +3129,11 @@ PHP_FUNCTION(imagesx) | |
zval *IM; | |
gdImagePtr im; | |
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &IM) == FAILURE) { | |
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &IM, php_gd_image_ce) == FAILURE) { | |
return; | |
} | |
- if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
+ im = php_gd_image_object_from(IM); | |
RETURN_LONG(gdImageSX(im)); | |
} | |
@@ -3225,13 +3146,11 @@ PHP_FUNCTION(imagesy) | |
zval *IM; | |
gdImagePtr im; | |
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &IM) == FAILURE) { | |
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &IM, php_gd_image_ce) == FAILURE) { | |
return; | |
} | |
- if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
+ im = php_gd_image_object_from(IM); | |
RETURN_LONG(gdImageSY(im)); | |
} | |
@@ -3245,13 +3164,11 @@ PHP_FUNCTION(imagesetclip) | |
gdImagePtr im; | |
zend_long x1, y1, x2, y2; | |
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rllll", &im_zval, &x1, &y1, &x2, &y2) == FAILURE) { | |
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "Ollll", &im_zval, php_gd_image_ce, &x1, &y1, &x2, &y2) == FAILURE) { | |
return; | |
} | |
- if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(im_zval), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
+ im = php_gd_image_object_from(im_zval); | |
gdImageSetClip(im, x1, y1, x2, y2); | |
RETURN_TRUE; | |
@@ -3266,13 +3183,11 @@ PHP_FUNCTION(imagegetclip) | |
gdImagePtr im; | |
int x1, y1, x2, y2; | |
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &im_zval) == FAILURE) { | |
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &im_zval, php_gd_image_ce) == FAILURE) { | |
return; | |
} | |
- if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(im_zval), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
+ im = php_gd_image_object_from(im_zval); | |
gdImageGetClip(im, &x1, &y1, &x2, &y2); | |
@@ -3344,12 +3259,10 @@ static void php_imagettftext_common(INTERNAL_FUNCTION_PARAMETERS, int mode, int | |
} else { | |
if (argc < 8 || argc > ((extended) ? 9 : 8)) { | |
ZEND_WRONG_PARAM_COUNT(); | |
- } else if (zend_parse_parameters(argc, "rddlllss|a", &IM, &ptsize, &angle, &x, &y, &col, &fontname, &fontname_len, &str, &str_len, &EXT) == FAILURE) { | |
- return; | |
- } | |
- if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) { | |
+ } else if (zend_parse_parameters(argc, "Oddlllss|a", &IM, php_gd_image_ce, &ptsize, &angle, &x, &y, &col, &fontname, &fontname_len, &str, &str_len, &EXT) == FAILURE) { | |
return; | |
} | |
+ im = php_gd_image_object_from(IM); | |
} | |
/* convert angle to radians */ | |
@@ -3408,12 +3321,10 @@ static void php_imagettftext_common(INTERNAL_FUNCTION_PARAMETERS, int mode, int | |
#define PHP_GD_SINGLE_RES \ | |
zval *SIM; \ | |
gdImagePtr im_src; \ | |
- if (zend_parse_parameters(1, "r", &SIM) == FAILURE) { \ | |
+ if (zend_parse_parameters(1, "O", &SIM, php_gd_image_ce) == FAILURE) { \ | |
return; \ | |
} \ | |
- if ((im_src = (gdImagePtr)zend_fetch_resource(Z_RES_P(SIM), "Image", le_gd)) == NULL) { \ | |
- return; \ | |
- } | |
+ im_src = php_gd_image_object_from(SIM); | |
static void php_image_filter_negate(INTERNAL_FUNCTION_PARAMETERS) | |
{ | |
@@ -3443,13 +3354,11 @@ static void php_image_filter_brightness(INTERNAL_FUNCTION_PARAMETERS) | |
gdImagePtr im_src; | |
zend_long brightness, tmp; | |
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "zll", &SIM, &tmp, &brightness) == FAILURE) { | |
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "Oll", &SIM, php_gd_image_ce, &tmp, &brightness) == FAILURE) { | |
return; | |
} | |
- if ((im_src = (gdImagePtr)zend_fetch_resource(Z_RES_P(SIM), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
+ im_src = php_gd_image_object_from(SIM); | |
if (gdImageBrightness(im_src, (int)brightness) == 1) { | |
RETURN_TRUE; | |
@@ -3464,13 +3373,11 @@ static void php_image_filter_contrast(INTERNAL_FUNCTION_PARAMETERS) | |
gdImagePtr im_src; | |
zend_long contrast, tmp; | |
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rll", &SIM, &tmp, &contrast) == FAILURE) { | |
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "Oll", &SIM, php_gd_image_ce, &tmp, &contrast) == FAILURE) { | |
return; | |
} | |
- if ((im_src = (gdImagePtr)zend_fetch_resource(Z_RES_P(SIM), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
+ im_src = php_gd_image_object_from(SIM); | |
if (gdImageContrast(im_src, (int)contrast) == 1) { | |
RETURN_TRUE; | |
@@ -3486,13 +3393,11 @@ static void php_image_filter_colorize(INTERNAL_FUNCTION_PARAMETERS) | |
zend_long r,g,b,tmp; | |
zend_long a = 0; | |
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rllll|l", &SIM, &tmp, &r, &g, &b, &a) == FAILURE) { | |
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "Ollll|l", &SIM, php_gd_image_ce, &tmp, &r, &g, &b, &a) == FAILURE) { | |
return; | |
} | |
- if ((im_src = (gdImagePtr)zend_fetch_resource(Z_RES_P(SIM), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
+ im_src = php_gd_image_object_from(SIM); | |
if (gdImageColor(im_src, (int) r, (int) g, (int) b, (int) a) == 1) { | |
RETURN_TRUE; | |
@@ -3563,13 +3468,11 @@ static void php_image_filter_smooth(INTERNAL_FUNCTION_PARAMETERS) | |
gdImagePtr im_src; | |
double weight; | |
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rld", &SIM, &tmp, &weight) == FAILURE) { | |
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "Old", &SIM, php_gd_image_ce, &tmp, &weight) == FAILURE) { | |
return; | |
} | |
- if ((im_src = (gdImagePtr)zend_fetch_resource(Z_RES_P(SIM), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
+ im_src = php_gd_image_object_from(SIM); | |
if (gdImageSmooth(im_src, (float)weight)==1) { | |
RETURN_TRUE; | |
@@ -3585,13 +3488,11 @@ static void php_image_filter_pixelate(INTERNAL_FUNCTION_PARAMETERS) | |
zend_long tmp, blocksize; | |
zend_bool mode = 0; | |
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rll|b", &IM, &tmp, &blocksize, &mode) == FAILURE) { | |
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "Oll|b", &IM, php_gd_image_ce, &tmp, &blocksize, &mode) == FAILURE) { | |
return; | |
} | |
- if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
+ im = php_gd_image_object_from(IM); | |
if (gdImagePixelate(im, (int) blocksize, (const unsigned int) mode)) { | |
RETURN_TRUE; | |
@@ -3608,13 +3509,11 @@ static void php_image_filter_scatter(INTERNAL_FUNCTION_PARAMETERS) | |
zend_long tmp; | |
zend_long scatter_sub, scatter_plus; | |
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rlll|a", &IM, &tmp, &scatter_sub, &scatter_plus, &hash_colors) == FAILURE) { | |
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "Olll|a", &IM, php_gd_image_ce, &tmp, &scatter_sub, &scatter_plus, &hash_colors) == FAILURE) { | |
return; | |
} | |
- if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
+ im = php_gd_image_object_from(IM); | |
if (hash_colors) { | |
uint32_t i = 0; | |
@@ -3667,7 +3566,7 @@ PHP_FUNCTION(imagefilter) | |
if (ZEND_NUM_ARGS() < 2 || ZEND_NUM_ARGS() > IMAGE_FILTER_MAX_ARGS) { | |
WRONG_PARAM_COUNT; | |
- } else if (zend_parse_parameters(2, "rl", &tmp, &filtertype) == FAILURE) { | |
+ } else if (zend_parse_parameters(2, "Ol", &tmp, php_gd_image_ce, &filtertype) == FAILURE) { | |
return; | |
} | |
@@ -3688,13 +3587,11 @@ PHP_FUNCTION(imageconvolution) | |
int nelem, i, j, res; | |
float matrix[3][3] = {{0,0,0}, {0,0,0}, {0,0,0}}; | |
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "radd", &SIM, &hash_matrix, &div, &offset) == FAILURE) { | |
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "Oadd", &SIM, php_gd_image_ce, &hash_matrix, &div, &offset) == FAILURE) { | |
return; | |
} | |
- if ((im_src = (gdImagePtr)zend_fetch_resource(Z_RES_P(SIM), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
+ im_src = php_gd_image_object_from(SIM); | |
nelem = zend_hash_num_elements(Z_ARRVAL_P(hash_matrix)); | |
if (nelem != 3) { | |
@@ -3738,13 +3635,11 @@ PHP_FUNCTION(imageflip) | |
zend_long mode; | |
gdImagePtr im; | |
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rl", &IM, &mode) == FAILURE) { | |
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "Ol", &IM, php_gd_image_ce, &mode) == FAILURE) { | |
return; | |
} | |
- if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
+ im = php_gd_image_object_from(IM); | |
switch (mode) { | |
case GD_FLIP_VERTICAL: | |
@@ -3776,14 +3671,11 @@ PHP_FUNCTION(imageantialias) | |
zend_bool alias; | |
gdImagePtr im; | |
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rb", &IM, &alias) == FAILURE) { | |
- return; | |
- } | |
- | |
- if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) { | |
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "Ob", &IM, php_gd_image_ce, &alias) == FAILURE) { | |
return; | |
} | |
+ im = php_gd_image_object_from(IM); | |
if (im->trueColor) { | |
im->AA = alias; | |
} | |
@@ -3803,13 +3695,11 @@ PHP_FUNCTION(imagecrop) | |
zval *z_rect; | |
zval *tmp; | |
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ra", &IM, &z_rect) == FAILURE) { | |
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "Oa", &IM, php_gd_image_ce, &z_rect) == FAILURE) { | |
return; | |
} | |
- if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
+ im = php_gd_image_object_from(IM); | |
if ((tmp = zend_hash_str_find(Z_ARRVAL_P(z_rect), "x", sizeof("x") -1)) != NULL) { | |
rect.x = zval_get_long(tmp); | |
@@ -3843,9 +3733,9 @@ PHP_FUNCTION(imagecrop) | |
if (im_crop == NULL) { | |
RETURN_FALSE; | |
- } else { | |
- RETURN_RES(zend_register_resource(im_crop, le_gd)); | |
} | |
+ | |
+ RETURN_OBJ(php_gd_image_object_construct(return_value, im_crop)); | |
} | |
/* }}} */ | |
@@ -3860,13 +3750,11 @@ PHP_FUNCTION(imagecropauto) | |
gdImagePtr im; | |
gdImagePtr im_crop; | |
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|ldl", &IM, &mode, &threshold, &color) == FAILURE) { | |
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "O|ldl", &IM, php_gd_image_ce, &mode, &threshold, &color) == FAILURE) { | |
return; | |
} | |
- if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
+ im = php_gd_image_object_from(IM); | |
switch (mode) { | |
case GD_CROP_DEFAULT: | |
@@ -3892,9 +3780,9 @@ PHP_FUNCTION(imagecropauto) | |
if (im_crop == NULL) { | |
RETURN_FALSE; | |
- } else { | |
- RETURN_RES(zend_register_resource(im_crop, le_gd)); | |
} | |
+ | |
+ RETURN_OBJ(php_gd_image_object_construct(return_value, im_crop)); | |
} | |
/* }}} */ | |
@@ -3909,14 +3797,12 @@ PHP_FUNCTION(imagescale) | |
zend_long tmp_w, tmp_h=-1, tmp_m = GD_BILINEAR_FIXED; | |
gdInterpolationMethod method, old_method; | |
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rl|ll", &IM, &tmp_w, &tmp_h, &tmp_m) == FAILURE) { | |
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "Ol|ll", &IM, php_gd_image_ce, &tmp_w, &tmp_h, &tmp_m) == FAILURE) { | |
return; | |
} | |
method = tmp_m; | |
- if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
+ im = php_gd_image_object_from(IM); | |
if (tmp_h < 0 || tmp_w < 0) { | |
/* preserve ratio */ | |
@@ -3949,9 +3835,9 @@ PHP_FUNCTION(imagescale) | |
if (im_scaled == NULL) { | |
RETURN_FALSE; | |
- } else { | |
- RETURN_RES(zend_register_resource(im_scaled, le_gd)); | |
} | |
+ | |
+ RETURN_OBJ(php_gd_image_object_construct(return_value, im_scaled)); | |
} | |
/* }}} */ | |
@@ -3971,13 +3857,11 @@ PHP_FUNCTION(imageaffine) | |
int i, nelems; | |
zval *zval_affine_elem = NULL; | |
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ra|a", &IM, &z_affine, &z_rect) == FAILURE) { | |
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "Oa|a", &IM, php_gd_image_ce, &z_affine, &z_rect) == FAILURE) { | |
return; | |
} | |
- if ((src = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
+ src = php_gd_image_object_from(IM); | |
if ((nelems = zend_hash_num_elements(Z_ARRVAL_P(z_affine))) != 6) { | |
zend_value_error("Affine array must have six elements"); | |
@@ -4046,9 +3930,9 @@ PHP_FUNCTION(imageaffine) | |
if (dst == NULL) { | |
RETURN_FALSE; | |
- } else { | |
- RETURN_RES(zend_register_resource(dst, le_gd)); | |
} | |
+ | |
+ RETURN_OBJ(php_gd_image_object_construct(return_value, dst)); | |
} | |
/* }}} */ | |
@@ -4210,13 +4094,11 @@ PHP_FUNCTION(imagesetinterpolation) | |
gdImagePtr im; | |
zend_long method = GD_BILINEAR_FIXED; | |
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|l", &IM, &method) == FAILURE) { | |
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "O|l", &IM, php_gd_image_ce, &method) == FAILURE) { | |
return; | |
} | |
- if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
+ im = php_gd_image_object_from(IM); | |
if (method == -1) { | |
method = GD_BILINEAR_FIXED; | |
@@ -4233,13 +4115,11 @@ PHP_FUNCTION(imageresolution) | |
gdImagePtr im; | |
zend_long res_x = GD_RESOLUTION, res_y = GD_RESOLUTION; | |
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|ll", &IM, &res_x, &res_y) == FAILURE) { | |
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "O|ll", &IM, php_gd_image_ce, &res_x, &res_y) == FAILURE) { | |
return; | |
} | |
- if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) { | |
- return; | |
- } | |
+ im = php_gd_image_object_from(IM); | |
switch (ZEND_NUM_ARGS()) { | |
case 3: | |
diff --git a/ext/gd/gd.stub.php b/ext/gd/gd.stub.php | |
index 75d0916751..addffb1433 100644 | |
--- a/ext/gd/gd.stub.php | |
+++ b/ext/gd/gd.stub.php | |
@@ -10,39 +10,39 @@ function imagesetstyle($im, array $styles): bool {} | |
/** @return resource|false */ | |
function imagecreatetruecolor(int $x_size, int $y_size) {} | |
-function imageistruecolor($im): bool {} | |
+function imageistruecolor(GdImage $im): bool {} | |
-function imagetruecolortopalette($im, bool $ditherFlag, int $colorWanted): bool {} | |
+function imagetruecolortopalette(GdImage $im, bool $ditherFlag, int $colorWanted): bool {} | |
-function imagepalettetotruecolor($im): bool {} | |
+function imagepalettetotruecolor(GdImage $im): bool {} | |
function imagecolormatch($im1, $im2): bool {} | |
-function imagesetthickness($im, int $thickness): bool {} | |
+function imagesetthickness(GdImage $im, int $thickness): bool {} | |
-function imagefilledellipse($im, int $cx, int $cy, int $w, int $h, int $color): bool {} | |
+function imagefilledellipse(GdImage $im, int $cx, int $cy, int $w, int $h, int $color): bool {} | |
-function imagefilledarc($im, int $cx, int $cy, int $w, int $h, int $s, int $e, int $col, int $style): bool {} | |
+function imagefilledarc(GdImage $im, int $cx, int $cy, int $w, int $h, int $s, int $e, int $col, int $style): bool {} | |
-function imagealphablending($im, bool $blend): bool {} | |
+function imagealphablending(GdImage $im, bool $blend): bool {} | |
-function imagesavealpha($im, bool $save): bool {} | |
+function imagesavealpha(GdImage $im, bool $save): bool {} | |
-function imagelayereffect($im, int $effect): bool {} | |
+function imagelayereffect(GdImage $im, int $effect): bool {} | |
/** @return int|false */ | |
-function imagecolorallocatealpha($im, int $red, int $green, int $blue, int $alpha) {} | |
+function imagecolorallocatealpha(GdImage $im, int $red, int $green, int $blue, int $alpha) {} | |
/** @return int|false */ | |
-function imagecolorresolvealpha($im, int $red, int $green, int $blue, int $alpha) {} | |
+function imagecolorresolvealpha(GdImage $im, int $red, int $green, int $blue, int $alpha) {} | |
/** @return int|false */ | |
-function imagecolorclosestalpha($im, int $red, int $green, int $blue, int $alpha) {} | |
+function imagecolorclosestalpha(GdImage $im, int $red, int $green, int $blue, int $alpha) {} | |
/** @return int|false */ | |
-function imagecolorexactalpha($im, int $red, int $green, int $blue, int $alpha) {} | |
+function imagecolorexactalpha(GdImage $im, int $red, int $green, int $blue, int $alpha) {} | |
-function imagecopyresampled($dst_im, $src_im, int $dst_x, int $dst_y, int $src_x, int $src_y, int $dst_w, int $dst_h, int $src_w, int $src_h): bool {} | |
+function imagecopyresampled(GdImage $dst_im, GdImage $src_im, int $dst_x, int $dst_y, int $src_x, int $src_y, int $dst_w, int $dst_h, int $src_w, int $src_h): bool {} | |
#ifdef PHP_WIN32 | |
@@ -55,11 +55,11 @@ function imagegrabscreen() {} | |
#endif | |
/** @return resource|false */ | |
-function imagerotate($im, float $angle, int $bgdcolor, int $ignoretransparent = 0) {} | |
+function imagerotate(GdImage $im, float $angle, int $bgdcolor, int $ignoretransparent = 0) {} | |
-function imagesettile($im, $tile): bool {} | |
+function imagesettile(GdImage $im, $tile): bool {} | |
-function imagesetbrush($im, $brush): bool {} | |
+function imagesetbrush(GdImage $im, $brush): bool {} | |
/** @return resource|false */ | |
function imagecreate(int $x_size, int $y_size) {} | |
@@ -117,152 +117,152 @@ function imagecreatefrombmp(string $filename) {} | |
function imagecreatefromtga(string $filename) {} | |
#endif | |
-function imagexbm($im, ?string $filename, int $foreground = UNKNOWN): bool {} | |
+function imagexbm(GdImage $im, ?string $filename, int $foreground = UNKNOWN): bool {} | |
-function imagegif($im, $to = NULL): bool {} | |
+function imagegif(GdImage $im, $to = NULL): bool {} | |
#ifdef HAVE_GD_PNG | |
-function imagepng($im, $to = NULL, int $quality = UNKNOWN, int $filters = UNKNOWN): bool {} | |
+function imagepng(GdImage $im, $to = NULL, int $quality = UNKNOWN, int $filters = UNKNOWN): bool {} | |
#endif | |
#ifdef HAVE_GD_WEBP | |
-function imagewebp($im, $to = NULL, int $quality = UNKNOWN): bool {} | |
+function imagewebp(GdImage $im, $to = NULL, int $quality = UNKNOWN): bool {} | |
#endif | |
#ifdef HAVE_GD_JPG | |
-function imagejpeg($im, $to = NULL, int $quality = UNKNOWN): bool {} | |
+function imagejpeg(GdImage $im, $to = NULL, int $quality = UNKNOWN): bool {} | |
#endif | |
-function imagewbmp($im, $to = NULL, int $foreground = UNKNOWN): bool {} | |
+function imagewbmp(GdImage $im, $to = NULL, int $foreground = UNKNOWN): bool {} | |
-function imagegd($im, $to = UNKNOWN): bool {} | |
+function imagegd(GdImage $im, $to = UNKNOWN): bool {} | |
-function imagegd2($im, $to = UNKNOWN, int $chunk_size = UNKNOWN, int $type = UNKNOWN): bool {} | |
+function imagegd2(GdImage $im, $to = UNKNOWN, int $chunk_size = UNKNOWN, int $type = UNKNOWN): bool {} | |
#ifdef HAVE_GD_BMP | |
-function imagebmp($im, $to = NULL, int $compressed = 1): bool {} | |
+function imagebmp(GdImage $im, $to = NULL, int $compressed = 1): bool {} | |
#endif | |
-function imagedestroy($im): bool {} | |
+function imagedestroy(GdImage $im): bool {} | |
/** @return int|false */ | |
-function imagecolorallocate($im, int $red, int $green, int $blue) {} | |
+function imagecolorallocate(GdImage $im, int $red, int $green, int $blue) {} | |
-function imagepalettecopy($dst, $src): void {} | |
+function imagepalettecopy(GdImage $dst, GdImage $src): void {} | |
/** @return int|false */ | |
-function imagecolorat($im, int $x, int $y) {} | |
+function imagecolorat(GdImage $im, int $x, int $y) {} | |
/** @return int|false */ | |
-function imagecolorclosest($im, int $red, int $green, int $blue) {} | |
+function imagecolorclosest(GdImage $im, int $red, int $green, int $blue) {} | |
/** @return int|false */ | |
-function imagecolorclosesthwb($im, int $red, int $green, int $blue) {} | |
+function imagecolorclosesthwb(GdImage $im, int $red, int $green, int $blue) {} | |
-function imagecolordeallocate($im, int $index): bool {} | |
+function imagecolordeallocate(GdImage $im, int $index): bool {} | |
/** @return int|false */ | |
-function imagecolorresolve($im, int $red, int $green, int $blue) {} | |
+function imagecolorresolve(GdImage $im, int $red, int $green, int $blue) {} | |
/** @return int|false */ | |
-function imagecolorexact($im, int $red, int $green, int $blue) {} | |
+function imagecolorexact(GdImage $im, int $red, int $green, int $blue) {} | |
/** @return ?false */ | |
-function imagecolorset($im, int $color, int $red, int $green, int $blue, int $alpha = 0) {} | |
+function imagecolorset(GdImage $im, int $color, int $red, int $green, int $blue, int $alpha = 0) {} | |
/** @return array|false */ | |
-function imagecolorsforindex($im, int $index) {} | |
+function imagecolorsforindex(GdImage $im, int $index) {} | |
-function imagegammacorrect($im, float $inputgamma, float $outputgamma): bool {} | |
+function imagegammacorrect(GdImage $im, float $inputgamma, float $outputgamma): bool {} | |
-function imagesetpixel($im, int $x, int $y, int $col): bool {} | |
+function imagesetpixel(GdImage $im, int $x, int $y, int $col): bool {} | |
-function imageline($im, int $x1, int $y1, int $x2, int $y2, int $col): bool {} | |
+function imageline(GdImage $im, int $x1, int $y1, int $x2, int $y2, int $col): bool {} | |
-function imagedashedline($im, int $x1, int $y1, int $x2, int $y2, int $col): bool {} | |
+function imagedashedline(GdImage $im, int $x1, int $y1, int $x2, int $y2, int $col): bool {} | |
-function imagerectangle($im, int $x1, int $y1, int $x2, int $y2, int $col): bool {} | |
+function imagerectangle(GdImage $im, int $x1, int $y1, int $x2, int $y2, int $col): bool {} | |
-function imagefilledrectangle($im, int $x1, int $y1, int $x2, int $y2, int $col): bool {} | |
+function imagefilledrectangle(GdImage $im, int $x1, int $y1, int $x2, int $y2, int $col): bool {} | |
-function imagearc($im, int $cx, int $cy, int $w, int $h, int $s, int $e, int $col): bool {} | |
+function imagearc(GdImage $im, int $cx, int $cy, int $w, int $h, int $s, int $e, int $col): bool {} | |
-function imageellipse($im, int $cx, int $cy, int $w, int $h, int $color): bool {} | |
+function imageellipse(GdImage $im, int $cx, int $cy, int $w, int $h, int $color): bool {} | |
-function imagefilltoborder($im, int $x, int $y, int $border, int $col): bool {} | |
+function imagefilltoborder(GdImage $im, int $x, int $y, int $border, int $col): bool {} | |
-function imagefill($im, int $x, int $y, int $col): bool {} | |
+function imagefill(GdImage $im, int $x, int $y, int $col): bool {} | |
-function imagecolorstotal($im): int {} | |
+function imagecolorstotal(GdImage $im): int {} | |
-function imagecolortransparent($im, int $col = UNKNOWN): ?int {} | |
+function imagecolortransparent(GdImage $im, int $col = UNKNOWN): ?int {} | |
-function imageinterlace($im, int $interlace = UNKNOWN): ?int {} | |
+function imageinterlace(GdImage $im, int $interlace = UNKNOWN): ?int {} | |
-function imagepolygon($im, array $points, int $num_pos, int $col): bool {} | |
+function imagepolygon(GdImage $im, array $points, int $num_pos, int $col): bool {} | |
-function imageopenpolygon($im, array $points, int $num_pos, int $col): bool {} | |
+function imageopenpolygon(GdImage $im, array $points, int $num_pos, int $col): bool {} | |
-function imagefilledpolygon($im, array $points, int $num_pos, int $col): bool {} | |
+function imagefilledpolygon(GdImage $im, array $points, int $num_pos, int $col): bool {} | |
function imagefontwidth(int $font): int {} | |
function imagefontheight(int $font): int {} | |
-function imagechar($im, int $font, int $x, int $y, string $c, int $col): bool {} | |
+function imagechar(GdImage $im, int $font, int $x, int $y, string $c, int $col): bool {} | |
-function imagecharup($im, int $font, int $x, int $y, string $c, int $col): bool {} | |
+function imagecharup(GdImage $im, int $font, int $x, int $y, string $c, int $col): bool {} | |
-function imagestring($im, int $font, int $x, int $y, string $str, int $col): bool {} | |
+function imagestring(GdImage $im, int $font, int $x, int $y, string $str, int $col): bool {} | |
function imagestringup($im, int $font, int $x, int $y, string $str, int $col): bool {} | |
-function imagecopy($dst_im, $src_im, int $dst_x, int $dst_y, int $src_x, int $src_y, int $src_w, int $src_h): bool {} | |
+function imagecopy(GdImage $dst_im, GdImage $src_im, int $dst_x, int $dst_y, int $src_x, int $src_y, int $src_w, int $src_h): bool {} | |
-function imagecopymerge($dst_im, $src_im, int $dst_x, int $dst_y, int $src_x, int $src_y, int $src_w, int $src_h, int $pct): bool {} | |
+function imagecopymerge(GdImage $dst_im, GdImage $src_im, int $dst_x, int $dst_y, int $src_x, int $src_y, int $src_w, int $src_h, int $pct): bool {} | |
-function imagecopymergegray($dst_im, $src_im, int $dst_x, int $dst_y, int $src_x, int $src_y, int $src_w, int $src_h, int $pct): bool {} | |
+function imagecopymergegray(GdImage $dst_im, GdImage $src_im, int $dst_x, int $dst_y, int $src_x, int $src_y, int $src_w, int $src_h, int $pct): bool {} | |
-function imagecopyresized($dst_im, $src_im, int $dst_x, int $dst_y, int $src_x, int $src_y, int $dst_w, int $dst_h, int $src_w, int $src_h): bool {} | |
+function imagecopyresized(GdImage $dst_im, GdImage $src_im, int $dst_x, int $dst_y, int $src_x, int $src_y, int $dst_w, int $dst_h, int $src_w, int $src_h): bool {} | |
-function imagesx($im): int {} | |
+function imagesx(GdImage $im): int {} | |
-function imagesy($im): int {} | |
+function imagesy(GdImage $im): int {} | |
-function imagesetclip($im, int $x1, int $x2, int $y1, int $y2): bool {} | |
+function imagesetclip(GdImage $im, int $x1, int $x2, int $y1, int $y2): bool {} | |
-function imagegetclip($im): array {} | |
+function imagegetclip(GdImage $im): array {} | |
#ifdef HAVE_GD_FREETYPE | |
/** @return array|false */ | |
function imageftbbox(float $size, float $angle, string $font_file, string $text, array $extrainfo = UNKNOWN) {} | |
-function imagefttext($im, float $size, float $angle, int $x, int $y, int $col, string $font_file, string $text, array $extrainfo = UNKNOWN) {} | |
+function imagefttext(GdImage $im, float $size, float $angle, int $x, int $y, int $col, string $font_file, string $text, array $extrainfo = UNKNOWN) {} | |
function imagettfbbox(float $size, float $angle, string $font_file, string $text) {} | |
-function imagettftext($im, float $size, float $angle, int $x, int $y, int $col, string $font_file, string $text) {} | |
+function imagettftext(GdImage $im, float $size, float $angle, int $x, int $y, int $col, string $font_file, string $text) {} | |
#endif | |
-function imagefilter($im, int $filtertype, $arg1 = UNKNOWN, $arg2 = UNKNOWN, $arg3 = UNKNOWN, $arg4 = UNKNOWN): bool {} | |
+function imagefilter(GdImage $im, int $filtertype, $arg1 = UNKNOWN, $arg2 = UNKNOWN, $arg3 = UNKNOWN, $arg4 = UNKNOWN): bool {} | |
-function imageconvolution($im, array $matrix3x3, float $div, float $offset): bool {} | |
+function imageconvolution(GdImage $im, array $matrix3x3, float $div, float $offset): bool {} | |
-function imageflip($im, int $mode): bool {} | |
+function imageflip(GdImage $im, int $mode): bool {} | |
-function imageantialias($im, bool $on): bool {} | |
+function imageantialias(GdImage $im, bool $on): bool {} | |
/** @return resource|false */ | |
-function imagecrop($im, array $rect) {} | |
+function imagecrop(GdImage $im, array $rect) {} | |
/** @return resource|false */ | |
-function imagecropauto($im, int $mode = IMG_CROP_DEFAULT, float $threshold = 0.5, int $color = -1) {} | |
+function imagecropauto(GdImage $im, int $mode = IMG_CROP_DEFAULT, float $threshold = 0.5, int $color = -1) {} | |
/** @return resource|false */ | |
-function imagescale($im, int $new_width, int $new_height = UNKNOWN, int $mode = IMG_BILINEAR_FIXED) {} | |
+function imagescale(GdImage $im, int $new_width, int $new_height = UNKNOWN, int $mode = IMG_BILINEAR_FIXED) {} | |
/** @return resource|false */ | |
-function imageaffine($im, array $affine, array $clip = UNKNOWN) {} | |
+function imageaffine(GdImage $im, array $affine, array $clip = UNKNOWN) {} | |
/** @return array|false */ | |
function imageaffinematrixget(int $type, $options = UNKNOWN) {} | |
@@ -270,7 +270,7 @@ function imageaffinematrixget(int $type, $options = UNKNOWN) {} | |
/** @return array|false */ | |
function imageaffinematrixconcat(array $m1, array $m2) {} | |
-function imagesetinterpolation($im, int $method = IMG_BILENEAR_FIXED): bool {} | |
+function imagesetinterpolation(GdImage $im, int $method = IMG_BILENEAR_FIXED): bool {} | |
/** @return array|true */ | |
-function imageresolution($im, int $res_x = UNKNOWN, int $res_y = UNKNOWN) {} | |
+function imageresolution(GdImage $im, int $res_x = UNKNOWN, int $res_y = UNKNOWN) {} | |
diff --git a/ext/gd/gd_arginfo.h b/ext/gd/gd_arginfo.h | |
index 0544802c7e..40639b46c6 100644 | |
--- a/ext/gd/gd_arginfo.h | |
+++ b/ext/gd/gd_arginfo.h | |
@@ -18,11 +18,11 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_imagecreatetruecolor, 0, 0, 2) | |
ZEND_END_ARG_INFO() | |
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imageistruecolor, 0, 1, _IS_BOOL, 0) | |
- ZEND_ARG_INFO(0, im) | |
+ ZEND_ARG_OBJ_INFO(0, im, GdImage, 0) | |
ZEND_END_ARG_INFO() | |
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagetruecolortopalette, 0, 3, _IS_BOOL, 0) | |
- ZEND_ARG_INFO(0, im) | |
+ ZEND_ARG_OBJ_INFO(0, im, GdImage, 0) | |
ZEND_ARG_TYPE_INFO(0, ditherFlag, _IS_BOOL, 0) | |
ZEND_ARG_TYPE_INFO(0, colorWanted, IS_LONG, 0) | |
ZEND_END_ARG_INFO() | |
@@ -35,12 +35,12 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagecolormatch, 0, 2, _IS_BOOL, | |
ZEND_END_ARG_INFO() | |
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagesetthickness, 0, 2, _IS_BOOL, 0) | |
- ZEND_ARG_INFO(0, im) | |
+ ZEND_ARG_OBJ_INFO(0, im, GdImage, 0) | |
ZEND_ARG_TYPE_INFO(0, thickness, IS_LONG, 0) | |
ZEND_END_ARG_INFO() | |
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagefilledellipse, 0, 6, _IS_BOOL, 0) | |
- ZEND_ARG_INFO(0, im) | |
+ ZEND_ARG_OBJ_INFO(0, im, GdImage, 0) | |
ZEND_ARG_TYPE_INFO(0, cx, IS_LONG, 0) | |
ZEND_ARG_TYPE_INFO(0, cy, IS_LONG, 0) | |
ZEND_ARG_TYPE_INFO(0, w, IS_LONG, 0) | |
@@ -49,7 +49,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagefilledellipse, 0, 6, _IS_BO | |
ZEND_END_ARG_INFO() | |
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagefilledarc, 0, 9, _IS_BOOL, 0) | |
- ZEND_ARG_INFO(0, im) | |
+ ZEND_ARG_OBJ_INFO(0, im, GdImage, 0) | |
ZEND_ARG_TYPE_INFO(0, cx, IS_LONG, 0) | |
ZEND_ARG_TYPE_INFO(0, cy, IS_LONG, 0) | |
ZEND_ARG_TYPE_INFO(0, w, IS_LONG, 0) | |
@@ -61,22 +61,22 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagefilledarc, 0, 9, _IS_BOOL, | |
ZEND_END_ARG_INFO() | |
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagealphablending, 0, 2, _IS_BOOL, 0) | |
- ZEND_ARG_INFO(0, im) | |
+ ZEND_ARG_OBJ_INFO(0, im, GdImage, 0) | |
ZEND_ARG_TYPE_INFO(0, blend, _IS_BOOL, 0) | |
ZEND_END_ARG_INFO() | |
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagesavealpha, 0, 2, _IS_BOOL, 0) | |
- ZEND_ARG_INFO(0, im) | |
+ ZEND_ARG_OBJ_INFO(0, im, GdImage, 0) | |
ZEND_ARG_TYPE_INFO(0, save, _IS_BOOL, 0) | |
ZEND_END_ARG_INFO() | |
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagelayereffect, 0, 2, _IS_BOOL, 0) | |
- ZEND_ARG_INFO(0, im) | |
+ ZEND_ARG_OBJ_INFO(0, im, GdImage, 0) | |
ZEND_ARG_TYPE_INFO(0, effect, IS_LONG, 0) | |
ZEND_END_ARG_INFO() | |
ZEND_BEGIN_ARG_INFO_EX(arginfo_imagecolorallocatealpha, 0, 0, 5) | |
- ZEND_ARG_INFO(0, im) | |
+ ZEND_ARG_OBJ_INFO(0, im, GdImage, 0) | |
ZEND_ARG_TYPE_INFO(0, red, IS_LONG, 0) | |
ZEND_ARG_TYPE_INFO(0, green, IS_LONG, 0) | |
ZEND_ARG_TYPE_INFO(0, blue, IS_LONG, 0) | |
@@ -90,8 +90,8 @@ ZEND_END_ARG_INFO() | |
#define arginfo_imagecolorexactalpha arginfo_imagecolorallocatealpha | |
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagecopyresampled, 0, 10, _IS_BOOL, 0) | |
- ZEND_ARG_INFO(0, dst_im) | |
- ZEND_ARG_INFO(0, src_im) | |
+ ZEND_ARG_OBJ_INFO(0, dst_im, GdImage, 0) | |
+ ZEND_ARG_OBJ_INFO(0, src_im, GdImage, 0) | |
ZEND_ARG_TYPE_INFO(0, dst_x, IS_LONG, 0) | |
ZEND_ARG_TYPE_INFO(0, dst_y, IS_LONG, 0) | |
ZEND_ARG_TYPE_INFO(0, src_x, IS_LONG, 0) | |
@@ -115,19 +115,19 @@ ZEND_END_ARG_INFO() | |
#endif | |
ZEND_BEGIN_ARG_INFO_EX(arginfo_imagerotate, 0, 0, 3) | |
- ZEND_ARG_INFO(0, im) | |
+ ZEND_ARG_OBJ_INFO(0, im, GdImage, 0) | |
ZEND_ARG_TYPE_INFO(0, angle, IS_DOUBLE, 0) | |
ZEND_ARG_TYPE_INFO(0, bgdcolor, IS_LONG, 0) | |
ZEND_ARG_TYPE_INFO(0, ignoretransparent, IS_LONG, 0) | |
ZEND_END_ARG_INFO() | |
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagesettile, 0, 2, _IS_BOOL, 0) | |
- ZEND_ARG_INFO(0, im) | |
+ ZEND_ARG_OBJ_INFO(0, im, GdImage, 0) | |
ZEND_ARG_INFO(0, tile) | |
ZEND_END_ARG_INFO() | |
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagesetbrush, 0, 2, _IS_BOOL, 0) | |
- ZEND_ARG_INFO(0, im) | |
+ ZEND_ARG_OBJ_INFO(0, im, GdImage, 0) | |
ZEND_ARG_INFO(0, brush) | |
ZEND_END_ARG_INFO() | |
@@ -195,19 +195,19 @@ ZEND_END_ARG_INFO() | |
#endif | |
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagexbm, 0, 2, _IS_BOOL, 0) | |
- ZEND_ARG_INFO(0, im) | |
+ ZEND_ARG_OBJ_INFO(0, im, GdImage, 0) | |
ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 1) | |
ZEND_ARG_TYPE_INFO(0, foreground, IS_LONG, 0) | |
ZEND_END_ARG_INFO() | |
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagegif, 0, 1, _IS_BOOL, 0) | |
- ZEND_ARG_INFO(0, im) | |
+ ZEND_ARG_OBJ_INFO(0, im, GdImage, 0) | |
ZEND_ARG_INFO(0, to) | |
ZEND_END_ARG_INFO() | |
#if defined(HAVE_GD_PNG) | |
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagepng, 0, 1, _IS_BOOL, 0) | |
- ZEND_ARG_INFO(0, im) | |
+ ZEND_ARG_OBJ_INFO(0, im, GdImage, 0) | |
ZEND_ARG_INFO(0, to) | |
ZEND_ARG_TYPE_INFO(0, quality, IS_LONG, 0) | |
ZEND_ARG_TYPE_INFO(0, filters, IS_LONG, 0) | |
@@ -216,7 +216,7 @@ ZEND_END_ARG_INFO() | |
#if defined(HAVE_GD_WEBP) | |
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagewebp, 0, 1, _IS_BOOL, 0) | |
- ZEND_ARG_INFO(0, im) | |
+ ZEND_ARG_OBJ_INFO(0, im, GdImage, 0) | |
ZEND_ARG_INFO(0, to) | |
ZEND_ARG_TYPE_INFO(0, quality, IS_LONG, 0) | |
ZEND_END_ARG_INFO() | |
@@ -224,14 +224,14 @@ ZEND_END_ARG_INFO() | |
#if defined(HAVE_GD_JPG) | |
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagejpeg, 0, 1, _IS_BOOL, 0) | |
- ZEND_ARG_INFO(0, im) | |
+ ZEND_ARG_OBJ_INFO(0, im, GdImage, 0) | |
ZEND_ARG_INFO(0, to) | |
ZEND_ARG_TYPE_INFO(0, quality, IS_LONG, 0) | |
ZEND_END_ARG_INFO() | |
#endif | |
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagewbmp, 0, 1, _IS_BOOL, 0) | |
- ZEND_ARG_INFO(0, im) | |
+ ZEND_ARG_OBJ_INFO(0, im, GdImage, 0) | |
ZEND_ARG_INFO(0, to) | |
ZEND_ARG_TYPE_INFO(0, foreground, IS_LONG, 0) | |
ZEND_END_ARG_INFO() | |
@@ -239,7 +239,7 @@ ZEND_END_ARG_INFO() | |
#define arginfo_imagegd arginfo_imagegif | |
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagegd2, 0, 1, _IS_BOOL, 0) | |
- ZEND_ARG_INFO(0, im) | |
+ ZEND_ARG_OBJ_INFO(0, im, GdImage, 0) | |
ZEND_ARG_INFO(0, to) | |
ZEND_ARG_TYPE_INFO(0, chunk_size, IS_LONG, 0) | |
ZEND_ARG_TYPE_INFO(0, type, IS_LONG, 0) | |
@@ -247,7 +247,7 @@ ZEND_END_ARG_INFO() | |
#if defined(HAVE_GD_BMP) | |
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagebmp, 0, 1, _IS_BOOL, 0) | |
- ZEND_ARG_INFO(0, im) | |
+ ZEND_ARG_OBJ_INFO(0, im, GdImage, 0) | |
ZEND_ARG_INFO(0, to) | |
ZEND_ARG_TYPE_INFO(0, compressed, IS_LONG, 0) | |
ZEND_END_ARG_INFO() | |
@@ -256,19 +256,19 @@ ZEND_END_ARG_INFO() | |
#define arginfo_imagedestroy arginfo_imageistruecolor | |
ZEND_BEGIN_ARG_INFO_EX(arginfo_imagecolorallocate, 0, 0, 4) | |
- ZEND_ARG_INFO(0, im) | |
+ ZEND_ARG_OBJ_INFO(0, im, GdImage, 0) | |
ZEND_ARG_TYPE_INFO(0, red, IS_LONG, 0) | |
ZEND_ARG_TYPE_INFO(0, green, IS_LONG, 0) | |
ZEND_ARG_TYPE_INFO(0, blue, IS_LONG, 0) | |
ZEND_END_ARG_INFO() | |
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagepalettecopy, 0, 2, IS_VOID, 0) | |
- ZEND_ARG_INFO(0, dst) | |
- ZEND_ARG_INFO(0, src) | |
+ ZEND_ARG_OBJ_INFO(0, dst, GdImage, 0) | |
+ ZEND_ARG_OBJ_INFO(0, src, GdImage, 0) | |
ZEND_END_ARG_INFO() | |
ZEND_BEGIN_ARG_INFO_EX(arginfo_imagecolorat, 0, 0, 3) | |
- ZEND_ARG_INFO(0, im) | |
+ ZEND_ARG_OBJ_INFO(0, im, GdImage, 0) | |
ZEND_ARG_TYPE_INFO(0, x, IS_LONG, 0) | |
ZEND_ARG_TYPE_INFO(0, y, IS_LONG, 0) | |
ZEND_END_ARG_INFO() | |
@@ -278,7 +278,7 @@ ZEND_END_ARG_INFO() | |
#define arginfo_imagecolorclosesthwb arginfo_imagecolorallocate | |
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagecolordeallocate, 0, 2, _IS_BOOL, 0) | |
- ZEND_ARG_INFO(0, im) | |
+ ZEND_ARG_OBJ_INFO(0, im, GdImage, 0) | |
ZEND_ARG_TYPE_INFO(0, index, IS_LONG, 0) | |
ZEND_END_ARG_INFO() | |
@@ -287,7 +287,7 @@ ZEND_END_ARG_INFO() | |
#define arginfo_imagecolorexact arginfo_imagecolorallocate | |
ZEND_BEGIN_ARG_INFO_EX(arginfo_imagecolorset, 0, 0, 5) | |
- ZEND_ARG_INFO(0, im) | |
+ ZEND_ARG_OBJ_INFO(0, im, GdImage, 0) | |
ZEND_ARG_TYPE_INFO(0, color, IS_LONG, 0) | |
ZEND_ARG_TYPE_INFO(0, red, IS_LONG, 0) | |
ZEND_ARG_TYPE_INFO(0, green, IS_LONG, 0) | |
@@ -296,25 +296,25 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_imagecolorset, 0, 0, 5) | |
ZEND_END_ARG_INFO() | |
ZEND_BEGIN_ARG_INFO_EX(arginfo_imagecolorsforindex, 0, 0, 2) | |
- ZEND_ARG_INFO(0, im) | |
+ ZEND_ARG_OBJ_INFO(0, im, GdImage, 0) | |
ZEND_ARG_TYPE_INFO(0, index, IS_LONG, 0) | |
ZEND_END_ARG_INFO() | |
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagegammacorrect, 0, 3, _IS_BOOL, 0) | |
- ZEND_ARG_INFO(0, im) | |
+ ZEND_ARG_OBJ_INFO(0, im, GdImage, 0) | |
ZEND_ARG_TYPE_INFO(0, inputgamma, IS_DOUBLE, 0) | |
ZEND_ARG_TYPE_INFO(0, outputgamma, IS_DOUBLE, 0) | |
ZEND_END_ARG_INFO() | |
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagesetpixel, 0, 4, _IS_BOOL, 0) | |
- ZEND_ARG_INFO(0, im) | |
+ ZEND_ARG_OBJ_INFO(0, im, GdImage, 0) | |
ZEND_ARG_TYPE_INFO(0, x, IS_LONG, 0) | |
ZEND_ARG_TYPE_INFO(0, y, IS_LONG, 0) | |
ZEND_ARG_TYPE_INFO(0, col, IS_LONG, 0) | |
ZEND_END_ARG_INFO() | |
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imageline, 0, 6, _IS_BOOL, 0) | |
- ZEND_ARG_INFO(0, im) | |
+ ZEND_ARG_OBJ_INFO(0, im, GdImage, 0) | |
ZEND_ARG_TYPE_INFO(0, x1, IS_LONG, 0) | |
ZEND_ARG_TYPE_INFO(0, y1, IS_LONG, 0) | |
ZEND_ARG_TYPE_INFO(0, x2, IS_LONG, 0) | |
@@ -329,7 +329,7 @@ ZEND_END_ARG_INFO() | |
#define arginfo_imagefilledrectangle arginfo_imageline | |
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagearc, 0, 8, _IS_BOOL, 0) | |
- ZEND_ARG_INFO(0, im) | |
+ ZEND_ARG_OBJ_INFO(0, im, GdImage, 0) | |
ZEND_ARG_TYPE_INFO(0, cx, IS_LONG, 0) | |
ZEND_ARG_TYPE_INFO(0, cy, IS_LONG, 0) | |
ZEND_ARG_TYPE_INFO(0, w, IS_LONG, 0) | |
@@ -342,7 +342,7 @@ ZEND_END_ARG_INFO() | |
#define arginfo_imageellipse arginfo_imagefilledellipse | |
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagefilltoborder, 0, 5, _IS_BOOL, 0) | |
- ZEND_ARG_INFO(0, im) | |
+ ZEND_ARG_OBJ_INFO(0, im, GdImage, 0) | |
ZEND_ARG_TYPE_INFO(0, x, IS_LONG, 0) | |
ZEND_ARG_TYPE_INFO(0, y, IS_LONG, 0) | |
ZEND_ARG_TYPE_INFO(0, border, IS_LONG, 0) | |
@@ -352,21 +352,21 @@ ZEND_END_ARG_INFO() | |
#define arginfo_imagefill arginfo_imagesetpixel | |
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagecolorstotal, 0, 1, IS_LONG, 0) | |
- ZEND_ARG_INFO(0, im) | |
+ ZEND_ARG_OBJ_INFO(0, im, GdImage, 0) | |
ZEND_END_ARG_INFO() | |
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagecolortransparent, 0, 1, IS_LONG, 1) | |
- ZEND_ARG_INFO(0, im) | |
+ ZEND_ARG_OBJ_INFO(0, im, GdImage, 0) | |
ZEND_ARG_TYPE_INFO(0, col, IS_LONG, 0) | |
ZEND_END_ARG_INFO() | |
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imageinterlace, 0, 1, IS_LONG, 1) | |
- ZEND_ARG_INFO(0, im) | |
+ ZEND_ARG_OBJ_INFO(0, im, GdImage, 0) | |
ZEND_ARG_TYPE_INFO(0, interlace, IS_LONG, 0) | |
ZEND_END_ARG_INFO() | |
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagepolygon, 0, 4, _IS_BOOL, 0) | |
- ZEND_ARG_INFO(0, im) | |
+ ZEND_ARG_OBJ_INFO(0, im, GdImage, 0) | |
ZEND_ARG_TYPE_INFO(0, points, IS_ARRAY, 0) | |
ZEND_ARG_TYPE_INFO(0, num_pos, IS_LONG, 0) | |
ZEND_ARG_TYPE_INFO(0, col, IS_LONG, 0) | |
@@ -383,7 +383,7 @@ ZEND_END_ARG_INFO() | |
#define arginfo_imagefontheight arginfo_imagefontwidth | |
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagechar, 0, 6, _IS_BOOL, 0) | |
- ZEND_ARG_INFO(0, im) | |
+ ZEND_ARG_OBJ_INFO(0, im, GdImage, 0) | |
ZEND_ARG_TYPE_INFO(0, font, IS_LONG, 0) | |
ZEND_ARG_TYPE_INFO(0, x, IS_LONG, 0) | |
ZEND_ARG_TYPE_INFO(0, y, IS_LONG, 0) | |
@@ -394,7 +394,7 @@ ZEND_END_ARG_INFO() | |
#define arginfo_imagecharup arginfo_imagechar | |
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagestring, 0, 6, _IS_BOOL, 0) | |
- ZEND_ARG_INFO(0, im) | |
+ ZEND_ARG_OBJ_INFO(0, im, GdImage, 0) | |
ZEND_ARG_TYPE_INFO(0, font, IS_LONG, 0) | |
ZEND_ARG_TYPE_INFO(0, x, IS_LONG, 0) | |
ZEND_ARG_TYPE_INFO(0, y, IS_LONG, 0) | |
@@ -402,11 +402,18 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagestring, 0, 6, _IS_BOOL, 0) | |
ZEND_ARG_TYPE_INFO(0, col, IS_LONG, 0) | |
ZEND_END_ARG_INFO() | |
-#define arginfo_imagestringup arginfo_imagestring | |
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagestringup, 0, 6, _IS_BOOL, 0) | |
+ ZEND_ARG_INFO(0, im) | |
+ ZEND_ARG_TYPE_INFO(0, font, IS_LONG, 0) | |
+ ZEND_ARG_TYPE_INFO(0, x, IS_LONG, 0) | |
+ ZEND_ARG_TYPE_INFO(0, y, IS_LONG, 0) | |
+ ZEND_ARG_TYPE_INFO(0, str, IS_STRING, 0) | |
+ ZEND_ARG_TYPE_INFO(0, col, IS_LONG, 0) | |
+ZEND_END_ARG_INFO() | |
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagecopy, 0, 8, _IS_BOOL, 0) | |
- ZEND_ARG_INFO(0, dst_im) | |
- ZEND_ARG_INFO(0, src_im) | |
+ ZEND_ARG_OBJ_INFO(0, dst_im, GdImage, 0) | |
+ ZEND_ARG_OBJ_INFO(0, src_im, GdImage, 0) | |
ZEND_ARG_TYPE_INFO(0, dst_x, IS_LONG, 0) | |
ZEND_ARG_TYPE_INFO(0, dst_y, IS_LONG, 0) | |
ZEND_ARG_TYPE_INFO(0, src_x, IS_LONG, 0) | |
@@ -416,8 +423,8 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagecopy, 0, 8, _IS_BOOL, 0) | |
ZEND_END_ARG_INFO() | |
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagecopymerge, 0, 9, _IS_BOOL, 0) | |
- ZEND_ARG_INFO(0, dst_im) | |
- ZEND_ARG_INFO(0, src_im) | |
+ ZEND_ARG_OBJ_INFO(0, dst_im, GdImage, 0) | |
+ ZEND_ARG_OBJ_INFO(0, src_im, GdImage, 0) | |
ZEND_ARG_TYPE_INFO(0, dst_x, IS_LONG, 0) | |
ZEND_ARG_TYPE_INFO(0, dst_y, IS_LONG, 0) | |
ZEND_ARG_TYPE_INFO(0, src_x, IS_LONG, 0) | |
@@ -436,7 +443,7 @@ ZEND_END_ARG_INFO() | |
#define arginfo_imagesy arginfo_imagecolorstotal | |
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagesetclip, 0, 5, _IS_BOOL, 0) | |
- ZEND_ARG_INFO(0, im) | |
+ ZEND_ARG_OBJ_INFO(0, im, GdImage, 0) | |
ZEND_ARG_TYPE_INFO(0, x1, IS_LONG, 0) | |
ZEND_ARG_TYPE_INFO(0, x2, IS_LONG, 0) | |
ZEND_ARG_TYPE_INFO(0, y1, IS_LONG, 0) | |
@@ -444,7 +451,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagesetclip, 0, 5, _IS_BOOL, 0) | |
ZEND_END_ARG_INFO() | |
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagegetclip, 0, 1, IS_ARRAY, 0) | |
- ZEND_ARG_INFO(0, im) | |
+ ZEND_ARG_OBJ_INFO(0, im, GdImage, 0) | |
ZEND_END_ARG_INFO() | |
#if defined(HAVE_GD_FREETYPE) | |
@@ -459,7 +466,7 @@ ZEND_END_ARG_INFO() | |
#if defined(HAVE_GD_FREETYPE) | |
ZEND_BEGIN_ARG_INFO_EX(arginfo_imagefttext, 0, 0, 8) | |
- ZEND_ARG_INFO(0, im) | |
+ ZEND_ARG_OBJ_INFO(0, im, GdImage, 0) | |
ZEND_ARG_TYPE_INFO(0, size, IS_DOUBLE, 0) | |
ZEND_ARG_TYPE_INFO(0, angle, IS_DOUBLE, 0) | |
ZEND_ARG_TYPE_INFO(0, x, IS_LONG, 0) | |
@@ -482,7 +489,7 @@ ZEND_END_ARG_INFO() | |
#if defined(HAVE_GD_FREETYPE) | |
ZEND_BEGIN_ARG_INFO_EX(arginfo_imagettftext, 0, 0, 8) | |
- ZEND_ARG_INFO(0, im) | |
+ ZEND_ARG_OBJ_INFO(0, im, GdImage, 0) | |
ZEND_ARG_TYPE_INFO(0, size, IS_DOUBLE, 0) | |
ZEND_ARG_TYPE_INFO(0, angle, IS_DOUBLE, 0) | |
ZEND_ARG_TYPE_INFO(0, x, IS_LONG, 0) | |
@@ -494,7 +501,7 @@ ZEND_END_ARG_INFO() | |
#endif | |
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagefilter, 0, 2, _IS_BOOL, 0) | |
- ZEND_ARG_INFO(0, im) | |
+ ZEND_ARG_OBJ_INFO(0, im, GdImage, 0) | |
ZEND_ARG_TYPE_INFO(0, filtertype, IS_LONG, 0) | |
ZEND_ARG_INFO(0, arg1) | |
ZEND_ARG_INFO(0, arg2) | |
@@ -503,43 +510,43 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagefilter, 0, 2, _IS_BOOL, 0) | |
ZEND_END_ARG_INFO() | |
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imageconvolution, 0, 4, _IS_BOOL, 0) | |
- ZEND_ARG_INFO(0, im) | |
+ ZEND_ARG_OBJ_INFO(0, im, GdImage, 0) | |
ZEND_ARG_TYPE_INFO(0, matrix3x3, IS_ARRAY, 0) | |
ZEND_ARG_TYPE_INFO(0, div, IS_DOUBLE, 0) | |
ZEND_ARG_TYPE_INFO(0, offset, IS_DOUBLE, 0) | |
ZEND_END_ARG_INFO() | |
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imageflip, 0, 2, _IS_BOOL, 0) | |
- ZEND_ARG_INFO(0, im) | |
+ ZEND_ARG_OBJ_INFO(0, im, GdImage, 0) | |
ZEND_ARG_TYPE_INFO(0, mode, IS_LONG, 0) | |
ZEND_END_ARG_INFO() | |
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imageantialias, 0, 2, _IS_BOOL, 0) | |
- ZEND_ARG_INFO(0, im) | |
+ ZEND_ARG_OBJ_INFO(0, im, GdImage, 0) | |
ZEND_ARG_TYPE_INFO(0, on, _IS_BOOL, 0) | |
ZEND_END_ARG_INFO() | |
ZEND_BEGIN_ARG_INFO_EX(arginfo_imagecrop, 0, 0, 2) | |
- ZEND_ARG_INFO(0, im) | |
+ ZEND_ARG_OBJ_INFO(0, im, GdImage, 0) | |
ZEND_ARG_TYPE_INFO(0, rect, IS_ARRAY, 0) | |
ZEND_END_ARG_INFO() | |
ZEND_BEGIN_ARG_INFO_EX(arginfo_imagecropauto, 0, 0, 1) | |
- ZEND_ARG_INFO(0, im) | |
+ ZEND_ARG_OBJ_INFO(0, im, GdImage, 0) | |
ZEND_ARG_TYPE_INFO(0, mode, IS_LONG, 0) | |
ZEND_ARG_TYPE_INFO(0, threshold, IS_DOUBLE, 0) | |
ZEND_ARG_TYPE_INFO(0, color, IS_LONG, 0) | |
ZEND_END_ARG_INFO() | |
ZEND_BEGIN_ARG_INFO_EX(arginfo_imagescale, 0, 0, 2) | |
- ZEND_ARG_INFO(0, im) | |
+ ZEND_ARG_OBJ_INFO(0, im, GdImage, 0) | |
ZEND_ARG_TYPE_INFO(0, new_width, IS_LONG, 0) | |
ZEND_ARG_TYPE_INFO(0, new_height, IS_LONG, 0) | |
ZEND_ARG_TYPE_INFO(0, mode, IS_LONG, 0) | |
ZEND_END_ARG_INFO() | |
ZEND_BEGIN_ARG_INFO_EX(arginfo_imageaffine, 0, 0, 2) | |
- ZEND_ARG_INFO(0, im) | |
+ ZEND_ARG_OBJ_INFO(0, im, GdImage, 0) | |
ZEND_ARG_TYPE_INFO(0, affine, IS_ARRAY, 0) | |
ZEND_ARG_TYPE_INFO(0, clip, IS_ARRAY, 0) | |
ZEND_END_ARG_INFO() | |
@@ -555,12 +562,12 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_imageaffinematrixconcat, 0, 0, 2) | |
ZEND_END_ARG_INFO() | |
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagesetinterpolation, 0, 1, _IS_BOOL, 0) | |
- ZEND_ARG_INFO(0, im) | |
+ ZEND_ARG_OBJ_INFO(0, im, GdImage, 0) | |
ZEND_ARG_TYPE_INFO(0, method, IS_LONG, 0) | |
ZEND_END_ARG_INFO() | |
ZEND_BEGIN_ARG_INFO_EX(arginfo_imageresolution, 0, 0, 1) | |
- ZEND_ARG_INFO(0, im) | |
+ ZEND_ARG_OBJ_INFO(0, im, GdImage, 0) | |
ZEND_ARG_TYPE_INFO(0, res_x, IS_LONG, 0) | |
ZEND_ARG_TYPE_INFO(0, res_y, IS_LONG, 0) | |
ZEND_END_ARG_INFO() | |
diff --git a/ext/gd/gd_ctx.c b/ext/gd/gd_ctx.c | |
index 52265de4ba..6f38887068 100644 | |
--- a/ext/gd/gd_ctx.c | |
+++ b/ext/gd/gd_ctx.c | |
@@ -98,12 +98,12 @@ static void _php_image_output_ctx(INTERNAL_FUNCTION_PARAMETERS, int image_type, | |
*/ | |
switch (image_type) { | |
case PHP_GDIMG_TYPE_XBM: | |
- if (zend_parse_parameters(argc, "rp!|ll", &imgind, &file, &file_len, &quality, &basefilter) == FAILURE) { | |
+ if (zend_parse_parameters(argc, "Op!|ll", &imgind, php_gd_image_ce, &file, &file_len, &quality, &basefilter) == FAILURE) { | |
return; | |
} | |
break; | |
case PHP_GDIMG_TYPE_BMP: | |
- if (zend_parse_parameters(argc, "r|z!b", &imgind, &to_zval, &compressed) == FAILURE) { | |
+ if (zend_parse_parameters(argc, "O|z!b", &imgind, php_gd_image_ce, &to_zval, &compressed) == FAILURE) { | |
return; | |
} | |
break; | |
@@ -114,14 +114,12 @@ static void _php_image_output_ctx(INTERNAL_FUNCTION_PARAMETERS, int image_type, | |
* PHP_GDIMG_TYPE_WBM | |
* PHP_GDIMG_TYPE_WEBP | |
* */ | |
- if (zend_parse_parameters(argc, "r|z!ll", &imgind, &to_zval, &quality, &basefilter) == FAILURE) { | |
+ if (zend_parse_parameters(argc, "O|z!ll", &imgind, php_gd_image_ce, &to_zval, &quality, &basefilter) == FAILURE) { | |
return; | |
} | |
} | |
- if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(imgind), "Image", phpi_get_le_gd())) == NULL) { | |
- return; | |
- } | |
+ im = (gdImagePtr) php_gd_image_object_cast(imgind); | |
if (image_type != PHP_GDIMG_TYPE_BMP && argc >= 3) { | |
q = quality; /* or colorindex for foreground of BW images (defaults to black) */ | |
diff --git a/ext/gd/php_gd.h b/ext/gd/php_gd.h | |
index a74a7cc6c2..cca6f86bb7 100644 | |
--- a/ext/gd/php_gd.h | |
+++ b/ext/gd/php_gd.h | |
@@ -29,6 +29,7 @@ | |
RETURN_FALSE; \ | |
} | |
+ | |
#define PHP_GDIMG_TYPE_GIF 1 | |
#define PHP_GDIMG_TYPE_PNG 2 | |
#define PHP_GDIMG_TYPE_JPG 3 | |
@@ -68,6 +69,10 @@ PHPAPI extern const char php_sig_bmp[2]; | |
PHPAPI extern const char php_sig_riff[4]; | |
PHPAPI extern const char php_sig_webp[4]; | |
+PHPAPI zend_class_entry* php_gd_image_ce; | |
+ | |
+void* php_gd_image_object_cast(zval *zv); | |
+ | |
extern zend_module_entry gd_module_entry; | |
#define phpext_gd_ptr &gd_module_entry | |
diff --git a/ext/gd/tests/bug41442.phpt b/ext/gd/tests/bug41442.phpt | |
index 5c590deb77..351734931a 100644 | |
--- a/ext/gd/tests/bug41442.phpt | |
+++ b/ext/gd/tests/bug41442.phpt | |
@@ -31,7 +31,9 @@ var_dump(imagecreatefromstring($str2)); | |
echo "Done\n"; | |
?> | |
---EXPECTF-- | |
-resource(%d) of type (gd) | |
-resource(%d) of type (gd) | |
+--EXPECT-- | |
+object(GdImage)#2 (0) { | |
+} | |
+object(GdImage)#2 (0) { | |
+} | |
Done | |
diff --git a/ext/gd/tests/bug66356.phpt b/ext/gd/tests/bug66356.phpt | |
index 7dbfb1b40e..0e13bca9b3 100644 | |
--- a/ext/gd/tests/bug66356.phpt | |
+++ b/ext/gd/tests/bug66356.phpt | |
@@ -28,8 +28,10 @@ var_dump(imagecrop($img, array("x" => 0x7fffff00, "y" => 0, "width" => 10, "heig | |
var_dump(imagecrop($img, array("x" => 0, "y" => 0, "width" => 65535, "height" => 65535))); | |
?> | |
--EXPECTF-- | |
-resource(%d) of type (gd) | |
-resource(%d) of type (gd) | |
+object(GdImage)#2 (0) { | |
+} | |
+object(GdImage)#2 (0) { | |
+} | |
Array | |
( | |
[x] => a | |
@@ -39,11 +41,13 @@ Array | |
) | |
Warning: imagecrop(): one parameter to a memory allocation multiplication is negative or zero, failing operation gracefully | |
- in %sbug66356.php on line %d | |
+ in %s on line %d | |
bool(false) | |
-resource(%d) of type (gd) | |
-resource(%d) of type (gd) | |
+object(GdImage)#2 (0) { | |
+} | |
+object(GdImage)#2 (0) { | |
+} | |
Warning: imagecrop(): product of memory allocation multiplication would exceed INT_MAX, failing operation gracefully | |
- in %sbug66356.php on line %d | |
+ in %s on line %d | |
bool(false) | |
diff --git a/ext/gd/tests/bug70976.phpt b/ext/gd/tests/bug70976.phpt | |
index b4f5c9b78b..cd10a8ffc0 100644 | |
--- a/ext/gd/tests/bug70976.phpt | |
+++ b/ext/gd/tests/bug70976.phpt | |
@@ -10,4 +10,5 @@ $img = imagerotate(imagecreate(10,10),45,0x7ffffff9); | |
var_dump($img); | |
?> | |
--EXPECT-- | |
-resource(5) of type (gd) | |
+object(GdImage)#2 (0) { | |
+} | |
diff --git a/ext/gd/tests/bug73968.phpt b/ext/gd/tests/bug73968.phpt | |
index 2211840f58..c1101c61bf 100644 | |
--- a/ext/gd/tests/bug73968.phpt | |
+++ b/ext/gd/tests/bug73968.phpt | |
@@ -9,7 +9,6 @@ if (!extension_loaded('gd')) die('skip gd extension not available'); | |
$im = imagecreatefromxbm(__DIR__ . DIRECTORY_SEPARATOR . 'bug73968.xbm'); | |
var_dump($im); | |
?> | |
-===DONE=== | |
---EXPECTF-- | |
-resource(%d) of type (gd) | |
-===DONE=== | |
+--EXPECT-- | |
+object(GdImage)#1 (0) { | |
+} | |
diff --git a/ext/gd/tests/bug74435.phpt b/ext/gd/tests/bug74435.phpt | |
index 9d11eb3839..78f2103247 100644 | |
--- a/ext/gd/tests/bug74435.phpt | |
+++ b/ext/gd/tests/bug74435.phpt | |
@@ -21,7 +21,6 @@ for ($i = 0; $i < $width; $i += 16) { | |
} | |
} | |
?> | |
-===DONE=== | |
---EXPECTF-- | |
-resource(%d) of type (gd) | |
-===DONE=== | |
+--EXPECT-- | |
+object(GdImage)#1 (0) { | |
+} | |
diff --git a/ext/gd/tests/bug77269.phpt b/ext/gd/tests/bug77269.phpt | |
index c89f674b8a..527f26c397 100644 | |
--- a/ext/gd/tests/bug77269.phpt | |
+++ b/ext/gd/tests/bug77269.phpt | |
@@ -10,9 +10,8 @@ memory_limit=2G | |
--FILE-- | |
<?php | |
$im = imagecreate(2**28, 1); | |
-if(is_resource($im)) { | |
- imagescale($im, 1, 1, IMG_TRIANGLE); | |
-} | |
+imagescale($im, 1, 1, IMG_TRIANGLE); | |
+ | |
?> | |
===DONE=== | |
--EXPECTF-- | |
diff --git a/ext/gd/tests/bug77391.phpt b/ext/gd/tests/bug77391.phpt | |
index aa76c1470e..fbfa8a8026 100644 | |
--- a/ext/gd/tests/bug77391.phpt | |
+++ b/ext/gd/tests/bug77391.phpt | |
@@ -9,7 +9,6 @@ if (!GD_BUNDLED && version_compare(GD_VERSION, '2.2.5', '<=')) die('skip upstrea | |
<?php | |
var_dump(imagecreatefrombmp(__DIR__ . '/bug77391.bmp')); | |
?> | |
-===DONE=== | |
---EXPECTF-- | |
-resource(%d) of type (gd) | |
-===DONE=== | |
+--EXPECT-- | |
+object(GdImage)#1 (0) { | |
+} | |
diff --git a/ext/gd/tests/gdimage_prevent_cloning.phpt b/ext/gd/tests/gdimage_prevent_cloning.phpt | |
new file mode 100644 | |
index 0000000000..0f5c198e88 | |
--- /dev/null | |
+++ b/ext/gd/tests/gdimage_prevent_cloning.phpt | |
@@ -0,0 +1,20 @@ | |
+--TEST-- | |
+Checks that GdImage instances cannot be cloned | |
+--SKIPIF-- | |
+<?php | |
+if(!extension_loaded('gd')) { | |
+ die('skip gd extension is not loaded'); | |
+} | |
+?> | |
+--FILE-- | |
+<?php | |
+ | |
+ $img_src = imagecreatetruecolor(32, 32); | |
+ $img_dst = clone $img_src; | |
+ | |
+?> | |
+--EXPECTF-- | |
+Fatal error: Uncaught Error: Trying to clone an uncloneable object of class GdImage in %s:%d | |
+Stack trace: | |
+#0 {main} | |
+ thrown in %s on line %d | |
diff --git a/ext/gd/tests/imageantialias_error1.phpt b/ext/gd/tests/imageantialias_error1.phpt | |
deleted file mode 100644 | |
index d74a2ad9a2..0000000000 | |
--- a/ext/gd/tests/imageantialias_error1.phpt | |
+++ /dev/null | |
@@ -1,21 +0,0 @@ | |
---TEST-- | |
-Testing wrong parameter resource in imageantialias() of GD library | |
---CREDITS-- | |
-Guilherme Blanco <guilhermeblanco [at] hotmail [dot] com> | |
-#testfest PHPSP on 2009-06-20 | |
---SKIPIF-- | |
-<?php | |
-if (!extension_loaded("gd")) die("skip GD not present"); | |
-?> | |
---FILE-- | |
-<?php | |
-$image = tmpfile(); | |
- | |
-try { | |
- var_dump(imageantialias($image, true)); | |
-} catch (TypeError $e) { | |
- echo $e->getMessage(), "\n"; | |
-} | |
-?> | |
---EXPECT-- | |
-imageantialias(): supplied resource is not a valid Image resource | |
diff --git a/ext/gd/tests/imagechar_error2.phpt b/ext/gd/tests/imagechar_error2.phpt | |
deleted file mode 100644 | |
index a829282307..0000000000 | |
--- a/ext/gd/tests/imagechar_error2.phpt | |
+++ /dev/null | |
@@ -1,21 +0,0 @@ | |
---TEST-- | |
-Testing error on non-image resource parameter 1 of imagechar() of GD library | |
---CREDITS-- | |
-Rafael Dohms <rdohms [at] gmail [dot] com> | |
-#testfest PHPSP on 2009-06-20 | |
---SKIPIF-- | |
-<?php | |
- if (!extension_loaded("gd")) die("skip GD not present"); | |
-?> | |
---FILE-- | |
-<?php | |
- | |
-try { | |
- $result = imagechar(tmpfile(), 1, 5, 5, 'C', 1); | |
-} catch (TypeError $e) { | |
- echo $e->getMessage(), "\n"; | |
-} | |
- | |
-?> | |
---EXPECT-- | |
-imagechar(): supplied resource is not a valid Image resource | |
diff --git a/ext/gd/tests/imagecharup_error2.phpt b/ext/gd/tests/imagecharup_error2.phpt | |
deleted file mode 100644 | |
index f8b0bc4ebf..0000000000 | |
--- a/ext/gd/tests/imagecharup_error2.phpt | |
+++ /dev/null | |
@@ -1,21 +0,0 @@ | |
---TEST-- | |
-Testing error on non-image resource parameter 1 of imagecharup() of GD library | |
---CREDITS-- | |
-Rafael Dohms <rdohms [at] gmail [dot] com> | |
-#testfest PHPSP on 2009-06-20 | |
---SKIPIF-- | |
-<?php | |
- if (!extension_loaded("gd")) die("skip GD not present"); | |
-?> | |
---FILE-- | |
-<?php | |
- | |
-try { | |
- $result = imagecharup(tmpfile(), 1, 5, 5, 'C', 1); | |
-} catch (TypeError $e) { | |
- echo $e->getMessage(), "\n"; | |
-} | |
- | |
-?> | |
---EXPECT-- | |
-imagecharup(): supplied resource is not a valid Image resource | |
diff --git a/ext/gd/tests/imagecolorallocatealpha_error1.phpt b/ext/gd/tests/imagecolorallocatealpha_error1.phpt | |
deleted file mode 100644 | |
index ea490dd526..0000000000 | |
--- a/ext/gd/tests/imagecolorallocatealpha_error1.phpt | |
+++ /dev/null | |
@@ -1,19 +0,0 @@ | |
---TEST-- | |
-Testing imagecolorallocatealpha(): Wrong types for parameter 1 | |
---CREDITS-- | |
-Rafael Dohms <rdohms [at] gmail [dot] com> | |
---SKIPIF-- | |
-<?php | |
- if (!extension_loaded("gd")) die("skip GD not present"); | |
-?> | |
---FILE-- | |
-<?php | |
-$resource = tmpfile(); | |
-try { | |
- imagecolorallocatealpha($resource, 255, 255, 255, 50); | |
-} catch (TypeError $e) { | |
- echo $e->getMessage(), "\n"; | |
-} | |
-?> | |
---EXPECT-- | |
-imagecolorallocatealpha(): supplied resource is not a valid Image resource | |
diff --git a/ext/gd/tests/imagecolordeallocate_error1.phpt b/ext/gd/tests/imagecolordeallocate_error1.phpt | |
deleted file mode 100644 | |
index 3c75055a5f..0000000000 | |
--- a/ext/gd/tests/imagecolordeallocate_error1.phpt | |
+++ /dev/null | |
@@ -1,26 +0,0 @@ | |
---TEST-- | |
-Testing imagecolordeallocate() of GD library with invalid resource type | |
---CREDITS-- | |
-Rafael Dohms <rdohms [at] gmail [dot] com> | |
-#testfest PHPSP on 2009-06-20 | |
---SKIPIF-- | |
-<?php | |
- if (!extension_loaded("gd")) die("skip GD not present"); | |
-?> | |
---FILE-- | |
-<?php | |
- | |
-$image = imagecreatetruecolor(180, 30); | |
-$white = imagecolorallocate($image, 255, 255, 255); | |
- | |
-$resource = tmpfile(); | |
- | |
-try { | |
- $result = imagecolordeallocate($resource, $white); | |
-} catch (TypeError $e) { | |
- echo $e->getMessage(), "\n"; | |
-} | |
- | |
-?> | |
---EXPECT-- | |
-imagecolordeallocate(): supplied resource is not a valid Image resource | |
diff --git a/ext/gd/tests/imagecolordeallocate_error3.phpt b/ext/gd/tests/imagecolordeallocate_error3.phpt | |
index e9be1ea66a..f81b52192a 100644 | |
--- a/ext/gd/tests/imagecolordeallocate_error3.phpt | |
+++ b/ext/gd/tests/imagecolordeallocate_error3.phpt | |
@@ -9,14 +9,17 @@ Rafael Dohms <rdohms [at] gmail [dot] com> | |
?> | |
--FILE-- | |
<?php | |
+require_once __DIR__ . '/func.inc'; | |
+ | |
$image = imagecreate(180, 30); | |
$white = imagecolorallocate($image, 255, 255, 255); | |
$totalColors = imagecolorstotal($image); | |
-$result = imagecolordeallocate($image, $totalColors + 100); | |
-var_dump($result); | |
+trycatch_dump( | |
+ fn() => imagecolordeallocate($image, $totalColors + 100) | |
+); | |
+ | |
?> | |
---EXPECTF-- | |
-Warning: imagecolordeallocate(): Color index 101 out of range in %s on line %d | |
-bool(false) | |
+--EXPECT-- | |
+!! [ValueError] Color index 101 out of range | |
diff --git a/ext/gd/tests/imagecolordeallocate_error4.phpt b/ext/gd/tests/imagecolordeallocate_error4.phpt | |
index 22fc2fa3ef..4d3009dcae 100644 | |
--- a/ext/gd/tests/imagecolordeallocate_error4.phpt | |
+++ b/ext/gd/tests/imagecolordeallocate_error4.phpt | |
@@ -9,14 +9,17 @@ Rafael Dohms <rdohms [at] gmail [dot] com> | |
?> | |
--FILE-- | |
<?php | |
+ | |
+require_once __DIR__ . '/func.inc'; | |
$image = imagecreate(180, 30); | |
$white = imagecolorallocate($image, 255, 255, 255); | |
$totalColors = imagecolorstotal($image); | |
-$result = imagecolordeallocate($image, -1.0); | |
-var_dump($result); | |
+trycatch_dump( | |
+ fn() => imagecolordeallocate($image, -1.0) | |
+); | |
+ | |
?> | |
---EXPECTF-- | |
-Warning: imagecolordeallocate(): Color index -1 out of range in %s on line %d | |
-bool(false) | |
+--EXPECT-- | |
+!! [ValueError] Color index -1 out of range | |
diff --git a/ext/gd/tests/imagecolorstotal_error.phpt b/ext/gd/tests/imagecolorstotal_error.phpt | |
deleted file mode 100644 | |
index e05c6894db..0000000000 | |
--- a/ext/gd/tests/imagecolorstotal_error.phpt | |
+++ /dev/null | |
@@ -1,39 +0,0 @@ | |
---TEST-- | |
-Test imagecolorstotal() function : error conditions - Pass invalid resource type | |
---SKIPIF-- | |
-<?php | |
-if(!extension_loaded('gd')) { | |
- die('skip gd extension is not loaded'); | |
-} | |
-if(!function_exists('imagecolorstotal')) { | |
- die('skip imagecolorstotal function is not available'); | |
-} | |
-?> | |
---FILE-- | |
-<?php | |
-/* Prototype : int imagecolorstotal ( resource $image ) | |
- * Description: Find out the number of colors in an image's palette | |
- * Source code: ext/gd/gd.c | |
- */ | |
- | |
-echo "*** Testing imagecolorstotal() : error conditions ***\n"; | |
- | |
-// Get a resource | |
-$im = fopen(__FILE__, 'r'); | |
- | |
-echo "\n-- Testing imagecolorstotal() function with a invalid resource\n"; | |
-try { | |
- var_dump( imagecolorstotal($im) ); | |
-} catch (TypeError $e) { | |
- echo $e->getMessage(), "\n"; | |
-} | |
- | |
-fclose($im); | |
-?> | |
-===DONE=== | |
---EXPECT-- | |
-*** Testing imagecolorstotal() : error conditions *** | |
- | |
--- Testing imagecolorstotal() function with a invalid resource | |
-imagecolorstotal(): supplied resource is not a valid Image resource | |
-===DONE=== | |
diff --git a/ext/gd/tests/imageellipse_error7.phpt b/ext/gd/tests/imageellipse_error7.phpt | |
deleted file mode 100644 | |
index bc78875d3d..0000000000 | |
--- a/ext/gd/tests/imageellipse_error7.phpt | |
+++ /dev/null | |
@@ -1,24 +0,0 @@ | |
---TEST-- | |
-Testing wrong param passing imageellipse() of GD library | |
---CREDITS-- | |
-Ivan Rosolen <contato [at] ivanrosolen [dot] com> | |
-#testfest PHPSP on 2009-06-20 | |
---SKIPIF-- | |
-<?php | |
-if (!extension_loaded("gd")) die("skip GD not present"); | |
-?> | |
---FILE-- | |
-<?php | |
- | |
-// Create a resource | |
-$image = tmpfile(); | |
- | |
-// try to draw a white ellipse | |
-try { | |
- imageellipse($image, 200, 150, 300, 200, 16777215); | |
-} catch (TypeError $e) { | |
- echo $e->getMessage(), "\n"; | |
-} | |
-?> | |
---EXPECT-- | |
-imageellipse(): supplied resource is not a valid Image resource | |
diff --git a/ext/gd/tests/imagefilltoborder_error6.phpt b/ext/gd/tests/imagefilltoborder_error6.phpt | |
deleted file mode 100644 | |
index 5a77db798e..0000000000 | |
--- a/ext/gd/tests/imagefilltoborder_error6.phpt | |
+++ /dev/null | |
@@ -1,31 +0,0 @@ | |
---TEST-- | |
-Testing wrong param passing imagefilltoborder() of GD library | |
---CREDITS-- | |
-Ivan Rosolen <contato [at] ivanrosolen [dot] com> | |
-#testfest PHPSP on 2009-06-30 | |
---SKIPIF-- | |
-<?php | |
-if (!extension_loaded("gd")) die("skip GD not present"); | |
-?> | |
---FILE-- | |
-<?php | |
-// Create a image | |
-$image = imagecreatetruecolor( 100, 100 ); | |
- | |
-// Draw a rectangle | |
-imagefilledrectangle( $image, 0, 0, 100, 100, imagecolorallocate( $image, 255, 255, 255 ) ); | |
- | |
-// Draw an ellipse to fill with a black border | |
-imageellipse( $image, 50, 50, 50, 50, imagecolorallocate( $image, 0, 0, 0 ) ); | |
- | |
-// Try to fill border | |
-$image_foo = tmpfile(); | |
-try { | |
- imagefilltoborder( $image_foo, 50, 50, imagecolorallocate( $image, 0, 0, 0 ), imagecolorallocate( $image, 255, 0, 0 ) ); | |
-} catch (TypeError $e) { | |
- echo $e->getMessage(), "\n"; | |
-} | |
- | |
-?> | |
---EXPECT-- | |
-imagefilltoborder(): supplied resource is not a valid Image resource | |
diff --git a/ext/gd/tests/imagefilter_error10.phpt b/ext/gd/tests/imagefilter_error10.phpt | |
deleted file mode 100644 | |
index 07aecee632..0000000000 | |
--- a/ext/gd/tests/imagefilter_error10.phpt | |
+++ /dev/null | |
@@ -1,21 +0,0 @@ | |
---TEST-- | |
-Testing wrong parameter resource of EMBOSS in imagefilter() of GD library | |
---CREDITS-- | |
-Guilherme Blanco <guilhermeblanco [at] hotmail [dot] com> | |
-#testfest PHPSP on 2009-06-20 | |
---SKIPIF-- | |
-<?php | |
-if (!extension_loaded("gd")) die("skip GD not present"); | |
-?> | |
---FILE-- | |
-<?php | |
-$image = tmpfile(); | |
- | |
-try { | |
- var_dump(imagefilter($image, IMG_FILTER_EMBOSS)); | |
-} catch (TypeError $e) { | |
- echo $e->getMessage(), "\n"; | |
-} | |
-?> | |
---EXPECT-- | |
-imagefilter(): supplied resource is not a valid Image resource | |
diff --git a/ext/gd/tests/imagegammacorrect_error2.phpt b/ext/gd/tests/imagegammacorrect_error2.phpt | |
deleted file mode 100644 | |
index 013dd67b9a..0000000000 | |
--- a/ext/gd/tests/imagegammacorrect_error2.phpt | |
+++ /dev/null | |
@@ -1,21 +0,0 @@ | |
---TEST-- | |
-Testing error with non-Image resource paramenter of imagegammacorrect() of GD library, | |
---CREDITS-- | |
-Rafael Dohms <rdohms [at] gmail [dot] com> | |
-#testfest PHPSP on 2009-06-20 | |
---SKIPIF-- | |
-<?php | |
- if (!extension_loaded("gd")) die("skip GD not present"); | |
-?> | |
---FILE-- | |
-<?php | |
-$image = tmpfile(); | |
-try { | |
- $gamma = imagegammacorrect($image, 1, 5); | |
-} catch (TypeError $e) { | |
- echo $e->getMessage(), "\n"; | |
-} | |
- | |
-?> | |
---EXPECT-- | |
-imagegammacorrect(): supplied resource is not a valid Image resource | |
diff --git a/ext/gd/tests/imageinterlace_error2.phpt b/ext/gd/tests/imageinterlace_error2.phpt | |
deleted file mode 100644 | |
index e906c61261..0000000000 | |
--- a/ext/gd/tests/imageinterlace_error2.phpt | |
+++ /dev/null | |
@@ -1,20 +0,0 @@ | |
---TEST-- | |
-Testing resource that is not a image to imageinterlace() of GD library | |
---CREDITS-- | |
-Edgar Ferreira da Silva <contato [at] edgarfs [dot] com [dot] br> | |
-#testfest PHPSP on 2009-06-20 | |
---SKIPIF-- | |
-<?php | |
-if (!extension_loaded("gd")) die("skip GD not present"); | |
-?> | |
---FILE-- | |
-<?php | |
-$image = fopen('php://stdin', 'r'); | |
-try { | |
- var_dump(imageinterlace($image)); | |
-} catch (TypeError $e) { | |
- echo $e->getMessage(), "\n"; | |
-} | |
-?> | |
---EXPECT-- | |
-imageinterlace(): supplied resource is not a valid Image resource | |
diff --git a/ext/gd/tests/imageistruecolor_error1.phpt b/ext/gd/tests/imageistruecolor_error1.phpt | |
deleted file mode 100644 | |
index b99dd93b00..0000000000 | |
--- a/ext/gd/tests/imageistruecolor_error1.phpt | |
+++ /dev/null | |
@@ -1,20 +0,0 @@ | |
---TEST-- | |
-Testing imageistruecolor(): wrong parameters | |
---CREDITS-- | |
-Rafael Dohms <rdohms [at] gmail [dot] com> | |
---SKIPIF-- | |
-<?php | |
- if (!extension_loaded("gd")) die("skip GD not present"); | |
- if (!function_exists("imagecreatetruecolor")) die("skip GD Version not compatible"); | |
-?> | |
---FILE-- | |
-<?php | |
-$resource = tmpfile(); | |
-try { | |
- imageistruecolor($resource); | |
-} catch (TypeError $e) { | |
- echo $e->getMessage(), "\n"; | |
-} | |
-?> | |
---EXPECT-- | |
-imageistruecolor(): supplied resource is not a valid Image resource | |
diff --git a/ext/gd/tests/imagelayereffect_error3.phpt b/ext/gd/tests/imagelayereffect_error3.phpt | |
deleted file mode 100644 | |
index c3b793c45d..0000000000 | |
--- a/ext/gd/tests/imagelayereffect_error3.phpt | |
+++ /dev/null | |
@@ -1,21 +0,0 @@ | |
---TEST-- | |
-Testing imagelayereffect() with invalid resource of GD library | |
---CREDITS-- | |
-Rafael Dohms <rdohms [at] gmail [dot] com> | |
-#testfest PHPSP on 2009-06-20 | |
---SKIPIF-- | |
-<?php | |
- if (!extension_loaded("gd")) die("skip GD not present"); | |
- if (!GD_BUNDLED) die('skip function only available in bundled, external GD detected'); | |
-?> | |
---FILE-- | |
-<?php | |
-$resource = tmpfile(); | |
-try { | |
- $layer = imagelayereffect($resource, IMG_EFFECT_REPLACE); | |
-} catch (TypeError $e) { | |
- echo $e->getMessage(), "\n"; | |
-} | |
-?> | |
---EXPECT-- | |
-imagelayereffect(): supplied resource is not a valid Image resource | |
diff --git a/ext/gd/tests/imagepalettetotruecolor_basic.phpt b/ext/gd/tests/imagepalettetotruecolor_basic.phpt | |
index 63a2b51e77..89fb514a5f 100644 | |
--- a/ext/gd/tests/imagepalettetotruecolor_basic.phpt | |
+++ b/ext/gd/tests/imagepalettetotruecolor_basic.phpt | |
@@ -9,7 +9,7 @@ Carlos André Ferrari <caferrari [at] gmail [dot] com> | |
--FILE-- | |
<?php | |
$im = imagecreate(100, 100); | |
-var_dump(is_resource($im)); | |
+var_dump($im instanceof GdImage); | |
var_dump(imageistruecolor($im)); | |
var_dump(imagepalettetotruecolor($im)); | |
var_dump(imageistruecolor($im)); | |
diff --git a/ext/gd/tests/imagepalettetotruecolor_error3.phpt b/ext/gd/tests/imagepalettetotruecolor_error3.phpt | |
deleted file mode 100644 | |
index 09a7d9ab06..0000000000 | |
--- a/ext/gd/tests/imagepalettetotruecolor_error3.phpt | |
+++ /dev/null | |
@@ -1,19 +0,0 @@ | |
---TEST-- | |
-imagepalettetotruecollor must return an error if not an image resource is given | |
---CREDITS-- | |
-Carlos André Ferrari <caferrari [at] gmail [dot] com> | |
---SKIPIF-- | |
-<?php | |
- if (!extension_loaded('gd')) die("skip gd extension not available."); | |
-?> | |
---FILE-- | |
-<?php | |
-$im = fopen('php://memory', 'w'); | |
-try { | |
- imagepalettetotruecolor($im); | |
-} catch (TypeError $e) { | |
- echo $e->getMessage(), "\n"; | |
-} | |
-?> | |
---EXPECT-- | |
-imagepalettetotruecolor(): supplied resource is not a valid Image resource | |
diff --git a/ext/gd/tests/imagerectangle_error2.phpt b/ext/gd/tests/imagerectangle_error2.phpt | |
deleted file mode 100644 | |
index fdc4678d57..0000000000 | |
--- a/ext/gd/tests/imagerectangle_error2.phpt | |
+++ /dev/null | |
@@ -1,23 +0,0 @@ | |
---TEST-- | |
-Testing wrong param passing imagerectangle() of GD library | |
---CREDITS-- | |
-Ivan Rosolen <contato [at] ivanrosolen [dot] com> | |
-#testfest PHPSP on 2009-06-30 | |
---SKIPIF-- | |
-<?php | |
-if ( ! extension_loaded('gd') ) die( 'skip GD not present; skipping test' ); | |
-?> | |
---FILE-- | |
-<?php | |
-// Create a resource | |
-$image = tmpfile(); | |
- | |
-// Draw a rectangle | |
-try { | |
- imagerectangle( $image, 0, 0, 50, 50, 2 ); | |
-} catch (TypeError $e) { | |
- echo $e->getMessage(), "\n"; | |
-} | |
-?> | |
---EXPECT-- | |
-imagerectangle(): supplied resource is not a valid Image resource | |
diff --git a/ext/gd/tests/imagesetthickness_error1.phpt b/ext/gd/tests/imagesetthickness_error1.phpt | |
deleted file mode 100644 | |
index a9ee7f9fcc..0000000000 | |
--- a/ext/gd/tests/imagesetthickness_error1.phpt | |
+++ /dev/null | |
@@ -1,19 +0,0 @@ | |
---TEST-- | |
-Testing imagetruecolortopalette(): wrong types for first parameter | |
---CREDITS-- | |
-Rafael Dohms <rdohms [at] gmail [dot] com> | |
---SKIPIF-- | |
-<?php | |
- if (!extension_loaded("gd")) die("skip GD not present"); | |
-?> | |
---FILE-- | |
-<?php | |
-$resource = tmpfile(); | |
-try { | |
- imagesetthickness($resource, 5); | |
-} catch (TypeError $e) { | |
- echo $e->getMessage(), "\n"; | |
-} | |
-?> | |
---EXPECT-- | |
-imagesetthickness(): supplied resource is not a valid Image resource | |
diff --git a/ext/gd/tests/imagestring_error2.phpt b/ext/gd/tests/imagestring_error2.phpt | |
deleted file mode 100644 | |
index ff9032a312..0000000000 | |
--- a/ext/gd/tests/imagestring_error2.phpt | |
+++ /dev/null | |
@@ -1,21 +0,0 @@ | |
---TEST-- | |
-Testing error on non-image resource parameter 1 of imagestring() of GD library | |
---CREDITS-- | |
-Rafael Dohms <rdohms [at] gmail [dot] com> | |
-#testfest PHPSP on 2009-06-20 | |
---SKIPIF-- | |
-<?php | |
- if (!extension_loaded("gd")) die("skip GD not present"); | |
-?> | |
---FILE-- | |
-<?php | |
- | |
-try { | |
- $result = imagestring(tmpfile(), 1, 5, 5, 'String', 1); | |
-} catch (TypeError $e) { | |
- echo $e->getMessage(), "\n"; | |
-} | |
- | |
-?> | |
---EXPECT-- | |
-imagestring(): supplied resource is not a valid Image resource | |
diff --git a/ext/gd/tests/imagestringup_error2.phpt b/ext/gd/tests/imagestringup_error2.phpt | |
deleted file mode 100644 | |
index c09792c982..0000000000 | |
--- a/ext/gd/tests/imagestringup_error2.phpt | |
+++ /dev/null | |
@@ -1,21 +0,0 @@ | |
---TEST-- | |
-Testing error on non-image resource parameter 1 of imagestringup() of GD library | |
---CREDITS-- | |
-Rafael Dohms <rdohms [at] gmail [dot] com> | |
-#testfest PHPSP on 2009-06-20 | |
---SKIPIF-- | |
-<?php | |
- if (!extension_loaded("gd")) die("skip GD not present"); | |
-?> | |
---FILE-- | |
-<?php | |
- | |
-try { | |
- $result = imagestringup(tmpfile(), 1, 5, 5, 'String', 1); | |
-} catch (TypeError $e) { | |
- echo $e->getMessage(), "\n"; | |
-} | |
- | |
-?> | |
---EXPECT-- | |
-imagestringup(): supplied resource is not a valid Image resource | |
diff --git a/ext/gd/tests/imagetruecolortopalette_error1.phpt b/ext/gd/tests/imagetruecolortopalette_error1.phpt | |
deleted file mode 100644 | |
index dcdcfaea20..0000000000 | |
--- a/ext/gd/tests/imagetruecolortopalette_error1.phpt | |
+++ /dev/null | |
@@ -1,20 +0,0 @@ | |
---TEST-- | |
-Testing imagetruecolortopalette(): wrong parameters for parameter 1 | |
---CREDITS-- | |
-Rafael Dohms <rdohms [at] gmail [dot] com> | |
---SKIPIF-- | |
-<?php | |
- if (!extension_loaded("gd")) die("skip GD not present"); | |
- if (!function_exists("imagecreatetruecolor")) die("skip GD Version not compatible"); | |
-?> | |
---FILE-- | |
-<?php | |
-$resource = tmpfile(); | |
-try { | |
- imagetruecolortopalette($resource, true, 2); | |
-} catch (TypeError $e) { | |
- echo $e->getMessage(), "\n"; | |
-} | |
-?> | |
---EXPECT-- | |
-imagetruecolortopalette(): supplied resource is not a valid Image resource | |
diff --git a/ext/posix/tests/posix_ttyname_error_wrongparams.phpt b/ext/posix/tests/posix_ttyname_error_wrongparams.phpt | |
index 6dcb1d324d..4ff7aaf3fe 100644 | |
--- a/ext/posix/tests/posix_ttyname_error_wrongparams.phpt | |
+++ b/ext/posix/tests/posix_ttyname_error_wrongparams.phpt | |
@@ -3,6 +3,7 @@ Test posix_ttyname() with wrong parameters | |
--DESCRIPTION-- | |
Gets the absolute path to the current terminal device that is open on a given file descriptor. | |
Source code: ext/posix/posix.c | |
+ | |
--CREDITS-- | |
Falko Menge, mail at falko-menge dot de | |
PHP Testfest Berlin 2009-05-10 | |
@@ -11,18 +12,16 @@ PHP Testfest Berlin 2009-05-10 | |
if (!extension_loaded('posix')) { | |
die('SKIP - POSIX extension not available'); | |
} | |
- if (!extension_loaded('gd')) { | |
- die('SKIP - GD extension not available'); | |
- } | |
- if (!function_exists('imagecreate')) { | |
- die('SKIP - Function imagecreate() not available'); | |
+ | |
+ if (!function_exists('curl_init')) { | |
+ die('SKIP - Function curl_init() not available'); | |
} | |
?> | |
--FILE-- | |
<?php | |
var_dump(posix_ttyname(0)); // param not a ressource | |
try { | |
- var_dump(posix_ttyname(imagecreate(1, 1))); // wrong resource type | |
+ var_dump(posix_ttyname(curl_init())); // wrong resource type | |
} catch (TypeError $e) { | |
echo $e->getMessage(), "\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment