com php-src: Use new params API for throwable constructors in date: ext/date/php_date.c
| From: | Sara Golemon | Date: | Fri, 30 Dec 2016 02:26:27 +0000 |
| Subject: | com php-src: Use new params API for throwable constructors in date: ext/date/php_date.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-96446@lists.php.net to get a copy of this message | ||
Commit: 85e88d1d6ec984f2be0e36a12ad4dcd1726dfab4
Author: Sara Golemon <pollita@php.net> Wed, 28 Dec 2016 11:18:46 -0800
Parents: 52db03b3e52bfc886896925d050af79bc4dc1ba3
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=85e88d1d6ec984f2be0e36a12ad4dcd1726dfab4
Log:
Use new params API for throwable constructors in date
Changed paths:
M ext/date/php_date.c
Diff:
diff --git a/ext/date/php_date.c b/ext/date/php_date.c
index 5120df1..5a839e3 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;