]> granicus.if.org Git - php/commitdiff
Add Z_PARAM_STRING/ARRAY_OR_NULL convenience macros
authorNikita Popov <nikita.ppv@gmail.com>
Tue, 29 Oct 2019 12:29:52 +0000 (13:29 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Tue, 29 Oct 2019 12:29:52 +0000 (13:29 +0100)
Zend/zend_API.h
ext/date/php_date.c
ext/pdo/pdo_dbh.c
ext/pdo/pdo_stmt.c
ext/standard/basic_functions.c
ext/standard/math.c
ext/standard/proc_open.c
ext/standard/streamsfuncs.c

index 0b9fcd76af42c0aff0868bf57018c71e36f9ac94..cb97f5e94d98408a0b55d09c7ec9d95d4476e3b4 100644 (file)
@@ -1226,6 +1226,9 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_callback_error(int num, char *e
 #define Z_PARAM_ARRAY(dest) \
        Z_PARAM_ARRAY_EX(dest, 0, 0)
 
+#define Z_PARAM_ARRAY_OR_NULL(dest) \
+       Z_PARAM_ARRAY_EX(dest, 1, 0)
+
 /* old "A" */
 #define Z_PARAM_ARRAY_OR_OBJECT_EX2(dest, check_null, deref, separate) \
                Z_PARAM_PROLOGUE(deref, separate); \
@@ -1463,6 +1466,9 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_callback_error(int num, char *e
 #define Z_PARAM_STRING(dest, dest_len) \
        Z_PARAM_STRING_EX(dest, dest_len, 0, 0)
 
+#define Z_PARAM_STRING_OR_NULL(dest, dest_len) \
+       Z_PARAM_STRING_EX(dest, dest_len, 1, 0)
+
 /* old "S" */
 #define Z_PARAM_STR_EX2(dest, check_null, deref, separate) \
                Z_PARAM_PROLOGUE(deref, separate); \
index dfad240fb17145f55a1dd4108a05ad9bf36ae6b3..6e878063eb2eb9937981a432c45715b5b028e541 100644 (file)
@@ -4444,7 +4444,7 @@ PHP_FUNCTION(timezone_identifiers_list)
        ZEND_PARSE_PARAMETERS_START(0, 2)
                Z_PARAM_OPTIONAL
                Z_PARAM_LONG(what)
-               Z_PARAM_STRING_EX(option, option_len, 1, 0)
+               Z_PARAM_STRING_OR_NULL(option, option_len)
        ZEND_PARSE_PARAMETERS_END();
 
        /* Extra validation */
index 873aa2d68152cf72ba43cf62b2cb9b3a8f936d70..b3d4f243637f5e185edca95f6e1843aa6d324675 100644 (file)
@@ -210,9 +210,9 @@ static PHP_METHOD(PDO, dbh_constructor)
        ZEND_PARSE_PARAMETERS_START(1, 4)
                Z_PARAM_STRING(data_source, data_source_len)
                Z_PARAM_OPTIONAL
-               Z_PARAM_STRING_EX(username, usernamelen, 1, 0)
-               Z_PARAM_STRING_EX(password, passwordlen, 1, 0)
-               Z_PARAM_ARRAY_EX(options, 1, 0)
+               Z_PARAM_STRING_OR_NULL(username, usernamelen)
+               Z_PARAM_STRING_OR_NULL(password, passwordlen)
+               Z_PARAM_ARRAY_OR_NULL(options)
        ZEND_PARSE_PARAMETERS_END();
 
        /* parse the data source name */
@@ -938,7 +938,7 @@ static PHP_METHOD(PDO, lastInsertId)
 
        ZEND_PARSE_PARAMETERS_START(0, 1)
                Z_PARAM_OPTIONAL
-               Z_PARAM_STRING_EX(name, namelen, 1, 0)
+               Z_PARAM_STRING_OR_NULL(name, namelen)
        ZEND_PARSE_PARAMETERS_END();
 
        PDO_DBH_CLEAR_ERR();
index 4acfcb0003289dfbe1c19aff78b9568094cf47b0..771c7a4ddef73d63797cf22b5536192f044af202 100644 (file)
@@ -423,7 +423,7 @@ static PHP_METHOD(PDOStatement, execute)
 
        ZEND_PARSE_PARAMETERS_START(0, 1)
                Z_PARAM_OPTIONAL
-               Z_PARAM_ARRAY_EX(input_params, 1, 0)
+               Z_PARAM_ARRAY_OR_NULL(input_params)
        ZEND_PARSE_PARAMETERS_END();
 
        PDO_STMT_CLEAR_ERR();
index 1c3ad1d2bd2ccc5800a83369c786c088459ea588..80c1ea9ec385077fbb9190174a5c84a4aa007a4c 100755 (executable)
@@ -4413,7 +4413,7 @@ PHP_FUNCTION(ini_get_all)
 
        ZEND_PARSE_PARAMETERS_START(0, 2)
                Z_PARAM_OPTIONAL
-               Z_PARAM_STRING_EX(extname, extname_len, 1, 0)
+               Z_PARAM_STRING_OR_NULL(extname, extname_len)
                Z_PARAM_BOOL(details)
        ZEND_PARSE_PARAMETERS_END();
 
index ef5beeb1601bbd26e763882673f1c8d111aa50f6..18498a21d26da88fc434d537e989bee9ca3423ef 100644 (file)
@@ -1251,8 +1251,8 @@ PHP_FUNCTION(number_format)
                Z_PARAM_DOUBLE(num)
                Z_PARAM_OPTIONAL
                Z_PARAM_LONG(dec)
-               Z_PARAM_STRING_EX(dec_point, dec_point_len, 1, 0)
-               Z_PARAM_STRING_EX(thousand_sep, thousand_sep_len, 1, 0)
+               Z_PARAM_STRING_OR_NULL(dec_point, dec_point_len)
+               Z_PARAM_STRING_OR_NULL(thousand_sep, thousand_sep_len)
        ZEND_PARSE_PARAMETERS_END();
 
        switch(ZEND_NUM_ARGS()) {
index 12e9820522b91b44d4cf99b861ed35c471fb32ea..166b4b03981bbefa0842329c4c15c1909a39636f 100644 (file)
@@ -518,9 +518,9 @@ PHP_FUNCTION(proc_open)
                Z_PARAM_ARRAY(descriptorspec)
                Z_PARAM_ZVAL(pipes)
                Z_PARAM_OPTIONAL
-               Z_PARAM_STRING_EX(cwd, cwd_len, 1, 0)
-               Z_PARAM_ARRAY_EX(environment, 1, 0)
-               Z_PARAM_ARRAY_EX(other_options, 1, 0)
+               Z_PARAM_STRING_OR_NULL(cwd, cwd_len)
+               Z_PARAM_ARRAY_OR_NULL(environment)
+               Z_PARAM_ARRAY_OR_NULL(other_options)
        ZEND_PARSE_PARAMETERS_END();
 
        memset(&env, 0, sizeof(env));
index 7c08083f5b63cdb2ec7b127f136f03ecf1b9c410..89d5abd251480fb6a3b561fe4c05f4f389e2964f 100644 (file)
@@ -1128,8 +1128,8 @@ PHP_FUNCTION(stream_context_create)
 
        ZEND_PARSE_PARAMETERS_START(0, 2)
                Z_PARAM_OPTIONAL
-               Z_PARAM_ARRAY_EX(options, 1, 0)
-               Z_PARAM_ARRAY_EX(params, 1, 0)
+               Z_PARAM_ARRAY_OR_NULL(options)
+               Z_PARAM_ARRAY_OR_NULL(params)
        ZEND_PARSE_PARAMETERS_END();
 
        context = php_stream_context_alloc();