diff options
Diffstat (limited to 'ext/date/php_date.c')
-rw-r--r-- | ext/date/php_date.c | 195 |
1 files changed, 96 insertions, 99 deletions
diff --git a/ext/date/php_date.c b/ext/date/php_date.c index 6bc5936a74..03fdc18284 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -409,12 +409,8 @@ static const zend_function_entry date_functions[] = { PHP_FE(mktime, arginfo_mktime) PHP_FE(gmmktime, arginfo_gmmktime) PHP_FE(checkdate, arginfo_checkdate) - -#ifdef HAVE_STRFTIME PHP_FE(strftime, arginfo_strftime) PHP_FE(gmstrftime, arginfo_gmstrftime) -#endif - PHP_FE(time, arginfo_time) PHP_FE(localtime, arginfo_localtime) PHP_FE(getdate, arginfo_getdate) @@ -477,7 +473,7 @@ static const zend_function_entry date_funcs_interface[] = { }; static const zend_function_entry date_funcs_date[] = { - PHP_ME(DateTime, __construct, arginfo_date_create, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC) + PHP_ME(DateTime, __construct, arginfo_date_create, ZEND_ACC_PUBLIC) PHP_ME(DateTime, __wakeup, NULL, ZEND_ACC_PUBLIC) PHP_ME(DateTime, __set_state, arginfo_date_set_state, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) PHP_ME(DateTime, createFromImmutable, arginfo_date_method_create_from_immutable, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) @@ -500,7 +496,7 @@ static const zend_function_entry date_funcs_date[] = { }; static const zend_function_entry date_funcs_immutable[] = { - PHP_ME(DateTimeImmutable, __construct, arginfo_date_create, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC) + PHP_ME(DateTimeImmutable, __construct, arginfo_date_create, ZEND_ACC_PUBLIC) PHP_ME(DateTime, __wakeup, NULL, ZEND_ACC_PUBLIC) PHP_ME(DateTimeImmutable, __set_state, arginfo_date_set_state, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) PHP_ME_MAPPING(createFromFormat, date_create_immutable_from_format, arginfo_date_create_from_format, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) @@ -523,7 +519,7 @@ static const zend_function_entry date_funcs_immutable[] = { }; static const zend_function_entry date_funcs_timezone[] = { - PHP_ME(DateTimeZone, __construct, arginfo_timezone_open, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC) + PHP_ME(DateTimeZone, __construct, arginfo_timezone_open, ZEND_ACC_PUBLIC) PHP_ME(DateTimeZone, __wakeup, NULL, ZEND_ACC_PUBLIC) PHP_ME(DateTimeZone, __set_state, arginfo_date_set_state, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) PHP_ME_MAPPING(getName, timezone_name_get, arginfo_timezone_method_name_get, 0) @@ -536,7 +532,7 @@ static const zend_function_entry date_funcs_timezone[] = { }; static const zend_function_entry date_funcs_interval[] = { - PHP_ME(DateInterval, __construct, arginfo_date_interval_construct, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC) + PHP_ME(DateInterval, __construct, arginfo_date_interval_construct, ZEND_ACC_PUBLIC) PHP_ME(DateInterval, __wakeup, NULL, ZEND_ACC_PUBLIC) PHP_ME(DateInterval, __set_state, arginfo_date_set_state, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) PHP_ME_MAPPING(format, date_interval_format, arginfo_date_method_interval_format, 0) @@ -545,7 +541,7 @@ static const zend_function_entry date_funcs_interval[] = { }; static const zend_function_entry date_funcs_period[] = { - PHP_ME(DatePeriod, __construct, arginfo_date_period_construct, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC) + PHP_ME(DatePeriod, __construct, arginfo_date_period_construct, ZEND_ACC_PUBLIC) PHP_ME(DatePeriod, __wakeup, NULL, ZEND_ACC_PUBLIC) PHP_ME(DatePeriod, __set_state, arginfo_date_set_state, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) PHP_ME(DatePeriod, getStartDate, NULL, ZEND_ACC_PUBLIC) @@ -627,24 +623,6 @@ static zend_object_handlers date_object_handlers_timezone; static zend_object_handlers date_object_handlers_interval; static zend_object_handlers date_object_handlers_period; -#define DATE_SET_CONTEXT \ - zval *object; \ - object = getThis(); \ - -#define DATE_FETCH_OBJECT \ - php_date_obj *obj; \ - DATE_SET_CONTEXT; \ - if (object) { \ - if (zend_parse_parameters_none() == FAILURE) { \ - return; \ - } \ - } else { \ - if (zend_parse_method_parameters(ZEND_NUM_ARGS(), NULL, "O", &object, date_ce_date) == FAILURE) { \ - RETURN_FALSE; \ - } \ - } \ - obj = Z_PHPDATE_P(object); \ - #define DATE_CHECK_INITIALIZED(member, class_name) \ if (!(member)) { \ php_error_docref(NULL, E_WARNING, "The " #class_name " object has not been correctly initialized by its constructor"); \ @@ -668,21 +646,21 @@ static zend_object *date_object_clone_period(zval *this_ptr); static int date_object_compare_date(zval *d1, zval *d2); static HashTable *date_object_get_gc(zval *object, zval **table, int *n); -static HashTable *date_object_get_properties(zval *object); +static HashTable *date_object_get_properties_for(zval *object, zend_prop_purpose purpose); static HashTable *date_object_get_gc_interval(zval *object, zval **table, int *n); static HashTable *date_object_get_properties_interval(zval *object); static HashTable *date_object_get_gc_period(zval *object, zval **table, int *n); static HashTable *date_object_get_properties_period(zval *object); -static HashTable *date_object_get_properties_timezone(zval *object); +static HashTable *date_object_get_properties_for_timezone(zval *object, zend_prop_purpose purpose); static HashTable *date_object_get_gc_timezone(zval *object, zval **table, int *n); static HashTable *date_object_get_debug_info_timezone(zval *object, int *is_temp); static void php_timezone_to_string(php_timezone_obj *tzobj, zval *zv); zval *date_interval_read_property(zval *object, zval *member, int type, void **cache_slot, zval *rv); -void date_interval_write_property(zval *object, zval *member, zval *value, void **cache_slot); +zval *date_interval_write_property(zval *object, zval *member, zval *value, void **cache_slot); static zval *date_interval_get_property_ptr_ptr(zval *object, zval *member, int type, void **cache_slot); static zval *date_period_read_property(zval *object, zval *member, int type, void **cache_slot, zval *rv); -static void date_period_write_property(zval *object, zval *member, zval *value, void **cache_slot); +static zval *date_period_write_property(zval *object, zval *member, zval *value, void **cache_slot); /* {{{ Module struct */ zend_module_entry date_module_entry = { @@ -787,7 +765,7 @@ PHP_RSHUTDOWN_FUNCTION(date) * Wdy, DD Mon YY HH:MM:SS TIMEZONE * There is no hope of having a complete list of timezones. Universal * Time (GMT), the North American timezones (PST, PDT, MST, MDT, CST, - * CDT, EST, EDT) and the +/-hhmm offset specifed in RFC-822 should be supported. + * CDT, EST, EDT) and the +/-hhmm offset specified in RFC-822 should be supported. */ #define DATE_FORMAT_RFC1036 "D, d M y H:i:s O" @@ -1655,7 +1633,6 @@ PHP_FUNCTION(checkdate) } /* }}} */ -#ifdef HAVE_STRFTIME /* {{{ php_strftime - (gm)strftime helper */ PHPAPI void php_strftime(INTERNAL_FUNCTION_PARAMETERS, int gmt) { @@ -1701,20 +1678,20 @@ PHPAPI void php_strftime(INTERNAL_FUNCTION_PARAMETERS, int gmt) ta.tm_yday = timelib_day_of_year(ts->y, ts->m, ts->d); if (gmt) { ta.tm_isdst = 0; -#if HAVE_TM_GMTOFF +#if HAVE_STRUCT_TM_TM_GMTOFF ta.tm_gmtoff = 0; #endif -#if HAVE_TM_ZONE +#if HAVE_STRUCT_TM_TM_ZONE ta.tm_zone = "GMT"; #endif } else { offset = timelib_get_time_zone_info(timestamp, tzi); ta.tm_isdst = offset->is_dst; -#if HAVE_TM_GMTOFF +#if HAVE_STRUCT_TM_TM_GMTOFF ta.tm_gmtoff = offset->offset; #endif -#if HAVE_TM_ZONE +#if HAVE_STRUCT_TM_TM_ZONE ta.tm_zone = offset->abbr; #endif } @@ -1767,7 +1744,6 @@ PHP_FUNCTION(gmstrftime) php_strftime(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1); } /* }}} */ -#endif /* {{{ proto int time(void) Return current UNIX timestamp */ @@ -1785,7 +1761,7 @@ PHP_FUNCTION(time) Returns the results of the C system call localtime as an associative array if the associative_array argument is set to 1 other wise it is a regular array */ PHP_FUNCTION(localtime) { - zend_long timestamp = (zend_long)time(NULL); + zend_long timestamp; zend_bool associative = 0; timelib_tzinfo *tzi; timelib_time *ts; @@ -1796,6 +1772,10 @@ PHP_FUNCTION(localtime) Z_PARAM_BOOL(associative) ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE); + if (ZEND_NUM_ARGS() == 0) { + timestamp = (zend_long) time(NULL); + } + tzi = get_timezone_info(); ts = timelib_time_ctor(); ts->tz_info = tzi; @@ -1834,7 +1814,7 @@ PHP_FUNCTION(localtime) Get date/time information */ PHP_FUNCTION(getdate) { - zend_long timestamp = (zend_long)time(NULL); + zend_long timestamp; timelib_tzinfo *tzi; timelib_time *ts; @@ -1843,6 +1823,10 @@ PHP_FUNCTION(getdate) Z_PARAM_LONG(timestamp) ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE); + if (ZEND_NUM_ARGS() == 0) { + timestamp = (zend_long) time(NULL); + } + tzi = get_timezone_info(); ts = timelib_time_ctor(); ts->tz_info = tzi; @@ -2124,7 +2108,7 @@ static void date_register_classes(void) /* {{{ */ date_object_handlers_date.free_obj = date_object_free_storage_date; date_object_handlers_date.clone_obj = date_object_clone_date; date_object_handlers_date.compare_objects = date_object_compare_date; - date_object_handlers_date.get_properties = date_object_get_properties; + date_object_handlers_date.get_properties_for = date_object_get_properties_for; date_object_handlers_date.get_gc = date_object_get_gc; zend_class_implements(date_ce_date, 1, date_ce_interface); @@ -2134,7 +2118,7 @@ static void date_register_classes(void) /* {{{ */ memcpy(&date_object_handlers_immutable, &std_object_handlers, sizeof(zend_object_handlers)); date_object_handlers_immutable.clone_obj = date_object_clone_date; date_object_handlers_immutable.compare_objects = date_object_compare_date; - date_object_handlers_immutable.get_properties = date_object_get_properties; + date_object_handlers_immutable.get_properties_for = date_object_get_properties_for; date_object_handlers_immutable.get_gc = date_object_get_gc; zend_class_implements(date_ce_immutable, 1, date_ce_interface); @@ -2145,7 +2129,7 @@ static void date_register_classes(void) /* {{{ */ date_object_handlers_timezone.offset = XtOffsetOf(php_timezone_obj, std); date_object_handlers_timezone.free_obj = date_object_free_storage_timezone; date_object_handlers_timezone.clone_obj = date_object_clone_timezone; - date_object_handlers_timezone.get_properties = date_object_get_properties_timezone; + date_object_handlers_timezone.get_properties_for = date_object_get_properties_for_timezone; date_object_handlers_timezone.get_gc = date_object_get_gc_timezone; date_object_handlers_timezone.get_debug_info = date_object_get_debug_info_timezone; @@ -2274,17 +2258,24 @@ static HashTable *date_object_get_gc_timezone(zval *object, zval **table, int *n return zend_std_get_properties(object); } /* }}} */ -static HashTable *date_object_get_properties(zval *object) /* {{{ */ +static HashTable *date_object_get_properties_for(zval *object, zend_prop_purpose purpose) /* {{{ */ { HashTable *props; zval zv; - php_date_obj *dateobj; + php_date_obj *dateobj; + switch (purpose) { + case ZEND_PROP_PURPOSE_DEBUG: + case ZEND_PROP_PURPOSE_SERIALIZE: + case ZEND_PROP_PURPOSE_VAR_EXPORT: + case ZEND_PROP_PURPOSE_JSON: + break; + default: + return zend_std_get_properties_for(object, purpose); + } dateobj = Z_PHPDATE_P(object); - - props = zend_std_get_properties(object); - + props = zend_array_dup(zend_std_get_properties(object)); if (!dateobj->time) { return props; } @@ -2388,16 +2379,24 @@ static void php_timezone_to_string(php_timezone_obj *tzobj, zval *zv) } } -static HashTable *date_object_get_properties_timezone(zval *object) /* {{{ */ +static HashTable *date_object_get_properties_for_timezone(zval *object, zend_prop_purpose purpose) /* {{{ */ { HashTable *props; zval zv; - php_timezone_obj *tzobj; - - tzobj = Z_PHPTIMEZONE_P(object); + php_timezone_obj *tzobj; - props = zend_std_get_properties(object); + switch (purpose) { + case ZEND_PROP_PURPOSE_DEBUG: + case ZEND_PROP_PURPOSE_SERIALIZE: + case ZEND_PROP_PURPOSE_VAR_EXPORT: + case ZEND_PROP_PURPOSE_JSON: + break; + default: + return zend_std_get_properties_for(object, purpose); + } + tzobj = Z_PHPTIMEZONE_P(object); + props = zend_array_dup(zend_std_get_properties(object)); if (!tzobj->initialized) { return props; } @@ -2469,12 +2468,10 @@ static HashTable *date_object_get_properties_interval(zval *object) /* {{{ */ { HashTable *props; zval zv; - php_interval_obj *intervalobj; + php_interval_obj *intervalobj; intervalobj = Z_PHPINTERVAL_P(object); - props = zend_std_get_properties(object); - if (!intervalobj->initialized) { return props; } @@ -2832,7 +2829,7 @@ PHP_METHOD(DateTime, __construct) 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); + php_date_initialize(Z_PHPDATE_P(ZEND_THIS), time_str, time_str_len, NULL, timezone_object, 1); zend_restore_error_handling(&error_handling); } /* }}} */ @@ -2854,7 +2851,7 @@ PHP_METHOD(DateTimeImmutable, __construct) 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); + php_date_initialize(Z_PHPDATE_P(ZEND_THIS), time_str, time_str_len, NULL, timezone_object, 1); zend_restore_error_handling(&error_handling); } /* }}} */ @@ -2998,7 +2995,7 @@ PHP_METHOD(DateTimeImmutable, __set_state) */ PHP_METHOD(DateTime, __wakeup) { - zval *object = getThis(); + zval *object = ZEND_THIS; php_date_obj *dateobj; HashTable *myht; @@ -3275,7 +3272,8 @@ PHP_METHOD(DateTimeImmutable, modify) char *modify; size_t modify_len; - if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Os", &object, date_ce_immutable, &modify, &modify_len) == FAILURE) { + object = ZEND_THIS; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &modify, &modify_len) == FAILURE) { RETURN_FALSE; } @@ -3328,7 +3326,8 @@ PHP_METHOD(DateTimeImmutable, add) { zval *object, *interval, new_object; - if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO", &object, date_ce_immutable, &interval, date_ce_interval) == FAILURE) { + object = ZEND_THIS; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &interval, date_ce_interval) == FAILURE) { RETURN_FALSE; } @@ -3384,7 +3383,8 @@ PHP_METHOD(DateTimeImmutable, sub) { zval *object, *interval, new_object; - if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO", &object, date_ce_immutable, &interval, date_ce_interval) == FAILURE) { + object = ZEND_THIS; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &interval, date_ce_interval) == FAILURE) { RETURN_FALSE; } @@ -3488,7 +3488,8 @@ PHP_METHOD(DateTimeImmutable, setTimezone) zval *object, new_object; zval *timezone_object; - if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO", &object, date_ce_immutable, &timezone_object, date_ce_timezone) == FAILURE) { + object = ZEND_THIS; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &timezone_object, date_ce_timezone) == FAILURE) { RETURN_FALSE; } @@ -3573,7 +3574,8 @@ PHP_METHOD(DateTimeImmutable, setTime) zval *object, new_object; zend_long h, i, s = 0, ms = 0; - if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oll|ll", &object, date_ce_immutable, &h, &i, &s, &ms) == FAILURE) { + object = ZEND_THIS; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "ll|ll", &h, &i, &s, &ms) == FAILURE) { RETURN_FALSE; } @@ -3622,7 +3624,8 @@ PHP_METHOD(DateTimeImmutable, setDate) zval *object, new_object; zend_long y, m, d; - if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Olll", &object, date_ce_immutable, &y, &m, &d) == FAILURE) { + object = ZEND_THIS; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "lll", &y, &m, &d) == FAILURE) { RETURN_FALSE; } @@ -3675,7 +3678,8 @@ PHP_METHOD(DateTimeImmutable, setISODate) zval *object, new_object; zend_long y, w, d = 1; - if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oll|l", &object, date_ce_immutable, &y, &w, &d) == FAILURE) { + object = ZEND_THIS; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "ll|l", &y, &w, &d) == FAILURE) { RETURN_FALSE; } @@ -3723,7 +3727,8 @@ PHP_METHOD(DateTimeImmutable, setTimestamp) zval *object, new_object; zend_long timestamp; - if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ol", &object, date_ce_immutable, ×tamp) == FAILURE) { + object = ZEND_THIS; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", ×tamp) == FAILURE) { RETURN_FALSE; } @@ -3849,7 +3854,7 @@ PHP_METHOD(DateTimeZone, __construct) ZEND_PARSE_PARAMETERS_END(); zend_replace_error_handling(EH_THROW, NULL, &error_handling); - tzobj = Z_PHPTIMEZONE_P(getThis()); + tzobj = Z_PHPTIMEZONE_P(ZEND_THIS); timezone_initialize(tzobj, ZSTR_VAL(tz), ZSTR_LEN(tz)); zend_restore_error_handling(&error_handling); } @@ -3904,7 +3909,7 @@ PHP_METHOD(DateTimeZone, __set_state) * */ PHP_METHOD(DateTimeZone, __wakeup) { - zval *object = getThis(); + zval *object = ZEND_THIS; php_timezone_obj *tzobj; HashTable *myht; @@ -3936,7 +3941,7 @@ PHP_FUNCTION(timezone_name_get) /* }}} */ /* {{{ proto string timezone_name_from_abbr(string abbr[, int gmtOffset[, int isdst]]) - Returns the timezone name from abbrevation + Returns the timezone name from abbreviation */ PHP_FUNCTION(timezone_name_from_abbr) { @@ -4209,7 +4214,7 @@ zval *date_interval_read_property(zval *object, zval *member, int type, void **c /* }}} */ /* {{{ date_interval_write_property */ -void date_interval_write_property(zval *object, zval *member, zval *value, void **cache_slot) +zval *date_interval_write_property(zval *object, zval *member, zval *value, void **cache_slot) { php_interval_obj *obj; zval tmp_member; @@ -4223,17 +4228,17 @@ void date_interval_write_property(zval *object, zval *member, zval *value, void obj = Z_PHPINTERVAL_P(object); if (!obj->initialized) { - zend_std_write_property(object, member, value, cache_slot); + value = zend_std_write_property(object, member, value, cache_slot); if (member == &tmp_member) { zval_ptr_dtor_str(&tmp_member); } - return; + return value; } #define SET_VALUE_FROM_STRUCT(n,m) \ if (strcmp(Z_STRVAL_P(member), m) == 0) { \ obj->diff->n = zval_get_long(value); \ - break; \ + break; \ } do { @@ -4249,12 +4254,14 @@ void date_interval_write_property(zval *object, zval *member, zval *value, void } SET_VALUE_FROM_STRUCT(invert, "invert"); /* didn't find any */ - zend_std_write_property(object, member, value, cache_slot); + value = zend_std_write_property(object, member, value, cache_slot); } while(0); if (member == &tmp_member) { zval_ptr_dtor_str(&tmp_member); } + + return value; } /* }}} */ @@ -4307,7 +4314,7 @@ PHP_METHOD(DateInterval, __construct) zend_replace_error_handling(EH_THROW, NULL, &error_handling); if (date_interval_initialize(&reltime, ZSTR_VAL(interval_string), ZSTR_LEN(interval_string)) == SUCCESS) { - php_interval_obj *diobj = Z_PHPINTERVAL_P(getThis()); + php_interval_obj *diobj = Z_PHPINTERVAL_P(ZEND_THIS); diobj->diff = reltime; diobj->initialized = 1; } @@ -4405,7 +4412,7 @@ PHP_METHOD(DateInterval, __set_state) */ PHP_METHOD(DateInterval, __wakeup) { - zval *object = getThis(); + zval *object = ZEND_THIS; php_interval_obj *intobj; HashTable *myht; @@ -4590,7 +4597,7 @@ PHP_METHOD(DatePeriod, __construct) } } - dpobj = Z_PHPPERIOD_P(getThis()); + dpobj = Z_PHPPERIOD_P(ZEND_THIS); dpobj->current = NULL; if (isostr) { @@ -4668,7 +4675,7 @@ PHP_METHOD(DatePeriod, getStartDate) return; } - dpobj = Z_PHPPERIOD_P(getThis()); + dpobj = Z_PHPPERIOD_P(ZEND_THIS); php_date_instantiate(dpobj->start_ce, return_value); dateobj = Z_PHPDATE_P(return_value); @@ -4695,7 +4702,7 @@ PHP_METHOD(DatePeriod, getEndDate) return; } - dpobj = Z_PHPPERIOD_P(getThis()); + dpobj = Z_PHPPERIOD_P(ZEND_THIS); if (!dpobj->end) { return; @@ -4726,7 +4733,7 @@ PHP_METHOD(DatePeriod, getDateInterval) return; } - dpobj = Z_PHPPERIOD_P(getThis()); + dpobj = Z_PHPPERIOD_P(ZEND_THIS); php_date_instantiate(date_ce_interval, return_value); diobj = Z_PHPINTERVAL_P(return_value); @@ -4740,16 +4747,16 @@ PHP_METHOD(DatePeriod, getDateInterval) */ PHP_METHOD(DatePeriod, getRecurrences) { - php_period_obj *dpobj; + php_period_obj *dpobj; if (zend_parse_parameters_none() == FAILURE) { - return; + return; } - dpobj = Z_PHPPERIOD_P(getThis()); + dpobj = Z_PHPPERIOD_P(ZEND_THIS); if (0 == dpobj->recurrences - dpobj->include_start_date) { - return; + return; } RETURN_LONG(dpobj->recurrences - dpobj->include_start_date); @@ -5129,9 +5136,7 @@ static HashTable *date_object_get_properties_period(zval *object) /* {{{ */ php_period_obj *period_obj; period_obj = Z_PHPPERIOD_P(object); - props = zend_std_get_properties(object); - if (!period_obj->start) { return props; } @@ -5293,7 +5298,7 @@ PHP_METHOD(DatePeriod, __set_state) */ PHP_METHOD(DatePeriod, __wakeup) { - zval *object = getThis(); + zval *object = ZEND_THIS; php_period_obj *period_obj; HashTable *myht; @@ -5322,17 +5327,9 @@ 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) +static zval *date_period_write_property(zval *object, zval *member, zval *value, void **cache_slot) { zend_throw_error(NULL, "Writing to DatePeriod properties is unsupported"); + return value; } /* }}} */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: fdm=marker - * vim: noet sw=4 ts=4 - */ |