mirror of
https://github.com/php/php-src.git
synced 2024-12-03 23:05:57 +08:00
Use new params API for throwable constructors in date
This commit is contained in:
parent
52db03b3e5
commit
85e88d1d6e
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user