Improve some TypeError and ValueError messages

Closes GH-5377
This commit is contained in:
Máté Kocsis 2020-04-13 10:41:23 +02:00
parent 11c5c78401
commit 1f48feebb9
No known key found for this signature in database
GPG Key ID: FD055E41728BF310
46 changed files with 188 additions and 189 deletions

View File

@ -345,7 +345,7 @@ PHP_FUNCTION(bzopen)
}
if (mode_len != 1 || (mode[0] != 'r' && mode[0] != 'w')) {
zend_argument_value_error(2, "must be a valid mode. Only 'w' and 'r' are supported");
zend_argument_value_error(2, "must be either 'r' or 'w'");
RETURN_THROWS();
}

View File

@ -37,15 +37,15 @@ var_dump(bzopen($fp, "r"));
?>
--EXPECTF--
bzopen(): Argument #2 ($mode) must be a valid mode. Only 'w' and 'r' are supported
bzopen(): Argument #2 ($mode) must be either 'r' or 'w'
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)
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
bzopen(): Argument #2 ($mode) must be either 'r' or 'w'
bzopen(): Argument #2 ($mode) must be either 'r' or 'w'
Warning: bzopen(no_such_file): Failed to open stream: No such file or directory in %s on line %d
bool(false)

View File

@ -338,7 +338,7 @@ PHP_MINIT_FUNCTION(gd)
/* GD2 image format types */
REGISTER_LONG_CONSTANT("IMG_GD2_RAW", GD2_FMT_RAW, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("IMG_GD2_COMPRESSED", GD2_FMT_COMPRESSED, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("IMG_FLIP_HORIZONTAL", GD_FLIP_HORINZONTAL, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("IMG_FLIP_HORIZONTAL", GD_FLIP_HORIZONTAL, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("IMG_FLIP_VERTICAL", GD_FLIP_VERTICAL, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("IMG_FLIP_BOTH", GD_FLIP_BOTH, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("IMG_EFFECT_REPLACE", gdEffectReplace, CONST_CS | CONST_PERSISTENT);
@ -3536,7 +3536,7 @@ PHP_FUNCTION(imageflip)
gdImageFlipVertical(im);
break;
case GD_FLIP_HORINZONTAL:
case GD_FLIP_HORIZONTAL:
gdImageFlipHorizontal(im);
break;
@ -3545,7 +3545,7 @@ PHP_FUNCTION(imageflip)
break;
default:
zend_argument_value_error(2, "must be a valid mode");
zend_argument_value_error(2, "must be either IMG_FLIP_VERTICAL, IMG_FLIP_HORIZONTAL, or IMG_FLIP_BOTH");
RETURN_THROWS();
}

View File

@ -824,7 +824,7 @@ void gdImageFlipHorizontal(gdImagePtr im);
void gdImageFlipVertical(gdImagePtr im);
void gdImageFlipBoth(gdImagePtr im);
#define GD_FLIP_HORINZONTAL 1
#define GD_FLIP_HORIZONTAL 1
#define GD_FLIP_VERTICAL 2
#define GD_FLIP_BOTH 3

View File

@ -36,12 +36,12 @@ var_dump(iconv_strpos("string", ""));
var_dump(iconv_strpos("", "string"));
?>
--EXPECTF--
--EXPECT--
bool(false)
bool(false)
int(5)
int(5)
Offset not contained in string
strpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
bool(false)
int(7)
int(7)

View File

@ -1986,10 +1986,10 @@ static void handle_strpos_error(size_t error) {
php_error_docref(NULL, E_WARNING, "Conversion error");
break;
case MBFL_ERROR_OFFSET:
zend_value_error("Offset not contained in string");
zend_argument_value_error(3, "must be contained in argument #1 ($haystack)");
break;
default:
zend_value_error("Unknown error in mb_strpos");
zend_value_error("mb_strpos(): Unknown error");
break;
}
}

View File

@ -54,18 +54,18 @@ bool(false)
-- Offset is 22 --
--Multibyte String:--
Offset not contained in string
mb_strpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
--ASCII String:--
Offset not contained in string
mb_strpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
-- Offset is 53 --
--Multibyte String:--
Offset not contained in string
mb_strpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
--ASCII String:--
Offset not contained in string
mb_strpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
-- Offset is 54 --
--Multibyte String:--
Offset not contained in string
mb_strpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
--ASCII String:--
Offset not contained in string
mb_strpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)

View File

@ -47,21 +47,21 @@ foreach ($offsets as $i) {
--EXPECT--
-- Offset is -25 --
Multibyte String:
Offset not contained in string
mb_strrpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
ASCII String:
mb_strrpos:
Offset not contained in string
mb_strrpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
strrpos:
Offset not contained in string
strrpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
-- Offset is -24 --
Multibyte String:
Offset not contained in string
mb_strrpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
ASCII String:
mb_strrpos:
Offset not contained in string
mb_strrpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
strrpos:
Offset not contained in string
strrpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
-- Offset is -13 --
Multibyte String:

View File

@ -44,7 +44,7 @@ bool(false)
> Offset: 11
bool(false)
> Offset: 12
Offset not contained in string
strpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
> Offset: -1
bool(false)
> Offset: -3
@ -52,7 +52,7 @@ int(8)
> Offset: -6
int(8)
> Offset: -20
Offset not contained in string
strpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
------- mb_strpos -----------
@ -67,7 +67,7 @@ bool(false)
> Offset: 11
bool(false)
> Offset: 12
Offset not contained in string
mb_strpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
> Offset: -1
bool(false)
> Offset: -3
@ -75,7 +75,7 @@ int(8)
> Offset: -6
int(8)
> Offset: -20
Offset not contained in string
mb_strpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
------- stripos -----------
@ -90,7 +90,7 @@ bool(false)
> Offset: 11
bool(false)
> Offset: 12
Offset not contained in string
stripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
> Offset: -1
bool(false)
> Offset: -3
@ -98,7 +98,7 @@ int(8)
> Offset: -6
int(8)
> Offset: -20
Offset not contained in string
stripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
------- mb_stripos -----------
@ -113,7 +113,7 @@ bool(false)
> Offset: 11
bool(false)
> Offset: 12
Offset not contained in string
mb_stripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
> Offset: -1
bool(false)
> Offset: -3
@ -121,7 +121,7 @@ int(8)
> Offset: -6
int(8)
> Offset: -20
Offset not contained in string
mb_stripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
------- strrpos -----------
@ -136,7 +136,7 @@ bool(false)
> Offset: 11
bool(false)
> Offset: 12
Offset not contained in string
strrpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
> Offset: -1
int(8)
> Offset: -3
@ -144,7 +144,7 @@ int(8)
> Offset: -6
int(4)
> Offset: -20
Offset not contained in string
strrpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
------- mb_strrpos -----------
@ -159,7 +159,7 @@ bool(false)
> Offset: 11
bool(false)
> Offset: 12
Offset not contained in string
mb_strrpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
> Offset: -1
int(8)
> Offset: -3
@ -167,7 +167,7 @@ int(8)
> Offset: -6
int(4)
> Offset: -20
Offset not contained in string
mb_strrpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
------- strripos -----------
@ -182,7 +182,7 @@ bool(false)
> Offset: 11
bool(false)
> Offset: 12
Offset not contained in string
strripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
> Offset: -1
int(8)
> Offset: -3
@ -190,7 +190,7 @@ int(8)
> Offset: -6
int(4)
> Offset: -20
Offset not contained in string
strripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
------- mb_strripos -----------
@ -205,7 +205,7 @@ bool(false)
> Offset: 11
bool(false)
> Offset: 12
Offset not contained in string
mb_strripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
> Offset: -1
int(8)
> Offset: -3
@ -213,4 +213,4 @@ int(8)
> Offset: -6
int(4)
> Offset: -20
Offset not contained in string
mb_strripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)

View File

@ -73,10 +73,10 @@ int(2)
int(5)
-- ASCII string with out of bound positive offset --
Offset not contained in string
mb_stripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
-- ASCII string with out of bound negative offset --
Offset not contained in string
mb_stripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
-- Multi-byte string without offset --
int(0)
@ -88,7 +88,7 @@ int(2)
int(19)
-- Multi-byte string with out of bound positive offset --
Offset not contained in string
mb_stripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
-- Multi-byte string with out of bound negative offset --
Offset not contained in string
mb_stripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)

View File

@ -81,13 +81,13 @@ try {
--EXPECT--
String len: 42
== INVALID OFFSET ==
Offset not contained in string
Offset not contained in string
Offset not contained in string
Offset not contained in string
Offset not contained in string
Offset not contained in string
Offset not contained in string
Offset not contained in string
Offset not contained in string
Offset not contained in string
mb_stripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
mb_stripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
mb_stripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
mb_stripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
mb_stripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
mb_stripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
mb_stripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
mb_stripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
mb_stripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
mb_stripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)

View File

@ -55,9 +55,9 @@ for ($i = -30; $i <= 60; $i += 10) {
**-- Offset is: -30 --**
-- ASCII String --
Offset not contained in string
mb_stripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
--Multibyte String --
Offset not contained in string
mb_stripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
**-- Offset is: -20 --**
-- ASCII String --
@ -91,24 +91,24 @@ int(20)
**-- Offset is: 30 --**
-- ASCII String --
Offset not contained in string
mb_stripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
--Multibyte String --
Offset not contained in string
mb_stripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
**-- Offset is: 40 --**
-- ASCII String --
Offset not contained in string
mb_stripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
--Multibyte String --
Offset not contained in string
mb_stripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
**-- Offset is: 50 --**
-- ASCII String --
Offset not contained in string
mb_stripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
--Multibyte String --
Offset not contained in string
mb_stripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
**-- Offset is: 60 --**
-- ASCII String --
Offset not contained in string
mb_stripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
--Multibyte String --
Offset not contained in string
mb_stripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)

View File

@ -72,10 +72,10 @@ int(2)
int(5)
-- ASCII string with out of bound positive offset --
Offset not contained in string
mb_strpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
-- ASCII string with out of bound negative offset --
Offset not contained in string
mb_strpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
-- Multi-byte string without offset --
int(0)
@ -87,7 +87,7 @@ int(2)
int(19)
-- Multi-byte string with out of bound positive offset --
Offset not contained in string
mb_strpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
-- Multi-byte string with out of bound negative offset --
Offset not contained in string
mb_strpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)

View File

@ -81,13 +81,13 @@ try {
--EXPECT--
String len: 42
== INVALID OFFSET ==
Offset not contained in string
Offset not contained in string
Offset not contained in string
Offset not contained in string
Offset not contained in string
Offset not contained in string
Offset not contained in string
Offset not contained in string
Offset not contained in string
Offset not contained in string
mb_strpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
mb_strpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
mb_strpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
mb_strpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
mb_strpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
mb_strpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
mb_strpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
mb_strpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
mb_strpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
mb_strpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)

View File

@ -46,11 +46,11 @@ try {
?>
--EXPECT--
Offset not contained in string
Offset not contained in string
Offset not contained in string
Offset not contained in string
Offset not contained in string
Offset not contained in string
Offset not contained in string
Offset not contained in string
mb_strpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
mb_strpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
mb_strrpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
mb_strrpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
mb_stripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
mb_stripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
mb_strripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
mb_strripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)

View File

@ -55,9 +55,9 @@ for ($i = -30; $i <= 60; $i += 10) {
**-- Offset is: -30 --**
-- ASCII String --
Offset not contained in string
mb_strpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
--Multibyte String --
Offset not contained in string
mb_strpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
**-- Offset is: -20 --**
-- ASCII String --
@ -91,24 +91,24 @@ int(20)
**-- Offset is: 30 --**
-- ASCII String --
Offset not contained in string
mb_strpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
--Multibyte String --
Offset not contained in string
mb_strpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
**-- Offset is: 40 --**
-- ASCII String --
Offset not contained in string
mb_strpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
--Multibyte String --
Offset not contained in string
mb_strpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
**-- Offset is: 50 --**
-- ASCII String --
Offset not contained in string
mb_strpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
--Multibyte String --
Offset not contained in string
mb_strpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
**-- Offset is: 60 --**
-- ASCII String --
Offset not contained in string
mb_strpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
--Multibyte String --
Offset not contained in string
mb_strpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)

View File

@ -73,10 +73,10 @@ int(7)
int(5)
-- ASCII string with out of bound positive offset --
Offset not contained in string
mb_strripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
-- ASCII string with out of bound negative offset --
Offset not contained in string
mb_strripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
-- Multi-byte string without offset --
int(21)
@ -88,7 +88,7 @@ int(21)
int(19)
-- Multi-byte string with out of bound positive offset --
Offset not contained in string
mb_strripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
-- Multi-byte string with out of bound negative offset --
Offset not contained in string
mb_strripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)

View File

@ -81,24 +81,24 @@ int(20)
**-- Offset is: 30 --**
-- ASCII String --
Offset not contained in string
mb_strripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
--Multibyte String --
Offset not contained in string
mb_strripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
**-- Offset is: 40 --**
-- ASCII String --
Offset not contained in string
mb_strripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
--Multibyte String --
Offset not contained in string
mb_strripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
**-- Offset is: 50 --**
-- ASCII String --
Offset not contained in string
mb_strripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
--Multibyte String --
Offset not contained in string
mb_strripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
**-- Offset is: 60 --**
-- ASCII String --
Offset not contained in string
mb_strripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
--Multibyte String --
Offset not contained in string
mb_strripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)

View File

@ -73,10 +73,10 @@ int(7)
int(5)
-- ASCII string with out of bound positive offset --
Offset not contained in string
mb_strrpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
-- ASCII string with out of bound negative offset --
Offset not contained in string
mb_strrpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
-- Multi-byte string without offset --
int(21)
@ -88,7 +88,7 @@ int(21)
int(19)
-- Multi-byte string with out of bound positive offset --
Offset not contained in string
mb_strrpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
-- Multi-byte string with out of bound negative offset --
Offset not contained in string
mb_strrpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)

View File

@ -5335,7 +5335,7 @@ ZEND_METHOD(ReflectionProperty, getValue)
zval rv;
if (!object) {
zend_type_error("No object provided for getValue() on instance property");
zend_argument_type_error(1, "must be provided for instance properties");
RETURN_THROWS();
}
@ -5428,7 +5428,7 @@ ZEND_METHOD(ReflectionProperty, isInitialized)
int retval;
if (!object) {
zend_type_error("No object provided for isInitialized() on instance property");
zend_argument_type_error(1, "must be provided for instance properties");
RETURN_THROWS();
}

View File

@ -66,4 +66,4 @@ Invalid instance:
Given object is not an instance of the class this property was declared in
Missing instance:
No object provided for getValue() on instance property
ReflectionProperty::getValue(): Argument #1 ($object) must be provided for instance properties

View File

@ -114,7 +114,7 @@ bool(false)
Object type:
bool(false)
Given object is not an instance of the class this property was declared in
No object provided for isInitialized() on instance property
ReflectionProperty::isInitialized(): Argument #1 ($object) must be provided for instance properties
Class with __isset:
bool(false)
bool(false)

View File

@ -704,7 +704,7 @@ PHP_FUNCTION(count)
ZEND_PARSE_PARAMETERS_END();
if (mode != COUNT_NORMAL && mode != COUNT_RECURSIVE) {
zend_argument_value_error(2, "must be a valid mode");
zend_argument_value_error(2, "must be either COUNT_NORMAL or COUNT_RECURSIVE");
RETURN_THROWS();
}
@ -4087,8 +4087,7 @@ PHP_FUNCTION(array_count_values)
* Specialized conversion rules for array_column() function
*/
static inline
zend_bool array_column_param_helper(zval *param,
const char *name) {
zend_bool array_column_param_helper(zval *param, int parameter_number) {
switch (Z_TYPE_P(param)) {
case IS_DOUBLE:
convert_to_long_ex(param);
@ -4105,7 +4104,7 @@ zend_bool array_column_param_helper(zval *param,
return 1;
default:
zend_type_error("The %s key should be either a string or an integer", name);
zend_argument_type_error(parameter_number, "must be of type string|int, %s given", zend_zval_type_name(param));
return 0;
}
}
@ -4166,9 +4165,9 @@ PHP_FUNCTION(array_column)
Z_PARAM_ZVAL_EX(index, 1, 0)
ZEND_PARSE_PARAMETERS_END();
if ((column && !array_column_param_helper(column, "column")) ||
(index && !array_column_param_helper(index, "index"))) {
return;
if ((column && !array_column_param_helper(column, 2)) ||
(index && !array_column_param_helper(index, 3))) {
RETURN_THROWS();
}
array_init_size(return_value, zend_hash_num_elements(input));

View File

@ -254,7 +254,7 @@ PHP_FUNCTION(closedir)
FETCH_DIRP();
if (!(dirp->flags & PHP_STREAM_FLAG_IS_DIR)) {
zend_type_error("%d is not a valid Directory resource", dirp->res->handle);
zend_argument_type_error(1, "must be a valid Directory resource");
RETURN_THROWS();
}
@ -368,7 +368,7 @@ PHP_FUNCTION(rewinddir)
FETCH_DIRP();
if (!(dirp->flags & PHP_STREAM_FLAG_IS_DIR)) {
zend_type_error("%d is not a valid Directory resource", dirp->res->handle);
zend_argument_type_error(1, "must be a valid Directory resource");
RETURN_THROWS();
}

View File

@ -1889,7 +1889,7 @@ PHP_FUNCTION(strpos)
offset += (zend_long)ZSTR_LEN(haystack);
}
if (offset < 0 || (size_t)offset > ZSTR_LEN(haystack)) {
zend_value_error("Offset not contained in string");
zend_argument_value_error(3, "must be contained in argument #1 ($haystack)");
RETURN_THROWS();
}
@ -1925,7 +1925,7 @@ PHP_FUNCTION(stripos)
offset += (zend_long)ZSTR_LEN(haystack);
}
if (offset < 0 || (size_t)offset > ZSTR_LEN(haystack)) {
zend_value_error("Offset not contained in string");
zend_argument_value_error(3, "must be contained in argument #1 ($haystack)");
RETURN_THROWS();
}
@ -1967,14 +1967,14 @@ PHP_FUNCTION(strrpos)
if (offset >= 0) {
if ((size_t)offset > ZSTR_LEN(haystack)) {
zend_value_error("Offset not contained in string");
zend_argument_value_error(3, "must be contained in argument #1 ($haystack)");
RETURN_THROWS();
}
p = ZSTR_VAL(haystack) + (size_t)offset;
e = ZSTR_VAL(haystack) + ZSTR_LEN(haystack);
} else {
if (offset < -ZEND_LONG_MAX || (size_t)(-offset) > ZSTR_LEN(haystack)) {
zend_value_error("Offset not contained in string");
zend_argument_value_error(3, "must be contained in argument #1 ($haystack)");
RETURN_THROWS();
}
@ -2017,7 +2017,7 @@ PHP_FUNCTION(strripos)
char lowered;
if (offset >= 0) {
if ((size_t)offset > ZSTR_LEN(haystack)) {
zend_value_error("Offset not contained in string");
zend_argument_value_error(3, "must be contained in argument #1 ($haystack)");
RETURN_THROWS();
}
p = ZSTR_VAL(haystack) + (size_t)offset;
@ -2025,7 +2025,7 @@ PHP_FUNCTION(strripos)
} else {
p = ZSTR_VAL(haystack);
if (offset < -ZEND_LONG_MAX || (size_t)(-offset) > ZSTR_LEN(haystack)) {
zend_value_error("Offset not contained in string");
zend_argument_value_error(3, "must be contained in argument #1 ($haystack)");
RETURN_THROWS();
}
e = ZSTR_VAL(haystack) + (ZSTR_LEN(haystack) + (size_t)offset);
@ -2045,7 +2045,7 @@ PHP_FUNCTION(strripos)
if (offset >= 0) {
if ((size_t)offset > ZSTR_LEN(haystack)) {
zend_string_release_ex(haystack_dup, 0);
zend_value_error("Offset not contained in string");
zend_argument_value_error(3, "must be contained in argument #1 ($haystack)");
RETURN_THROWS();
}
p = ZSTR_VAL(haystack_dup) + offset;
@ -2053,7 +2053,7 @@ PHP_FUNCTION(strripos)
} else {
if (offset < -ZEND_LONG_MAX || (size_t)(-offset) > ZSTR_LEN(haystack)) {
zend_string_release_ex(haystack_dup, 0);
zend_value_error("Offset not contained in string");
zend_argument_value_error(3, "must be contained in argument #1 ($haystack)");
RETURN_THROWS();
}
@ -5273,7 +5273,7 @@ PHP_FUNCTION(str_repeat)
ZEND_PARSE_PARAMETERS_END();
if (mult < 0) {
zend_value_error("Second argument has to be greater than or equal to 0");
zend_argument_value_error(2, "must be greater than or equal to 0");
RETURN_THROWS();
}
@ -5331,7 +5331,7 @@ PHP_FUNCTION(count_chars)
ZEND_PARSE_PARAMETERS_END();
if (mymode < 0 || mymode > 4) {
zend_value_error("Unknown mode");
zend_argument_value_error(2, "must be between 1 and 4 (inclusive)");
RETURN_THROWS();
}

View File

@ -46,15 +46,15 @@ DONE
*** Testing array_column() : error conditions ***
-- Testing array_column() column key parameter should be a string or an integer (testing bool) --
The column key should be either a string or an integer
array_column(): Argument #2 ($column_key) must be of type string|int, bool given
-- Testing array_column() column key parameter should be a string or integer (testing array) --
The column key should be either a string or an integer
array_column(): Argument #2 ($column_key) must be of type string|int, array given
-- Testing array_column() index key parameter should be a string or an integer (testing bool) --
The index key should be either a string or an integer
array_column(): Argument #3 ($index_key) must be of type string|int, bool given
-- Testing array_column() index key parameter should be a string or integer (testing array) --
The index key should be either a string or an integer
array_column(): Argument #3 ($index_key) must be of type string|int, array given
DONE

View File

@ -29,9 +29,9 @@ int(0)
int(0)
int(0)
int(0)
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
count(): Argument #2 ($mode) must be either COUNT_NORMAL or COUNT_RECURSIVE
count(): Argument #2 ($mode) must be either COUNT_NORMAL or COUNT_RECURSIVE
count(): Argument #2 ($mode) must be either COUNT_NORMAL or COUNT_RECURSIVE
int(0)
int(0)
int(0)

View File

@ -37,7 +37,7 @@ if(is_resource($fp)) {
resource(%d) of type (stream)
-- Try to close the file pointer using closedir() --
%d is not a valid Directory resource
closedir(): Argument #1 ($dir_handle) must be a valid Directory resource
-- Check file pointer: --
resource(%d) of type (stream)

View File

@ -38,7 +38,7 @@ if ($result1 === $result2) {
-- Open a file using fopen --
resource(%d) of type (stream)
%d is not a valid Directory resource
rewinddir(): Argument #1 ($dir_handle) must be a valid Directory resource
-- Check if rewinddir() has repositioned the file pointer --
rewinddir() does not work on file pointers

View File

@ -104,8 +104,8 @@ var_dump(is_array(unserialize(
?>
--EXPECTF--
Invalid max_depth:
max_depth should be int
max_depth cannot be negative
unserialize(): 'max_depth' option must be of type int, string given
unserialize(): 'max_depth' option must be greater than or equal to 0
Array:
bool(true)

View File

@ -71,15 +71,15 @@ substr_count(): Argument #3 ($offset) must be contained in argument #1 ($haystac
Warning: substr_compare(): The start position cannot exceed initial string length in %s on line %d
bool(false)
Offset not contained in string
stripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
substr_count(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
Warning: substr_count(): Invalid length value in %s on line %d
bool(false)
Offset not contained in string
Offset not contained in string
Offset not contained in string
Offset not contained in string
strpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
stripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
strrpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
strripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
int(2)
string(8) "abcdeabc"
bool(false)

View File

@ -1575,4 +1575,4 @@ array(238) {
}
string(18) " Rabcdefghimnorstu"
string(476) "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f2122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f5051535455565758595a5b5c5d5e5f606a6b6c7071767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff"
Unknown mode
count_chars(): Argument #2 ($mode) must be between 1 and 4 (inclusive)

View File

@ -29,8 +29,8 @@ echo "*** Done ***";
*** Testing stripos() function: error conditions ***
-- Offset beyond the end of the string --
Offset not contained in string
stripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
-- Offset before the start of the string --
Offset not contained in string
stripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
*** Done ***

View File

@ -145,35 +145,35 @@ int(0)
bool(false)
-- Iteration 16 --
int(0)
ValueError: Offset not contained in string
ValueError: stripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
-- Iteration 17 --
int(0)
bool(false)
-- Iteration 18 --
int(0)
ValueError: Offset not contained in string
ValueError: stripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
-- Iteration 19 --
int(0)
bool(false)
-- Iteration 20 --
int(0)
ValueError: Offset not contained in string
ValueError: stripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
-- Iteration 21 --
int(0)
ValueError: Offset not contained in string
ValueError: stripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
-- Iteration 22 --
int(0)
ValueError: Offset not contained in string
ValueError: stripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
-- Iteration 23 --
int(0)
ValueError: Offset not contained in string
ValueError: stripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
-- Iteration 24 --
TypeError: stripos(): Argument #1 ($haystack) must be of type string, resource given
TypeError: stripos(): Argument #1 ($haystack) must be of type string, resource given
-- Iteration 25 --
int(0)
ValueError: Offset not contained in string
ValueError: stripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
-- Iteration 26 --
int(0)
ValueError: Offset not contained in string
ValueError: stripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
*** Done ***

View File

@ -31,7 +31,7 @@ echo "*** Done ***";
*** Testing stripos() function: with heredoc strings ***
-- With empty heredoc string --
int(0)
Offset not contained in string
stripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
int(0)
int(0)
*** Done ***

View File

@ -37,8 +37,8 @@ echo "Done\n";
?>
--EXPECT--
strripos(): Argument #3 ($offset) must be of type int, float given
Offset not contained in string
Offset not contained in string
Offset not contained in string
Offset not contained in string
strripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
strripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
strripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
strripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
Done

View File

@ -32,11 +32,11 @@ int(7)
bool(false)
int(5)
int(1)
Offset not contained in string
strrpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
int(0)
int(0)
int(7)
bool(false)
int(5)
int(1)
Offset not contained in string
strripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)

View File

@ -37,8 +37,8 @@ echo "Done\n";
?>
--EXPECT--
strrpos(): Argument #3 ($offset) must be of type int, float given
Offset not contained in string
Offset not contained in string
Offset not contained in string
Offset not contained in string
strrpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
strrpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
strrpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
strrpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
Done

View File

@ -146,35 +146,35 @@ int(0)
bool(false)
-- Iteration 16 --
int(0)
ValueError: Offset not contained in string
ValueError: strrpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
-- Iteration 17 --
int(0)
bool(false)
-- Iteration 18 --
int(0)
ValueError: Offset not contained in string
ValueError: strrpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
-- Iteration 19 --
int(0)
bool(false)
-- Iteration 20 --
int(0)
ValueError: Offset not contained in string
ValueError: strrpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
-- Iteration 21 --
int(0)
ValueError: Offset not contained in string
ValueError: strrpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
-- Iteration 22 --
int(0)
ValueError: Offset not contained in string
ValueError: strrpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
-- Iteration 23 --
int(0)
ValueError: Offset not contained in string
ValueError: strrpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
-- Iteration 24 --
TypeError: strrpos(): Argument #1 ($haystack) must be of type string, resource given
TypeError: strrpos(): Argument #1 ($haystack) must be of type string, resource given
-- Iteration 25 --
int(0)
ValueError: Offset not contained in string
ValueError: strrpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
-- Iteration 26 --
int(0)
ValueError: Offset not contained in string
ValueError: strrpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
*** Done ***

View File

@ -30,7 +30,7 @@ echo "*** Done ***";
*** Testing strrpos() function: with heredoc strings ***
-- With empty heredoc string --
int(0)
Offset not contained in string
strrpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
int(0)
int(0)
*** Done ***

View File

@ -416,7 +416,7 @@ static void php_stream_bucket_attach(int append, INTERNAL_FUNCTION_PARAMETERS)
ZEND_PARSE_PARAMETERS_END();
if (NULL == (pzbucket = zend_hash_str_find(Z_OBJPROP_P(zobject), "bucket", sizeof("bucket")-1))) {
zend_value_error("Object has no bucket property");
zend_argument_value_error(2, "must be an object that has a 'bucket' property");
RETURN_THROWS();
}

View File

@ -1240,11 +1240,11 @@ PHP_FUNCTION(unserialize)
max_depth = zend_hash_str_find_deref(Z_ARRVAL_P(options), "max_depth", sizeof("max_depth") - 1);
if (max_depth) {
if (Z_TYPE_P(max_depth) != IS_LONG) {
zend_type_error("max_depth should be int");
zend_type_error("unserialize(): 'max_depth' option must be of type int, %s given", zend_zval_type_name(max_depth));
goto cleanup;
}
if (Z_LVAL_P(max_depth) < 0) {
zend_value_error("max_depth cannot be negative");
zend_value_error("unserialize(): 'max_depth' option must be greater than or equal to 0");
goto cleanup;
}

View File

@ -108,8 +108,8 @@ bool(false)
bool(false)
Error:
Kind must be of type int, string or array
Kind array must have elements of type int or string
PhpToken::is(): Argument #1 ($kind) must be of type string|int|array, float given
PhpToken::is(): Argument #1 ($kind) must only have elements of type string|int, float given
Typed property PhpToken::$id must not be accessed before initialization
Typed property PhpToken::$text must not be accessed before initialization
Typed property PhpToken::$id must not be accessed before initialization

View File

@ -192,13 +192,13 @@ PHP_METHOD(PhpToken, is)
RETURN_TRUE;
}
} else {
zend_type_error("Kind array must have elements of type int or string");
zend_argument_type_error(1, "must only have elements of type string|int, %s given", zend_zval_type_name(entry));
RETURN_THROWS();
}
} ZEND_HASH_FOREACH_END();
RETURN_FALSE;
} else {
zend_type_error("Kind must be of type int, string or array");
zend_argument_type_error(1, "must be of type string|int|array, %s given", zend_zval_type_name(kind));
RETURN_THROWS();
}
}