diff --git a/ext/gd/gd.c b/ext/gd/gd.c index a64f02aa22c3d..2cb33503fed81 100644 --- a/ext/gd/gd.c +++ b/ext/gd/gd.c @@ -1869,20 +1869,20 @@ PHP_FUNCTION(imagexbm) zval *imgind; char *file = NULL; size_t file_len = 0; - zend_long foreground_color = -1; + zend_long foreground_color; + zend_bool foreground_color_is_null = 1; gdImagePtr im; - int argc = ZEND_NUM_ARGS(); int i; gdIOCtx *ctx = NULL; php_stream *stream; - if (zend_parse_parameters(argc, "Op!|l", &imgind, gd_image_ce, &file, &file_len, &foreground_color) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "Op!|l!", &imgind, gd_image_ce, &file, &file_len, &foreground_color, &foreground_color_is_null) == FAILURE) { RETURN_THROWS(); } im = php_gd_libgdimageptr_from_zval_p(imgind); - if (argc > 1 && file != NULL) { + if (file != NULL) { stream = php_stream_open_wrapper(file, "wb", REPORT_ERRORS|IGNORE_PATH|IGNORE_URL_WIN, NULL); if (stream == NULL) { RETURN_FALSE; @@ -1893,10 +1893,13 @@ PHP_FUNCTION(imagexbm) ctx = create_output_context(); } - if (argc < 3) { + if (foreground_color_is_null) { for (i=0; i < gdImageColorsTotal(im); i++) { - if (!gdImageRed(im, i) && !gdImageGreen(im, i) && !gdImageBlue(im, i)) break; + if (!gdImageRed(im, i) && !gdImageGreen(im, i) && !gdImageBlue(im, i)) { + break; + } } + foreground_color = i; } @@ -1946,20 +1949,20 @@ PHP_FUNCTION(imagejpeg) PHP_FUNCTION(imagewbmp) { zval *imgind; - zend_long foreground_color = -1; + zend_long foreground_color; + zend_long foreground_color_is_null = 1; gdImagePtr im; - int argc = ZEND_NUM_ARGS(); int i; gdIOCtx *ctx = NULL; zval *to_zval = NULL; - if (zend_parse_parameters(argc, "O|z!l", &imgind, gd_image_ce, &to_zval, &foreground_color) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "O|z!l!", &imgind, gd_image_ce, &to_zval, &foreground_color) == FAILURE) { RETURN_THROWS(); } im = php_gd_libgdimageptr_from_zval_p(imgind); - if (argc > 1 && to_zval != NULL) { + if (to_zval != NULL) { ctx = create_stream_context_from_zval(to_zval); if (!ctx) { RETURN_FALSE; @@ -1968,10 +1971,11 @@ PHP_FUNCTION(imagewbmp) ctx = create_output_context(); } - if (argc < 3) { + if (foreground_color_is_null) { for (i=0; i < gdImageColorsTotal(im); i++) { - if (!gdImageRed(im, i) && !gdImageGreen(im, i) && !gdImageBlue(im, i)) + if (!gdImageRed(im, i) && !gdImageGreen(im, i) && !gdImageBlue(im, i)) { break; + } } foreground_color = i; @@ -2006,17 +2010,16 @@ PHP_FUNCTION(imagebmp) zval *imgind; zend_bool compressed = 1; gdImagePtr im; - int argc = ZEND_NUM_ARGS(); gdIOCtx *ctx = NULL; zval *to_zval = NULL; - if (zend_parse_parameters(argc, "O|z!b", &imgind, gd_image_ce, &to_zval, &compressed) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "O|z!b", &imgind, gd_image_ce, &to_zval, &compressed) == FAILURE) { RETURN_THROWS(); } im = php_gd_libgdimageptr_from_zval_p(imgind); - if (argc > 1 && to_zval != NULL) { + if (to_zval != NULL) { ctx = create_stream_context_from_zval(to_zval); if (!ctx) { RETURN_FALSE; @@ -2555,16 +2558,16 @@ PHP_FUNCTION(imagecolortransparent) { zval *IM; zend_long COL = 0; + zend_bool COL_IS_NULL = 1; gdImagePtr im; - int argc = ZEND_NUM_ARGS(); - if (zend_parse_parameters(argc, "O|l", &IM, gd_image_ce, &COL) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "O|l!", &IM, gd_image_ce, &COL, &COL_IS_NULL) == FAILURE) { RETURN_THROWS(); } im = php_gd_libgdimageptr_from_zval_p(IM); - if (argc > 1) { + if (!COL_IS_NULL) { gdImageColorTransparent(im, COL); } @@ -2576,17 +2579,17 @@ PHP_FUNCTION(imagecolortransparent) PHP_FUNCTION(imageinterlace) { zval *IM; - int argc = ZEND_NUM_ARGS(); zend_long INT = 0; + zend_bool INT_IS_NULL = 1; gdImagePtr im; - if (zend_parse_parameters(argc, "O|l", &IM, gd_image_ce, &INT) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "O|l!", &IM, gd_image_ce, &INT, &INT_IS_NULL) == FAILURE) { RETURN_THROWS(); } im = php_gd_libgdimageptr_from_zval_p(IM); - if (argc > 1) { + if (!INT_IS_NULL) { gdImageInterlace(im, INT); } @@ -2603,15 +2606,16 @@ static void php_imagepolygon(INTERNAL_FUNCTION_PARAMETERS, int filled) { zval *IM, *POINTS; zend_long NPOINTS, COL; + zend_bool COL_IS_NULL = 1; zval *var = NULL; gdImagePtr im; gdPointPtr points; int npoints, col, nelem, i; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "Oal|l", &IM, gd_image_ce, &POINTS, &NPOINTS, &COL) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "Oal|l!", &IM, gd_image_ce, &POINTS, &NPOINTS, &COL, &COL_IS_NULL) == FAILURE) { RETURN_THROWS(); } - if (ZEND_NUM_ARGS() == 3) { + if (COL_IS_NULL) { COL = NPOINTS; NPOINTS = zend_hash_num_elements(Z_ARRVAL_P(POINTS)); if (NPOINTS % 2 != 0) { @@ -3733,7 +3737,7 @@ PHP_FUNCTION(imageaffine) int i, nelems; zval *zval_affine_elem = NULL; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "Oa|a", &IM, gd_image_ce, &z_affine, &z_rect) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "Oa|a!", &IM, gd_image_ce, &z_affine, &z_rect) == FAILURE) { RETURN_THROWS(); } @@ -3856,7 +3860,7 @@ PHP_FUNCTION(imageaffinematrixget) double angle; if (!options) { - zend_argument_type_error(2, "must be of type int|double when using rotate or shear"); + zend_argument_type_error(2, "must be of type int|float when using rotate or shear"); RETURN_THROWS(); } @@ -4003,26 +4007,29 @@ PHP_FUNCTION(imageresolution) { zval *IM; gdImagePtr im; - zend_long res_x = GD_RESOLUTION, res_y = GD_RESOLUTION; + zend_long res_x, res_y; + zend_bool res_x_is_null = 1, res_y_is_null = 1; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "O|ll", &IM, gd_image_ce, &res_x, &res_y) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "O|l!l!", &IM, gd_image_ce, &res_x, &res_x_is_null, &res_y, &res_y_is_null) == FAILURE) { RETURN_THROWS(); } im = php_gd_libgdimageptr_from_zval_p(IM); - switch (ZEND_NUM_ARGS()) { - case 3: - gdImageSetResolution(im, res_x, res_y); - RETURN_TRUE; - case 2: - gdImageSetResolution(im, res_x, res_x); - RETURN_TRUE; - default: - array_init(return_value); - add_next_index_long(return_value, gdImageResolutionX(im)); - add_next_index_long(return_value, gdImageResolutionY(im)); + if (!res_x_is_null && !res_y_is_null) { + gdImageSetResolution(im, res_x, res_y); + RETURN_TRUE; + } else if (!res_x_is_null && res_y_is_null) { + gdImageSetResolution(im, res_x, res_x); + RETURN_TRUE; + } else if (res_x_is_null && !res_y_is_null) { + gdImageSetResolution(im, res_y, res_y); + RETURN_TRUE; } + + array_init(return_value); + add_next_index_long(return_value, gdImageResolutionX(im)); + add_next_index_long(return_value, gdImageResolutionY(im)); } /* }}} */ @@ -4151,24 +4158,26 @@ static void _php_image_output_ctx(INTERNAL_FUNCTION_PARAMETERS, int image_type, zval *imgind; zend_long quality = -1, basefilter = -1; gdImagePtr im; - int argc = ZEND_NUM_ARGS(); - int i; gdIOCtx *ctx = NULL; zval *to_zval = NULL; - if (image_type == PHP_GDIMG_TYPE_PNG) { - if (zend_parse_parameters(argc, "O|z!ll", &imgind, gd_image_ce, &to_zval, &quality, &basefilter) == FAILURE) { + if (image_type == PHP_GDIMG_TYPE_GIF) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "O|z", &imgind, gd_image_ce, &to_zval) == FAILURE) { + RETURN_THROWS(); + } + } else if (image_type == PHP_GDIMG_TYPE_PNG) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "O|z!ll", &imgind, gd_image_ce, &to_zval, &quality, &basefilter) == FAILURE) { RETURN_THROWS(); } } else { - if (zend_parse_parameters(argc, "O|z!l", &imgind, gd_image_ce, &to_zval, &quality) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "O|z!l", &imgind, gd_image_ce, &to_zval, &quality) == FAILURE) { RETURN_THROWS(); } } im = php_gd_libgdimageptr_from_zval_p(imgind); - if (argc > 1 && to_zval != NULL) { + if (to_zval != NULL) { ctx = create_stream_context_from_zval(to_zval); if (!ctx) { RETURN_FALSE; @@ -4190,16 +4199,6 @@ static void _php_image_output_ctx(INTERNAL_FUNCTION_PARAMETERS, int image_type, case PHP_GDIMG_TYPE_PNG: (*func_p)(im, ctx, (int) quality, (int) basefilter); break; - case PHP_GDIMG_TYPE_WBM: - if (argc < 3) { - for (i=0; i < gdImageColorsTotal(im); i++) { - if (!gdImageRed(im, i) && !gdImageGreen(im, i) && !gdImageBlue(im, i)) break; - } - quality = (int) i; - } - - (*func_p)(im, (int) quality, ctx); - break; case PHP_GDIMG_TYPE_GIF: (*func_p)(im, ctx); break; diff --git a/ext/gd/gd.stub.php b/ext/gd/gd.stub.php index a284944102e1f..22f2c4f256f44 100644 --- a/ext/gd/gd.stub.php +++ b/ext/gd/gd.stub.php @@ -10,7 +10,7 @@ function gd_info(): array {} function imageloadfont(string $filename): int|false {} -function imagesetstyle($im, array $styles): bool {} +function imagesetstyle(GdImage $im, array $styles): bool {} function imagecreatetruecolor(int $x_size, int $y_size): GdImage|false {} @@ -20,7 +20,7 @@ function imagetruecolortopalette(GdImage $im, bool $ditherFlag, int $colorWanted function imagepalettetotruecolor(GdImage $im): bool {} -function imagecolormatch($im1, $im2): bool {} +function imagecolormatch(GdImage $im1, GdImage $im2): bool {} function imagesetthickness(GdImage $im, int $thickness): bool {} @@ -54,9 +54,9 @@ function imagegrabscreen(): GdImage|false {} function imagerotate(GdImage $im, float $angle, int $bgdcolor, int $ignoretransparent = 0): GdImage|false {} -function imagesettile(GdImage $im, $tile): bool {} +function imagesettile(GdImage $im, GdImage $tile): bool {} -function imagesetbrush(GdImage $im, $brush): bool {} +function imagesetbrush(GdImage $im, GdImage $brush): bool {} function imagecreate(int $x_size, int $y_size): GdImage|false {} @@ -100,30 +100,36 @@ function imagecreatefrombmp(string $filename): GdImage|false {} function imagecreatefromtga(string $filename): GdImage|false {} #endif -function imagexbm(GdImage $im, ?string $filename, int $foreground = UNKNOWN): bool {} +function imagexbm(GdImage $im, ?string $filename, ?int $foreground = null): bool {} +/** @param resource|string|null $to */ function imagegif(GdImage $im, $to = null): bool {} #ifdef HAVE_GD_PNG -function imagepng(GdImage $im, $to = null, int $quality = UNKNOWN, int $filters = UNKNOWN): bool {} +/** @param resource|string|null $to */ +function imagepng(GdImage $im, $to = null, int $quality = -1, int $filters = -1): bool {} #endif #ifdef HAVE_GD_WEBP -function imagewebp(GdImage $im, $to = null, int $quality = UNKNOWN): bool {} +/** @param resource|string|null $to */ +function imagewebp(GdImage $im, $to = null, int $quality = -1): bool {} #endif #ifdef HAVE_GD_JPG -function imagejpeg(GdImage $im, $to = null, int $quality = UNKNOWN): bool {} +/** @param resource|string|null $to */ +function imagejpeg(GdImage $im, $to = null, int $quality = -1): bool {} #endif -function imagewbmp(GdImage $im, $to = null, int $foreground = UNKNOWN): bool {} +/** @param resource|string|null $to */ +function imagewbmp(GdImage $im, $to = null, ?int $foreground = null): bool {} function imagegd(GdImage $im, $to = UNKNOWN): bool {} function imagegd2(GdImage $im, $to = UNKNOWN, int $chunk_size = UNKNOWN, int $type = UNKNOWN): bool {} #ifdef HAVE_GD_BMP -function imagebmp(GdImage $im, $to = null, int $compressed = 1): bool {} +/** @param resource|string|null $to */ +function imagebmp(GdImage $im, $to = null, bool $compressed = true): bool {} #endif function imagedestroy(GdImage $im): bool {} @@ -170,15 +176,15 @@ function imagefill(GdImage $im, int $x, int $y, int $col): bool {} function imagecolorstotal(GdImage $im): int {} -function imagecolortransparent(GdImage $im, int $col = UNKNOWN): ?int {} +function imagecolortransparent(GdImage $im, ?int $col = null): ?int {} -function imageinterlace(GdImage $im, int $interlace = UNKNOWN): ?int {} +function imageinterlace(GdImage $im, ?int $interlace = null): ?int {} -function imagepolygon(GdImage $im, array $points, int $num_points_or_col, int $col = UNKNOWN): bool {} +function imagepolygon(GdImage $im, array $points, int $num_points_or_col, ?int $col = null): bool {} -function imageopenpolygon(GdImage $im, array $points, int $num_points_or_col, int $col = UNKNOWN): bool {} +function imageopenpolygon(GdImage $im, array $points, int $num_points_or_col, ?int $col = null): bool {} -function imagefilledpolygon(GdImage $im, array $points, int $num_points_or_col, int $col = UNKNOWN): bool {} +function imagefilledpolygon(GdImage $im, array $points, int $num_points_or_col, ?int $col = null): bool {} function imagefontwidth(int $font): int {} @@ -230,10 +236,11 @@ function imagecrop(GdImage $im, array $rect): GdImage|false {} function imagecropauto(GdImage $im, int $mode = IMG_CROP_DEFAULT, float $threshold = 0.5, int $color = -1): GdImage|false {} -function imagescale(GdImage $im, int $new_width, int $new_height = UNKNOWN, int $mode = IMG_BILINEAR_FIXED): GdImage|false {} +function imagescale(GdImage $im, int $new_width, int $new_height = -1, int $mode = IMG_BILINEAR_FIXED): GdImage|false {} -function imageaffine(GdImage $im, array $affine, array $clip = UNKNOWN): GdImage|false {} +function imageaffine(GdImage $im, array $affine, ?array $clip = null): GdImage|false {} +/** @param array|int|float $options */ function imageaffinematrixget(int $type, $options = UNKNOWN): array|false {} function imageaffinematrixconcat(array $m1, array $m2): array|false {} @@ -242,4 +249,4 @@ function imagegetinterpolation(GdImage $im): int {} function imagesetinterpolation(GdImage $im, int $method = IMG_BILINEAR_FIXED): bool {} -function imageresolution(GdImage $im, int $res_x = UNKNOWN, int $res_y = UNKNOWN): array|bool {} +function imageresolution(GdImage $im, ?int $res_x = null, ?int $res_y = null): array|bool {} diff --git a/ext/gd/gd_arginfo.h b/ext/gd/gd_arginfo.h index 5209f7a34c279..371c3e2ecbc79 100644 --- a/ext/gd/gd_arginfo.h +++ b/ext/gd/gd_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: bb1f9f45ea75ccb96886d8fe5a2bc8f5c06e6661 */ + * Stub hash: 14cd8fc3865f7ef2b88c4834fbf33d360b302794 */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gd_info, 0, 0, IS_ARRAY, 0) ZEND_END_ARG_INFO() @@ -9,7 +9,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imageloadfont, 0, 1, MAY_BE_LONG ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagesetstyle, 0, 2, _IS_BOOL, 0) - ZEND_ARG_INFO(0, im) + ZEND_ARG_OBJ_INFO(0, im, GdImage, 0) ZEND_ARG_TYPE_INFO(0, styles, IS_ARRAY, 0) ZEND_END_ARG_INFO() @@ -31,8 +31,8 @@ ZEND_END_ARG_INFO() #define arginfo_imagepalettetotruecolor arginfo_imageistruecolor ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagecolormatch, 0, 2, _IS_BOOL, 0) - ZEND_ARG_INFO(0, im1) - ZEND_ARG_INFO(0, im2) + ZEND_ARG_OBJ_INFO(0, im1, GdImage, 0) + ZEND_ARG_OBJ_INFO(0, im2, GdImage, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagesetthickness, 0, 2, _IS_BOOL, 0) @@ -124,12 +124,12 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagesettile, 0, 2, _IS_BOOL, 0) ZEND_ARG_OBJ_INFO(0, im, GdImage, 0) - ZEND_ARG_INFO(0, tile) + ZEND_ARG_OBJ_INFO(0, tile, GdImage, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagesetbrush, 0, 2, _IS_BOOL, 0) ZEND_ARG_OBJ_INFO(0, im, GdImage, 0) - ZEND_ARG_INFO(0, brush) + ZEND_ARG_OBJ_INFO(0, brush, GdImage, 0) ZEND_END_ARG_INFO() #define arginfo_imagecreate arginfo_imagecreatetruecolor @@ -200,7 +200,7 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagexbm, 0, 2, _IS_BOOL, 0) 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_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, foreground, IS_LONG, 1, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagegif, 0, 1, _IS_BOOL, 0) @@ -212,8 +212,8 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagepng, 0, 1, _IS_BOOL, 0) ZEND_ARG_OBJ_INFO(0, im, GdImage, 0) ZEND_ARG_INFO_WITH_DEFAULT_VALUE(0, to, "null") - ZEND_ARG_TYPE_INFO(0, quality, IS_LONG, 0) - ZEND_ARG_TYPE_INFO(0, filters, IS_LONG, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, quality, IS_LONG, 0, "-1") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, filters, IS_LONG, 0, "-1") ZEND_END_ARG_INFO() #endif @@ -221,7 +221,7 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagewebp, 0, 1, _IS_BOOL, 0) ZEND_ARG_OBJ_INFO(0, im, GdImage, 0) ZEND_ARG_INFO_WITH_DEFAULT_VALUE(0, to, "null") - ZEND_ARG_TYPE_INFO(0, quality, IS_LONG, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, quality, IS_LONG, 0, "-1") ZEND_END_ARG_INFO() #endif @@ -229,14 +229,14 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagejpeg, 0, 1, _IS_BOOL, 0) ZEND_ARG_OBJ_INFO(0, im, GdImage, 0) ZEND_ARG_INFO_WITH_DEFAULT_VALUE(0, to, "null") - ZEND_ARG_TYPE_INFO(0, quality, IS_LONG, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, quality, IS_LONG, 0, "-1") ZEND_END_ARG_INFO() #endif ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagewbmp, 0, 1, _IS_BOOL, 0) ZEND_ARG_OBJ_INFO(0, im, GdImage, 0) ZEND_ARG_INFO_WITH_DEFAULT_VALUE(0, to, "null") - ZEND_ARG_TYPE_INFO(0, foreground, IS_LONG, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, foreground, IS_LONG, 1, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagegd, 0, 1, _IS_BOOL, 0) @@ -255,7 +255,7 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagebmp, 0, 1, _IS_BOOL, 0) ZEND_ARG_OBJ_INFO(0, im, GdImage, 0) ZEND_ARG_INFO_WITH_DEFAULT_VALUE(0, to, "null") - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, compressed, IS_LONG, 0, "1") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, compressed, _IS_BOOL, 0, "true") ZEND_END_ARG_INFO() #endif @@ -363,19 +363,19 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagecolortransparent, 0, 1, IS_LONG, 1) ZEND_ARG_OBJ_INFO(0, im, GdImage, 0) - ZEND_ARG_TYPE_INFO(0, col, IS_LONG, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, col, IS_LONG, 1, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imageinterlace, 0, 1, IS_LONG, 1) ZEND_ARG_OBJ_INFO(0, im, GdImage, 0) - ZEND_ARG_TYPE_INFO(0, interlace, IS_LONG, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, interlace, IS_LONG, 1, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagepolygon, 0, 3, _IS_BOOL, 0) ZEND_ARG_OBJ_INFO(0, im, GdImage, 0) ZEND_ARG_TYPE_INFO(0, points, IS_ARRAY, 0) ZEND_ARG_TYPE_INFO(0, num_points_or_col, IS_LONG, 0) - ZEND_ARG_TYPE_INFO(0, col, IS_LONG, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, col, IS_LONG, 1, "null") ZEND_END_ARG_INFO() #define arginfo_imageopenpolygon arginfo_imagepolygon @@ -540,14 +540,14 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_imagescale, 0, 2, GdImage, MAY_BE_FALSE) 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_WITH_DEFAULT_VALUE(0, new_height, IS_LONG, 0, "-1") ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, mode, IS_LONG, 0, "IMG_BILINEAR_FIXED") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_imageaffine, 0, 2, GdImage, MAY_BE_FALSE) 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_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, clip, IS_ARRAY, 1, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imageaffinematrixget, 0, 1, MAY_BE_ARRAY|MAY_BE_FALSE) @@ -569,8 +569,8 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imageresolution, 0, 1, MAY_BE_ARRAY|MAY_BE_BOOL) 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_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, res_x, IS_LONG, 1, "null") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, res_y, IS_LONG, 1, "null") ZEND_END_ARG_INFO() diff --git a/ext/gd/tests/bug67248.phpt b/ext/gd/tests/bug67248.phpt index b54a20ba8e336..054ba52861caf 100644 --- a/ext/gd/tests/bug67248.phpt +++ b/ext/gd/tests/bug67248.phpt @@ -18,8 +18,8 @@ for($i=0;$i<7;$i++) { --EXPECT-- !! [TypeError] imageaffinematrixget(): Argument #1 ($type) must be of type array when using translate or scale !! [TypeError] imageaffinematrixget(): Argument #1 ($type) must be of type array when using translate or scale -!! [TypeError] imageaffinematrixget(): Argument #2 ($options) must be of type int|double when using rotate or shear -!! [TypeError] imageaffinematrixget(): Argument #2 ($options) must be of type int|double when using rotate or shear -!! [TypeError] imageaffinematrixget(): Argument #2 ($options) must be of type int|double when using rotate or shear +!! [TypeError] imageaffinematrixget(): Argument #2 ($options) must be of type int|float when using rotate or shear +!! [TypeError] imageaffinematrixget(): Argument #2 ($options) must be of type int|float when using rotate or shear +!! [TypeError] imageaffinematrixget(): Argument #2 ($options) must be of type int|float when using rotate or shear !! [ValueError] imageaffinematrixget(): Argument #1 ($type) must be a valid element type !! [ValueError] imageaffinematrixget(): Argument #1 ($type) must be a valid element type diff --git a/ext/gd/tests/bug75437.phpt b/ext/gd/tests/bug75437.phpt deleted file mode 100644 index 7da6d2f2361b0..0000000000000 --- a/ext/gd/tests/bug75437.phpt +++ /dev/null @@ -1,17 +0,0 @@ ---TEST-- -Bug #75437 Wrong reflection on imagewebp ---SKIPIF-- - ---FILE-- -getNumberOfParameters()); -var_dump($rf->getNumberOfRequiredParameters()); -?> ---EXPECT-- -int(3) -int(1) diff --git a/ext/mbstring/mbstring.c b/ext/mbstring/mbstring.c index 393cd44da4e0d..7bed59422c151 100644 --- a/ext/mbstring/mbstring.c +++ b/ext/mbstring/mbstring.c @@ -1304,7 +1304,7 @@ PHP_FUNCTION(mb_language) { zend_string *name = NULL; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|S", &name) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|S!", &name) == FAILURE) { RETURN_THROWS(); } if (name == NULL) { @@ -1330,7 +1330,7 @@ PHP_FUNCTION(mb_internal_encoding) size_t name_len; const mbfl_encoding *encoding; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s", &name, &name_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s!", &name, &name_len) == FAILURE) { RETURN_THROWS(); } if (name == NULL) { @@ -1355,19 +1355,19 @@ PHP_FUNCTION(mb_internal_encoding) PHP_FUNCTION(mb_http_input) { char *typ = NULL; - size_t typ_len; + size_t typ_len = 0; int retname; char *list, *temp; const mbfl_encoding *result = NULL; retname = 1; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s", &typ, &typ_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s!", &typ, &typ_len) == FAILURE) { RETURN_THROWS(); - } - if (typ == NULL) { - result = MBSTRG(http_input_identify); - } else { - switch (*typ) { + } + if (typ == NULL) { + result = MBSTRG(http_input_identify); + } else { + switch (*typ) { case 'G': case 'g': result = MBSTRG(http_input_identify_get); @@ -1452,7 +1452,7 @@ PHP_FUNCTION(mb_http_output) size_t name_len; const mbfl_encoding *encoding; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s", &name, &name_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s!", &name, &name_len) == FAILURE) { RETURN_THROWS(); } @@ -1482,7 +1482,7 @@ PHP_FUNCTION(mb_detect_order) ZEND_PARSE_PARAMETERS_START(0, 1) Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_ARRAY_HT(order_str, order_ht) + Z_PARAM_STR_OR_ARRAY_HT_OR_NULL(order_str, order_ht) ZEND_PARSE_PARAMETERS_END(); if (!order_str && !order_ht) { @@ -1814,7 +1814,7 @@ PHP_FUNCTION(mb_str_split) Z_PARAM_STR(str) Z_PARAM_OPTIONAL Z_PARAM_LONG(split_length) - Z_PARAM_STR(encoding) + Z_PARAM_STR_OR_NULL(encoding) ZEND_PARSE_PARAMETERS_END(); if (split_length <= 0) { @@ -1943,7 +1943,7 @@ PHP_FUNCTION(mb_strlen) ZEND_PARSE_PARAMETERS_START(1, 2) Z_PARAM_STRING(str, str_len) Z_PARAM_OPTIONAL - Z_PARAM_STR(enc_name) + Z_PARAM_STR_OR_NULL(enc_name) ZEND_PARSE_PARAMETERS_END(); string.val = (unsigned char *) str; @@ -1986,7 +1986,7 @@ PHP_FUNCTION(mb_strpos) zend_string *enc_name = NULL; size_t n; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss|lS", (char **)&haystack.val, &haystack.len, (char **)&needle.val, &needle.len, &offset, &enc_name) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss|lS!", (char **)&haystack.val, &haystack.len, (char **)&needle.val, &needle.len, &offset, &enc_name) == FAILURE) { RETURN_THROWS(); } @@ -2012,7 +2012,7 @@ PHP_FUNCTION(mb_strrpos) zend_string *enc_name = NULL; zend_long offset = 0, n; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss|lS", (char **)&haystack.val, &haystack.len, (char **)&needle.val, &needle.len, &offset, &enc_name) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss|lS!", (char **)&haystack.val, &haystack.len, (char **)&needle.val, &needle.len, &offset, &enc_name) == FAILURE) { RETURN_THROWS(); } @@ -2040,7 +2040,7 @@ PHP_FUNCTION(mb_stripos) zend_string *from_encoding = NULL; const mbfl_encoding *enc; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss|lS", (char **)&haystack.val, &haystack.len, (char **)&needle.val, &needle.len, &offset, &from_encoding) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss|lS!", (char **)&haystack.val, &haystack.len, (char **)&needle.val, &needle.len, &offset, &from_encoding) == FAILURE) { RETURN_THROWS(); } @@ -2069,7 +2069,7 @@ PHP_FUNCTION(mb_strripos) zend_string *from_encoding = NULL; const mbfl_encoding *enc; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss|lS", (char **)&haystack.val, &haystack.len, (char **)&needle.val, &needle.len, &offset, &from_encoding) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss|lS!", (char **)&haystack.val, &haystack.len, (char **)&needle.val, &needle.len, &offset, &from_encoding) == FAILURE) { RETURN_THROWS(); } @@ -2102,7 +2102,7 @@ static void php_mb_strstr_variants(INTERNAL_FUNCTION_PARAMETERS, unsigned int va zend_string *encoding_name = NULL; zend_bool part = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss|bS", + if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss|bS!", (char **)&haystack.val, &haystack.len, (char **)&needle.val, &needle.len, &part, &encoding_name) == FAILURE ) { @@ -2183,7 +2183,7 @@ PHP_FUNCTION(mb_substr_count) mbfl_string haystack, needle; zend_string *enc_name = NULL; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss|S", (char **)&haystack.val, &haystack.len, (char **)&needle.val, &needle.len, &enc_name) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss|S!", (char **)&haystack.val, &haystack.len, (char **)&needle.val, &needle.len, &enc_name) == FAILURE) { RETURN_THROWS(); } @@ -2218,7 +2218,7 @@ PHP_FUNCTION(mb_substr) zend_bool len_is_null = 1; mbfl_string string, result, *ret; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "sl|l!S", &str, &str_len, &from, &len, &len_is_null, &encoding) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "sl|l!S!", &str, &str_len, &from, &len, &len_is_null, &encoding) == FAILURE) { RETURN_THROWS(); } @@ -2331,7 +2331,7 @@ PHP_FUNCTION(mb_strwidth) mbfl_string string; zend_string *enc_name = NULL; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|S", (char **)&string.val, &string.len, &enc_name) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|S!", (char **)&string.val, &string.len, &enc_name) == FAILURE) { RETURN_THROWS(); } @@ -2355,7 +2355,7 @@ PHP_FUNCTION(mb_strimwidth) size_t str_len, trimmarker_len; mbfl_string string, result, marker, *ret; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "sll|sS", &str, &str_len, &from, &width, &trimmarker, &trimmarker_len, &encoding) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "sll|sS!", &str, &str_len, &from, &width, &trimmarker, &trimmarker_len, &encoding) == FAILURE) { RETURN_THROWS(); } @@ -2583,7 +2583,7 @@ PHP_FUNCTION(mb_convert_encoding) Z_PARAM_STR_OR_ARRAY_HT(input_str, input_ht) Z_PARAM_STR(to_encoding_name) Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_ARRAY_HT(from_encodings_str, from_encodings_ht) + Z_PARAM_STR_OR_ARRAY_HT_OR_NULL(from_encodings_str, from_encodings_ht) ZEND_PARSE_PARAMETERS_END(); to_encoding = php_mb_get_encoding(to_encoding_name, 2); @@ -2868,7 +2868,10 @@ PHP_FUNCTION(mb_encode_mimeheader) string.encoding = MBSTRG(current_internal_encoding); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|Sssl", (char **)&string.val, &string.len, &charset_name, &trans_enc_name, &trans_enc_name_len, &linefeed, &linefeed_len, &indent) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|S!s!sl", + (char **)&string.val, &string.len, &charset_name, &trans_enc_name, &trans_enc_name_len, + &linefeed, &linefeed_len, &indent + ) == FAILURE) { RETURN_THROWS(); } @@ -2934,7 +2937,7 @@ PHP_FUNCTION(mb_convert_kana) size_t optstr_len; zend_string *encname = NULL; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|sS", (char **)&string.val, &string.len, &optstr, &optstr_len, &encname) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s!S!", (char **)&string.val, &string.len, &optstr, &optstr_len, &encname) == FAILURE) { RETURN_THROWS(); } @@ -3241,11 +3244,11 @@ php_mb_numericentity_exec(INTERNAL_FUNCTION_PARAMETERS, int type) mbfl_string string, result, *ret; if (type == 0) { - if (zend_parse_parameters(ZEND_NUM_ARGS(), "sh|Sb", &str, &str_len, &target_hash, &encoding, &is_hex) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "sh|S!b", &str, &str_len, &target_hash, &encoding, &is_hex) == FAILURE) { RETURN_THROWS(); } } else { - if (zend_parse_parameters(ZEND_NUM_ARGS(), "sh|S", &str, &str_len, &target_hash, &encoding) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "sh|S!", &str, &str_len, &target_hash, &encoding) == FAILURE) { RETURN_THROWS(); } } @@ -3534,7 +3537,7 @@ PHP_FUNCTION(mb_send_mail) body_enc = mbfl_no2encoding(lang->mail_body_encoding); } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "sss|zS", &to, &to_len, &subject, &subject_len, &message, &message_len, &headers, &extra_cmd) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "sss|z!S!", &to, &to_len, &subject, &subject_len, &message, &message_len, &headers, &extra_cmd) == FAILURE) { RETURN_THROWS(); } @@ -3554,8 +3557,8 @@ PHP_FUNCTION(mb_send_mail) str_headers = php_mail_build_headers(Z_ARRVAL_P(headers)); break; default: - php_error_docref(NULL, E_WARNING, "headers parameter must be string or array"); - RETURN_FALSE; + zend_argument_value_error(4, "must be of type string|array|null, %s given", zend_zval_type_name(headers)); + RETURN_THROWS(); } } if (extra_cmd) { @@ -4041,8 +4044,8 @@ PHP_FUNCTION(mb_check_encoding) ZEND_PARSE_PARAMETERS_START(0, 2) Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_ARRAY_HT(input_str, input_ht) - Z_PARAM_STR(enc) + Z_PARAM_STR_OR_ARRAY_HT_OR_NULL(input_str, input_ht) + Z_PARAM_STR_OR_NULL(enc) ZEND_PARSE_PARAMETERS_END(); encoding = php_mb_get_encoding(enc, 2); @@ -4128,7 +4131,7 @@ PHP_FUNCTION(mb_ord) ZEND_PARSE_PARAMETERS_START(1, 2) Z_PARAM_STRING(str, str_len) Z_PARAM_OPTIONAL - Z_PARAM_STR(enc) + Z_PARAM_STR_OR_NULL(enc) ZEND_PARSE_PARAMETERS_END(); if (str_len == 0) { @@ -4244,7 +4247,7 @@ PHP_FUNCTION(mb_chr) ZEND_PARSE_PARAMETERS_START(1, 2) Z_PARAM_LONG(cp) Z_PARAM_OPTIONAL - Z_PARAM_STR(enc) + Z_PARAM_STR_OR_NULL(enc) ZEND_PARSE_PARAMETERS_END(); ret = php_mb_chr(cp, enc, 2); @@ -4269,7 +4272,7 @@ PHP_FUNCTION(mb_scrub) ZEND_PARSE_PARAMETERS_START(1, 2) Z_PARAM_STRING(str, str_len) Z_PARAM_OPTIONAL - Z_PARAM_STR(enc_name) + Z_PARAM_STR_OR_NULL(enc_name) ZEND_PARSE_PARAMETERS_END(); enc = php_mb_get_encoding(enc_name, 2); diff --git a/ext/mbstring/mbstring.stub.php b/ext/mbstring/mbstring.stub.php index 2d88b26ee92b5..6bd6aeae6fe6d 100644 --- a/ext/mbstring/mbstring.stub.php +++ b/ext/mbstring/mbstring.stub.php @@ -2,15 +2,15 @@ /** @generate-function-entries */ -function mb_language(string $language = UNKNOWN): string|bool {} +function mb_language(?string $language = null): string|bool {} -function mb_internal_encoding(string $encoding = UNKNOWN): string|bool {} +function mb_internal_encoding(?string $encoding = null): string|bool {} -function mb_http_input(string $type = UNKNOWN): array|string|false {} +function mb_http_input(?string $type = null): array|string|false {} -function mb_http_output(string $encoding = UNKNOWN): string|bool {} +function mb_http_output(?string $encoding = null): string|bool {} -function mb_detect_order(array|string $encoding = UNKNOWN): array|bool {} +function mb_detect_order(array|string|null $encoding = null): array|bool {} function mb_substitute_character(string|int|null $substitute_character = null): string|int|bool {} @@ -20,37 +20,37 @@ function mb_parse_str(string $encoded_string, &$result): bool {} function mb_output_handler(string $contents, int $status): string {} -function mb_str_split(string $str, int $split_length = 1, string $encoding = UNKNOWN): array {} +function mb_str_split(string $str, int $split_length = 1, ?string $encoding = null): array {} -function mb_strlen(string $str, string $encoding = UNKNOWN): int {} +function mb_strlen(string $str, ?string $encoding = null): int {} -function mb_strpos(string $haystack, string $needle, int $offset = 0, string $encoding = UNKNOWN): int|false {} +function mb_strpos(string $haystack, string $needle, int $offset = 0, ?string $encoding = null): int|false {} -function mb_strrpos(string $haystack, string $needle, int $offset = 0, string $encoding = UNKNOWN): int|false {} +function mb_strrpos(string $haystack, string $needle, int $offset = 0, ?string $encoding = null): int|false {} -function mb_stripos(string $haystack, string $needle, int $offset = 0, string $encoding = UNKNOWN): int|false {} +function mb_stripos(string $haystack, string $needle, int $offset = 0, ?string $encoding = null): int|false {} -function mb_strripos(string $haystack, string $needle, int $offset = 0, string $encoding = UNKNOWN): int|false {} +function mb_strripos(string $haystack, string $needle, int $offset = 0, ?string $encoding = null): int|false {} -function mb_strstr(string $haystack, string $needle, bool $part = false, string $encoding = UNKNOWN): string|false {} +function mb_strstr(string $haystack, string $needle, bool $part = false, ?string $encoding = null): string|false {} -function mb_strrchr(string $haystack, string $needle, bool $part = false, string $encoding = UNKNOWN): string|false {} +function mb_strrchr(string $haystack, string $needle, bool $part = false, ?string $encoding = null): string|false {} -function mb_stristr(string $haystack, string $needle, bool $part = false, string $encoding = UNKNOWN): string|false {} +function mb_stristr(string $haystack, string $needle, bool $part = false, ?string $encoding = null): string|false {} -function mb_strrichr(string $haystack, string $needle, bool $part = false, string $encoding = UNKNOWN): string|false {} +function mb_strrichr(string $haystack, string $needle, bool $part = false, ?string $encoding = null): string|false {} -function mb_substr_count(string $haystack, string $needle, string $encoding = UNKNOWN): int {} +function mb_substr_count(string $haystack, string $needle, ?string $encoding = null): int {} -function mb_substr(string $str, int $start, ?int $length = null, string $encoding = UNKNOWN): string {} +function mb_substr(string $str, int $start, ?int $length = null, ?string $encoding = null): string {} -function mb_strcut(string $str, int $start, ?int $length = null, string $encoding = UNKNOWN): string|false {} +function mb_strcut(string $str, int $start, ?int $length = null, ?string $encoding = null): string|false {} -function mb_strwidth(string $str, string $encoding = UNKNOWN): int {} +function mb_strwidth(string $str, ?string $encoding = null): int {} -function mb_strimwidth(string $str, int $start, int $width, string $trim_marker = UNKNOWN, string $encoding = UNKNOWN): string {} +function mb_strimwidth(string $str, int $start, int $width, string $trim_marker = "", ?string $encoding = null): string {} -function mb_convert_encoding(array|string $str, string $to, array|string $from = UNKNOWN): array|string|false {} +function mb_convert_encoding(array|string $str, string $to, array|string|null $from = null): array|string|false {} function mb_convert_case(string $source_string, int $mode, ?string $encoding = null): string {} @@ -64,54 +64,55 @@ function mb_list_encodings(): array {} function mb_encoding_aliases(string $encoding): array {} -function mb_encode_mimeheader(string $str, string $charset = UNKNOWN, string $transfer = UNKNOWN, string $linefeed = UNKNOWN, int $indent = 0): string {} +function mb_encode_mimeheader(string $str, ?string $charset = null, ?string $transfer = null, string $linefeed = "\r\n", int $indent = 0): string {} function mb_decode_mimeheader(string $string): string {} -function mb_convert_kana(string $str, string $option = UNKNOWN, string $encoding = UNKNOWN): string {} +function mb_convert_kana(string $str, string $option = "KV", ?string $encoding = null): string {} function mb_convert_variables(string $to, array|string $from, &$var, &...$vars): string|false {} -function mb_encode_numericentity(string $string, array $convmap, string $encoding = UNKNOWN, bool $is_hex = false): string {} +function mb_encode_numericentity(string $string, array $convmap, ?string $encoding = null, bool $is_hex = false): string {} -function mb_decode_numericentity(string $string, array $convmap, string $encoding = UNKNOWN): string {} +function mb_decode_numericentity(string $string, array $convmap, ?string $encoding = null): string {} -function mb_send_mail(string $to, string $subject, string $message, $additional_headers = UNKNOWN, string $additional_parameters = UNKNOWN): bool {} +/** @param string|array|null $additional_headers */ +function mb_send_mail(string $to, string $subject, string $message, $additional_headers = null, ?string $additional_parameters = null): bool {} -function mb_get_info(string $type = UNKNOWN): array|string|int|false {} +function mb_get_info(string $type = "all"): array|string|int|false {} -function mb_check_encoding(array|string $var = UNKNOWN, string $encoding = UNKNOWN): bool {} +function mb_check_encoding(array|string|null $var = null, ?string $encoding = null): bool {} -function mb_scrub(string $str, string $encoding = UNKNOWN): string {} +function mb_scrub(string $str, ?string $encoding = null): string {} -function mb_ord(string $str, string $encoding = UNKNOWN): int|false {} +function mb_ord(string $str, ?string $encoding = null): int|false {} -function mb_chr(int $cp, string $encoding = UNKNOWN): string|false {} +function mb_chr(int $cp, ?string $encoding = null): string|false {} #ifdef HAVE_MBREGEX -function mb_regex_encoding(string $encoding = UNKNOWN): string|bool {} +function mb_regex_encoding(?string $encoding = null): string|bool {} -function mb_ereg(string $pattern, string $string, &$registers = UNKNOWN): int|false {} +function mb_ereg(string $pattern, string $string, &$registers = null): int|false {} -function mb_eregi(string $pattern, string $string, &$registers = UNKNOWN): int|false {} +function mb_eregi(string $pattern, string $string, &$registers = null): int|false {} -function mb_ereg_replace(string $pattern, string $replacement, string $string, string $option = UNKNOWN): string|false|null {} +function mb_ereg_replace(string $pattern, string $replacement, string $string, ?string $option = null): string|false|null {} -function mb_eregi_replace(string $pattern, string $replacement, string $string, string $option = UNKNOWN): string|false|null {} +function mb_eregi_replace(string $pattern, string $replacement, string $string, ?string $option = null): string|false|null {} -function mb_ereg_replace_callback(string $pattern, callable $callback, string $string, string $option = UNKNOWN): string|false|null {} +function mb_ereg_replace_callback(string $pattern, callable $callback, string $string, ?string $option = null): string|false|null {} function mb_split(string $pattern, string $string, int $limit = -1): array|false {} -function mb_ereg_match(string $pattern, string $string, string $option = UNKNOWN): bool {} +function mb_ereg_match(string $pattern, string $string, ?string $option = null): bool {} -function mb_ereg_search(string $pattern = UNKNOWN, string $option = UNKNOWN): bool {} +function mb_ereg_search(?string $pattern = null, ?string $option = null): bool {} -function mb_ereg_search_pos(string $pattern = UNKNOWN, string $option = UNKNOWN): array|false {} +function mb_ereg_search_pos(?string $pattern = null, ?string $option = null): array|false {} -function mb_ereg_search_regs(string $pattern = UNKNOWN, string $option = UNKNOWN): array|false {} +function mb_ereg_search_regs(?string $pattern = null, ?string $option = null): array|false {} -function mb_ereg_search_init(string $string, string $pattern = UNKNOWN, string $option = UNKNOWN): bool {} +function mb_ereg_search_init(string $string, ?string $pattern = null, ?string $option = null): bool {} function mb_ereg_search_getregs(): array|false {} @@ -119,5 +120,5 @@ function mb_ereg_search_getpos(): int {} function mb_ereg_search_setpos(int $position): bool {} -function mb_regex_set_options(string $options = UNKNOWN): string {} +function mb_regex_set_options(?string $options = null): string {} #endif diff --git a/ext/mbstring/mbstring_arginfo.h b/ext/mbstring/mbstring_arginfo.h index 74be402d31812..66fb381ed4f44 100644 --- a/ext/mbstring/mbstring_arginfo.h +++ b/ext/mbstring/mbstring_arginfo.h @@ -1,22 +1,22 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: fad341194e6c8e180b17f9ba168c062a13db2977 */ + * Stub hash: 282413dbcb1b92e1efadf4352f443692076aea59 */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_mb_language, 0, 0, MAY_BE_STRING|MAY_BE_BOOL) - ZEND_ARG_TYPE_INFO(0, language, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, language, IS_STRING, 1, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_mb_internal_encoding, 0, 0, MAY_BE_STRING|MAY_BE_BOOL) - ZEND_ARG_TYPE_INFO(0, encoding, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, encoding, IS_STRING, 1, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_mb_http_input, 0, 0, MAY_BE_ARRAY|MAY_BE_STRING|MAY_BE_FALSE) - ZEND_ARG_TYPE_INFO(0, type, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, type, IS_STRING, 1, "null") ZEND_END_ARG_INFO() #define arginfo_mb_http_output arginfo_mb_internal_encoding ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_mb_detect_order, 0, 0, MAY_BE_ARRAY|MAY_BE_BOOL) - ZEND_ARG_TYPE_MASK(0, encoding, MAY_BE_ARRAY|MAY_BE_STRING, NULL) + ZEND_ARG_TYPE_MASK(0, encoding, MAY_BE_ARRAY|MAY_BE_STRING|MAY_BE_NULL, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_mb_substitute_character, 0, 0, MAY_BE_STRING|MAY_BE_LONG|MAY_BE_BOOL) @@ -40,19 +40,19 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_mb_str_split, 0, 1, IS_ARRAY, 0) ZEND_ARG_TYPE_INFO(0, str, IS_STRING, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, split_length, IS_LONG, 0, "1") - ZEND_ARG_TYPE_INFO(0, encoding, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, encoding, IS_STRING, 1, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_mb_strlen, 0, 1, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, str, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, encoding, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, encoding, IS_STRING, 1, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_mb_strpos, 0, 2, MAY_BE_LONG|MAY_BE_FALSE) ZEND_ARG_TYPE_INFO(0, haystack, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, needle, IS_STRING, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, offset, IS_LONG, 0, "0") - ZEND_ARG_TYPE_INFO(0, encoding, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, encoding, IS_STRING, 1, "null") ZEND_END_ARG_INFO() #define arginfo_mb_strrpos arginfo_mb_strpos @@ -65,7 +65,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_mb_strstr, 0, 2, MAY_BE_STRING|M ZEND_ARG_TYPE_INFO(0, haystack, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, needle, IS_STRING, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, part, _IS_BOOL, 0, "false") - ZEND_ARG_TYPE_INFO(0, encoding, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, encoding, IS_STRING, 1, "null") ZEND_END_ARG_INFO() #define arginfo_mb_strrchr arginfo_mb_strstr @@ -77,21 +77,21 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_mb_substr_count, 0, 2, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, haystack, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, needle, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, encoding, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, encoding, IS_STRING, 1, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_mb_substr, 0, 2, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, str, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, start, IS_LONG, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, length, IS_LONG, 1, "null") - ZEND_ARG_TYPE_INFO(0, encoding, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, encoding, IS_STRING, 1, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_mb_strcut, 0, 2, MAY_BE_STRING|MAY_BE_FALSE) ZEND_ARG_TYPE_INFO(0, str, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, start, IS_LONG, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, length, IS_LONG, 1, "null") - ZEND_ARG_TYPE_INFO(0, encoding, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, encoding, IS_STRING, 1, "null") ZEND_END_ARG_INFO() #define arginfo_mb_strwidth arginfo_mb_strlen @@ -100,14 +100,14 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_mb_strimwidth, 0, 3, IS_STRING, ZEND_ARG_TYPE_INFO(0, str, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, start, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, width, IS_LONG, 0) - ZEND_ARG_TYPE_INFO(0, trim_marker, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, encoding, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, trim_marker, IS_STRING, 0, "\"\"") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, encoding, IS_STRING, 1, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_mb_convert_encoding, 0, 2, MAY_BE_ARRAY|MAY_BE_STRING|MAY_BE_FALSE) ZEND_ARG_TYPE_MASK(0, str, MAY_BE_ARRAY|MAY_BE_STRING, NULL) ZEND_ARG_TYPE_INFO(0, to, IS_STRING, 0) - ZEND_ARG_TYPE_MASK(0, from, MAY_BE_ARRAY|MAY_BE_STRING, NULL) + ZEND_ARG_TYPE_MASK(0, from, MAY_BE_ARRAY|MAY_BE_STRING|MAY_BE_NULL, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_mb_convert_case, 0, 2, IS_STRING, 0) @@ -138,9 +138,9 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_mb_encode_mimeheader, 0, 1, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, str, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, charset, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, transfer, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, linefeed, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, charset, IS_STRING, 1, "null") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, transfer, IS_STRING, 1, "null") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, linefeed, IS_STRING, 0, "\"\\r\\n\"") ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, indent, IS_LONG, 0, "0") ZEND_END_ARG_INFO() @@ -150,8 +150,8 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_mb_convert_kana, 0, 1, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, str, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, option, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, encoding, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, option, IS_STRING, 0, "\"KV\"") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, encoding, IS_STRING, 1, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_mb_convert_variables, 0, 3, MAY_BE_STRING|MAY_BE_FALSE) @@ -164,51 +164,51 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_mb_encode_numericentity, 0, 2, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, string, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, convmap, IS_ARRAY, 0) - ZEND_ARG_TYPE_INFO(0, encoding, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, encoding, IS_STRING, 1, "null") ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, is_hex, _IS_BOOL, 0, "false") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_mb_decode_numericentity, 0, 2, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, string, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, convmap, IS_ARRAY, 0) - ZEND_ARG_TYPE_INFO(0, encoding, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, encoding, IS_STRING, 1, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_mb_send_mail, 0, 3, _IS_BOOL, 0) ZEND_ARG_TYPE_INFO(0, to, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, subject, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, message, IS_STRING, 0) - ZEND_ARG_INFO(0, additional_headers) - ZEND_ARG_TYPE_INFO(0, additional_parameters, IS_STRING, 0) + ZEND_ARG_INFO_WITH_DEFAULT_VALUE(0, additional_headers, "null") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, additional_parameters, IS_STRING, 1, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_mb_get_info, 0, 0, MAY_BE_ARRAY|MAY_BE_STRING|MAY_BE_LONG|MAY_BE_FALSE) - ZEND_ARG_TYPE_INFO(0, type, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, type, IS_STRING, 0, "\"all\"") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_mb_check_encoding, 0, 0, _IS_BOOL, 0) - ZEND_ARG_TYPE_MASK(0, var, MAY_BE_ARRAY|MAY_BE_STRING, NULL) - ZEND_ARG_TYPE_INFO(0, encoding, IS_STRING, 0) + ZEND_ARG_TYPE_MASK(0, var, MAY_BE_ARRAY|MAY_BE_STRING|MAY_BE_NULL, "null") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, encoding, IS_STRING, 1, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_mb_scrub, 0, 1, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, str, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, encoding, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, encoding, IS_STRING, 1, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_mb_ord, 0, 1, MAY_BE_LONG|MAY_BE_FALSE) ZEND_ARG_TYPE_INFO(0, str, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, encoding, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, encoding, IS_STRING, 1, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_mb_chr, 0, 1, MAY_BE_STRING|MAY_BE_FALSE) ZEND_ARG_TYPE_INFO(0, cp, IS_LONG, 0) - ZEND_ARG_TYPE_INFO(0, encoding, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, encoding, IS_STRING, 1, "null") ZEND_END_ARG_INFO() #if defined(HAVE_MBREGEX) ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_mb_regex_encoding, 0, 0, MAY_BE_STRING|MAY_BE_BOOL) - ZEND_ARG_TYPE_INFO(0, encoding, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, encoding, IS_STRING, 1, "null") ZEND_END_ARG_INFO() #endif @@ -216,7 +216,7 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_mb_ereg, 0, 2, MAY_BE_LONG|MAY_BE_FALSE) ZEND_ARG_TYPE_INFO(0, pattern, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, string, IS_STRING, 0) - ZEND_ARG_INFO(1, registers) + ZEND_ARG_INFO_WITH_DEFAULT_VALUE(1, registers, "null") ZEND_END_ARG_INFO() #endif @@ -229,7 +229,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_mb_ereg_replace, 0, 3, MAY_BE_ST ZEND_ARG_TYPE_INFO(0, pattern, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, replacement, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, string, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, option, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, option, IS_STRING, 1, "null") ZEND_END_ARG_INFO() #endif @@ -242,7 +242,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_mb_ereg_replace_callback, 0, 3, ZEND_ARG_TYPE_INFO(0, pattern, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, callback, IS_CALLABLE, 0) ZEND_ARG_TYPE_INFO(0, string, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, option, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, option, IS_STRING, 1, "null") ZEND_END_ARG_INFO() #endif @@ -258,21 +258,21 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_mb_ereg_match, 0, 2, _IS_BOOL, 0) ZEND_ARG_TYPE_INFO(0, pattern, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, string, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, option, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, option, IS_STRING, 1, "null") ZEND_END_ARG_INFO() #endif #if defined(HAVE_MBREGEX) ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_mb_ereg_search, 0, 0, _IS_BOOL, 0) - ZEND_ARG_TYPE_INFO(0, pattern, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, option, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, pattern, IS_STRING, 1, "null") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, option, IS_STRING, 1, "null") ZEND_END_ARG_INFO() #endif #if defined(HAVE_MBREGEX) ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_mb_ereg_search_pos, 0, 0, MAY_BE_ARRAY|MAY_BE_FALSE) - ZEND_ARG_TYPE_INFO(0, pattern, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, option, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, pattern, IS_STRING, 1, "null") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, option, IS_STRING, 1, "null") ZEND_END_ARG_INFO() #endif @@ -283,8 +283,8 @@ ZEND_END_ARG_INFO() #if defined(HAVE_MBREGEX) ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_mb_ereg_search_init, 0, 1, _IS_BOOL, 0) ZEND_ARG_TYPE_INFO(0, string, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, pattern, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, option, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, pattern, IS_STRING, 1, "null") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, option, IS_STRING, 1, "null") ZEND_END_ARG_INFO() #endif @@ -306,7 +306,7 @@ ZEND_END_ARG_INFO() #if defined(HAVE_MBREGEX) ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_mb_regex_set_options, 0, 0, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, options, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_STRING, 1, "null") ZEND_END_ARG_INFO() #endif diff --git a/ext/mbstring/php_mbregex.c b/ext/mbstring/php_mbregex.c index a797efbf7b7a9..85309e7cfdb8b 100644 --- a/ext/mbstring/php_mbregex.c +++ b/ext/mbstring/php_mbregex.c @@ -852,7 +852,7 @@ PHP_FUNCTION(mb_regex_encoding) char *encoding = NULL; size_t encoding_len; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s", &encoding, &encoding_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s!", &encoding, &encoding_len) == FAILURE) { RETURN_THROWS(); } @@ -1030,7 +1030,7 @@ static void _php_mb_regex_ereg_replace_exec(INTERNAL_FUNCTION_PARAMETERS, OnigOp size_t option_str_len = 0; if (!is_callable) { - if (zend_parse_parameters(ZEND_NUM_ARGS(), "sss|s", + if (zend_parse_parameters(ZEND_NUM_ARGS(), "sss|s!", &arg_pattern, &arg_pattern_len, &replace, &replace_len, &string, &string_len, @@ -1038,7 +1038,7 @@ static void _php_mb_regex_ereg_replace_exec(INTERNAL_FUNCTION_PARAMETERS, OnigOp RETURN_THROWS(); } } else { - if (zend_parse_parameters(ZEND_NUM_ARGS(), "sfs|s", + if (zend_parse_parameters(ZEND_NUM_ARGS(), "sfs|s!", &arg_pattern, &arg_pattern_len, &arg_replace_fci, &arg_replace_fci_cache, &string, &string_len, @@ -1297,7 +1297,7 @@ PHP_FUNCTION(mb_ereg_match) char *option_str = NULL; size_t option_str_len = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss|s", + if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss|s!", &arg_pattern, &arg_pattern_len, &string, &string_len, &option_str, &option_str_len)==FAILURE) { RETURN_THROWS(); @@ -1340,8 +1340,7 @@ PHP_FUNCTION(mb_ereg_match) /* regex search */ /* {{{ _php_mb_regex_ereg_search_exec */ -static void -_php_mb_regex_ereg_search_exec(INTERNAL_FUNCTION_PARAMETERS, int mode) +static void _php_mb_regex_ereg_search_exec(INTERNAL_FUNCTION_PARAMETERS, int mode) { char *arg_pattern = NULL, *arg_options = NULL; size_t arg_pattern_len, arg_options_len; @@ -1353,7 +1352,7 @@ _php_mb_regex_ereg_search_exec(INTERNAL_FUNCTION_PARAMETERS, int mode) OnigUChar *str; OnigSyntaxType *syntax; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ss", &arg_pattern, &arg_pattern_len, &arg_options, &arg_options_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s!s!", &arg_pattern, &arg_pattern_len, &arg_options, &arg_options_len) == FAILURE) { RETURN_THROWS(); } @@ -1485,24 +1484,24 @@ PHP_FUNCTION(mb_ereg_search_init) OnigSyntaxType *syntax = NULL; OnigOptionType option; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|ss", &arg_str, &arg_pattern, &arg_pattern_len, &arg_options, &arg_options_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|s!s!", &arg_str, &arg_pattern, &arg_pattern_len, &arg_options, &arg_options_len) == FAILURE) { RETURN_THROWS(); } - if (ZEND_NUM_ARGS() > 1 && arg_pattern_len == 0) { + if (arg_pattern && arg_pattern_len == 0) { php_error_docref(NULL, E_WARNING, "Empty pattern"); RETURN_FALSE; } - option = MBREX(regex_default_options); - syntax = MBREX(regex_default_syntax); - - if (ZEND_NUM_ARGS() == 3) { + if (arg_options) { option = 0; _php_mb_regex_init_options(arg_options, arg_options_len, &option, &syntax, NULL); + } else { + option = MBREX(regex_default_options); + syntax = MBREX(regex_default_syntax); } - if (ZEND_NUM_ARGS() > 1) { + if (arg_pattern) { /* create regex pattern buffer */ if ((MBREX(search_re) = php_mbregex_compile_pattern(arg_pattern, arg_pattern_len, option, syntax)) == NULL) { RETURN_FALSE; @@ -1515,11 +1514,7 @@ PHP_FUNCTION(mb_ereg_search_init) ZVAL_STR_COPY(&MBREX(search_str), arg_str); - if (php_mb_check_encoding( - ZSTR_VAL(arg_str), - ZSTR_LEN(arg_str), - php_mb_regex_get_mbctype_encoding() - )) { + if (php_mb_check_encoding(ZSTR_VAL(arg_str), ZSTR_LEN(arg_str), php_mb_regex_get_mbctype_encoding())) { MBREX(search_pos) = 0; RETVAL_TRUE; } else { @@ -1635,7 +1630,7 @@ PHP_FUNCTION(mb_regex_set_options) size_t string_len; char buf[16]; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s", + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s!", &string, &string_len) == FAILURE) { RETURN_THROWS(); }