]> granicus.if.org Git - php/commitdiff
Use new param API in standard
authorSara Golemon <pollita@php.net>
Sat, 31 Dec 2016 02:03:33 +0000 (18:03 -0800)
committerSara Golemon <pollita@php.net>
Sat, 31 Dec 2016 02:28:54 +0000 (18:28 -0800)
ext/standard/browscap.c
ext/standard/cyr_convert.c
ext/standard/datetime.c
ext/standard/dl.c
ext/standard/dns.c
ext/standard/fsock.c
ext/standard/metaphone.c
ext/standard/type.c
ext/standard/uniqid.c
ext/standard/var.c
ext/standard/versioning.c

index a52ed2501f6f6814fe432ac68e15ee0a934dde02..722a7fd91e32d79708dd6fbeea23cd7f236f10ac 100644 (file)
@@ -457,9 +457,11 @@ PHP_FUNCTION(get_browser)
                bdata = &global_bdata;
        }
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s!b", &agent_name, &agent_name_len, &return_array) == FAILURE) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(0, 2)
+               Z_PARAM_OPTIONAL
+               Z_PARAM_STRING_EX(agent_name, agent_name_len, 1, 0)
+               Z_PARAM_BOOL(return_array)
+       ZEND_PARSE_PARAMETERS_END();
 
        if (agent_name == NULL) {
                if ((Z_TYPE(PG(http_globals)[TRACK_VARS_SERVER]) == IS_ARRAY || zend_is_auto_global_str(ZEND_STRL("_SERVER"))) && 
index 8baef3d06caca171d0c38f1155ef28d44a5e221d..05616de457b951d772fdc6ecc964221bd26f8dbd 100644 (file)
@@ -274,9 +274,11 @@ PHP_FUNCTION(convert_cyr_string)
        size_t input_len, fr_cs_len, to_cs_len;
        zend_string *str;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "sss", &input, &input_len, &fr_cs, &fr_cs_len, &to_cs, &to_cs_len) == FAILURE) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(3, 3)
+               Z_PARAM_STRING(input, input_len)
+               Z_PARAM_STRING(fr_cs, fr_cs_len)
+               Z_PARAM_STRING(to_cs, to_cs_len)
+       ZEND_PARSE_PARAMETERS_END();
 
        str = zend_string_init(input, input_len, 0);
 
index 3e6d6a2338fee304948b3551fe7ad62162f4e9f4..5b53edafce16175544c1d2ea7d71237e18acd88e 100644 (file)
@@ -92,9 +92,10 @@ PHP_FUNCTION(strptime)
        struct tm  parsed_time;
        char      *unparsed_part;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &ts, &ts_length, &format, &format_length) == FAILURE) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(2, 2)
+               Z_PARAM_STRING(ts, ts_length)
+               Z_PARAM_STRING(format, format_length)
+       ZEND_PARSE_PARAMETERS_END();
 
        memset(&parsed_time, 0, sizeof(parsed_time));
 
index 8ff8674fc23e82eb0d0540b99472e07e91d8aafd..abb7853c31b2235716d4052b813d05bd630c348c 100644 (file)
@@ -53,9 +53,9 @@ PHPAPI PHP_FUNCTION(dl)
        char *filename;
        size_t filename_len;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &filename, &filename_len) == FAILURE) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(1, 1)
+               Z_PARAM_STRING(filename, filename_len)
+       ZEND_PARSE_PARAMETERS_END();
 
        if (!PG(enable_dl)) {
                php_error_docref(NULL, E_WARNING, "Dynamically loaded extensions aren't enabled");
index f1cc5e89059e03c35137e03468392b4e2ccb4789..23d09862f3b37fba4d6be0be101f014b442c2274 100644 (file)
@@ -151,9 +151,9 @@ PHP_FUNCTION(gethostbyaddr)
        size_t addr_len;
        zend_string *hostname;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &addr, &addr_len) == FAILURE) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(1, 1)
+               Z_PARAM_STRING(addr, addr_len)
+       ZEND_PARSE_PARAMETERS_END();
 
        hostname = php_gethostbyaddr(addr);
 
@@ -212,9 +212,9 @@ PHP_FUNCTION(gethostbyname)
        char *hostname;
        size_t hostname_len;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &hostname, &hostname_len) == FAILURE) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(1, 1)
+               Z_PARAM_STRING(hostname, hostname_len)
+       ZEND_PARSE_PARAMETERS_END();
 
        if(hostname_len > MAXFQDNLEN) {
                /* name too long, protect from CVE-2015-0235 */
@@ -236,9 +236,9 @@ PHP_FUNCTION(gethostbynamel)
        struct in_addr in;
        int i;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &hostname, &hostname_len) == FAILURE) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(1, 1)
+               Z_PARAM_STRING(hostname, hostname_len)
+       ZEND_PARSE_PARAMETERS_END();
 
        if(hostname_len > MAXFQDNLEN) {
                /* name too long, protect from CVE-2015-0235 */
@@ -363,9 +363,11 @@ PHP_FUNCTION(dns_check_record)
        struct __res_state *handle = &state;
 #endif
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &hostname, &hostname_len, &rectype, &rectype_len) == FAILURE) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(1, 2)
+               Z_PARAM_STRING(hostname, hostname_len)
+               Z_PARAM_OPTIONAL
+               Z_PARAM_STRING(rectype, rectype_len)
+       ZEND_PARSE_PARAMETERS_END();
 
        if (hostname_len == 0) {
                php_error_docref(NULL, E_WARNING, "Host cannot be empty");
@@ -780,10 +782,14 @@ PHP_FUNCTION(dns_get_record)
        int type, first_query = 1, store_results = 1;
        zend_bool raw = 0;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|lz/!z/!b",
-                       &hostname, &hostname_len, &type_param, &authns, &addtl, &raw) == FAILURE) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(1, 5)
+               Z_PARAM_STRING(hostname, hostname_len)
+               Z_PARAM_OPTIONAL
+               Z_PARAM_LONG(type_param)
+               Z_PARAM_ZVAL_DEREF_EX(authns, 1, 1)
+               Z_PARAM_ZVAL_DEREF_EX(addtl, 1, 1)
+               Z_PARAM_BOOL(raw)
+       ZEND_PARSE_PARAMETERS_END();
 
        if (authns) {
                zval_dtor(authns);
@@ -1008,9 +1014,12 @@ PHP_FUNCTION(dns_get_mx)
        struct __res_state *handle = &state;
 #endif
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "sz/|z/", &hostname, &hostname_len, &mx_list, &weight_list) == FAILURE) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(2, 3)
+               Z_PARAM_STRING(hostname, hostname_len)
+               Z_PARAM_ZVAL_DEREF_EX(mx_list, 0, 1)
+               Z_PARAM_OPTIONAL
+               Z_PARAM_ZVAL_DEREF_EX(weight_list, 0, 1)
+       ZEND_PARSE_PARAMETERS_END();
 
        zval_dtor(mx_list);
        array_init(mx_list);
index 675e1154a9675c55e1e33436a2097e3d4323ea1d..68579b71c34df70808c5dc1b0aa389ca080e584c 100644 (file)
@@ -51,9 +51,14 @@ static void php_fsockopen_stream(INTERNAL_FUNCTION_PARAMETERS, int persistent)
 
        RETVAL_FALSE;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|lz/z/d", &host, &host_len, &port, &zerrno, &zerrstr, &timeout) == FAILURE) {
-               RETURN_FALSE;
-       }
+       ZEND_PARSE_PARAMETERS_START(1, 5)
+               Z_PARAM_STRING(host, host_len)
+               Z_PARAM_OPTIONAL
+               Z_PARAM_LONG(port)
+               Z_PARAM_ZVAL_DEREF_EX(zerrno, 0, 1)
+               Z_PARAM_ZVAL_DEREF_EX(zerrstr, 0, 1)
+               Z_PARAM_DOUBLE(timeout)
+       ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
 
        if (persistent) {
                spprintf(&hashkey, 0, "pfsockopen__%s:" ZEND_LONG_FMT, host, port);
index 11968a6fb6dfad09383a370e562092e5cd38140b..b9b5bc7c1757a04702ba5031a4b1c19bf40a032b 100644 (file)
@@ -35,9 +35,11 @@ PHP_FUNCTION(metaphone)
        zend_string *result = NULL;
        zend_long phones = 0;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|l", &str, &phones) == FAILURE) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(1, 2)
+               Z_PARAM_STR(str)
+               Z_PARAM_OPTIONAL
+               Z_PARAM_LONG(phones)
+       ZEND_PARSE_PARAMETERS_END();
 
        if (metaphone((unsigned char *)ZSTR_VAL(str), ZSTR_LEN(str), phones, &result, 1) == 0) {
                RETVAL_STR(result);
index 88a150157025ade9454ecee6c25e4b6b9a5157a6..5f237aecd14d9e0dcd7ec365b7be1e421276f89f 100644 (file)
@@ -27,9 +27,9 @@ PHP_FUNCTION(gettype)
 {
        zval *arg;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &arg) == FAILURE) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(1, 1)
+               Z_PARAM_ZVAL_DEREF(arg)
+       ZEND_PARSE_PARAMETERS_END();
 
        switch (Z_TYPE_P(arg)) {
                case IS_NULL:
@@ -87,11 +87,11 @@ PHP_FUNCTION(settype)
        char *type;
        size_t type_len = 0;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "zs", &var, &type, &type_len) == FAILURE) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(2, 2)
+               Z_PARAM_ZVAL_DEREF(var)
+               Z_PARAM_STRING(type, type_len)
+       ZEND_PARSE_PARAMETERS_END();
 
-       ZVAL_DEREF(var);
        if (!strcasecmp(type, "integer")) {
                convert_to_long(var);
        } else if (!strcasecmp(type, "int")) {
@@ -153,9 +153,9 @@ PHP_FUNCTION(floatval)
 {
        zval *num;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &num) == FAILURE) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(1, 1)
+               Z_PARAM_ZVAL_DEREF(num)
+       ZEND_PARSE_PARAMETERS_END();
 
        RETURN_DOUBLE(zval_get_double(num));
 }
@@ -167,9 +167,9 @@ PHP_FUNCTION(boolval)
 {
        zval *val;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &val) == FAILURE) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(1, 1)
+               Z_PARAM_ZVAL_DEREF(val)
+       ZEND_PARSE_PARAMETERS_END();
 
        RETURN_BOOL(zend_is_true(val));
 }
@@ -236,11 +236,10 @@ PHP_FUNCTION(is_bool)
 {
        zval *arg;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &arg) == FAILURE) {
-               RETURN_FALSE;
-       }
+       ZEND_PARSE_PARAMETERS_START(1, 1)
+               Z_PARAM_ZVAL_DEREF(arg)
+       ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
 
-       ZVAL_DEREF(arg);
        RETURN_BOOL(Z_TYPE_P(arg) == IS_FALSE || Z_TYPE_P(arg) == IS_TRUE);
 }
 /* }}} */
@@ -358,10 +357,12 @@ PHP_FUNCTION(is_callable)
        zend_bool syntax_only = 0;
        int check_flags = 0;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "z|bz/", &var,
-                                                         &syntax_only, &callable_name) == FAILURE) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(1, 3)
+               Z_PARAM_ZVAL_DEREF(var)
+               Z_PARAM_OPTIONAL
+               Z_PARAM_BOOL(syntax_only)
+               Z_PARAM_ZVAL_DEREF_EX(callable_name, 0, 1)
+       ZEND_PARSE_PARAMETERS_END();
 
        if (syntax_only) {
                check_flags |= IS_CALLABLE_CHECK_SYNTAX_ONLY;
@@ -393,10 +394,10 @@ PHP_FUNCTION(is_callable)
 PHP_FUNCTION(is_iterable)
 {
        zval *var;
-       
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &var) == FAILURE) {
-               return;
-       }
+
+       ZEND_PARSE_PARAMETERS_START(1, 1)
+               Z_PARAM_ZVAL_DEREF(var)
+       ZEND_PARSE_PARAMETERS_END();    
        
        RETURN_BOOL(zend_is_iterable(var));
 }
index f429e6d4a0e8e414687b82a0536ebf1be7de8aa4..48991964ed0a43775598e4591514c62c79c197cc 100644 (file)
@@ -54,10 +54,11 @@ PHP_FUNCTION(uniqid)
        size_t prefix_len = 0;
        struct timeval tv;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "|sb", &prefix, &prefix_len,
-                                                         &more_entropy)) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(0, 2)
+               Z_PARAM_OPTIONAL
+               Z_PARAM_STRING(prefix, prefix_len)
+               Z_PARAM_BOOL(more_entropy)
+       ZEND_PARSE_PARAMETERS_END();
 
 #if HAVE_USLEEP && !defined(PHP_WIN32)
        if (!more_entropy) {
index 7e84c91e70a4840d4fe29830ac0c893c7ecc588c..ef5e4272ef4d23e9c3697aa586e4ae4269cd12d8 100644 (file)
@@ -202,9 +202,9 @@ PHP_FUNCTION(var_dump)
        int argc;
        int     i;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "+", &args, &argc) == FAILURE) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(1, -1)
+               Z_PARAM_VARIADIC('+', args, argc)
+       ZEND_PARSE_PARAMETERS_END();
 
        for (i = 0; i < argc; i++) {
                php_var_dump(&args[i], 1);
@@ -366,9 +366,9 @@ PHP_FUNCTION(debug_zval_dump)
        int argc;
        int     i;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "+", &args, &argc) == FAILURE) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(1, -1)
+               Z_PARAM_VARIADIC('+', args, argc)
+       ZEND_PARSE_PARAMETERS_END();
 
        for (i = 0; i < argc; i++) {
                php_debug_zval_dump(&args[i], 1);
@@ -572,9 +572,11 @@ PHP_FUNCTION(var_export)
        zend_bool return_output = 0;
        smart_str buf = {0};
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "z|b", &var, &return_output) == FAILURE) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(1, 2)
+               Z_PARAM_ZVAL_DEREF(var)
+               Z_PARAM_OPTIONAL
+               Z_PARAM_BOOL(return_output)
+       ZEND_PARSE_PARAMETERS_END();
 
        php_var_export_ex(var, 1, &buf);
        smart_str_0 (&buf);
@@ -1035,9 +1037,9 @@ PHP_FUNCTION(serialize)
        php_serialize_data_t var_hash;
        smart_str buf = {0};
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &struc) == FAILURE) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(1, 1)
+               Z_PARAM_ZVAL_DEREF(struc)
+       ZEND_PARSE_PARAMETERS_END();
 
        PHP_VAR_SERIALIZE_INIT(var_hash);
        php_var_serialize(&buf, struc, &var_hash);
@@ -1068,9 +1070,11 @@ PHP_FUNCTION(unserialize)
        zval *retval;
        HashTable *class_hash = NULL, *prev_class_hash;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|a", &buf, &buf_len, &options) == FAILURE) {
-               RETURN_FALSE;
-       }
+       ZEND_PARSE_PARAMETERS_START(1, 2)
+               Z_PARAM_STRING(buf, buf_len)
+               Z_PARAM_OPTIONAL
+               Z_PARAM_ARRAY(options)
+       ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
 
        if (buf_len == 0) {
                RETURN_FALSE;
@@ -1134,9 +1138,10 @@ PHP_FUNCTION(unserialize)
 PHP_FUNCTION(memory_get_usage) {
        zend_bool real_usage = 0;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "|b", &real_usage) == FAILURE) {
-               RETURN_FALSE;
-       }
+       ZEND_PARSE_PARAMETERS_START(0, 1)
+               Z_PARAM_OPTIONAL
+               Z_PARAM_BOOL(real_usage)
+       ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
 
        RETURN_LONG(zend_memory_usage(real_usage));
 }
@@ -1147,9 +1152,10 @@ PHP_FUNCTION(memory_get_usage) {
 PHP_FUNCTION(memory_get_peak_usage) {
        zend_bool real_usage = 0;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "|b", &real_usage) == FAILURE) {
-               RETURN_FALSE;
-       }
+       ZEND_PARSE_PARAMETERS_START(0, 1)
+               Z_PARAM_OPTIONAL
+               Z_PARAM_BOOL(real_usage)
+       ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
 
        RETURN_LONG(zend_memory_peak_usage(real_usage));
 }
index 29f421c72fdb563e99f5d6d2a57ec77dd3f8a17a..bf82767ad7df7fe07ccf64861bf6faf3ec4e2fdc 100644 (file)
@@ -212,15 +212,17 @@ PHP_FUNCTION(version_compare)
 {
        char *v1, *v2, *op = NULL;
        size_t v1_len, v2_len, op_len = 0;
-       int compare, argc;
+       int compare;
+
+       ZEND_PARSE_PARAMETERS_START(2, 3)
+               Z_PARAM_STRING(v1, v1_len)
+               Z_PARAM_STRING(v2, v2_len)
+               Z_PARAM_OPTIONAL
+               Z_PARAM_STRING(op, op_len)
+       ZEND_PARSE_PARAMETERS_END();
 
-       argc = ZEND_NUM_ARGS();
-       if (zend_parse_parameters(argc, "ss|s", &v1, &v1_len, &v2,
-                                                         &v2_len, &op, &op_len) == FAILURE) {
-               return;
-       }
        compare = php_version_compare(v1, v2);
-       if (argc == 2) {
+       if (!op) {
                RETURN_LONG(compare);
        }
        if (!strncmp(op, "<", op_len) || !strncmp(op, "lt", op_len)) {