diff options
Diffstat (limited to 'ext/date')
-rw-r--r-- | ext/date/php_date.c | 72 |
1 files changed, 32 insertions, 40 deletions
diff --git a/ext/date/php_date.c b/ext/date/php_date.c index d8d6d32862..441e39c4ed 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -2573,18 +2573,16 @@ PHP_FUNCTION(date_create) zval *timezone_object = NULL; char *time_str = NULL; size_t time_str_len = 0; - zval datetime_object; if (zend_parse_parameters(ZEND_NUM_ARGS(), "|sO!", &time_str, &time_str_len, &timezone_object, date_ce_timezone) == FAILURE) { RETURN_FALSE; } - php_date_instantiate(date_ce_date, &datetime_object); - if (!php_date_initialize(Z_PHPDATE_P(&datetime_object), time_str, time_str_len, NULL, timezone_object, 0)) { - zval_dtor(&datetime_object); + php_date_instantiate(date_ce_date, return_value); + if (!php_date_initialize(Z_PHPDATE_P(return_value), time_str, time_str_len, NULL, timezone_object, 0)) { + zval_ptr_dtor(return_value); RETURN_FALSE; } - RETVAL_ZVAL(&datetime_object, 0, 0); } /* }}} */ @@ -2596,18 +2594,16 @@ PHP_FUNCTION(date_create_immutable) zval *timezone_object = NULL; char *time_str = NULL; size_t time_str_len = 0; - zval datetime_object; if (zend_parse_parameters(ZEND_NUM_ARGS(), "|sO!", &time_str, &time_str_len, &timezone_object, date_ce_timezone) == FAILURE) { RETURN_FALSE; } - php_date_instantiate(date_ce_immutable, &datetime_object); - if (!php_date_initialize(Z_PHPDATE_P(&datetime_object), time_str, time_str_len, NULL, timezone_object, 0)) { - zval_dtor(&datetime_object); + php_date_instantiate(date_ce_immutable, return_value); + if (!php_date_initialize(Z_PHPDATE_P(return_value), time_str, time_str_len, NULL, timezone_object, 0)) { + zval_ptr_dtor(return_value); RETURN_FALSE; } - RETVAL_ZVAL(&datetime_object, 0, 0); } /* }}} */ @@ -2619,18 +2615,16 @@ PHP_FUNCTION(date_create_from_format) zval *timezone_object = NULL; char *time_str = NULL, *format_str = NULL; size_t time_str_len = 0, format_str_len = 0; - zval datetime_object; if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss|O!", &format_str, &format_str_len, &time_str, &time_str_len, &timezone_object, date_ce_timezone) == FAILURE) { RETURN_FALSE; } - php_date_instantiate(date_ce_date, &datetime_object); - if (!php_date_initialize(Z_PHPDATE_P(&datetime_object), time_str, time_str_len, format_str, timezone_object, 0)) { - zval_dtor(&datetime_object); + php_date_instantiate(date_ce_date, return_value); + if (!php_date_initialize(Z_PHPDATE_P(return_value), time_str, time_str_len, format_str, timezone_object, 0)) { + zval_ptr_dtor(return_value); RETURN_FALSE; } - RETVAL_ZVAL(&datetime_object, 0, 0); } /* }}} */ @@ -2642,18 +2636,16 @@ PHP_FUNCTION(date_create_immutable_from_format) zval *timezone_object = NULL; char *time_str = NULL, *format_str = NULL; size_t time_str_len = 0, format_str_len = 0; - zval datetime_object; if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss|O!", &format_str, &format_str_len, &time_str, &time_str_len, &timezone_object, date_ce_timezone) == FAILURE) { RETURN_FALSE; } - php_date_instantiate(date_ce_immutable, &datetime_object); - if (!php_date_initialize(Z_PHPDATE_P(&datetime_object), time_str, time_str_len, format_str, timezone_object, 0)) { - zval_dtor(&datetime_object); + php_date_instantiate(date_ce_immutable, return_value); + if (!php_date_initialize(Z_PHPDATE_P(return_value), time_str, time_str_len, format_str, timezone_object, 0)) { + zval_ptr_dtor(return_value); RETURN_FALSE; } - RETVAL_ZVAL(&datetime_object, 0, 0); } /* }}} */ @@ -3079,11 +3071,11 @@ PHP_FUNCTION(date_modify) RETURN_FALSE; } - if (php_date_modify(object, modify, modify_len)) { - RETURN_ZVAL(object, 1, 0); + if (!php_date_modify(object, modify, modify_len)) { + RETURN_FALSE; } - RETURN_FALSE; + ZVAL_COPY(return_value, object); } /* }}} */ @@ -3100,11 +3092,11 @@ PHP_METHOD(DateTimeImmutable, modify) } date_clone_immutable(object, &new_object); - if (php_date_modify(&new_object, modify, modify_len)) { - RETURN_ZVAL(&new_object, 0, 1); + if (!php_date_modify(&new_object, modify, modify_len)) { + RETURN_FALSE; } - RETURN_FALSE; + ZVAL_COPY_VALUE(return_value, &new_object); } /* }}} */ @@ -3137,7 +3129,7 @@ PHP_FUNCTION(date_add) php_date_add(object, interval, return_value); - RETURN_ZVAL(object, 1, 0); + ZVAL_COPY(return_value, object); } /* }}} */ @@ -3154,7 +3146,7 @@ PHP_METHOD(DateTimeImmutable, add) date_clone_immutable(object, &new_object); php_date_add(&new_object, interval, return_value); - RETURN_ZVAL(&new_object, 0, 1); + ZVAL_COPY_VALUE(return_value, &new_object); } /* }}} */ @@ -3192,7 +3184,7 @@ PHP_FUNCTION(date_sub) php_date_sub(object, interval, return_value); - RETURN_ZVAL(object, 1, 0); + ZVAL_COPY(return_value, object); } /* }}} */ @@ -3209,7 +3201,7 @@ PHP_METHOD(DateTimeImmutable, sub) date_clone_immutable(object, &new_object); php_date_sub(&new_object, interval, return_value); - RETURN_ZVAL(&new_object, 0, 1); + ZVAL_COPY_VALUE(return_value, &new_object); } /* }}} */ @@ -3294,7 +3286,7 @@ PHP_FUNCTION(date_timezone_set) php_date_timezone_set(object, timezone_object, return_value); - RETURN_ZVAL(object, 1, 0); + ZVAL_COPY(return_value, object); } /* }}} */ @@ -3312,7 +3304,7 @@ PHP_METHOD(DateTimeImmutable, setTimezone) date_clone_immutable(object, &new_object); php_date_timezone_set(&new_object, timezone_object, return_value); - RETURN_ZVAL(&new_object, 0, 1); + ZVAL_COPY_VALUE(return_value, &new_object); } /* }}} */ @@ -3377,7 +3369,7 @@ PHP_FUNCTION(date_time_set) php_date_time_set(object, h, i, s, return_value); - RETURN_ZVAL(object, 1, 0); + ZVAL_COPY(return_value, object); } /* }}} */ @@ -3395,7 +3387,7 @@ PHP_METHOD(DateTimeImmutable, setTime) date_clone_immutable(object, &new_object); php_date_time_set(&new_object, h, i, s, return_value); - RETURN_ZVAL(&new_object, 0, 1); + ZVAL_COPY_VALUE(return_value, &new_object); } /* }}} */ @@ -3425,7 +3417,7 @@ PHP_FUNCTION(date_date_set) php_date_date_set(object, y, m, d, return_value); - RETURN_ZVAL(object, 1, 0); + ZVAL_COPY(return_value, object); } /* }}} */ @@ -3443,7 +3435,7 @@ PHP_METHOD(DateTimeImmutable, setDate) date_clone_immutable(object, &new_object); php_date_date_set(&new_object, y, m, d, return_value); - RETURN_ZVAL(&new_object, 0, 1); + ZVAL_COPY_VALUE(return_value, &new_object); } /* }}} */ @@ -3477,7 +3469,7 @@ PHP_FUNCTION(date_isodate_set) php_date_isodate_set(object, y, w, d, return_value); - RETURN_ZVAL(object, 1, 0); + ZVAL_COPY(return_value, object); } /* }}} */ @@ -3495,7 +3487,7 @@ PHP_METHOD(DateTimeImmutable, setISODate) date_clone_immutable(object, &new_object); php_date_isodate_set(&new_object, y, w, d, return_value); - RETURN_ZVAL(&new_object, 0, 1); + ZVAL_COPY_VALUE(return_value, &new_object); } /* }}} */ @@ -3523,7 +3515,7 @@ PHP_FUNCTION(date_timestamp_set) php_date_timestamp_set(object, timestamp, return_value); - RETURN_ZVAL(object, 1, 0); + ZVAL_COPY(return_value, object); } /* }}} */ @@ -3541,7 +3533,7 @@ PHP_METHOD(DateTimeImmutable, setTimestamp) date_clone_immutable(object, &new_object); php_date_timestamp_set(&new_object, timestamp, return_value); - RETURN_ZVAL(&new_object, 0, 1); + ZVAL_COPY_VALUE(return_value, &new_object); } /* }}} */ |