From: Máté Kocsis Date: Wed, 18 Mar 2020 21:44:02 +0000 (+0100) Subject: Improve error messages of various extensions X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=01b266aac405c3c4c677d46f348dc6b227b69f7f;p=php Improve error messages of various extensions Closes GH-5278 --- diff --git a/ext/bz2/bz2.c b/ext/bz2/bz2.c index c90c117d71..005520c2ad 100644 --- a/ext/bz2/bz2.c +++ b/ext/bz2/bz2.c @@ -379,7 +379,7 @@ static PHP_FUNCTION(bzopen) } 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(); } @@ -430,7 +430,7 @@ static PHP_FUNCTION(bzopen) 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(); } diff --git a/ext/bz2/tests/002.phpt b/ext/bz2/tests/002.phpt index 78c4a9bbdf..9a7f7f0855 100644 --- a/ext/bz2/tests/002.phpt +++ b/ext/bz2/tests/002.phpt @@ -91,10 +91,10 @@ resource(%d) of type (stream) 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) diff --git a/ext/bz2/tests/bzopen_string_filename_with_null_bytes.phpt b/ext/bz2/tests/bzopen_string_filename_with_null_bytes.phpt index 9a05015bb9..1261981c6b 100644 --- a/ext/bz2/tests/bzopen_string_filename_with_null_bytes.phpt +++ b/ext/bz2/tests/bzopen_string_filename_with_null_bytes.phpt @@ -7,17 +7,17 @@ bzopen(): throw TypeError if filename contains null bytes 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 diff --git a/ext/dom/parentnode.c b/ext/dom/parentnode.c index a9502a5159..0e7b49ef4e 100644 --- a/ext/dom/parentnode.c +++ b/ext/dom/parentnode.c @@ -197,7 +197,7 @@ xmlNode* dom_zvals_to_fragment(php_libxml_ref_obj *document, xmlNode *contextNod } 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) { @@ -213,7 +213,7 @@ xmlNode* dom_zvals_to_fragment(php_libxml_ref_obj *document, xmlNode *contextNod } 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; } diff --git a/ext/dom/tests/DOM4_ParentNode_append_invalidtypes.phpt b/ext/dom/tests/DOM4_ParentNode_append_invalidtypes.phpt index ab715caaa0..8e58f35a3e 100644 --- a/ext/dom/tests/DOM4_ParentNode_append_invalidtypes.phpt +++ b/ext/dom/tests/DOM4_ParentNode_append_invalidtypes.phpt @@ -15,4 +15,4 @@ try { 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 diff --git a/ext/gd/gd.c b/ext/gd/gd.c index 1775ae4627..8435d765b6 100644 --- a/ext/gd/gd.c +++ b/ext/gd/gd.c @@ -3885,7 +3885,7 @@ PHP_FUNCTION(imageaffine) 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(); } @@ -3902,7 +3902,7 @@ PHP_FUNCTION(imageaffine) 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(); } } @@ -3970,7 +3970,7 @@ PHP_FUNCTION(imageaffinematrixget) 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(); } @@ -4002,7 +4002,7 @@ PHP_FUNCTION(imageaffinematrixget) 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(); } @@ -4019,7 +4019,7 @@ PHP_FUNCTION(imageaffinematrixget) } 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(); } @@ -4068,7 +4068,7 @@ PHP_FUNCTION(imageaffinematrixconcat) 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(); } } @@ -4085,7 +4085,7 @@ PHP_FUNCTION(imageaffinematrixconcat) 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(); } } @@ -4299,7 +4299,7 @@ static void _php_image_output_ctx(INTERNAL_FUNCTION_PARAMETERS, int image_type, 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(); } diff --git a/ext/gd/tests/bug67248.phpt b/ext/gd/tests/bug67248.phpt index c5b54354f1..b54a20ba8e 100644 --- a/ext/gd/tests/bug67248.phpt +++ b/ext/gd/tests/bug67248.phpt @@ -16,10 +16,10 @@ for($i=0;$i<7;$i++) { } ?> --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 diff --git a/ext/gd/tests/imagebmp_nullbyte_injection.phpt b/ext/gd/tests/imagebmp_nullbyte_injection.phpt index 00d0a7168c..9f0398b5da 100644 --- a/ext/gd/tests/imagebmp_nullbyte_injection.phpt +++ b/ext/gd/tests/imagebmp_nullbyte_injection.phpt @@ -15,4 +15,4 @@ try { } ?> --EXPECT-- -Invalid 2nd parameter, filename must not contain null bytes +imagebmp(): Argument #2 ($to) must not contain null bytes diff --git a/ext/gd/tests/imagegif_nullbyte_injection.phpt b/ext/gd/tests/imagegif_nullbyte_injection.phpt index 4518ecad27..4b164392c2 100644 --- a/ext/gd/tests/imagegif_nullbyte_injection.phpt +++ b/ext/gd/tests/imagegif_nullbyte_injection.phpt @@ -14,4 +14,4 @@ try { } ?> --EXPECT-- -Invalid 2nd parameter, filename must not contain null bytes +imagegif(): Argument #2 ($to) must not contain null bytes diff --git a/ext/gd/tests/imagejpeg_nullbyte_injection.phpt b/ext/gd/tests/imagejpeg_nullbyte_injection.phpt index 1a7f6da03c..2f175271d1 100644 --- a/ext/gd/tests/imagejpeg_nullbyte_injection.phpt +++ b/ext/gd/tests/imagejpeg_nullbyte_injection.phpt @@ -18,4 +18,4 @@ try { } ?> --EXPECT-- -Invalid 2nd parameter, filename must not contain null bytes +imagejpeg(): Argument #2 ($to) must not contain null bytes diff --git a/ext/gd/tests/imagepng_nullbyte_injection.phpt b/ext/gd/tests/imagepng_nullbyte_injection.phpt index 86d614ab60..bd98a97dab 100644 --- a/ext/gd/tests/imagepng_nullbyte_injection.phpt +++ b/ext/gd/tests/imagepng_nullbyte_injection.phpt @@ -18,4 +18,4 @@ try { } ?> --EXPECTF-- -Invalid 2nd parameter, filename must not contain null bytes +imagepng(): Argument #2 ($to) must not contain null bytes diff --git a/ext/gd/tests/imagewbmp_nullbyte_injection.phpt b/ext/gd/tests/imagewbmp_nullbyte_injection.phpt index cce38a63df..8f2bdcec59 100644 --- a/ext/gd/tests/imagewbmp_nullbyte_injection.phpt +++ b/ext/gd/tests/imagewbmp_nullbyte_injection.phpt @@ -18,4 +18,4 @@ try { } ?> --EXPECT-- -Invalid 2nd parameter, filename must not contain null bytes +imagewbmp(): Argument #2 ($to) must not contain null bytes diff --git a/ext/gd/tests/imagewebp_nullbyte_injection.phpt b/ext/gd/tests/imagewebp_nullbyte_injection.phpt index 82e45aca02..c48fd7d821 100644 --- a/ext/gd/tests/imagewebp_nullbyte_injection.phpt +++ b/ext/gd/tests/imagewebp_nullbyte_injection.phpt @@ -18,4 +18,4 @@ try { } ?> --EXPECT-- -Invalid 2nd parameter, filename must not contain null bytes +imagewebp(): Argument #2 ($to) must not contain null bytes diff --git a/ext/mysqli/mysqli.c b/ext/mysqli/mysqli.c index cbfbb451bc..5d5413a593 100644 --- a/ext/mysqli/mysqli.c +++ b/ext/mysqli/mysqli.c @@ -1272,7 +1272,7 @@ void php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAMETERS, int override_flags * 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(); } } diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c index 62263d2f7e..a7d65dd430 100644 --- a/ext/openssl/openssl.c +++ b/ext/openssl/openssl.c @@ -6640,7 +6640,7 @@ PHP_OPENSSL_API zend_string* php_openssl_random_pseudo_bytes(zend_long buffer_le || 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); diff --git a/ext/openssl/tests/openssl_random_pseudo_bytes_error.phpt b/ext/openssl/tests/openssl_random_pseudo_bytes_error.phpt index ee3f1d032c..17bf181f17 100644 --- a/ext/openssl/tests/openssl_random_pseudo_bytes_error.phpt +++ b/ext/openssl/tests/openssl_random_pseudo_bytes_error.phpt @@ -11,4 +11,4 @@ try { } ?> --EXPECT-- -Length must be greater than 0 +openssl_random_pseudo_bytes(): Argument #1 ($length) must be greater than 0 diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c index fdc1b1b856..fc98542ef9 100644 --- a/ext/pcre/php_pcre.c +++ b/ext/pcre/php_pcre.c @@ -2303,7 +2303,7 @@ static void preg_replace_common(INTERNAL_FUNCTION_PARAMETERS, int is_filter) } } 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(); } } diff --git a/ext/pcre/tests/bug21732.phpt b/ext/pcre/tests/bug21732.phpt index a88d36c94c..6d162d159b 100644 --- a/ext/pcre/tests/bug21732.phpt +++ b/ext/pcre/tests/bug21732.phpt @@ -17,7 +17,7 @@ try { 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" diff --git a/ext/pcre/tests/preg_replace_error2.phpt b/ext/pcre/tests/preg_replace_error2.phpt index eeff2fae54..2401e0bb49 100644 --- a/ext/pcre/tests/preg_replace_error2.phpt +++ b/ext/pcre/tests/preg_replace_error2.phpt @@ -36,6 +36,6 @@ Arg value is: this is a string 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 diff --git a/ext/pdo/pdo_dbh.c b/ext/pdo/pdo_dbh.c index 9a1e0f53f6..c6b18b249b 100644 --- a/ext/pdo/pdo_dbh.c +++ b/ext/pdo/pdo_dbh.c @@ -225,7 +225,7 @@ static PHP_METHOD(PDO, dbh_constructor) 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(); } @@ -242,12 +242,12 @@ static PHP_METHOD(PDO, dbh_constructor) /* 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(); } } diff --git a/ext/pdo_mysql/tests/pdo_mysql___construct.phpt b/ext/pdo_mysql/tests/pdo_mysql___construct.phpt index 2231f8b449..7412402125 100644 --- a/ext/pdo_mysql/tests/pdo_mysql___construct.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql___construct.phpt @@ -293,11 +293,11 @@ MySQLPDOTest::skip(); 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 diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c index 460edd0f26..e7cd877906 100644 --- a/ext/simplexml/simplexml.c +++ b/ext/simplexml/simplexml.c @@ -2282,15 +2282,15 @@ SXE_METHOD(__construct) } 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(); } diff --git a/ext/simplexml/tests/bug74950.phpt b/ext/simplexml/tests/bug74950.phpt index 20976c7d38..86fb2f0f72 100644 --- a/ext/simplexml/tests/bug74950.phpt +++ b/ext/simplexml/tests/bug74950.phpt @@ -10,7 +10,7 @@ if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platforms only"); $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} diff --git a/ext/snmp/snmp.c b/ext/snmp/snmp.c index ac630871bd..6c720e2b17 100644 --- a/ext/snmp/snmp.c +++ b/ext/snmp/snmp.c @@ -1540,7 +1540,7 @@ PHP_METHOD(snmp, __construct) 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(); } diff --git a/ext/snmp/tests/snmp-object-error.phpt b/ext/snmp/tests/snmp-object-error.phpt index 20901ce702..56db079c35 100644 --- a/ext/snmp/tests/snmp-object-error.phpt +++ b/ext/snmp/tests/snmp-object-error.phpt @@ -72,7 +72,7 @@ var_dump($session->max_oids); 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 diff --git a/ext/spl/php_spl.c b/ext/spl/php_spl.c index 3fd3604072..9ccb9da3a5 100644 --- a/ext/spl/php_spl.c +++ b/ext/spl/php_spl.c @@ -93,7 +93,7 @@ PHP_FUNCTION(class_parents) } 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(); } @@ -126,7 +126,7 @@ PHP_FUNCTION(class_implements) 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(); } @@ -155,7 +155,7 @@ PHP_FUNCTION(class_uses) 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(); } diff --git a/ext/spl/tests/class_implements_variation1.phpt b/ext/spl/tests/class_implements_variation1.phpt index 5c998c7494..215abfe2c7 100644 --- a/ext/spl/tests/class_implements_variation1.phpt +++ b/ext/spl/tests/class_implements_variation1.phpt @@ -119,61 +119,61 @@ fclose($res); *** 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) @@ -194,10 +194,10 @@ array(0) { } --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 diff --git a/ext/spl/tests/class_uses_variation1.phpt b/ext/spl/tests/class_uses_variation1.phpt index c26fb67e0f..5c766b9426 100644 --- a/ext/spl/tests/class_uses_variation1.phpt +++ b/ext/spl/tests/class_uses_variation1.phpt @@ -119,61 +119,61 @@ fclose($res); *** 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) @@ -192,10 +192,10 @@ array(0) { } --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 diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c index abc855c752..6ccaf2c829 100644 --- a/ext/zlib/zlib.c +++ b/ext/zlib/zlib.c @@ -819,7 +819,7 @@ static zend_bool zlib_create_dictionary_string(HashTable *options, char **dict, } 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; } }