Skip to content

Commit 7f843b2

Browse files
committed
Make type and value error messages more consistent
1 parent d1764ca commit 7f843b2

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

ext/standard/filestat.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ static void php_do_chgrp(INTERNAL_FUNCTION_PARAMETERS, int do_lchgrp) /* {{{ */
353353
option = PHP_STREAM_META_GROUP_NAME;
354354
value = Z_STRVAL_P(group);
355355
} else {
356-
zend_type_error("Parameter 2 should be string or int, %s given", zend_zval_type_name(group));
356+
zend_type_error("Argument 2 must be string|int, %s given", zend_zval_type_name(group));
357357
RETURN_THROWS();
358358
}
359359
if(wrapper->wops->stream_metadata(wrapper, filename, option, value, NULL)) {
@@ -382,7 +382,7 @@ static void php_do_chgrp(INTERNAL_FUNCTION_PARAMETERS, int do_lchgrp) /* {{{ */
382382
RETURN_FALSE;
383383
}
384384
} else {
385-
zend_type_error("Parameter 2 should be string or int, %s given", zend_zval_type_name(group));
385+
zend_type_error("Argument 2 must be string|int, %s given", zend_zval_type_name(group));
386386
RETURN_THROWS();
387387
}
388388

ext/standard/random.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ PHP_FUNCTION(random_bytes)
205205
ZEND_PARSE_PARAMETERS_END();
206206

207207
if (size < 1) {
208-
zend_throw_exception(zend_ce_error, "Length must be greater than 0", 0);
208+
zend_throw_exception_ex(zend_ce_error, 0, "Argument 1 must be greater than 0, " ZEND_LONG_FMT " given", size);
209209
RETURN_THROWS();
210210
}
211211

ext/standard/string.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,15 +1276,15 @@ PHP_FUNCTION(implode)
12761276

12771277
if (pieces == NULL) {
12781278
if (arg1_array == NULL) {
1279-
zend_type_error("Argument must be an array");
1279+
zend_type_error("Argument must be of the type array, string given");
12801280
RETURN_THROWS();
12811281
}
12821282

12831283
arg1_str = ZSTR_EMPTY_ALLOC();
12841284
pieces = arg1_array;
12851285
} else {
12861286
if (arg1_str == NULL) {
1287-
zend_type_error("The first argument must be a string");
1287+
zend_type_error("Argument 1 must be of the type string, array given");
12881288
RETURN_THROWS();
12891289
}
12901290
}

ext/standard/var.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1240,7 +1240,7 @@ PHP_FUNCTION(unserialize)
12401240
max_depth = zend_hash_str_find_deref(Z_ARRVAL_P(options), "max_depth", sizeof("max_depth") - 1);
12411241
if (max_depth) {
12421242
if (Z_TYPE_P(max_depth) != IS_LONG) {
1243-
zend_type_error("max_depth should be int");
1243+
zend_type_error("The \"max_depth\" option must be of the type int, %s given", zend_zval_type_name(max_depth));
12441244
goto cleanup;
12451245
}
12461246
if (Z_LVAL_P(max_depth) < 0) {

0 commit comments

Comments
 (0)