diff options
author | Máté Kocsis <kocsismate@woohoolabs.com> | 2020-04-01 23:32:39 +0200 |
---|---|---|
committer | Máté Kocsis <kocsismate@woohoolabs.com> | 2020-04-06 10:41:01 +0200 |
commit | 50765075db6b6d5a9597589601c59f743f6ee9c8 (patch) | |
tree | 29ef6350004c95c3df9577e47ceaa1458e60921e /ext | |
parent | 21cfa03f1740042d0c48269430e0490e319e1408 (diff) | |
download | php-git-50765075db6b6d5a9597589601c59f743f6ee9c8.tar.gz |
Improve some ValueError messages
Closes GH-5340
Diffstat (limited to 'ext')
54 files changed, 274 insertions, 247 deletions
diff --git a/ext/bz2/bz2.c b/ext/bz2/bz2.c index 29046e7122..360f9d9c20 100644 --- a/ext/bz2/bz2.c +++ b/ext/bz2/bz2.c @@ -317,7 +317,7 @@ PHP_FUNCTION(bzread) php_stream_from_zval(stream, bz); if (len < 0) { - zend_value_error("Length cannot be negative"); + zend_argument_value_error(2, "must be greater than or equal to 0"); RETURN_THROWS(); } @@ -345,7 +345,7 @@ PHP_FUNCTION(bzopen) } if (mode_len != 1 || (mode[0] != 'r' && mode[0] != 'w')) { - zend_value_error("'%s' is not a valid mode for bzopen(). Only 'w' and 'r' are supported.", mode); + zend_argument_value_error(2, "must be a valid mode. Only 'w' and 'r' are supported"); RETURN_THROWS(); } diff --git a/ext/bz2/tests/001.phpt b/ext/bz2/tests/001.phpt index 1064e2b6a5..081558a7d4 100644 --- a/ext/bz2/tests/001.phpt +++ b/ext/bz2/tests/001.phpt @@ -37,15 +37,15 @@ var_dump(bzopen($fp, "r")); ?> --EXPECTF-- -'' is not a valid mode for bzopen(). Only 'w' and 'r' are supported. +bzopen(): Argument #2 ($mode) must be a valid mode. Only 'w' and 'r' are supported Warning: bzopen(): Filename cannot be empty in %s on line %d bool(false) Warning: bzopen(): Filename cannot be empty in %s on line %d bool(false) -'x' is not a valid mode for bzopen(). Only 'w' and 'r' are supported. -'rw' is not a valid mode for bzopen(). Only 'w' and 'r' are supported. +bzopen(): Argument #2 ($mode) must be a valid mode. Only 'w' and 'r' are supported +bzopen(): Argument #2 ($mode) must be a valid mode. Only 'w' and 'r' are supported Warning: bzopen(no_such_file): Failed to open stream: No such file or directory in %s on line %d bool(false) diff --git a/ext/bz2/tests/003-mb.phpt b/ext/bz2/tests/003-mb.phpt index c01a3d18c8..75ec54ae4d 100644 --- a/ext/bz2/tests/003-mb.phpt +++ b/ext/bz2/tests/003-mb.phpt @@ -21,7 +21,7 @@ var_dump(bzread($fd, 100000)); ?> --EXPECT-- string(0) "" -Length cannot be negative +bzread(): Argument #2 ($length) must be greater than or equal to 0 string(1) "R" string(2) "is" string(251) "ing up from the heart of the desert diff --git a/ext/bz2/tests/003.phpt b/ext/bz2/tests/003.phpt index 6c1f8ea4a9..229dd87058 100644 --- a/ext/bz2/tests/003.phpt +++ b/ext/bz2/tests/003.phpt @@ -21,7 +21,7 @@ var_dump(bzread($fd, 100000)); ?> --EXPECT-- string(0) "" -Length cannot be negative +bzread(): Argument #2 ($length) must be greater than or equal to 0 string(1) "R" string(2) "is" string(251) "ing up from the heart of the desert diff --git a/ext/calendar/cal_unix.c b/ext/calendar/cal_unix.c index 1d3401283d..4738772649 100644 --- a/ext/calendar/cal_unix.c +++ b/ext/calendar/cal_unix.c @@ -35,7 +35,7 @@ PHP_FUNCTION(unixtojd) if (!ts) { ts = time(NULL); } else if (ts < 0) { - zend_value_error("Timestamp must not be negative"); + zend_argument_value_error(1, "must be greater than or equal to 0"); RETURN_THROWS(); } diff --git a/ext/calendar/calendar.c b/ext/calendar/calendar.c index 32b229c41d..2853e72775 100644 --- a/ext/calendar/calendar.c +++ b/ext/calendar/calendar.c @@ -194,7 +194,7 @@ PHP_FUNCTION(cal_info) if (cal != -1 && (cal < 0 || cal >= CAL_NUM_CALS)) { - zend_value_error("Invalid calendar ID: " ZEND_LONG_FMT, cal); + zend_argument_value_error(1, "must be a valid calendar ID"); RETURN_THROWS(); } @@ -216,7 +216,7 @@ PHP_FUNCTION(cal_days_in_month) } if (cal < 0 || cal >= CAL_NUM_CALS) { - zend_value_error("Invalid calendar ID: " ZEND_LONG_FMT, cal); + zend_argument_value_error(1, "must be a valid calendar ID"); RETURN_THROWS(); } @@ -262,7 +262,7 @@ PHP_FUNCTION(cal_to_jd) } if (cal < 0 || cal >= CAL_NUM_CALS) { - zend_value_error("Invalid calendar ID: " ZEND_LONG_FMT, cal); + zend_argument_value_error(1, "must be a valid calendar ID"); RETURN_THROWS(); } @@ -283,7 +283,7 @@ PHP_FUNCTION(cal_from_jd) } if (cal < 0 || cal >= CAL_NUM_CALS) { - zend_value_error("Invalid calendar ID: " ZEND_LONG_FMT, cal); + zend_argument_value_error(2, "must be a valid calendar ID"); RETURN_THROWS(); } calendar = &cal_conversion_table[cal]; diff --git a/ext/calendar/easter.c b/ext/calendar/easter.c index 98087d318c..7f26de0c00 100644 --- a/ext/calendar/easter.c +++ b/ext/calendar/easter.c @@ -49,7 +49,7 @@ static void _cal_easter(INTERNAL_FUNCTION_PARAMETERS, zend_long gm) } if (gm && (year<1970 || year>2037)) { /* out of range for timestamps */ - zend_value_error("This function is only valid for years between 1970 and 2037 inclusive"); + zend_argument_value_error(1, "must be between 1970 and 2037 (inclusive)"); RETURN_THROWS(); } diff --git a/ext/calendar/tests/cal_days_in_month_error1.phpt b/ext/calendar/tests/cal_days_in_month_error1.phpt index b7c82f2cbe..2b7ee0ea88 100644 --- a/ext/calendar/tests/cal_days_in_month_error1.phpt +++ b/ext/calendar/tests/cal_days_in_month_error1.phpt @@ -18,5 +18,5 @@ try{ } ?> --EXPECT-- -Invalid calendar ID: -1 +cal_days_in_month(): Argument #1 ($calendar) must be a valid calendar ID Invalid date diff --git a/ext/calendar/tests/cal_from_jd_error1.phpt b/ext/calendar/tests/cal_from_jd_error1.phpt index 8539117c0d..feafe240b5 100644 --- a/ext/calendar/tests/cal_from_jd_error1.phpt +++ b/ext/calendar/tests/cal_from_jd_error1.phpt @@ -13,4 +13,4 @@ try { } ?> --EXPECT-- -Invalid calendar ID: -1 +cal_from_jd(): Argument #2 ($calendar) must be a valid calendar ID diff --git a/ext/calendar/tests/cal_info.phpt b/ext/calendar/tests/cal_info.phpt index 3e7e3b3188..0d4b823486 100644 --- a/ext/calendar/tests/cal_info.phpt +++ b/ext/calendar/tests/cal_info.phpt @@ -216,4 +216,4 @@ Array [calname] => Julian [calsymbol] => CAL_JULIAN ) -Invalid calendar ID: 99999 +cal_info(): Argument #1 ($calendar) must be a valid calendar ID diff --git a/ext/calendar/tests/cal_to_jd_error1.phpt b/ext/calendar/tests/cal_to_jd_error1.phpt index c1911a77b7..b8585c7f05 100644 --- a/ext/calendar/tests/cal_to_jd_error1.phpt +++ b/ext/calendar/tests/cal_to_jd_error1.phpt @@ -13,4 +13,4 @@ try { } ?> --EXPECT-- -Invalid calendar ID: -1 +cal_to_jd(): Argument #1 ($calendar) must be a valid calendar ID diff --git a/ext/calendar/tests/easter_date.phpt b/ext/calendar/tests/easter_date.phpt index a7cdbea516..c784f02ebd 100644 --- a/ext/calendar/tests/easter_date.phpt +++ b/ext/calendar/tests/easter_date.phpt @@ -22,4 +22,4 @@ try { 2000-04-23 2001-04-15 2002-03-31 -This function is only valid for years between 1970 and 2037 inclusive +easter_date(): Argument #1 ($year) must be between 1970 and 2037 (inclusive) diff --git a/ext/calendar/tests/unixtojd_error1.phpt b/ext/calendar/tests/unixtojd_error1.phpt index 856fc1bcf4..000f047f0a 100644 --- a/ext/calendar/tests/unixtojd_error1.phpt +++ b/ext/calendar/tests/unixtojd_error1.phpt @@ -20,7 +20,7 @@ var_dump(unixtojd(null)) . PHP_EOL; var_dump(unixtojd(time())) . PHP_EOL; ?> --EXPECTF-- -Timestamp must not be negative +unixtojd(): Argument #1 ($timestamp) must be greater than or equal to 0 int(%d) int(%d) int(%d) diff --git a/ext/gd/gd.c b/ext/gd/gd.c index 5bb840aad8..157460b50b 100644 --- a/ext/gd/gd.c +++ b/ext/gd/gd.c @@ -736,7 +736,7 @@ PHP_FUNCTION(imagesetstyle) num_styles = zend_hash_num_elements(Z_ARRVAL_P(styles)); if (num_styles == 0) { - zend_value_error("Styles array must not be empty"); + zend_argument_value_error(2, "cannot be empty"); RETURN_THROWS(); } @@ -767,12 +767,12 @@ PHP_FUNCTION(imagecreatetruecolor) } if (x_size <= 0 || x_size >= INT_MAX) { - zend_value_error("Invalid width (x_size)"); + zend_argument_value_error(1, "must be greater than 0"); RETURN_THROWS(); } if (y_size <= 0 || y_size >= INT_MAX) { - zend_value_error("Invalid height (y_size)"); + zend_argument_value_error(2, "must be greater than 0"); RETURN_THROWS(); } @@ -819,7 +819,7 @@ PHP_FUNCTION(imagetruecolortopalette) im = php_gd_libgdimageptr_from_zval_p(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); + zend_argument_value_error(3, "must be greater than 0 and less than %d", INT_MAX); RETURN_THROWS(); } @@ -1022,9 +1022,9 @@ PHP_FUNCTION(imagelayereffect) } /* }}} */ -#define CHECK_RGBA_RANGE(component, name) \ +#define CHECK_RGBA_RANGE(component, name, argument_number) \ if (component < 0 || component > gd##name##Max) { \ - zend_value_error(#name " component is out of range, must be between 0 and %d (inclusive)", gd##name##Max); \ + zend_argument_value_error(argument_number, "must be between 0 and %d (inclusive)", gd##name##Max); \ RETURN_THROWS(); \ } @@ -1043,10 +1043,10 @@ PHP_FUNCTION(imagecolorallocatealpha) im = php_gd_libgdimageptr_from_zval_p(IM); - CHECK_RGBA_RANGE(red, Red); - CHECK_RGBA_RANGE(green, Green); - CHECK_RGBA_RANGE(blue, Blue); - CHECK_RGBA_RANGE(alpha, Alpha); + CHECK_RGBA_RANGE(red, Red, 2); + CHECK_RGBA_RANGE(green, Green, 3); + CHECK_RGBA_RANGE(blue, Blue, 4); + CHECK_RGBA_RANGE(alpha, Alpha, 5); ct = gdImageColorAllocateAlpha(im, red, green, blue, alpha); if (ct < 0) { @@ -1070,10 +1070,10 @@ PHP_FUNCTION(imagecolorresolvealpha) im = php_gd_libgdimageptr_from_zval_p(IM); - CHECK_RGBA_RANGE(red, Red); - CHECK_RGBA_RANGE(green, Green); - CHECK_RGBA_RANGE(blue, Blue); - CHECK_RGBA_RANGE(alpha, Alpha); + CHECK_RGBA_RANGE(red, Red, 2); + CHECK_RGBA_RANGE(green, Green, 3); + CHECK_RGBA_RANGE(blue, Blue, 4); + CHECK_RGBA_RANGE(alpha, Alpha, 5); RETURN_LONG(gdImageColorResolveAlpha(im, red, green, blue, alpha)); } @@ -1093,10 +1093,10 @@ PHP_FUNCTION(imagecolorclosestalpha) im = php_gd_libgdimageptr_from_zval_p(IM); - CHECK_RGBA_RANGE(red, Red); - CHECK_RGBA_RANGE(green, Green); - CHECK_RGBA_RANGE(blue, Blue); - CHECK_RGBA_RANGE(alpha, Alpha); + CHECK_RGBA_RANGE(red, Red, 2); + CHECK_RGBA_RANGE(green, Green, 3); + CHECK_RGBA_RANGE(blue, Blue, 4); + CHECK_RGBA_RANGE(alpha, Alpha, 5); RETURN_LONG(gdImageColorClosestAlpha(im, red, green, blue, alpha)); } @@ -1110,16 +1110,16 @@ PHP_FUNCTION(imagecolorexactalpha) zend_long red, green, blue, alpha; gdImagePtr im; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "Ollll", &IM, gd_image_ce, &red, &green, &blue, &alpha) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "Ollll", &IM, gd_image_ce, &red, &green, &blue, &alpha) == FAILURE) { RETURN_THROWS(); } im = php_gd_libgdimageptr_from_zval_p(IM); - CHECK_RGBA_RANGE(red, Red); - CHECK_RGBA_RANGE(green, Green); - CHECK_RGBA_RANGE(blue, Blue); - CHECK_RGBA_RANGE(alpha, Alpha); + CHECK_RGBA_RANGE(red, Red, 2); + CHECK_RGBA_RANGE(green, Green, 3); + CHECK_RGBA_RANGE(blue, Blue, 4); + CHECK_RGBA_RANGE(alpha, Alpha, 5); RETURN_LONG(gdImageColorExactAlpha(im, red, green, blue, alpha)); } @@ -1362,12 +1362,12 @@ PHP_FUNCTION(imagecreate) } if (x_size <= 0 || x_size >= INT_MAX) { - zend_value_error("Invalid width (x_size)"); + zend_argument_value_error(1, "must be greater than 0"); RETURN_THROWS(); } if (y_size <= 0 || y_size >= INT_MAX) { - zend_value_error("Invalid height (y_size)"); + zend_argument_value_error(2, "must be greater than 0"); RETURN_THROWS(); } @@ -1601,12 +1601,12 @@ static void _php_image_create_from(INTERNAL_FUNCTION_PARAMETERS, int image_type, } if (width < 1) { - zend_value_error("Width must be at least 1"); + zend_argument_value_error(4, "must be greater than or equal to 1"); RETURN_THROWS(); } if (height < 1) { - zend_value_error("Height must be at least 1"); + zend_argument_value_error(5, "must be greater than or equal to 1"); RETURN_THROWS(); } @@ -2023,9 +2023,9 @@ PHP_FUNCTION(imagecolorallocate) im = php_gd_libgdimageptr_from_zval_p(IM); - CHECK_RGBA_RANGE(red, Red); - CHECK_RGBA_RANGE(green, Green); - CHECK_RGBA_RANGE(blue, Blue); + CHECK_RGBA_RANGE(red, Red, 2); + CHECK_RGBA_RANGE(green, Green, 3); + CHECK_RGBA_RANGE(blue, Blue, 4); ct = gdImageColorAllocate(im, red, green, blue); if (ct < 0) { @@ -2101,9 +2101,9 @@ PHP_FUNCTION(imagecolorclosest) im = php_gd_libgdimageptr_from_zval_p(IM); - CHECK_RGBA_RANGE(red, Red); - CHECK_RGBA_RANGE(green, Green); - CHECK_RGBA_RANGE(blue, Blue); + CHECK_RGBA_RANGE(red, Red, 2); + CHECK_RGBA_RANGE(green, Green, 3); + CHECK_RGBA_RANGE(blue, Blue, 4); RETURN_LONG(gdImageColorClosest(im, red, green, blue)); } @@ -2123,9 +2123,9 @@ PHP_FUNCTION(imagecolorclosesthwb) im = php_gd_libgdimageptr_from_zval_p(IM); - CHECK_RGBA_RANGE(red, Red); - CHECK_RGBA_RANGE(green, Green); - CHECK_RGBA_RANGE(blue, Blue); + CHECK_RGBA_RANGE(red, Red, 2); + CHECK_RGBA_RANGE(green, Green, 3); + CHECK_RGBA_RANGE(blue, Blue, 4); RETURN_LONG(gdImageColorClosestHWB(im, red, green, blue)); } @@ -2157,7 +2157,7 @@ PHP_FUNCTION(imagecolordeallocate) gdImageColorDeallocate(im, col); RETURN_TRUE; } else { - zend_value_error("Color index %d out of range", col); + zend_argument_value_error(2, "must be between 0 and %d", gdImageColorsTotal(im)); RETURN_THROWS(); } } @@ -2177,9 +2177,9 @@ PHP_FUNCTION(imagecolorresolve) im = php_gd_libgdimageptr_from_zval_p(IM); - CHECK_RGBA_RANGE(red, Red); - CHECK_RGBA_RANGE(green, Green); - CHECK_RGBA_RANGE(blue, Blue); + CHECK_RGBA_RANGE(red, Red, 2); + CHECK_RGBA_RANGE(green, Green, 3); + CHECK_RGBA_RANGE(blue, Blue, 4); RETURN_LONG(gdImageColorResolve(im, red, green, blue)); } @@ -2199,9 +2199,9 @@ PHP_FUNCTION(imagecolorexact) im = php_gd_libgdimageptr_from_zval_p(IM); - CHECK_RGBA_RANGE(red, Red); - CHECK_RGBA_RANGE(green, Green); - CHECK_RGBA_RANGE(blue, Blue); + CHECK_RGBA_RANGE(red, Red, 2); + CHECK_RGBA_RANGE(green, Green, 3); + CHECK_RGBA_RANGE(blue, Blue, 4); RETURN_LONG(gdImageColorExact(im, red, green, blue)); } @@ -2222,10 +2222,9 @@ PHP_FUNCTION(imagecolorset) im = php_gd_libgdimageptr_from_zval_p(IM); - CHECK_RGBA_RANGE(red, Red); - CHECK_RGBA_RANGE(green, Green); - CHECK_RGBA_RANGE(blue, Blue); - CHECK_RGBA_RANGE(alpha, Alpha); + CHECK_RGBA_RANGE(red, Red, 2); + CHECK_RGBA_RANGE(green, Green, 3); + CHECK_RGBA_RANGE(blue, Blue, 4); col = color; @@ -2284,8 +2283,13 @@ PHP_FUNCTION(imagegammacorrect) RETURN_THROWS(); } - if ( input <= 0.0 || output <= 0.0 ) { - zend_value_error("Gamma values must be positive"); + if (input <= 0.0) { + zend_argument_value_error(2, "must be greater than 0"); + RETURN_THROWS(); + } + + if (output <= 0.0) { + zend_argument_value_error(3, "must be greater than 0"); RETURN_THROWS(); } @@ -2594,7 +2598,7 @@ static void php_imagepolygon(INTERNAL_FUNCTION_PARAMETERS, int filled) COL = NPOINTS; NPOINTS = zend_hash_num_elements(Z_ARRVAL_P(POINTS)); if (NPOINTS % 2 != 0) { - zend_value_error("Points array must have an even number of elements"); + zend_argument_value_error(2, "must have an even number of elements"); RETURN_THROWS(); } NPOINTS /= 2; @@ -2607,7 +2611,7 @@ static void php_imagepolygon(INTERNAL_FUNCTION_PARAMETERS, int filled) nelem = zend_hash_num_elements(Z_ARRVAL_P(POINTS)); if (npoints < 3) { - zend_value_error("Polygon must have at least 3 points"); + zend_argument_value_error(3, "must be greater than or equal to 3"); RETURN_THROWS(); } @@ -2983,8 +2987,23 @@ PHP_FUNCTION(imagecopyresized) dstH = DH; dstW = DW; - if (dstW <= 0 || dstH <= 0 || srcW <= 0 || srcH <= 0) { - zend_value_error("Invalid image dimensions"); + if (dstW <= 0) { + zend_argument_value_error(3, "must be greater than 0"); + RETURN_THROWS(); + } + + if (dstH <= 0) { + zend_argument_value_error(4, "must be greater than 0"); + RETURN_THROWS(); + } + + if (srcW <= 0) { + zend_argument_value_error(5, "must be greater than 0"); + RETURN_THROWS(); + } + + if (srcH <= 0) { + zend_argument_value_error(6, "must be greater than 0"); RETURN_THROWS(); } @@ -3466,14 +3485,14 @@ PHP_FUNCTION(imageconvolution) nelem = zend_hash_num_elements(Z_ARRVAL_P(hash_matrix)); if (nelem != 3) { - zend_value_error("Convolution matrix must be a 3x3 array"); + zend_argument_value_error(2, "must be a 3x3 array"); RETURN_THROWS(); } for (i=0; i<3; i++) { if ((var = zend_hash_index_find(Z_ARRVAL_P(hash_matrix), (i))) != NULL && Z_TYPE_P(var) == IS_ARRAY) { if (zend_hash_num_elements(Z_ARRVAL_P(var)) != 3 ) { - zend_value_error("Convolution matrix must be a 3x3 array, matrix[%d] only has %d elements", i, zend_hash_num_elements(Z_ARRVAL_P(var))); + zend_argument_value_error(2, "must be a 3x3 array, matrix[%d] only has %d elements", i, zend_hash_num_elements(Z_ARRVAL_P(var))); RETURN_THROWS(); } @@ -3481,7 +3500,7 @@ PHP_FUNCTION(imageconvolution) if ((var2 = zend_hash_index_find(Z_ARRVAL_P(var), j)) != NULL) { matrix[i][j] = (float) zval_get_double(var2); } else { - zend_value_error("Convolution matrix must be a 3x3 array, matrix[%d][%d] cannot be found (missing integer key)", i, j); + zend_argument_value_error(2, "must be a 3x3 array, matrix[%d][%d] cannot be found (missing integer key)", i, j); RETURN_THROWS(); } } @@ -3526,7 +3545,7 @@ PHP_FUNCTION(imageflip) break; default: - zend_value_error("Unknown flip mode"); + zend_argument_value_error(2, "must be a valid mode"); RETURN_THROWS(); } @@ -3575,28 +3594,28 @@ PHP_FUNCTION(imagecrop) if ((tmp = zend_hash_str_find(Z_ARRVAL_P(z_rect), "x", sizeof("x") -1)) != NULL) { rect.x = zval_get_long(tmp); } else { - zend_value_error("Cropping rectangle is missing x position"); + zend_argument_value_error(2, "must have an 'x' key"); RETURN_THROWS(); } if ((tmp = zend_hash_str_find(Z_ARRVAL_P(z_rect), "y", sizeof("y") - 1)) != NULL) { rect.y = zval_get_long(tmp); } else { - zend_value_error("Cropping rectangle is missing y position"); + zend_argument_value_error(2, "must have a 'y' key"); RETURN_THROWS(); } if ((tmp = zend_hash_str_find(Z_ARRVAL_P(z_rect), "width", sizeof("width") - 1)) != NULL) { rect.width = zval_get_long(tmp); } else { - zend_value_error("Cropping rectangle is missing width"); + zend_argument_value_error(2, "must have a 'width' key"); RETURN_THROWS(); } if ((tmp = zend_hash_str_find(Z_ARRVAL_P(z_rect), "height", sizeof("height") - 1)) != NULL) { rect.height = zval_get_long(tmp); } else { - zend_value_error("Cropping rectangle is missing height"); + zend_argument_value_error(2, "must have a 'height' key"); RETURN_THROWS(); } @@ -3638,14 +3657,14 @@ PHP_FUNCTION(imagecropauto) case GD_CROP_THRESHOLD: if (color < 0 || (!gdImageTrueColor(im) && color >= gdImageColorsTotal(im))) { - zend_value_error("Color argument missing with threshold mode"); + zend_argument_value_error(4, "must be greater than or equal to 0 when using the threshold mode"); RETURN_THROWS(); } im_crop = gdImageCropThreshold(im, color, (float) threshold); break; default: - zend_value_error("Unknown crop mode"); + zend_argument_value_error(2, "must be a valid mode"); RETURN_THROWS(); } @@ -3762,28 +3781,28 @@ PHP_FUNCTION(imageaffine) if ((tmp = zend_hash_str_find(Z_ARRVAL_P(z_rect), "x", sizeof("x") - 1)) != NULL) { rect.x = zval_get_long(tmp); } else { - zend_value_error("Clip array is missing x position"); + zend_argument_value_error(3, "must have an 'x' key"); RETURN_THROWS(); } if ((tmp = zend_hash_str_find(Z_ARRVAL_P(z_rect), "y", sizeof("y") - 1)) != NULL) { rect.y = zval_get_long(tmp); } else { - zend_value_error("Clip array is missing y position"); + zend_argument_value_error(3, "must have a 'y' key"); RETURN_THROWS(); } if ((tmp = zend_hash_str_find(Z_ARRVAL_P(z_rect), "width", sizeof("width") - 1)) != NULL) { rect.width = zval_get_long(tmp); } else { - zend_value_error("Clip array is missing width"); + zend_argument_value_error(3, "must have a 'width' key"); RETURN_THROWS(); } if ((tmp = zend_hash_str_find(Z_ARRVAL_P(z_rect), "height", sizeof("height") - 1)) != NULL) { rect.height = zval_get_long(tmp); } else { - zend_value_error("Clip array is missing height"); + zend_argument_value_error(3, "must have a 'height' key"); RETURN_THROWS(); } pRect = ▭ @@ -3827,14 +3846,14 @@ PHP_FUNCTION(imageaffinematrixget) if ((tmp = zend_hash_str_find(Z_ARRVAL_P(options), "x", sizeof("x") - 1)) != NULL) { x = zval_get_double(tmp); } else { - zend_value_error("Options array is missing x position"); + zend_argument_value_error(2, "must have an 'x' key"); RETURN_THROWS(); } if ((tmp = zend_hash_str_find(Z_ARRVAL_P(options), "y", sizeof("y") - 1)) != NULL) { y = zval_get_double(tmp); } else { - zend_value_error("Options array is missing y position"); + zend_argument_value_error(2, "must have a 'y' key"); RETURN_THROWS(); } @@ -3894,14 +3913,19 @@ PHP_FUNCTION(imageaffinematrixconcat) zval *tmp; zval *z_m1; zval *z_m2; - int i, nelems; + int i; if (zend_parse_parameters(ZEND_NUM_ARGS(), "aa", &z_m1, &z_m2) == FAILURE) { RETURN_THROWS(); } - if (((nelems = zend_hash_num_elements(Z_ARRVAL_P(z_m1))) != 6) || (nelems = zend_hash_num_elements(Z_ARRVAL_P(z_m2))) != 6) { - zend_value_error("Affine arrays must have six elements"); + if (zend_hash_num_elements(Z_ARRVAL_P(z_m1)) != 6) { + zend_argument_value_error(1, "must have 6 elements"); + RETURN_THROWS(); + } + + if (zend_hash_num_elements(Z_ARRVAL_P(z_m2)) != 6) { + zend_argument_value_error(1, "must have 6 elements"); RETURN_THROWS(); } diff --git a/ext/gd/tests/bug38212-mb.phpt b/ext/gd/tests/bug38212-mb.phpt index d69d604e5d..f316aed00b 100644 --- a/ext/gd/tests/bug38212-mb.phpt +++ b/ext/gd/tests/bug38212-mb.phpt @@ -21,5 +21,5 @@ trycatch_dump( unlink($file); ?> --EXPECT-- -!! [ValueError] Width must be at least 1 -!! [ValueError] Height must be at least 1 +!! [ValueError] imagecreatefromgd2part(): Argument #4 ($width) must be greater than or equal to 1 +!! [ValueError] imagecreatefromgd2part(): Argument #5 ($height) must be greater than or equal to 1 diff --git a/ext/gd/tests/bug38212.phpt b/ext/gd/tests/bug38212.phpt index 8645989e09..311077141e 100644 --- a/ext/gd/tests/bug38212.phpt +++ b/ext/gd/tests/bug38212.phpt @@ -21,5 +21,5 @@ trycatch_dump( unlink($file); ?> --EXPECT-- -!! [ValueError] Width must be at least 1 -!! [ValueError] Height must be at least 1 +!! [ValueError] imagecreatefromgd2part(): Argument #4 ($width) must be greater than or equal to 1 +!! [ValueError] imagecreatefromgd2part(): Argument #5 ($height) must be greater than or equal to 1 diff --git a/ext/gd/tests/bug55005.phpt b/ext/gd/tests/bug55005.phpt index 38fb25db07..9b7044cee1 100644 --- a/ext/gd/tests/bug55005.phpt +++ b/ext/gd/tests/bug55005.phpt @@ -1,21 +1,21 @@ ---TEST--
-Bug #55005 (imagepolygon num_points requirement)
---SKIPIF--
-<?php
-if (!extension_loaded('gd')) die('skip gd extension not available');
-?>
---FILE--
-<?php
-require_once __DIR__ . '/func.inc';
-
-$g = imagecreate(300, 300);
-$bgnd = imagecolorallocate($g, 255, 255, 255);
-$fgnd = imagecolorallocate($g, 0, 0, 0);
-trycatch_dump(
- fn () => imagefilledpolygon($g, array(100,10, 100,100, 180,100), 2, $fgnd),
- fn () => imagepolygon($g, array(200,10, 200,100, 280,100), 2, $fgnd)
-);
-?>
---EXPECTF--
-!! [ValueError] Polygon must have at least 3 points
-!! [ValueError] Polygon must have at least 3 points
+--TEST-- +Bug #55005 (imagepolygon num_points requirement) +--SKIPIF-- +<?php +if (!extension_loaded('gd')) die('skip gd extension not available'); +?> +--FILE-- +<?php +require_once __DIR__ . '/func.inc'; + +$g = imagecreate(300, 300); +$bgnd = imagecolorallocate($g, 255, 255, 255); +$fgnd = imagecolorallocate($g, 0, 0, 0); +trycatch_dump( + fn () => imagefilledpolygon($g, array(100,10, 100,100, 180,100), 2, $fgnd), + fn () => imagepolygon($g, array(200,10, 200,100, 280,100), 2, $fgnd) +); +?> +--EXPECTF-- +!! [ValueError] imagefilledpolygon(): Argument #3 ($num_points_or_col) must be greater than or equal to 3 +!! [ValueError] imagepolygon(): Argument #3 ($num_points_or_col) must be greater than or equal to 3 diff --git a/ext/gd/tests/bug72494.phpt b/ext/gd/tests/bug72494.phpt index b01a19179a..97663cedf6 100644 --- a/ext/gd/tests/bug72494.phpt +++ b/ext/gd/tests/bug72494.phpt @@ -16,4 +16,4 @@ trycatch_dump( ?> --EXPECT-- -!! [ValueError] Color argument missing with threshold mode +!! [ValueError] imagecropauto(): Argument #4 ($color) must be greater than or equal to 0 when using the threshold mode diff --git a/ext/gd/tests/bug72697.phpt b/ext/gd/tests/bug72697.phpt index 2c293d14be..369e5c6c83 100644 --- a/ext/gd/tests/bug72697.phpt +++ b/ext/gd/tests/bug72697.phpt @@ -19,5 +19,5 @@ trycatch_dump( ?> DONE --EXPECT-- -!! [ValueError] Number of colors has to be greater than zero and no more than 2147483647 +!! [ValueError] imagetruecolortopalette(): Argument #3 ($colorWanted) must be greater than 0 and less than 2147483647 DONE diff --git a/ext/gd/tests/bug72709.phpt b/ext/gd/tests/bug72709.phpt index a5b0463f62..02df1bb7c7 100644 --- a/ext/gd/tests/bug72709.phpt +++ b/ext/gd/tests/bug72709.phpt @@ -20,5 +20,5 @@ imagedestroy($im); ?> ====DONE==== --EXPECT-- -Styles array must not be empty +imagesetstyle(): Argument #2 ($styles) cannot be empty ====DONE==== diff --git a/ext/gd/tests/bug72730.phpt b/ext/gd/tests/bug72730.phpt index 09b6657add..d021f70a48 100644 --- a/ext/gd/tests/bug72730.phpt +++ b/ext/gd/tests/bug72730.phpt @@ -17,4 +17,4 @@ trycatch_dump( ?> --EXPECT-- -!! [ValueError] Gamma values must be positive +!! [ValueError] imagegammacorrect(): Argument #2 ($inputgamma) must be greater than 0 diff --git a/ext/gd/tests/imagecolorallocate_variation5.phpt b/ext/gd/tests/imagecolorallocate_variation5.phpt index 1451af5a83..bc7f82c847 100644 --- a/ext/gd/tests/imagecolorallocate_variation5.phpt +++ b/ext/gd/tests/imagecolorallocate_variation5.phpt @@ -63,9 +63,9 @@ int(657930) int(657930) --Octal -012-- -!! [ValueError] Red component is out of range, must be between 0 and 255 (inclusive) -!! [ValueError] Green component is out of range, must be between 0 and 255 (inclusive) -!! [ValueError] Blue component is out of range, must be between 0 and 255 (inclusive) +!! [ValueError] imagecolorallocate(): Argument #2 ($red) must be between 0 and 255 (inclusive) +!! [ValueError] imagecolorallocate(): Argument #3 ($green) must be between 0 and 255 (inclusive) +!! [ValueError] imagecolorallocate(): Argument #4 ($blue) must be between 0 and 255 (inclusive) --Octal 0377-- int(16714250) @@ -83,9 +83,9 @@ int(657930) int(657930) --Hexa-decimal -0xA-- -!! [ValueError] Red component is out of range, must be between 0 and 255 (inclusive) -!! [ValueError] Green component is out of range, must be between 0 and 255 (inclusive) -!! [ValueError] Blue component is out of range, must be between 0 and 255 (inclusive) +!! [ValueError] imagecolorallocate(): Argument #2 ($red) must be between 0 and 255 (inclusive) +!! [ValueError] imagecolorallocate(): Argument #3 ($green) must be between 0 and 255 (inclusive) +!! [ValueError] imagecolorallocate(): Argument #4 ($blue) must be between 0 and 255 (inclusive) --Hexa-decimal 0xFF-- int(16714250) diff --git a/ext/gd/tests/imagecolorallocate_variation6.phpt b/ext/gd/tests/imagecolorallocate_variation6.phpt index 6af26801b8..355010d198 100644 --- a/ext/gd/tests/imagecolorallocate_variation6.phpt +++ b/ext/gd/tests/imagecolorallocate_variation6.phpt @@ -51,25 +51,25 @@ foreach($values as $key => $value) { *** Testing imagecolorallocate() : usage variations *** --Decimal 256-- -!! [ValueError] Red component is out of range, must be between 0 and 255 (inclusive) -!! [ValueError] Red component is out of range, must be between 0 and 255 (inclusive) -!! [ValueError] Green component is out of range, must be between 0 and 255 (inclusive) -!! [ValueError] Green component is out of range, must be between 0 and 255 (inclusive) -!! [ValueError] Blue component is out of range, must be between 0 and 255 (inclusive) -!! [ValueError] Blue component is out of range, must be between 0 and 255 (inclusive) +!! [ValueError] imagecolorallocate(): Argument #2 ($red) must be between 0 and 255 (inclusive) +!! [ValueError] imagecolorallocate(): Argument #2 ($red) must be between 0 and 255 (inclusive) +!! [ValueError] imagecolorallocate(): Argument #3 ($green) must be between 0 and 255 (inclusive) +!! [ValueError] imagecolorallocate(): Argument #3 ($green) must be between 0 and 255 (inclusive) +!! [ValueError] imagecolorallocate(): Argument #4 ($blue) must be between 0 and 255 (inclusive) +!! [ValueError] imagecolorallocate(): Argument #4 ($blue) must be between 0 and 255 (inclusive) --Octal 0400-- -!! [ValueError] Red component is out of range, must be between 0 and 255 (inclusive) -!! [ValueError] Red component is out of range, must be between 0 and 255 (inclusive) -!! [ValueError] Green component is out of range, must be between 0 and 255 (inclusive) -!! [ValueError] Green component is out of range, must be between 0 and 255 (inclusive) -!! [ValueError] Blue component is out of range, must be between 0 and 255 (inclusive) -!! [ValueError] Blue component is out of range, must be between 0 and 255 (inclusive) +!! [ValueError] imagecolorallocate(): Argument #2 ($red) must be between 0 and 255 (inclusive) +!! [ValueError] imagecolorallocate(): Argument #2 ($red) must be between 0 and 255 (inclusive) +!! [ValueError] imagecolorallocate(): Argument #3 ($green) must be between 0 and 255 (inclusive) +!! [ValueError] imagecolorallocate(): Argument #3 ($green) must be between 0 and 255 (inclusive) +!! [ValueError] imagecolorallocate(): Argument #4 ($blue) must be between 0 and 255 (inclusive) +!! [ValueError] imagecolorallocate(): Argument #4 ($blue) must be between 0 and 255 (inclusive) --Hexa-decimal 0x100-- -!! [ValueError] Red component is out of range, must be between 0 and 255 (inclusive) -!! [ValueError] Red component is out of range, must be between 0 and 255 (inclusive) -!! [ValueError] Green component is out of range, must be between 0 and 255 (inclusive) -!! [ValueError] Green component is out of range, must be between 0 and 255 (inclusive) -!! [ValueError] Blue component is out of range, must be between 0 and 255 (inclusive) -!! [ValueError] Blue component is out of range, must be between 0 and 255 (inclusive) +!! [ValueError] imagecolorallocate(): Argument #2 ($red) must be between 0 and 255 (inclusive) +!! [ValueError] imagecolorallocate(): Argument #2 ($red) must be between 0 and 255 (inclusive) +!! [ValueError] imagecolorallocate(): Argument #3 ($green) must be between 0 and 255 (inclusive) +!! [ValueError] imagecolorallocate(): Argument #3 ($green) must be between 0 and 255 (inclusive) +!! [ValueError] imagecolorallocate(): Argument #4 ($blue) must be between 0 and 255 (inclusive) +!! [ValueError] imagecolorallocate(): Argument #4 ($blue) must be between 0 and 255 (inclusive) diff --git a/ext/gd/tests/imagecolordeallocate_error3.phpt b/ext/gd/tests/imagecolordeallocate_error3.phpt index e0748c44ba..51df328f8c 100644 --- a/ext/gd/tests/imagecolordeallocate_error3.phpt +++ b/ext/gd/tests/imagecolordeallocate_error3.phpt @@ -22,4 +22,4 @@ trycatch_dump( ?> --EXPECT-- -!! [ValueError] Color index 101 out of range +!! [ValueError] imagecolordeallocate(): Argument #2 ($index) must be between 0 and 1 diff --git a/ext/gd/tests/imagecolordeallocate_error4.phpt b/ext/gd/tests/imagecolordeallocate_error4.phpt index e35c529879..6d9bceb3ac 100644 --- a/ext/gd/tests/imagecolordeallocate_error4.phpt +++ b/ext/gd/tests/imagecolordeallocate_error4.phpt @@ -22,4 +22,4 @@ trycatch_dump( ?> --EXPECT-- -!! [ValueError] Color index -1 out of range +!! [ValueError] imagecolordeallocate(): Argument #2 ($index) must be between 0 and 1 diff --git a/ext/gd/tests/imageconvolution_error2.phpt b/ext/gd/tests/imageconvolution_error2.phpt index d26851c26c..b9c32af1e4 100644 --- a/ext/gd/tests/imageconvolution_error2.phpt +++ b/ext/gd/tests/imageconvolution_error2.phpt @@ -27,4 +27,4 @@ trycatch_dump( ?> --EXPECT-- -!! [ValueError] Convolution matrix must be a 3x3 array +!! [ValueError] imageconvolution(): Argument #2 ($matrix3x3) must be a 3x3 array diff --git a/ext/gd/tests/imageconvolution_error3.phpt b/ext/gd/tests/imageconvolution_error3.phpt index 8974fdbda0..2ad99f9617 100644 --- a/ext/gd/tests/imageconvolution_error3.phpt +++ b/ext/gd/tests/imageconvolution_error3.phpt @@ -35,5 +35,5 @@ trycatch_dump( ?> --EXPECT-- -!! [ValueError] Convolution matrix must be a 3x3 array, matrix[2] only has 2 elements -!! [ValueError] Convolution matrix must be a 3x3 array, matrix[2][2] cannot be found (missing integer key) +!! [ValueError] imageconvolution(): Argument #2 ($matrix3x3) must be a 3x3 array, matrix[2] only has 2 elements +!! [ValueError] imageconvolution(): Argument #2 ($matrix3x3) must be a 3x3 array, matrix[2][2] cannot be found (missing integer key) diff --git a/ext/gd/tests/imagecreate_error.phpt b/ext/gd/tests/imagecreate_error.phpt index 9fd8679c13..b0b6c3abf7 100644 --- a/ext/gd/tests/imagecreate_error.phpt +++ b/ext/gd/tests/imagecreate_error.phpt @@ -17,5 +17,5 @@ trycatch_dump( ?> --EXPECT-- -!! [ValueError] Invalid width (x_size) -!! [ValueError] Invalid height (y_size) +!! [ValueError] imagecreate(): Argument #1 ($x_size) must be greater than 0 +!! [ValueError] imagecreate(): Argument #2 ($y_size) must be greater than 0 diff --git a/ext/gd/tests/imagecreatetruecolor_error2.phpt b/ext/gd/tests/imagecreatetruecolor_error2.phpt index e2784b1530..995aa03d7e 100644 --- a/ext/gd/tests/imagecreatetruecolor_error2.phpt +++ b/ext/gd/tests/imagecreatetruecolor_error2.phpt @@ -19,5 +19,5 @@ trycatch_dump( ?> --EXPECT-- -!! [ValueError] Invalid width (x_size) -!! [ValueError] Invalid height (y_size) +!! [ValueError] imagecreatetruecolor(): Argument #1 ($x_size) must be greater than 0 +!! [ValueError] imagecreatetruecolor(): Argument #2 ($y_size) must be greater than 0 diff --git a/ext/gd/tests/imagetruecolortopalette_error3.phpt b/ext/gd/tests/imagetruecolortopalette_error3.phpt index 40dc306116..707f7e37bc 100644 --- a/ext/gd/tests/imagetruecolortopalette_error3.phpt +++ b/ext/gd/tests/imagetruecolortopalette_error3.phpt @@ -19,4 +19,4 @@ trycatch_dump( ?> --EXPECT-- -!! [ValueError] Number of colors has to be greater than zero and no more than 2147483647 +!! [ValueError] imagetruecolortopalette(): Argument #3 ($colorWanted) must be greater than 0 and less than 2147483647 diff --git a/ext/gd/tests/imagetruecolortopalette_error4.phpt b/ext/gd/tests/imagetruecolortopalette_error4.phpt index 055fc657b2..5726befab2 100644 --- a/ext/gd/tests/imagetruecolortopalette_error4.phpt +++ b/ext/gd/tests/imagetruecolortopalette_error4.phpt @@ -20,5 +20,5 @@ trycatch_dump( ?> --EXPECT-- -!! [ValueError] Number of colors has to be greater than zero and no more than 2147483647 -!! [ValueError] Number of colors has to be greater than zero and no more than 2147483647 +!! [ValueError] imagetruecolortopalette(): Argument #3 ($colorWanted) must be greater than 0 and less than 2147483647 +!! [ValueError] imagetruecolortopalette(): Argument #3 ($colorWanted) must be greater than 0 and less than 2147483647 diff --git a/ext/json/json.c b/ext/json/json.c index b78de3ea16..c64378fd56 100644 --- a/ext/json/json.c +++ b/ext/json/json.c @@ -299,12 +299,12 @@ PHP_FUNCTION(json_decode) } if (depth <= 0) { - zend_value_error("Depth must be greater than zero"); + zend_argument_value_error(3, "must be greater than 0"); RETURN_THROWS(); } if (depth > INT_MAX) { - zend_value_error("Depth must be lower than %d", INT_MAX); + zend_argument_value_error(3, "must be less than %d", INT_MAX); RETURN_THROWS(); } diff --git a/ext/json/tests/bug72787.phpt b/ext/json/tests/bug72787.phpt index d2d1f80177..48983b0fb7 100644 --- a/ext/json/tests/bug72787.phpt +++ b/ext/json/tests/bug72787.phpt @@ -14,4 +14,4 @@ try { ?> --EXPECTF-- -Depth must be lower than %d +json_decode(): Argument #3 ($depth) must be less than %d diff --git a/ext/json/tests/json_decode_error.phpt b/ext/json/tests/json_decode_error.phpt index b286df8e74..36d86168cd 100644 --- a/ext/json/tests/json_decode_error.phpt +++ b/ext/json/tests/json_decode_error.phpt @@ -19,4 +19,4 @@ try { *** Testing json_decode() : error conditions *** -- Testing json_decode() function with depth below 0 -- -Depth must be greater than zero +json_decode(): Argument #3 ($depth) must be greater than 0 diff --git a/ext/sqlite3/sqlite3.c b/ext/sqlite3/sqlite3.c index 0d5fc6de08..18dddd962d 100644 --- a/ext/sqlite3/sqlite3.c +++ b/ext/sqlite3/sqlite3.c @@ -1299,7 +1299,7 @@ PHP_METHOD(sqlite3, openBlob) } if (ZEND_NUM_ARGS() >= 4 && CHECK_NULL_PATH(dbname, dbname_len)) { - zend_value_error("dbname must not contain null bytes"); + zend_argument_type_error(4, "must not contain null bytes"); RETURN_THROWS(); } @@ -1405,10 +1405,13 @@ PHP_METHOD(sqlite3, backup) RETURN_THROWS(); } - if ((ZEND_NUM_ARGS() >= 2 && CHECK_NULL_PATH(source_dbname, source_dbname_length)) - || (ZEND_NUM_ARGS() >= 3 && CHECK_NULL_PATH(destination_dbname, destination_dbname_length)) - ) { - zend_value_error("dbname must not contain null bytes"); + if (ZEND_NUM_ARGS() >= 2 && CHECK_NULL_PATH(source_dbname, source_dbname_length)) { + zend_argument_type_error(2, "must not contain null bytes"); + RETURN_THROWS(); + } + + if (ZEND_NUM_ARGS() >= 3 && CHECK_NULL_PATH(destination_dbname, destination_dbname_length)) { + zend_argument_type_error(3, "must not contain null bytes"); RETURN_THROWS(); } diff --git a/ext/standard/array.c b/ext/standard/array.c index 17c7f29d9a..daecdc7a52 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -704,7 +704,7 @@ PHP_FUNCTION(count) ZEND_PARSE_PARAMETERS_END(); if (mode != COUNT_NORMAL && mode != COUNT_RECURSIVE) { - zend_value_error("Mode value is invalid"); + zend_argument_value_error(2, "must be a valid mode"); RETURN_THROWS(); } @@ -2385,12 +2385,12 @@ PHP_FUNCTION(extract) extract_type &= 0xff; if (extract_type < EXTR_OVERWRITE || extract_type > EXTR_IF_EXISTS) { - zend_value_error("Invalid extract type"); + zend_argument_value_error(2, "must be a valid extract type"); RETURN_THROWS(); } if (extract_type > EXTR_SKIP && extract_type <= EXTR_PREFIX_IF_EXISTS && ZEND_NUM_ARGS() < 3) { - zend_value_error("Specified extract type requires the prefix parameter"); + zend_argument_value_error(3, "is required when using this extract type"); RETURN_THROWS(); } diff --git a/ext/standard/assert.c b/ext/standard/assert.c index 1995ec1da8..b039c169af 100644 --- a/ext/standard/assert.c +++ b/ext/standard/assert.c @@ -314,7 +314,7 @@ PHP_FUNCTION(assert_options) break; default: - zend_value_error("Unknown value " ZEND_LONG_FMT, what); + zend_argument_value_error(1, "must have a valid value"); break; } diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index d99b7fb498..8596ce4a50 100755 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -850,7 +850,7 @@ PHP_FUNCTION(putenv) ZEND_PARSE_PARAMETERS_END(); if (setting_len == 0 || setting[0] == '=') { - zend_value_error("Invalid parameter syntax"); + zend_argument_value_error(1, "must have a valid syntax"); RETURN_THROWS(); } diff --git a/ext/standard/dir.c b/ext/standard/dir.c index 535c536b72..0eaadac3e4 100644 --- a/ext/standard/dir.c +++ b/ext/standard/dir.c @@ -559,7 +559,7 @@ PHP_FUNCTION(scandir) ZEND_PARSE_PARAMETERS_END(); if (dirn_len < 1) { - zend_value_error("Directory name cannot be empty"); + zend_argument_value_error(1, "cannot be empty"); RETURN_THROWS(); } diff --git a/ext/standard/dns.c b/ext/standard/dns.c index c566f4e6ae..c6160aa9e6 100644 --- a/ext/standard/dns.c +++ b/ext/standard/dns.c @@ -381,7 +381,7 @@ PHP_FUNCTION(dns_check_record) ZEND_PARSE_PARAMETERS_END(); if (hostname_len == 0) { - zend_value_error("Host cannot be empty"); + zend_argument_value_error(1, "cannot be empty"); RETURN_THROWS(); } diff --git a/ext/standard/dns_win32.c b/ext/standard/dns_win32.c index b1cf4986fd..4572a84b05 100644 --- a/ext/standard/dns_win32.c +++ b/ext/standard/dns_win32.c @@ -107,7 +107,7 @@ PHP_FUNCTION(dns_check_record) } if (hostname_len == 0) { - zend_value_error("Host cannot be empty"); + zend_argument_value_error(1, "cannot be empty"); RETURN_THROWS(); } diff --git a/ext/standard/file.c b/ext/standard/file.c index 7639b20111..5cde0ef978 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -742,7 +742,7 @@ PHP_FUNCTION(file) ZEND_PARSE_PARAMETERS_END(); if (flags < 0 || flags > (PHP_FILE_USE_INCLUDE_PATH | PHP_FILE_IGNORE_NEW_LINES | PHP_FILE_SKIP_EMPTY_LINES | PHP_FILE_NO_DEFAULT_CONTEXT)) { - zend_value_error("'" ZEND_LONG_FMT "' flag is not supported", flags); + zend_argument_value_error(2, "must be a valid flag value"); RETURN_THROWS(); } @@ -1492,7 +1492,7 @@ PHP_FUNCTION(ftruncate) ZEND_PARSE_PARAMETERS_END(); if (size < 0) { - zend_value_error("Negative size is not supported"); + zend_argument_value_error(2, "must be greater than or equal to 0"); RETURN_THROWS(); } diff --git a/ext/standard/tests/array/count_invalid_mode.phpt b/ext/standard/tests/array/count_invalid_mode.phpt index 6e302fd0ce..a411a2983e 100644 --- a/ext/standard/tests/array/count_invalid_mode.phpt +++ b/ext/standard/tests/array/count_invalid_mode.phpt @@ -29,9 +29,9 @@ int(0) int(0) int(0) int(0) -Mode value is invalid -Mode value is invalid -Mode value is invalid +count(): Argument #2 ($mode) must be a valid mode +count(): Argument #2 ($mode) must be a valid mode +count(): Argument #2 ($mode) must be a valid mode int(0) int(0) int(0) diff --git a/ext/standard/tests/array/extract_error.phpt b/ext/standard/tests/array/extract_error.phpt index db6569e94c..40f517fb4d 100644 --- a/ext/standard/tests/array/extract_error.phpt +++ b/ext/standard/tests/array/extract_error.phpt @@ -33,6 +33,6 @@ try { *** Testing Error Conditions *** Notice: A non well formed numeric value encountered in %s on line %d -Invalid extract type -Invalid extract type -Specified extract type requires the prefix parameter +extract(): Argument #2 ($extract_type) must be a valid extract type +extract(): Argument #2 ($extract_type) must be a valid extract type +extract(): Argument #3 ($prefix) is required when using this extract type diff --git a/ext/standard/tests/assert/assert_options_error.phpt b/ext/standard/tests/assert/assert_options_error.phpt index ed94260ef8..ba92867737 100644 --- a/ext/standard/tests/assert/assert_options_error.phpt +++ b/ext/standard/tests/assert/assert_options_error.phpt @@ -10,4 +10,4 @@ try { } ?> --EXPECT-- -Unknown value 1000 +assert_options(): Argument #1 ($what) must have a valid value diff --git a/ext/standard/tests/dir/bug41693.phpt b/ext/standard/tests/dir/bug41693.phpt index 2f9fcabb9a..2c779bedcd 100644 --- a/ext/standard/tests/dir/bug41693.phpt +++ b/ext/standard/tests/dir/bug41693.phpt @@ -11,4 +11,4 @@ try { ?> --EXPECT-- -Directory name cannot be empty +scandir(): Argument #1 ($directory) cannot be empty diff --git a/ext/standard/tests/file/bug71882.phpt b/ext/standard/tests/file/bug71882.phpt index 7d3b911109..68f98f19b6 100644 --- a/ext/standard/tests/file/bug71882.phpt +++ b/ext/standard/tests/file/bug71882.phpt @@ -10,4 +10,4 @@ try { } ?> --EXPECT-- -Negative size is not supported +ftruncate(): Argument #2 ($size) must be greater than or equal to 0 diff --git a/ext/standard/tests/file/file_variation6.phpt b/ext/standard/tests/file/file_variation6.phpt index e5d8b6d51a..354f6ee509 100644 --- a/ext/standard/tests/file/file_variation6.phpt +++ b/ext/standard/tests/file/file_variation6.phpt @@ -236,12 +236,12 @@ array(3) { [2]=> string(6) "Line 3" } -'24' flag is not supported -'25' flag is not supported -'26' flag is not supported -'27' flag is not supported -'28' flag is not supported -'29' flag is not supported -'30' flag is not supported -'31' flag is not supported -'32' flag is not supported
\ No newline at end of file +file(): Argument #2 ($flags) must be a valid flag value +file(): Argument #2 ($flags) must be a valid flag value +file(): Argument #2 ($flags) must be a valid flag value +file(): Argument #2 ($flags) must be a valid flag value +file(): Argument #2 ($flags) must be a valid flag value +file(): Argument #2 ($flags) must be a valid flag value +file(): Argument #2 ($flags) must be a valid flag value +file(): Argument #2 ($flags) must be a valid flag value +file(): Argument #2 ($flags) must be a valid flag value diff --git a/ext/standard/tests/file/filesize_variation3.phpt b/ext/standard/tests/file/filesize_variation3.phpt index 74790e687c..7006740e4c 100644 --- a/ext/standard/tests/file/filesize_variation3.phpt +++ b/ext/standard/tests/file/filesize_variation3.phpt @@ -63,5 +63,5 @@ bool(true) int(1200) bool(true) int(0) -Negative size is not supported +ftruncate(): Argument #2 ($size) must be greater than or equal to 0 int(0) diff --git a/ext/standard/tests/file/ftruncate.phpt b/ext/standard/tests/file/ftruncate.phpt Binary files differindex d5d883b1a1..757bbb733d 100644 --- a/ext/standard/tests/file/ftruncate.phpt +++ b/ext/standard/tests/file/ftruncate.phpt diff --git a/ext/standard/tests/file/ftruncate_variation4.phpt b/ext/standard/tests/file/ftruncate_variation4.phpt index 95ae439b4d..87fc7b3524 100644 --- a/ext/standard/tests/file/ftruncate_variation4.phpt +++ b/ext/standard/tests/file/ftruncate_variation4.phpt @@ -77,7 +77,7 @@ echo "Done\n"; -- Testing ftruncate(): try truncating file to a negative size -- bool(true) int(0) -Negative size is not supported +ftruncate(): Argument #2 ($size) must be greater than or equal to 0 int(0) bool(false) bool(true) @@ -85,7 +85,7 @@ bool(true) -- Testing ftruncate(): try truncating file to a negative size -- bool(true) int(0) -Negative size is not supported +ftruncate(): Argument #2 ($size) must be greater than or equal to 0 int(0) bool(false) bool(true) @@ -93,7 +93,7 @@ bool(true) -- Testing ftruncate(): try truncating file to a negative size -- bool(true) int(0) -Negative size is not supported +ftruncate(): Argument #2 ($size) must be greater than or equal to 0 int(0) bool(false) bool(true) @@ -101,7 +101,7 @@ bool(true) -- Testing ftruncate(): try truncating file to a negative size -- bool(true) int(0) -Negative size is not supported +ftruncate(): Argument #2 ($size) must be greater than or equal to 0 int(0) bool(false) bool(true) @@ -109,7 +109,7 @@ bool(true) -- Testing ftruncate(): try truncating file to a negative size -- bool(true) int(0) -Negative size is not supported +ftruncate(): Argument #2 ($size) must be greater than or equal to 0 int(0) bool(false) bool(true) @@ -117,7 +117,7 @@ bool(true) -- Testing ftruncate(): try truncating file to a negative size -- bool(true) int(0) -Negative size is not supported +ftruncate(): Argument #2 ($size) must be greater than or equal to 0 int(0) bool(false) bool(true) @@ -125,7 +125,7 @@ bool(true) -- Testing ftruncate(): try truncating file to a negative size -- bool(true) int(0) -Negative size is not supported +ftruncate(): Argument #2 ($size) must be greater than or equal to 0 int(0) bool(false) bool(true) @@ -133,7 +133,7 @@ bool(true) -- Testing ftruncate(): try truncating file to a negative size -- bool(true) int(0) -Negative size is not supported +ftruncate(): Argument #2 ($size) must be greater than or equal to 0 int(0) bool(false) bool(true) @@ -141,7 +141,7 @@ bool(true) -- Testing ftruncate(): try truncating file to a negative size -- bool(true) int(0) -Negative size is not supported +ftruncate(): Argument #2 ($size) must be greater than or equal to 0 int(0) bool(false) bool(true) @@ -149,7 +149,7 @@ bool(true) -- Testing ftruncate(): try truncating file to a negative size -- bool(true) int(0) -Negative size is not supported +ftruncate(): Argument #2 ($size) must be greater than or equal to 0 int(0) bool(false) bool(true) @@ -157,7 +157,7 @@ bool(true) -- Testing ftruncate(): try truncating file to a negative size -- bool(true) int(0) -Negative size is not supported +ftruncate(): Argument #2 ($size) must be greater than or equal to 0 int(0) bool(false) bool(true) @@ -165,7 +165,7 @@ bool(true) -- Testing ftruncate(): try truncating file to a negative size -- bool(true) int(0) -Negative size is not supported +ftruncate(): Argument #2 ($size) must be greater than or equal to 0 int(0) bool(false) bool(true) @@ -173,7 +173,7 @@ bool(true) -- Testing ftruncate(): try truncating file to a negative size -- bool(true) int(0) -Negative size is not supported +ftruncate(): Argument #2 ($size) must be greater than or equal to 0 int(0) bool(false) bool(true) @@ -181,7 +181,7 @@ bool(true) -- Testing ftruncate(): try truncating file to a negative size -- bool(true) int(0) -Negative size is not supported +ftruncate(): Argument #2 ($size) must be greater than or equal to 0 int(0) bool(false) bool(true) @@ -189,7 +189,7 @@ bool(true) -- Testing ftruncate(): try truncating file to a negative size -- bool(true) int(0) -Negative size is not supported +ftruncate(): Argument #2 ($size) must be greater than or equal to 0 int(0) bool(false) bool(true) @@ -197,7 +197,7 @@ bool(true) -- Testing ftruncate(): try truncating file to a negative size -- bool(true) int(0) -Negative size is not supported +ftruncate(): Argument #2 ($size) must be greater than or equal to 0 int(0) bool(false) bool(true) @@ -205,7 +205,7 @@ bool(true) -- Testing ftruncate(): try truncating file to a negative size -- bool(true) int(0) -Negative size is not supported +ftruncate(): Argument #2 ($size) must be greater than or equal to 0 int(0) bool(false) bool(true) @@ -213,7 +213,7 @@ bool(true) -- Testing ftruncate(): try truncating file to a negative size -- bool(true) int(0) -Negative size is not supported +ftruncate(): Argument #2 ($size) must be greater than or equal to 0 int(0) bool(false) bool(true) @@ -221,7 +221,7 @@ bool(true) -- Testing ftruncate(): try truncating file to a negative size -- bool(true) int(0) -Negative size is not supported +ftruncate(): Argument #2 ($size) must be greater than or equal to 0 int(0) bool(false) bool(true) @@ -229,7 +229,7 @@ bool(true) -- Testing ftruncate(): try truncating file to a negative size -- bool(true) int(0) -Negative size is not supported +ftruncate(): Argument #2 ($size) must be greater than or equal to 0 int(0) bool(false) bool(true) @@ -237,7 +237,7 @@ bool(true) -- Testing ftruncate(): try truncating file to a negative size -- bool(true) int(0) -Negative size is not supported +ftruncate(): Argument #2 ($size) must be greater than or equal to 0 int(0) bool(false) bool(true) @@ -245,7 +245,7 @@ bool(true) -- Testing ftruncate(): try truncating file to a negative size -- bool(true) int(0) -Negative size is not supported +ftruncate(): Argument #2 ($size) must be greater than or equal to 0 int(0) bool(false) bool(true) @@ -253,7 +253,7 @@ bool(true) -- Testing ftruncate(): try truncating file to a negative size -- bool(true) int(0) -Negative size is not supported +ftruncate(): Argument #2 ($size) must be greater than or equal to 0 int(0) bool(false) bool(true) @@ -261,7 +261,7 @@ bool(true) -- Testing ftruncate(): try truncating file to a negative size -- bool(true) int(0) -Negative size is not supported +ftruncate(): Argument #2 ($size) must be greater than or equal to 0 int(0) bool(false) bool(true) @@ -271,7 +271,7 @@ bool(true) -- Testing ftruncate(): try truncating file to a negative size -- bool(true) int(0) -Negative size is not supported +ftruncate(): Argument #2 ($size) must be greater than or equal to 0 int(0) bool(false) bool(true) @@ -279,7 +279,7 @@ bool(true) -- Testing ftruncate(): try truncating file to a negative size -- bool(true) int(0) -Negative size is not supported +ftruncate(): Argument #2 ($size) must be greater than or equal to 0 int(0) bool(false) bool(true) @@ -287,7 +287,7 @@ bool(true) -- Testing ftruncate(): try truncating file to a negative size -- bool(true) int(0) -Negative size is not supported +ftruncate(): Argument #2 ($size) must be greater than or equal to 0 int(0) bool(false) bool(true) @@ -295,7 +295,7 @@ bool(true) -- Testing ftruncate(): try truncating file to a negative size -- bool(true) int(0) -Negative size is not supported +ftruncate(): Argument #2 ($size) must be greater than or equal to 0 int(0) bool(false) bool(true) @@ -303,7 +303,7 @@ bool(true) -- Testing ftruncate(): try truncating file to a negative size -- bool(true) int(0) -Negative size is not supported +ftruncate(): Argument #2 ($size) must be greater than or equal to 0 int(0) bool(false) bool(true) @@ -311,7 +311,7 @@ bool(true) -- Testing ftruncate(): try truncating file to a negative size -- bool(true) int(0) -Negative size is not supported +ftruncate(): Argument #2 ($size) must be greater than or equal to 0 int(0) bool(false) bool(true) @@ -319,7 +319,7 @@ bool(true) -- Testing ftruncate(): try truncating file to a negative size -- bool(true) int(0) -Negative size is not supported +ftruncate(): Argument #2 ($size) must be greater than or equal to 0 int(0) bool(false) bool(true) @@ -327,7 +327,7 @@ bool(true) -- Testing ftruncate(): try truncating file to a negative size -- bool(true) int(0) -Negative size is not supported +ftruncate(): Argument #2 ($size) must be greater than or equal to 0 int(0) bool(false) bool(true) @@ -335,7 +335,7 @@ bool(true) -- Testing ftruncate(): try truncating file to a negative size -- bool(true) int(0) -Negative size is not supported +ftruncate(): Argument #2 ($size) must be greater than or equal to 0 int(0) bool(false) bool(true) @@ -343,7 +343,7 @@ bool(true) -- Testing ftruncate(): try truncating file to a negative size -- bool(true) int(0) -Negative size is not supported +ftruncate(): Argument #2 ($size) must be greater than or equal to 0 int(0) bool(false) bool(true) @@ -351,7 +351,7 @@ bool(true) -- Testing ftruncate(): try truncating file to a negative size -- bool(true) int(0) -Negative size is not supported +ftruncate(): Argument #2 ($size) must be greater than or equal to 0 int(0) bool(false) bool(true) @@ -359,7 +359,7 @@ bool(true) -- Testing ftruncate(): try truncating file to a negative size -- bool(true) int(0) -Negative size is not supported +ftruncate(): Argument #2 ($size) must be greater than or equal to 0 int(0) bool(false) bool(true) @@ -367,7 +367,7 @@ bool(true) -- Testing ftruncate(): try truncating file to a negative size -- bool(true) int(0) -Negative size is not supported +ftruncate(): Argument #2 ($size) must be greater than or equal to 0 int(0) bool(false) bool(true) @@ -375,7 +375,7 @@ bool(true) -- Testing ftruncate(): try truncating file to a negative size -- bool(true) int(0) -Negative size is not supported +ftruncate(): Argument #2 ($size) must be greater than or equal to 0 int(0) bool(false) bool(true) @@ -383,7 +383,7 @@ bool(true) -- Testing ftruncate(): try truncating file to a negative size -- bool(true) int(0) -Negative size is not supported +ftruncate(): Argument #2 ($size) must be greater than or equal to 0 int(0) bool(false) bool(true) @@ -391,7 +391,7 @@ bool(true) -- Testing ftruncate(): try truncating file to a negative size -- bool(true) int(0) -Negative size is not supported +ftruncate(): Argument #2 ($size) must be greater than or equal to 0 int(0) bool(false) bool(true) @@ -399,7 +399,7 @@ bool(true) -- Testing ftruncate(): try truncating file to a negative size -- bool(true) int(0) -Negative size is not supported +ftruncate(): Argument #2 ($size) must be greater than or equal to 0 int(0) bool(false) bool(true) @@ -407,7 +407,7 @@ bool(true) -- Testing ftruncate(): try truncating file to a negative size -- bool(true) int(0) -Negative size is not supported +ftruncate(): Argument #2 ($size) must be greater than or equal to 0 int(0) bool(false) bool(true) @@ -415,7 +415,7 @@ bool(true) -- Testing ftruncate(): try truncating file to a negative size -- bool(true) int(0) -Negative size is not supported +ftruncate(): Argument #2 ($size) must be greater than or equal to 0 int(0) bool(false) bool(true) @@ -423,7 +423,7 @@ bool(true) -- Testing ftruncate(): try truncating file to a negative size -- bool(true) int(0) -Negative size is not supported +ftruncate(): Argument #2 ($size) must be greater than or equal to 0 int(0) bool(false) bool(true) @@ -431,7 +431,7 @@ bool(true) -- Testing ftruncate(): try truncating file to a negative size -- bool(true) int(0) -Negative size is not supported +ftruncate(): Argument #2 ($size) must be greater than or equal to 0 int(0) bool(false) bool(true) @@ -439,7 +439,7 @@ bool(true) -- Testing ftruncate(): try truncating file to a negative size -- bool(true) int(0) -Negative size is not supported +ftruncate(): Argument #2 ($size) must be greater than or equal to 0 int(0) bool(false) bool(true) @@ -447,7 +447,7 @@ bool(true) -- Testing ftruncate(): try truncating file to a negative size -- bool(true) int(0) -Negative size is not supported +ftruncate(): Argument #2 ($size) must be greater than or equal to 0 int(0) bool(false) bool(true) @@ -455,7 +455,7 @@ bool(true) -- Testing ftruncate(): try truncating file to a negative size -- bool(true) int(0) -Negative size is not supported +ftruncate(): Argument #2 ($size) must be greater than or equal to 0 int(0) bool(false) bool(true) diff --git a/ext/standard/tests/file/userstreams_005.phpt b/ext/standard/tests/file/userstreams_005.phpt index 5650df2aa0..e553e1c8ee 100644 --- a/ext/standard/tests/file/userstreams_005.phpt +++ b/ext/standard/tests/file/userstreams_005.phpt @@ -59,7 +59,7 @@ bool(true) truncation with new_size=10 bool(true) ------ stream_truncate negative size: ------- -Negative size is not supported +ftruncate(): Argument #2 ($size) must be greater than or equal to 0 ------ stream_truncate bad return: ------- truncation with new_size=0 diff --git a/ext/standard/tests/general_functions/putenv.phpt b/ext/standard/tests/general_functions/putenv.phpt index c1f4f98eeb..163fa7e4a7 100644 --- a/ext/standard/tests/general_functions/putenv.phpt +++ b/ext/standard/tests/general_functions/putenv.phpt @@ -29,7 +29,7 @@ try { echo "Done\n"; ?> ---EXPECTF-- +--EXPECT-- bool(false) bool(true) string(5) "value" @@ -37,6 +37,6 @@ bool(true) string(0) "" bool(true) bool(false) -Invalid parameter syntax -Invalid parameter syntax +putenv(): Argument #1 ($setting) must have a valid syntax +putenv(): Argument #1 ($setting) must have a valid syntax Done diff --git a/ext/standard/tests/network/bug41347.phpt b/ext/standard/tests/network/bug41347.phpt index 6390327a52..626561976b 100644 --- a/ext/standard/tests/network/bug41347.phpt +++ b/ext/standard/tests/network/bug41347.phpt @@ -9,4 +9,4 @@ try { } ?> --EXPECT-- -Host cannot be empty +dns_check_record(): Argument #1 ($hostname) cannot be empty |