From: Sara Golemon Date: Wed, 28 Dec 2016 19:18:46 +0000 (-0800) Subject: Use new params API for throwable constructors in date X-Git-Tag: php-7.2.0alpha1~726 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=85e88d1d6ec984f2be0e36a12ad4dcd1726dfab4;p=php Use new params API for throwable constructors in date --- diff --git a/ext/date/php_date.c b/ext/date/php_date.c index 5120df13f7..5a839e3a52 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -2768,9 +2768,11 @@ PHP_METHOD(DateTime, __construct) size_t time_str_len = 0; zend_error_handling error_handling; - if (FAILURE == zend_parse_parameters_throw(ZEND_NUM_ARGS(), "|sO!", &time_str, &time_str_len, &timezone_object, date_ce_timezone)) { - return; - } + ZEND_PARSE_PARAMETERS_START_EX(ZEND_PARSE_PARAMS_THROW, 0, 2) + Z_PARAM_OPTIONAL + Z_PARAM_STRING(time_str, time_str_len) + Z_PARAM_OBJECT_OF_CLASS_EX(timezone_object, date_ce_timezone, 1, 0) + ZEND_PARSE_PARAMETERS_END(); zend_replace_error_handling(EH_THROW, NULL, &error_handling); php_date_initialize(Z_PHPDATE_P(getThis()), time_str, time_str_len, NULL, timezone_object, 1); @@ -2788,9 +2790,11 @@ PHP_METHOD(DateTimeImmutable, __construct) size_t time_str_len = 0; zend_error_handling error_handling; - if (FAILURE == zend_parse_parameters_throw(ZEND_NUM_ARGS(), "|sO!", &time_str, &time_str_len, &timezone_object, date_ce_timezone)) { - return; - } + ZEND_PARSE_PARAMETERS_START_EX(ZEND_PARSE_PARAMS_THROW, 0, 2) + Z_PARAM_OPTIONAL + Z_PARAM_STRING(time_str, time_str_len) + Z_PARAM_OBJECT_OF_CLASS_EX(timezone_object, date_ce_timezone, 1, 0) + ZEND_PARSE_PARAMETERS_END(); zend_replace_error_handling(EH_THROW, NULL, &error_handling); php_date_initialize(Z_PHPDATE_P(getThis()), time_str, time_str_len, NULL, timezone_object, 1); @@ -3767,18 +3771,17 @@ PHP_FUNCTION(timezone_open) */ PHP_METHOD(DateTimeZone, __construct) { - char *tz; - size_t tz_len; + zend_string *tz; php_timezone_obj *tzobj; zend_error_handling error_handling; - if (FAILURE == zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &tz, &tz_len)) { - return; - } + ZEND_PARSE_PARAMETERS_START_EX(ZEND_PARSE_PARAMS_THROW, 1, 1) + Z_PARAM_STR(tz) + ZEND_PARSE_PARAMETERS_END(); zend_replace_error_handling(EH_THROW, NULL, &error_handling); tzobj = Z_PHPTIMEZONE_P(getThis()); - timezone_initialize(tzobj, tz, tz_len); + timezone_initialize(tzobj, ZSTR_VAL(tz), ZSTR_LEN(tz)); zend_restore_error_handling(&error_handling); } /* }}} */ @@ -4214,18 +4217,17 @@ void date_interval_write_property(zval *object, zval *member, zval *value, void */ PHP_METHOD(DateInterval, __construct) { - char *interval_string = NULL; - size_t interval_string_length; + zend_string *interval_string = NULL; php_interval_obj *diobj; timelib_rel_time *reltime; zend_error_handling error_handling; - if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &interval_string, &interval_string_length) == FAILURE) { - return; - } + ZEND_PARSE_PARAMETERS_START_EX(ZEND_PARSE_PARAMS_THROW, 1, 1) + Z_PARAM_STR(interval_string) + ZEND_PARSE_PARAMETERS_END(); zend_replace_error_handling(EH_THROW, NULL, &error_handling); - if (date_interval_initialize(&reltime, interval_string, interval_string_length) == SUCCESS) { + if (date_interval_initialize(&reltime, ZSTR_VAL(interval_string), ZSTR_LEN(interval_string)) == SUCCESS) { diobj = Z_PHPINTERVAL_P(getThis()); diobj->diff = reltime; diobj->initialized = 1;