Skip to content

Commit 6719d3e

Browse files
committed
Add Z_PARAM_STRING/ARRAY_OR_NULL convenience macros
1 parent 63a20cb commit 6719d3e

File tree

8 files changed

+20
-14
lines changed

8 files changed

+20
-14
lines changed

Zend/zend_API.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,6 +1226,9 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_callback_error(int num, char *e
12261226
#define Z_PARAM_ARRAY(dest) \
12271227
Z_PARAM_ARRAY_EX(dest, 0, 0)
12281228

1229+
#define Z_PARAM_ARRAY_OR_NULL(dest) \
1230+
Z_PARAM_ARRAY_EX(dest, 1, 0)
1231+
12291232
/* old "A" */
12301233
#define Z_PARAM_ARRAY_OR_OBJECT_EX2(dest, check_null, deref, separate) \
12311234
Z_PARAM_PROLOGUE(deref, separate); \
@@ -1463,6 +1466,9 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_callback_error(int num, char *e
14631466
#define Z_PARAM_STRING(dest, dest_len) \
14641467
Z_PARAM_STRING_EX(dest, dest_len, 0, 0)
14651468

1469+
#define Z_PARAM_STRING_OR_NULL(dest, dest_len) \
1470+
Z_PARAM_STRING_EX(dest, dest_len, 1, 0)
1471+
14661472
/* old "S" */
14671473
#define Z_PARAM_STR_EX2(dest, check_null, deref, separate) \
14681474
Z_PARAM_PROLOGUE(deref, separate); \

ext/date/php_date.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4444,7 +4444,7 @@ PHP_FUNCTION(timezone_identifiers_list)
44444444
ZEND_PARSE_PARAMETERS_START(0, 2)
44454445
Z_PARAM_OPTIONAL
44464446
Z_PARAM_LONG(what)
4447-
Z_PARAM_STRING_EX(option, option_len, 1, 0)
4447+
Z_PARAM_STRING_OR_NULL(option, option_len)
44484448
ZEND_PARSE_PARAMETERS_END();
44494449

44504450
/* Extra validation */

ext/pdo/pdo_dbh.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,9 @@ static PHP_METHOD(PDO, dbh_constructor)
210210
ZEND_PARSE_PARAMETERS_START(1, 4)
211211
Z_PARAM_STRING(data_source, data_source_len)
212212
Z_PARAM_OPTIONAL
213-
Z_PARAM_STRING_EX(username, usernamelen, 1, 0)
214-
Z_PARAM_STRING_EX(password, passwordlen, 1, 0)
215-
Z_PARAM_ARRAY_EX(options, 1, 0)
213+
Z_PARAM_STRING_OR_NULL(username, usernamelen)
214+
Z_PARAM_STRING_OR_NULL(password, passwordlen)
215+
Z_PARAM_ARRAY_OR_NULL(options)
216216
ZEND_PARSE_PARAMETERS_END();
217217

218218
/* parse the data source name */
@@ -938,7 +938,7 @@ static PHP_METHOD(PDO, lastInsertId)
938938

939939
ZEND_PARSE_PARAMETERS_START(0, 1)
940940
Z_PARAM_OPTIONAL
941-
Z_PARAM_STRING_EX(name, namelen, 1, 0)
941+
Z_PARAM_STRING_OR_NULL(name, namelen)
942942
ZEND_PARSE_PARAMETERS_END();
943943

944944
PDO_DBH_CLEAR_ERR();

ext/pdo/pdo_stmt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ static PHP_METHOD(PDOStatement, execute)
423423

424424
ZEND_PARSE_PARAMETERS_START(0, 1)
425425
Z_PARAM_OPTIONAL
426-
Z_PARAM_ARRAY_EX(input_params, 1, 0)
426+
Z_PARAM_ARRAY_OR_NULL(input_params)
427427
ZEND_PARSE_PARAMETERS_END();
428428

429429
PDO_STMT_CLEAR_ERR();

ext/standard/basic_functions.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4413,7 +4413,7 @@ PHP_FUNCTION(ini_get_all)
44134413

44144414
ZEND_PARSE_PARAMETERS_START(0, 2)
44154415
Z_PARAM_OPTIONAL
4416-
Z_PARAM_STRING_EX(extname, extname_len, 1, 0)
4416+
Z_PARAM_STRING_OR_NULL(extname, extname_len)
44174417
Z_PARAM_BOOL(details)
44184418
ZEND_PARSE_PARAMETERS_END();
44194419

ext/standard/math.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,8 +1251,8 @@ PHP_FUNCTION(number_format)
12511251
Z_PARAM_DOUBLE(num)
12521252
Z_PARAM_OPTIONAL
12531253
Z_PARAM_LONG(dec)
1254-
Z_PARAM_STRING_EX(dec_point, dec_point_len, 1, 0)
1255-
Z_PARAM_STRING_EX(thousand_sep, thousand_sep_len, 1, 0)
1254+
Z_PARAM_STRING_OR_NULL(dec_point, dec_point_len)
1255+
Z_PARAM_STRING_OR_NULL(thousand_sep, thousand_sep_len)
12561256
ZEND_PARSE_PARAMETERS_END();
12571257

12581258
switch(ZEND_NUM_ARGS()) {

ext/standard/proc_open.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -518,9 +518,9 @@ PHP_FUNCTION(proc_open)
518518
Z_PARAM_ARRAY(descriptorspec)
519519
Z_PARAM_ZVAL(pipes)
520520
Z_PARAM_OPTIONAL
521-
Z_PARAM_STRING_EX(cwd, cwd_len, 1, 0)
522-
Z_PARAM_ARRAY_EX(environment, 1, 0)
523-
Z_PARAM_ARRAY_EX(other_options, 1, 0)
521+
Z_PARAM_STRING_OR_NULL(cwd, cwd_len)
522+
Z_PARAM_ARRAY_OR_NULL(environment)
523+
Z_PARAM_ARRAY_OR_NULL(other_options)
524524
ZEND_PARSE_PARAMETERS_END();
525525

526526
memset(&env, 0, sizeof(env));

ext/standard/streamsfuncs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,8 +1128,8 @@ PHP_FUNCTION(stream_context_create)
11281128

11291129
ZEND_PARSE_PARAMETERS_START(0, 2)
11301130
Z_PARAM_OPTIONAL
1131-
Z_PARAM_ARRAY_EX(options, 1, 0)
1132-
Z_PARAM_ARRAY_EX(params, 1, 0)
1131+
Z_PARAM_ARRAY_OR_NULL(options)
1132+
Z_PARAM_ARRAY_OR_NULL(params)
11331133
ZEND_PARSE_PARAMETERS_END();
11341134

11351135
context = php_stream_context_alloc();

0 commit comments

Comments
 (0)