}
if (CHECK_ZVAL_NULL_PATH(file)) {
- zend_type_error("Filename must not contain null bytes");
+ zend_argument_type_error(1, "must not contain null bytes");
RETURN_THROWS();
}
stream = php_stream_bz2open_from_BZFILE(bz, mode, stream);
} else {
- zend_type_error("First parameter has to be string or file-resource");
+ zend_argument_type_error(1, "must be of type string or file-resource, %s given", zend_zval_type_name(file));
RETURN_THROWS();
}
resource(%d) of type (stream)
Warning: fopen(bz_open_002.txt): Failed to open stream: Bad file %s in %s on line %d
-First parameter has to be string or file-resource
+bzopen(): Argument #1 ($file) must be of type string or file-resource, bool given
Warning: fopen(bz_open_002.txt): Failed to open stream: Bad file %s in %s on line %d
-First parameter has to be string or file-resource
+bzopen(): Argument #1 ($file) must be of type string or file-resource, bool given
Warning: bzopen(): cannot write to a stream opened in read only mode in %s on line %d
bool(false)
try {
bzopen("file\0", "w");
-} catch (\TypeError $e) {
+} catch (TypeError $e) {
echo $e->getMessage() . \PHP_EOL;
}
try {
bzopen("file\0", "r");
-} catch (\TypeError $e) {
+} catch (TypeError $e) {
echo $e->getMessage() . \PHP_EOL;
}
?>
--EXPECT--
-Filename must not contain null bytes
-Filename must not contain null bytes
+bzopen(): Argument #1 ($file) must not contain null bytes
+bzopen(): Argument #1 ($file) must not contain null bytes
} else {
xmlFree(fragment);
- zend_type_error("Invalid argument type must be either DOMNode or string");
+ zend_argument_type_error(i + 1, "must be of type DOMNode|string, %s given", zend_zval_type_name(&nodes[i]));
return NULL;
}
} else if (Z_TYPE(nodes[i]) == IS_STRING) {
} else {
xmlFree(fragment);
- zend_type_error("Invalid argument type must be either DOMNode or string");
+ zend_argument_type_error(i + 1, "must be of type DOMNode|string, %s given", zend_zval_type_name(&nodes[i]));
return NULL;
}
echo "OK! {$e->getMessage()}";
}
--EXPECT--
-OK! Invalid argument type must be either DOMNode or string
+OK! DOMElement::append(): Argument #1 must be of type DOMNode|string, array given
src = php_gd_libgdimageptr_from_zval_p(IM);
if ((nelems = zend_hash_num_elements(Z_ARRVAL_P(z_affine))) != 6) {
- zend_value_error("Affine array must have six elements");
+ zend_argument_value_error(2, "must have 6 elements");
RETURN_THROWS();
}
affine[i] = zval_get_double(zval_affine_elem);
break;
default:
- zend_type_error("Invalid type for element %i", i);
+ zend_argument_type_error(3, "contains invalid type for element %i", i);
RETURN_THROWS();
}
}
case GD_AFFINE_SCALE: {
double x, y;
if (!options || Z_TYPE_P(options) != IS_ARRAY) {
- zend_type_error("Array expected as options when using translate or scale");
+ zend_argument_type_error(1, "must be of type array when using translate or scale");
RETURN_THROWS();
}
double angle;
if (!options) {
- zend_type_error("Number is expected as option when using rotate or shear");
+ zend_argument_type_error(2, "must be of type int|double when using rotate or shear");
RETURN_THROWS();
}
}
default:
- zend_value_error("Invalid type for element " ZEND_LONG_FMT, type);
+ zend_argument_value_error(1, "must be a valid element type");
RETURN_THROWS();
}
m1[i] = zval_get_double(tmp);
break;
default:
- zend_type_error("Matrix 1 contains invalid type for element %i", i);
+ zend_argument_type_error(1, "contains invalid type for element %i", i);
RETURN_THROWS();
}
}
m2[i] = zval_get_double(tmp);
break;
default:
- zend_type_error("Matrix 2 contains invalid type for element %i", i);
+ zend_argument_type_error(2, "contains invalid type for element %i", i);
RETURN_THROWS();
}
}
close_stream = 0;
} else if (Z_TYPE_P(to_zval) == IS_STRING) {
if (CHECK_ZVAL_NULL_PATH(to_zval)) {
- zend_type_error("Invalid 2nd parameter, filename must not contain null bytes");
+ zend_argument_type_error(2, "must not contain null bytes");
RETURN_THROWS();
}
}
?>
--EXPECT--
-!! [TypeError] Array expected as options when using translate or scale
-!! [TypeError] Array expected as options when using translate or scale
-!! [TypeError] Number is expected as option when using rotate or shear
-!! [TypeError] Number is expected as option when using rotate or shear
-!! [TypeError] Number is expected as option when using rotate or shear
-!! [ValueError] Invalid type for element 5
-!! [ValueError] Invalid type for element 6
+!! [TypeError] imageaffinematrixget(): Argument #1 ($type) must be of type array when using translate or scale
+!! [TypeError] imageaffinematrixget(): Argument #1 ($type) must be of type array when using translate or scale
+!! [TypeError] imageaffinematrixget(): Argument #2 ($options) must be of type int|double when using rotate or shear
+!! [TypeError] imageaffinematrixget(): Argument #2 ($options) must be of type int|double when using rotate or shear
+!! [TypeError] imageaffinematrixget(): Argument #2 ($options) must be of type int|double when using rotate or shear
+!! [ValueError] imageaffinematrixget(): Argument #1 ($type) must be a valid element type
+!! [ValueError] imageaffinematrixget(): Argument #1 ($type) must be a valid element type
}
?>
--EXPECT--
-Invalid 2nd parameter, filename must not contain null bytes
+imagebmp(): Argument #2 ($to) must not contain null bytes
}
?>
--EXPECT--
-Invalid 2nd parameter, filename must not contain null bytes
+imagegif(): Argument #2 ($to) must not contain null bytes
}
?>
--EXPECT--
-Invalid 2nd parameter, filename must not contain null bytes
+imagejpeg(): Argument #2 ($to) must not contain null bytes
}
?>
--EXPECTF--
-Invalid 2nd parameter, filename must not contain null bytes
+imagepng(): Argument #2 ($to) must not contain null bytes
}
?>
--EXPECT--
-Invalid 2nd parameter, filename must not contain null bytes
+imagewbmp(): Argument #2 ($to) must not contain null bytes
}
?>
--EXPECT--
-Invalid 2nd parameter, filename must not contain null bytes
+imagewebp(): Argument #2 ($to) must not contain null bytes
* single value is an array. Also we'd have to make that one
* argument passed by reference.
*/
- zend_throw_exception(zend_ce_exception, "Parameter ctor_params must be an array", 0);
+ zend_argument_error(zend_ce_exception, 3, "must be of type array, %s given", zend_zval_type_name(ctor_params));
RETURN_THROWS();
}
}
|| ZEND_LONG_INT_OVFL(buffer_length)
#endif
) {
- zend_throw_exception(zend_ce_error, "Length must be greater than 0", 0);
+ zend_argument_error(NULL, 1, "must be greater than 0");
return NULL;
}
buffer = zend_string_alloc(buffer_length, 0);
}
?>
--EXPECT--
-Length must be greater than 0
+openssl_random_pseudo_bytes(): Argument #1 ($length) must be greater than 0
}
} else {
if (Z_TYPE_P(regex) != IS_ARRAY) {
- zend_type_error("Parameter mismatch, pattern is a string while replacement is an array");
+ zend_argument_type_error(1, "must be of type array when argument #2 ($replace) is an array, %s given", zend_zval_type_name(regex));
RETURN_THROWS();
}
}
var_dump(preg_replace_callback("/(ab)(cd)(e)/", array(new foo(), "cb"), 'abcde'));
?>
--EXPECT--
-Parameter mismatch, pattern is a string while replacement is an array
+preg_replace(): Argument #1 ($regex) must be of type array when argument #2 ($replace) is an array, string given
array(4) {
[0]=>
string(5) "abcde"
string(64) "this is a stringthis is a stringthis is a stringthis is a string"
Arg value is: Array
-Parameter mismatch, pattern is a string while replacement is an array
+preg_replace(): Argument #1 ($regex) must be of type array when argument #2 ($replace) is an array, string given
Object of class stdClass could not be converted to string
Done
snprintf(alt_dsn, sizeof(alt_dsn), "pdo.dsn.%s", data_source);
if (FAILURE == cfg_get_string(alt_dsn, &ini_dsn)) {
- zend_throw_exception_ex(php_pdo_get_exception(), 0, "invalid data source name");
+ zend_argument_error(php_pdo_get_exception(), 1, "must be a valid data source name");
RETURN_THROWS();
}
/* the specified URI holds connection details */
data_source = dsn_from_uri(data_source + sizeof("uri:")-1, alt_dsn, sizeof(alt_dsn));
if (!data_source) {
- zend_throw_exception_ex(php_pdo_get_exception(), 0, "invalid data source URI");
+ zend_argument_error(php_pdo_get_exception(), 1, "must be a valid data source URI");
RETURN_THROWS();
}
colon = strchr(data_source, ':');
if (!colon) {
- zend_throw_exception_ex(php_pdo_get_exception(), 0, "invalid data source name (via URI)");
+ zend_argument_error(php_pdo_get_exception(), 1, "must be a valid data source name (via URI)");
RETURN_THROWS();
}
}
print "done!";
?>
--EXPECTF--
-[002] invalid data source name, [n/a] n/a
-[003] invalid data source name, [n/a] n/a
-[004] invalid data source name, [n/a] n/a
-[005] invalid data source name, [n/a] n/a
-[006] invalid data source name, [n/a] n/a
+[002] PDO::__construct(): Argument #1 ($dsn) must be a valid data source name, [n/a] n/a
+[003] PDO::__construct(): Argument #1 ($dsn) must be a valid data source name, [n/a] n/a
+[004] PDO::__construct(): Argument #1 ($dsn) must be a valid data source name, [n/a] n/a
+[005] PDO::__construct(): Argument #1 ($dsn) must be a valid data source name, [n/a] n/a
+[006] PDO::__construct(): Argument #1 ($dsn) must be a valid data source name, [n/a] n/a
[007] could not find driver, [n/a] n/a
[009] SQLSTATE[%s] [1045] Access denied for user 'dont%s'@'%s' (using password: YES), [n/a] n/a
[017] DSN=%s, SQLSTATE[%s] [%d] %s
}
if (ZEND_SIZE_T_INT_OVFL(data_len)) {
- zend_throw_exception(zend_ce_exception, "Data is too long", 0);
+ zend_argument_error(zend_ce_exception, 1, "is too long");
RETURN_THROWS();
}
if (ZEND_SIZE_T_INT_OVFL(ns_len)) {
- zend_throw_exception(zend_ce_exception, "Namespace is too long", 0);
+ zend_argument_error(zend_ce_exception, 4, "is too long");
RETURN_THROWS();
}
if (ZEND_LONG_EXCEEDS_INT(options)) {
- zend_throw_exception(zend_ce_exception, "Invalid options", 0);
+ zend_argument_error(zend_ce_exception, 2, "is invalid");
RETURN_THROWS();
}
$xml=new SimpleXMLElement(0,9000000000);var_dump($xml->getDocNamespaces())?>
?>
--EXPECTF--
-Fatal error: Uncaught Exception: Invalid options in %sbug74950.php:%d
+Fatal error: Uncaught Exception: SimpleXMLElement::__construct(): Argument #2 ($options) is invalid in %sbug74950.php:%d
Stack trace:
#0 %sbug74950.php(%d): SimpleXMLElement->__construct('0', 9000000000)
#1 {main}
case SNMP_VERSION_3:
break;
default:
- zend_throw_exception(zend_ce_exception, "Unknown SNMP protocol version", 0);
+ zend_argument_value_error(zend_ce_exception, 1, "must be a valid SNMP protocol version");
RETURN_THROWS();
}
SNMP::__construct() expects at least 3 parameters, 2 given
SNMP::__construct(): Argument #4 must be of type int, string given
SNMP::__construct(): Argument #5 must be of type int, string given
-Unknown SNMP protocol version
+SNMP::__construct(): Argument #1 ($version) must be a valid SNMP protocol version
Exception handling
Warning: SNMP::get(): Invalid object identifier: .1.3.6.1.2.1.1.1..0 in %s on line %d
}
if (Z_TYPE_P(obj) != IS_OBJECT && Z_TYPE_P(obj) != IS_STRING) {
- zend_type_error("Object or string expected");
+ zend_argument_type_error(1, "must be of type object|string, %s given", zend_zval_type_name(obj));
RETURN_THROWS();
}
RETURN_THROWS();
}
if (Z_TYPE_P(obj) != IS_OBJECT && Z_TYPE_P(obj) != IS_STRING) {
- zend_type_error("Object or string expected");
+ zend_argument_type_error(1, "must be of type object|string, %s given", zend_zval_type_name(obj));
RETURN_THROWS();
}
RETURN_THROWS();
}
if (Z_TYPE_P(obj) != IS_OBJECT && Z_TYPE_P(obj) != IS_STRING) {
- zend_type_error("Object or string expected");
+ zend_argument_type_error(1, "must be of type object|string, %s given", zend_zval_type_name(obj));
RETURN_THROWS();
}
*** Testing class_implements() : variation ***
--int 0--
-Object or string expected
+class_implements(): Argument #1 ($what) must be of type object|string, int given
--int 1--
-Object or string expected
+class_implements(): Argument #1 ($what) must be of type object|string, int given
--int 12345--
-Object or string expected
+class_implements(): Argument #1 ($what) must be of type object|string, int given
--int -12345--
-Object or string expected
+class_implements(): Argument #1 ($what) must be of type object|string, int given
--float 10.5--
-Object or string expected
+class_implements(): Argument #1 ($what) must be of type object|string, float given
--float -10.5--
-Object or string expected
+class_implements(): Argument #1 ($what) must be of type object|string, float given
--float 12.3456789000e10--
-Object or string expected
+class_implements(): Argument #1 ($what) must be of type object|string, float given
--float -12.3456789000e10--
-Object or string expected
+class_implements(): Argument #1 ($what) must be of type object|string, float given
--float .5--
-Object or string expected
+class_implements(): Argument #1 ($what) must be of type object|string, float given
--empty array--
-Object or string expected
+class_implements(): Argument #1 ($what) must be of type object|string, array given
--int indexed array--
-Object or string expected
+class_implements(): Argument #1 ($what) must be of type object|string, array given
--associative array--
-Object or string expected
+class_implements(): Argument #1 ($what) must be of type object|string, array given
--nested arrays--
-Object or string expected
+class_implements(): Argument #1 ($what) must be of type object|string, array given
--uppercase NULL--
-Object or string expected
+class_implements(): Argument #1 ($what) must be of type object|string, null given
--lowercase null--
-Object or string expected
+class_implements(): Argument #1 ($what) must be of type object|string, null given
--lowercase true--
-Object or string expected
+class_implements(): Argument #1 ($what) must be of type object|string, bool given
--lowercase false--
-Object or string expected
+class_implements(): Argument #1 ($what) must be of type object|string, bool given
--uppercase TRUE--
-Object or string expected
+class_implements(): Argument #1 ($what) must be of type object|string, bool given
--uppercase FALSE--
-Object or string expected
+class_implements(): Argument #1 ($what) must be of type object|string, bool given
--empty string DQ--
Error: 2 - class_implements(): Class does not exist and could not be loaded, %s(%d)
}
--undefined var--
-Object or string expected
+class_implements(): Argument #1 ($what) must be of type object|string, null given
--unset var--
-Object or string expected
+class_implements(): Argument #1 ($what) must be of type object|string, null given
--resource--
-Object or string expected
+class_implements(): Argument #1 ($what) must be of type object|string, resource given
*** Testing class_uses() : variation ***
--int 0--
-Object or string expected
+class_uses(): Argument #1 ($what) must be of type object|string, int given
--int 1--
-Object or string expected
+class_uses(): Argument #1 ($what) must be of type object|string, int given
--int 12345--
-Object or string expected
+class_uses(): Argument #1 ($what) must be of type object|string, int given
--int -12345--
-Object or string expected
+class_uses(): Argument #1 ($what) must be of type object|string, int given
--float 10.5--
-Object or string expected
+class_uses(): Argument #1 ($what) must be of type object|string, float given
--float -10.5--
-Object or string expected
+class_uses(): Argument #1 ($what) must be of type object|string, float given
--float 12.3456789000e10--
-Object or string expected
+class_uses(): Argument #1 ($what) must be of type object|string, float given
--float -12.3456789000e10--
-Object or string expected
+class_uses(): Argument #1 ($what) must be of type object|string, float given
--float .5--
-Object or string expected
+class_uses(): Argument #1 ($what) must be of type object|string, float given
--empty array--
-Object or string expected
+class_uses(): Argument #1 ($what) must be of type object|string, array given
--int indexed array--
-Object or string expected
+class_uses(): Argument #1 ($what) must be of type object|string, array given
--associative array--
-Object or string expected
+class_uses(): Argument #1 ($what) must be of type object|string, array given
--nested arrays--
-Object or string expected
+class_uses(): Argument #1 ($what) must be of type object|string, array given
--uppercase NULL--
-Object or string expected
+class_uses(): Argument #1 ($what) must be of type object|string, null given
--lowercase null--
-Object or string expected
+class_uses(): Argument #1 ($what) must be of type object|string, null given
--lowercase true--
-Object or string expected
+class_uses(): Argument #1 ($what) must be of type object|string, bool given
--lowercase false--
-Object or string expected
+class_uses(): Argument #1 ($what) must be of type object|string, bool given
--uppercase TRUE--
-Object or string expected
+class_uses(): Argument #1 ($what) must be of type object|string, bool given
--uppercase FALSE--
-Object or string expected
+class_uses(): Argument #1 ($what) must be of type object|string, bool given
--empty string DQ--
Error: 2 - class_uses(): Class does not exist and could not be loaded, %s(%d)
}
--undefined var--
-Object or string expected
+class_uses(): Argument #1 ($what) must be of type object|string, null given
--unset var--
-Object or string expected
+class_uses(): Argument #1 ($what) must be of type object|string, null given
--resource--
-Object or string expected
+class_uses(): Argument #1 ($what) must be of type object|string, resource given
} break;
default:
- zend_type_error("Dictionary must be of type zero-terminated string or array, got %s", zend_get_type_by_const(Z_TYPE_P(option_buffer)));
+ zend_argument_type_error(2, "must be of type zero-terminated string or array, %s given", zend_get_type_by_const(Z_TYPE_P(option_buffer)));
return 0;
}
}