summaryrefslogtreecommitdiff
path: root/ext/date/php_date.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/date/php_date.c')
-rw-r--r--ext/date/php_date.c49
1 files changed, 29 insertions, 20 deletions
diff --git a/ext/date/php_date.c b/ext/date/php_date.c
index dbcd9d0404..e960161987 100644
--- a/ext/date/php_date.c
+++ b/ext/date/php_date.c
@@ -585,6 +585,11 @@ PHPAPI zend_class_entry *php_date_get_immutable_ce(void)
return date_ce_immutable;
}
+PHPAPI zend_class_entry *php_date_get_interface_ce(void)
+{
+ return date_ce_interface;
+}
+
PHPAPI zend_class_entry *php_date_get_timezone_ce(void)
{
return date_ce_timezone;
@@ -1071,7 +1076,8 @@ char *php_date_short_day_name(timelib_sll y, timelib_sll m, timelib_sll d)
static zend_string *date_format(char *format, size_t format_len, timelib_time *t, int localtime)
{
smart_str string = {0};
- int i, length = 0;
+ size_t i;
+ int length = 0;
char buffer[97];
timelib_time_offset *offset = NULL;
timelib_sll isoweek, isoyear;
@@ -2786,7 +2792,7 @@ PHP_METHOD(DateTime, __set_state)
php_date_instantiate(date_ce_date, return_value);
dateobj = Z_PHPDATE_P(return_value);
if (!php_date_initialize_from_hash(&dateobj, myht)) {
- php_error(E_ERROR, "Invalid serialization data for DateTime object");
+ zend_throw_error(NULL, "Invalid serialization data for DateTime object");
}
}
/* }}} */
@@ -2808,7 +2814,7 @@ PHP_METHOD(DateTimeImmutable, __set_state)
php_date_instantiate(date_ce_immutable, return_value);
dateobj = Z_PHPDATE_P(return_value);
if (!php_date_initialize_from_hash(&dateobj, myht)) {
- php_error(E_ERROR, "Invalid serialization data for DateTimeImmutable object");
+ zend_throw_error(NULL, "Invalid serialization data for DateTimeImmutable object");
}
}
/* }}} */
@@ -2826,7 +2832,7 @@ PHP_METHOD(DateTime, __wakeup)
myht = Z_OBJPROP_P(object);
if (!php_date_initialize_from_hash(&dateobj, myht)) {
- php_error(E_ERROR, "Invalid serialization data for DateTime object");
+ zend_throw_error(NULL, "Invalid serialization data for DateTime object");
}
}
/* }}} */
@@ -3099,7 +3105,7 @@ PHP_METHOD(DateTimeImmutable, modify)
RETURN_FALSE;
}
- ZVAL_COPY_VALUE(return_value, &new_object);
+ ZVAL_OBJ(return_value, Z_OBJ(new_object));
}
/* }}} */
@@ -3150,7 +3156,7 @@ PHP_METHOD(DateTimeImmutable, add)
date_clone_immutable(object, &new_object);
php_date_add(&new_object, interval, return_value);
- ZVAL_COPY_VALUE(return_value, &new_object);
+ ZVAL_OBJ(return_value, Z_OBJ(new_object));
}
/* }}} */
@@ -3206,7 +3212,7 @@ PHP_METHOD(DateTimeImmutable, sub)
date_clone_immutable(object, &new_object);
php_date_sub(&new_object, interval, return_value);
- ZVAL_COPY_VALUE(return_value, &new_object);
+ ZVAL_OBJ(return_value, Z_OBJ(new_object));
}
/* }}} */
@@ -3310,7 +3316,7 @@ PHP_METHOD(DateTimeImmutable, setTimezone)
date_clone_immutable(object, &new_object);
php_date_timezone_set(&new_object, timezone_object, return_value);
- ZVAL_COPY_VALUE(return_value, &new_object);
+ ZVAL_OBJ(return_value, Z_OBJ(new_object));
}
/* }}} */
@@ -3394,7 +3400,7 @@ PHP_METHOD(DateTimeImmutable, setTime)
date_clone_immutable(object, &new_object);
php_date_time_set(&new_object, h, i, s, return_value);
- ZVAL_COPY_VALUE(return_value, &new_object);
+ ZVAL_OBJ(return_value, Z_OBJ(new_object));
}
/* }}} */
@@ -3443,7 +3449,7 @@ PHP_METHOD(DateTimeImmutable, setDate)
date_clone_immutable(object, &new_object);
php_date_date_set(&new_object, y, m, d, return_value);
- ZVAL_COPY_VALUE(return_value, &new_object);
+ ZVAL_OBJ(return_value, Z_OBJ(new_object));
}
/* }}} */
@@ -3496,7 +3502,7 @@ PHP_METHOD(DateTimeImmutable, setISODate)
date_clone_immutable(object, &new_object);
php_date_isodate_set(&new_object, y, w, d, return_value);
- ZVAL_COPY_VALUE(return_value, &new_object);
+ ZVAL_OBJ(return_value, Z_OBJ(new_object));
}
/* }}} */
@@ -3543,7 +3549,7 @@ PHP_METHOD(DateTimeImmutable, setTimestamp)
date_clone_immutable(object, &new_object);
php_date_timestamp_set(&new_object, timestamp, return_value);
- ZVAL_COPY_VALUE(return_value, &new_object);
+ ZVAL_OBJ(return_value, Z_OBJ(new_object));
}
/* }}} */
@@ -3699,7 +3705,7 @@ PHP_METHOD(DateTimeZone, __set_state)
HashTable *myht;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "a", &array) == FAILURE) {
- RETURN_FALSE;
+ return;
}
myht = Z_ARRVAL_P(array);
@@ -3707,7 +3713,8 @@ PHP_METHOD(DateTimeZone, __set_state)
php_date_instantiate(date_ce_timezone, return_value);
tzobj = Z_PHPTIMEZONE_P(return_value);
if(php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht) != SUCCESS) {
- php_error_docref(NULL, E_ERROR, "Timezone initialization failed");
+ zend_throw_error(NULL, "Timezone initialization failed");
+ zval_dtor(return_value);
}
}
/* }}} */
@@ -3725,7 +3732,7 @@ PHP_METHOD(DateTimeZone, __wakeup)
myht = Z_OBJPROP_P(object);
if(php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht) != SUCCESS) {
- php_error_docref(NULL, E_ERROR, "Timezone initialization failed");
+ zend_throw_error(NULL, "Timezone initialization failed");
}
}
/* }}} */
@@ -4218,7 +4225,8 @@ PHP_FUNCTION(date_interval_create_from_date_string)
static zend_string *date_interval_format(char *format, size_t format_len, timelib_rel_time *t)
{
smart_str string = {0};
- int i, length, have_format_spec = 0;
+ size_t i;
+ int length, have_format_spec = 0;
char buffer[33];
if (!format_len) {
@@ -5005,7 +5013,7 @@ PHP_METHOD(DatePeriod, __set_state)
object_init_ex(return_value, date_ce_period);
period_obj = Z_PHPPERIOD_P(return_value);
if (!php_date_period_initialize_from_hash(period_obj, myht)) {
- php_error(E_ERROR, "Invalid serialization data for DatePeriod object");
+ zend_throw_error(NULL, "Invalid serialization data for DatePeriod object");
}
}
/* }}} */
@@ -5023,7 +5031,7 @@ PHP_METHOD(DatePeriod, __wakeup)
myht = Z_OBJPROP_P(object);
if (!php_date_period_initialize_from_hash(period_obj, myht)) {
- php_error(E_ERROR, "Invalid serialization data for DatePeriod object");
+ zend_throw_error(NULL, "Invalid serialization data for DatePeriod object");
}
}
/* }}} */
@@ -5033,7 +5041,8 @@ static zval *date_period_read_property(zval *object, zval *member, int type, voi
{
zval *zv;
if (type != BP_VAR_IS && type != BP_VAR_R) {
- php_error_docref(NULL, E_ERROR, "Retrieval of DatePeriod properties for modification is unsupported");
+ zend_throw_error(NULL, "Retrieval of DatePeriod properties for modification is unsupported");
+ return &EG(uninitialized_zval);
}
Z_OBJPROP_P(object); /* build properties hash table */
@@ -5051,7 +5060,7 @@ static zval *date_period_read_property(zval *object, zval *member, int type, voi
/* {{{ date_period_write_property */
static void date_period_write_property(zval *object, zval *member, zval *value, void **cache_slot)
{
- php_error_docref(NULL, E_ERROR, "Writing to DatePeriod properties is unsupported");
+ zend_throw_error(NULL, "Writing to DatePeriod properties is unsupported");
}
/* }}} */