diff options
Diffstat (limited to 'ext/date/php_date.c')
| -rw-r--r-- | ext/date/php_date.c | 760 |
1 files changed, 169 insertions, 591 deletions
diff --git a/ext/date/php_date.c b/ext/date/php_date.c index 65e8213dda..cd22c76372 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -1,7 +1,5 @@ /* +----------------------------------------------------------------------+ - | PHP Version 7 | - +----------------------------------------------------------------------+ | Copyright (c) The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | @@ -76,345 +74,7 @@ PHPAPI time_t php_time() #endif } -/* {{{ arginfo */ -ZEND_BEGIN_ARG_INFO_EX(arginfo_date, 0, 0, 1) - ZEND_ARG_INFO(0, format) - ZEND_ARG_INFO(0, timestamp) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_gmdate, 0, 0, 1) - ZEND_ARG_INFO(0, format) - ZEND_ARG_INFO(0, timestamp) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_idate, 0, 0, 1) - ZEND_ARG_INFO(0, format) - ZEND_ARG_INFO(0, timestamp) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_strtotime, 0, 0, 1) - ZEND_ARG_INFO(0, time) - ZEND_ARG_INFO(0, now) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_mktime, 0, 0, 0) - ZEND_ARG_INFO(0, hour) - ZEND_ARG_INFO(0, min) - ZEND_ARG_INFO(0, sec) - ZEND_ARG_INFO(0, mon) - ZEND_ARG_INFO(0, day) - ZEND_ARG_INFO(0, year) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_gmmktime, 0, 0, 0) - ZEND_ARG_INFO(0, hour) - ZEND_ARG_INFO(0, min) - ZEND_ARG_INFO(0, sec) - ZEND_ARG_INFO(0, mon) - ZEND_ARG_INFO(0, day) - ZEND_ARG_INFO(0, year) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO(arginfo_checkdate, 0) - ZEND_ARG_INFO(0, month) - ZEND_ARG_INFO(0, day) - ZEND_ARG_INFO(0, year) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_strftime, 0, 0, 1) - ZEND_ARG_INFO(0, format) - ZEND_ARG_INFO(0, timestamp) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_gmstrftime, 0, 0, 1) - ZEND_ARG_INFO(0, format) - ZEND_ARG_INFO(0, timestamp) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO(arginfo_time, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_localtime, 0, 0, 0) - ZEND_ARG_INFO(0, timestamp) - ZEND_ARG_INFO(0, associative_array) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_getdate, 0, 0, 0) - ZEND_ARG_INFO(0, timestamp) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO(arginfo_date_default_timezone_set, 0) - ZEND_ARG_INFO(0, timezone_identifier) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO(arginfo_date_default_timezone_get, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_date_sunrise, 0, 0, 1) - ZEND_ARG_INFO(0, time) - ZEND_ARG_INFO(0, format) - ZEND_ARG_INFO(0, latitude) - ZEND_ARG_INFO(0, longitude) - ZEND_ARG_INFO(0, zenith) - ZEND_ARG_INFO(0, gmt_offset) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_date_sunset, 0, 0, 1) - ZEND_ARG_INFO(0, time) - ZEND_ARG_INFO(0, format) - ZEND_ARG_INFO(0, latitude) - ZEND_ARG_INFO(0, longitude) - ZEND_ARG_INFO(0, zenith) - ZEND_ARG_INFO(0, gmt_offset) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO(arginfo_date_sun_info, 0) - ZEND_ARG_INFO(0, time) - ZEND_ARG_INFO(0, latitude) - ZEND_ARG_INFO(0, longitude) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_date_create, 0, 0, 0) - ZEND_ARG_INFO(0, time) - ZEND_ARG_INFO(0, timezone) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_date_create_from_format, 0, 0, 2) - ZEND_ARG_INFO(0, format) - ZEND_ARG_INFO(0, time) - ZEND_ARG_OBJ_INFO(0, object, DateTimeZone, 1) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_date_parse, 0, 0, 1) - ZEND_ARG_INFO(0, date) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_date_parse_from_format, 0, 0, 2) - ZEND_ARG_INFO(0, format) - ZEND_ARG_INFO(0, date) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO(arginfo_date_get_last_errors, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_date_format, 0, 0, 2) - ZEND_ARG_INFO(0, object) - ZEND_ARG_INFO(0, format) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_date_method_format, 0, 0, 1) - ZEND_ARG_INFO(0, format) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_date_modify, 0, 0, 2) - ZEND_ARG_INFO(0, object) - ZEND_ARG_INFO(0, modify) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_date_method_modify, 0, 0, 1) - ZEND_ARG_INFO(0, modify) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_date_add, 0, 0, 2) - ZEND_ARG_INFO(0, object) - ZEND_ARG_INFO(0, interval) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_date_method_add, 0, 0, 1) - ZEND_ARG_INFO(0, interval) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_date_sub, 0, 0, 2) - ZEND_ARG_INFO(0, object) - ZEND_ARG_INFO(0, interval) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_date_method_sub, 0, 0, 1) - ZEND_ARG_INFO(0, interval) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_date_timezone_get, 0, 0, 1) - ZEND_ARG_INFO(0, object) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO(arginfo_date_method_timezone_get, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_date_timezone_set, 0, 0, 2) - ZEND_ARG_INFO(0, object) - ZEND_ARG_INFO(0, timezone) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_date_method_timezone_set, 0, 0, 1) - ZEND_ARG_INFO(0, timezone) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_date_offset_get, 0, 0, 1) - ZEND_ARG_INFO(0, object) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO(arginfo_date_method_offset_get, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_date_diff, 0, 0, 2) - ZEND_ARG_INFO(0, object) - ZEND_ARG_INFO(0, object2) - ZEND_ARG_INFO(0, absolute) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_date_method_diff, 0, 0, 1) - ZEND_ARG_INFO(0, object) - ZEND_ARG_INFO(0, absolute) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_date_time_set, 0, 0, 3) - ZEND_ARG_INFO(0, object) - ZEND_ARG_INFO(0, hour) - ZEND_ARG_INFO(0, minute) - ZEND_ARG_INFO(0, second) - ZEND_ARG_INFO(0, microseconds) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_date_method_time_set, 0, 0, 2) - ZEND_ARG_INFO(0, hour) - ZEND_ARG_INFO(0, minute) - ZEND_ARG_INFO(0, second) - ZEND_ARG_INFO(0, microseconds) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_date_date_set, 0, 0, 4) - ZEND_ARG_INFO(0, object) - ZEND_ARG_INFO(0, year) - ZEND_ARG_INFO(0, month) - ZEND_ARG_INFO(0, day) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_date_method_date_set, 0, 0, 3) - ZEND_ARG_INFO(0, year) - ZEND_ARG_INFO(0, month) - ZEND_ARG_INFO(0, day) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_date_isodate_set, 0, 0, 3) - ZEND_ARG_INFO(0, object) - ZEND_ARG_INFO(0, year) - ZEND_ARG_INFO(0, week) - ZEND_ARG_INFO(0, day) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_date_method_isodate_set, 0, 0, 2) - ZEND_ARG_INFO(0, year) - ZEND_ARG_INFO(0, week) - ZEND_ARG_INFO(0, day) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_date_timestamp_set, 0, 0, 2) - ZEND_ARG_INFO(0, object) - ZEND_ARG_INFO(0, unixtimestamp) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_date_method_timestamp_set, 0, 0, 1) - ZEND_ARG_INFO(0, unixtimestamp) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_date_timestamp_get, 0, 0, 1) - ZEND_ARG_INFO(0, object) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO(arginfo_date_method_timestamp_get, 0) -ZEND_END_ARG_INFO() - - -ZEND_BEGIN_ARG_INFO_EX(arginfo_date_method_create_from_immutable, 0, 0, 1) - ZEND_ARG_INFO(0, DateTimeImmutable) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_date_method_create_from_mutable, 0, 0, 1) - ZEND_ARG_INFO(0, DateTime) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_timezone_open, 0, 0, 1) - ZEND_ARG_INFO(0, timezone) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_timezone_name_get, 0, 0, 1) - ZEND_ARG_INFO(0, object) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO(arginfo_timezone_method_name_get, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_timezone_name_from_abbr, 0, 0, 1) - ZEND_ARG_INFO(0, abbr) - ZEND_ARG_INFO(0, gmtoffset) - ZEND_ARG_INFO(0, isdst) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_timezone_offset_get, 0, 0, 2) - ZEND_ARG_OBJ_INFO(0, object, DateTimeZone, 0) - ZEND_ARG_OBJ_INFO(0, datetime, DateTimeInterface, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_timezone_method_offset_get, 0, 0, 1) - ZEND_ARG_INFO(0, object) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_timezone_transitions_get, 0, 0, 1) - ZEND_ARG_INFO(0, object) - ZEND_ARG_INFO(0, timestamp_begin) - ZEND_ARG_INFO(0, timestamp_end) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_timezone_method_transitions_get, 0, 0, 0) - ZEND_ARG_INFO(0, timestamp_begin) - ZEND_ARG_INFO(0, timestamp_end) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_timezone_location_get, 0, 0, 1) - ZEND_ARG_INFO(0, object) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO(arginfo_timezone_method_location_get, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_timezone_identifiers_list, 0, 0, 0) - ZEND_ARG_INFO(0, what) - ZEND_ARG_INFO(0, country) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO(arginfo_timezone_abbreviations_list, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO(arginfo_timezone_version_get, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_date_interval_create_from_date_string, 0, 0, 1) - ZEND_ARG_INFO(0, time) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_date_interval_format, 0, 0, 2) - ZEND_ARG_INFO(0, object) - ZEND_ARG_INFO(0, format) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO(arginfo_date_method_interval_format, 0) - ZEND_ARG_INFO(0, format) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_date_period_construct, 0, 0, 3) - ZEND_ARG_INFO(0, start) - ZEND_ARG_INFO(0, interval) - ZEND_ARG_INFO(0, end) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_date_set_state, 0, 0, 1) - ZEND_ARG_ARRAY_INFO(0, array, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_date_interval_construct, 0, 0, 1) - ZEND_ARG_INFO(0, interval_spec) -ZEND_END_ARG_INFO() -/* }}} */ +#include "php_date_arginfo.h" /* {{{ Function table */ static const zend_function_entry date_functions[] = { @@ -479,91 +139,91 @@ static const zend_function_entry date_functions[] = { }; static const zend_function_entry date_funcs_interface[] = { - PHP_ABSTRACT_ME(DateTimeInterface, format, arginfo_date_method_format) - PHP_ABSTRACT_ME(DateTimeInterface, getTimezone, arginfo_date_method_timezone_get) - PHP_ABSTRACT_ME(DateTimeInterface, getOffset, arginfo_date_method_offset_get) - PHP_ABSTRACT_ME(DateTimeInterface, getTimestamp, arginfo_date_method_timestamp_get) - PHP_ABSTRACT_ME(DateTimeInterface, diff, arginfo_date_method_diff) - PHP_ABSTRACT_ME(DateTimeInterface, __wakeup, NULL) + PHP_ABSTRACT_ME(DateTimeInterface, format, arginfo_class_DateTimeInterface_format) + PHP_ABSTRACT_ME(DateTimeInterface, getTimezone, arginfo_class_DateTimeInterface_getTimezone) + PHP_ABSTRACT_ME(DateTimeInterface, getOffset, arginfo_class_DateTimeInterface_getOffset) + PHP_ABSTRACT_ME(DateTimeInterface, getTimestamp, arginfo_class_DateTimeInterface_getTimestamp) + PHP_ABSTRACT_ME(DateTimeInterface, diff, arginfo_class_DateTimeInterface_diff) + PHP_ABSTRACT_ME(DateTimeInterface, __wakeup, arginfo_class_DateTimeInterface___wakeup) PHP_FE_END }; static const zend_function_entry date_funcs_date[] = { - 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) - PHP_ME_MAPPING(createFromFormat, date_create_from_format, arginfo_date_create_from_format, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) - PHP_ME_MAPPING(getLastErrors, date_get_last_errors, arginfo_date_get_last_errors, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) - PHP_ME_MAPPING(format, date_format, arginfo_date_method_format, 0) - PHP_ME_MAPPING(modify, date_modify, arginfo_date_method_modify, 0) - PHP_ME_MAPPING(add, date_add, arginfo_date_method_add, 0) - PHP_ME_MAPPING(sub, date_sub, arginfo_date_method_sub, 0) - PHP_ME_MAPPING(getTimezone, date_timezone_get, arginfo_date_method_timezone_get, 0) - PHP_ME_MAPPING(setTimezone, date_timezone_set, arginfo_date_method_timezone_set, 0) - PHP_ME_MAPPING(getOffset, date_offset_get, arginfo_date_method_offset_get, 0) - PHP_ME_MAPPING(setTime, date_time_set, arginfo_date_method_time_set, 0) - PHP_ME_MAPPING(setDate, date_date_set, arginfo_date_method_date_set, 0) - PHP_ME_MAPPING(setISODate, date_isodate_set, arginfo_date_method_isodate_set, 0) - PHP_ME_MAPPING(setTimestamp, date_timestamp_set, arginfo_date_method_timestamp_set, 0) - PHP_ME_MAPPING(getTimestamp, date_timestamp_get, arginfo_date_method_timestamp_get, 0) - PHP_ME_MAPPING(diff, date_diff, arginfo_date_method_diff, 0) + PHP_ME(DateTime, __construct, arginfo_class_DateTime___construct, ZEND_ACC_PUBLIC) + PHP_ME(DateTime, __wakeup, arginfo_class_DateTimeInterface___wakeup, ZEND_ACC_PUBLIC) + PHP_ME(DateTime, __set_state, arginfo_class_DateTime___set_state, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) + PHP_ME(DateTime, createFromImmutable, arginfo_class_DateTime_createFromImmutable, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) + PHP_ME_MAPPING(createFromFormat, date_create_from_format, arginfo_class_DateTime_createFromFormat, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) + PHP_ME_MAPPING(getLastErrors, date_get_last_errors, arginfo_class_DateTime_getLastErrors, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) + PHP_ME_MAPPING(format, date_format, arginfo_class_DateTimeInterface_format, 0) + PHP_ME_MAPPING(modify, date_modify, arginfo_class_DateTime_modify, 0) + PHP_ME_MAPPING(add, date_add, arginfo_class_DateTime_add, 0) + PHP_ME_MAPPING(sub, date_sub, arginfo_class_DateTime_sub, 0) + PHP_ME_MAPPING(getTimezone, date_timezone_get, arginfo_class_DateTimeInterface_getTimezone, 0) + PHP_ME_MAPPING(setTimezone, date_timezone_set, arginfo_class_DateTime_setTimezone, 0) + PHP_ME_MAPPING(getOffset, date_offset_get, arginfo_class_DateTimeInterface_getOffset, 0) + PHP_ME_MAPPING(setTime, date_time_set, arginfo_class_DateTime_setTime, 0) + PHP_ME_MAPPING(setDate, date_date_set, arginfo_class_DateTime_setDate, 0) + PHP_ME_MAPPING(setISODate, date_isodate_set, arginfo_class_DateTime_setISODate, 0) + PHP_ME_MAPPING(setTimestamp, date_timestamp_set, arginfo_class_DateTime_setTimestamp, 0) + PHP_ME_MAPPING(getTimestamp, date_timestamp_get, arginfo_class_DateTimeInterface_getTimestamp, 0) + PHP_ME_MAPPING(diff, date_diff, arginfo_class_DateTimeInterface_diff, 0) PHP_FE_END }; static const zend_function_entry date_funcs_immutable[] = { - 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(DateTimeImmutable, __construct, arginfo_class_DateTimeImmutable___construct, ZEND_ACC_PUBLIC) + PHP_ME(DateTime, __wakeup, arginfo_class_DateTimeInterface___wakeup, ZEND_ACC_PUBLIC) + PHP_ME(DateTimeImmutable, __set_state, arginfo_class_DateTimeImmutable___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) PHP_ME_MAPPING(getLastErrors, date_get_last_errors, arginfo_date_get_last_errors, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) - PHP_ME_MAPPING(format, date_format, arginfo_date_method_format, 0) - PHP_ME_MAPPING(getTimezone, date_timezone_get, arginfo_date_method_timezone_get, 0) - PHP_ME_MAPPING(getOffset, date_offset_get, arginfo_date_method_offset_get, 0) - PHP_ME_MAPPING(getTimestamp, date_timestamp_get, arginfo_date_method_timestamp_get, 0) - PHP_ME_MAPPING(diff, date_diff, arginfo_date_method_diff, 0) - PHP_ME(DateTimeImmutable, modify, arginfo_date_method_modify, 0) - PHP_ME(DateTimeImmutable, add, arginfo_date_method_add, 0) - PHP_ME(DateTimeImmutable, sub, arginfo_date_method_sub, 0) - PHP_ME(DateTimeImmutable, setTimezone, arginfo_date_method_timezone_set, 0) - PHP_ME(DateTimeImmutable, setTime, arginfo_date_method_time_set, 0) - PHP_ME(DateTimeImmutable, setDate, arginfo_date_method_date_set, 0) - PHP_ME(DateTimeImmutable, setISODate, arginfo_date_method_isodate_set, 0) - PHP_ME(DateTimeImmutable, setTimestamp, arginfo_date_method_timestamp_set, 0) - PHP_ME(DateTimeImmutable, createFromMutable, arginfo_date_method_create_from_mutable, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) + PHP_ME_MAPPING(format, date_format, arginfo_class_DateTimeInterface_format, 0) + PHP_ME_MAPPING(getTimezone, date_timezone_get, arginfo_class_DateTimeInterface_getTimezone, 0) + PHP_ME_MAPPING(getOffset, date_offset_get, arginfo_class_DateTimeInterface_getOffset, 0) + PHP_ME_MAPPING(getTimestamp, date_timestamp_get, arginfo_class_DateTimeInterface_getTimestamp, 0) + PHP_ME_MAPPING(diff, date_diff, arginfo_class_DateTimeInterface_diff, 0) + PHP_ME(DateTimeImmutable, modify, arginfo_class_DateTimeImmutable_modify, 0) + PHP_ME(DateTimeImmutable, add, arginfo_class_DateTimeImmutable_add, 0) + PHP_ME(DateTimeImmutable, sub, arginfo_class_DateTimeImmutable_sub, 0) + PHP_ME(DateTimeImmutable, setTimezone, arginfo_class_DateTimeImmutable_setTimezone, 0) + PHP_ME(DateTimeImmutable, setTime, arginfo_class_DateTimeImmutable_setTime, 0) + PHP_ME(DateTimeImmutable, setDate, arginfo_class_DateTimeImmutable_setDate, 0) + PHP_ME(DateTimeImmutable, setISODate, arginfo_class_DateTimeImmutable_setISODate, 0) + PHP_ME(DateTimeImmutable, setTimestamp, arginfo_class_DateTimeImmutable_setTimestamp, 0) + PHP_ME(DateTimeImmutable, createFromMutable, arginfo_class_DateTimeImmutable_createFromMutable, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) PHP_FE_END }; static const zend_function_entry date_funcs_timezone[] = { - 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) - PHP_ME_MAPPING(getOffset, timezone_offset_get, arginfo_timezone_method_offset_get, 0) - PHP_ME_MAPPING(getTransitions, timezone_transitions_get, arginfo_timezone_method_transitions_get, 0) - PHP_ME_MAPPING(getLocation, timezone_location_get, arginfo_timezone_method_location_get, 0) - PHP_ME_MAPPING(listAbbreviations, timezone_abbreviations_list, arginfo_timezone_abbreviations_list, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) - PHP_ME_MAPPING(listIdentifiers, timezone_identifiers_list, arginfo_timezone_identifiers_list, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) + PHP_ME(DateTimeZone, __construct, arginfo_class_DateTimeZone___construct, ZEND_ACC_PUBLIC) + PHP_ME(DateTimeZone, __wakeup, arginfo_class_DateTimeZone___wakeup, ZEND_ACC_PUBLIC) + PHP_ME(DateTimeZone, __set_state, arginfo_class_DateTimeZone___set_state, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) + PHP_ME_MAPPING(getName, timezone_name_get, arginfo_class_DateTimeZone_getName, 0) + PHP_ME_MAPPING(getOffset, timezone_offset_get, arginfo_class_DateTimeZone_getOffset, 0) + PHP_ME_MAPPING(getTransitions, timezone_transitions_get, arginfo_class_DateTimeZone_getTransitions, 0) + PHP_ME_MAPPING(getLocation, timezone_location_get, arginfo_class_DateTimeZone_getLocation, 0) + PHP_ME_MAPPING(listAbbreviations, timezone_abbreviations_list, arginfo_class_DateTimeZone_listAbbreviations, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) + PHP_ME_MAPPING(listIdentifiers, timezone_identifiers_list, arginfo_class_DateTimeZone_listIdentifiers, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) PHP_FE_END }; static const zend_function_entry date_funcs_interval[] = { - 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) - PHP_ME_MAPPING(createFromDateString, date_interval_create_from_date_string, arginfo_date_interval_create_from_date_string, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) + PHP_ME(DateInterval, __construct, arginfo_class_DateInterval___construct, ZEND_ACC_PUBLIC) + PHP_ME(DateInterval, __wakeup, arginfo_class_DateInterval___wakeup, ZEND_ACC_PUBLIC) + PHP_ME(DateInterval, __set_state, arginfo_class_DateInterval___set_state, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) + PHP_ME_MAPPING(format, date_interval_format, arginfo_class_DateInterval_format, 0) + PHP_ME_MAPPING(createFromDateString, date_interval_create_from_date_string, arginfo_class_DateInterval_createFromDateString, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) PHP_FE_END }; static const zend_function_entry date_funcs_period[] = { - 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) - PHP_ME(DatePeriod, getEndDate, NULL, ZEND_ACC_PUBLIC) - PHP_ME(DatePeriod, getDateInterval, NULL, ZEND_ACC_PUBLIC) - PHP_ME(DatePeriod, getRecurrences, NULL, ZEND_ACC_PUBLIC) + PHP_ME(DatePeriod, __construct, arginfo_class_DatePeriod___construct, ZEND_ACC_PUBLIC) + PHP_ME(DatePeriod, __wakeup, arginfo_class_DatePeriod___wakeup, ZEND_ACC_PUBLIC) + PHP_ME(DatePeriod, __set_state, arginfo_class_DatePeriod___set_state, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) + PHP_ME(DatePeriod, getStartDate, arginfo_class_DatePeriod_getStartDate, ZEND_ACC_PUBLIC) + PHP_ME(DatePeriod, getEndDate, arginfo_class_DatePeriod_getEndDate, ZEND_ACC_PUBLIC) + PHP_ME(DatePeriod, getDateInterval, arginfo_class_DatePeriod_getDateInterval, ZEND_ACC_PUBLIC) + PHP_ME(DatePeriod, getRecurrences, arginfo_class_DatePeriod_getRecurrences, ZEND_ACC_PUBLIC) PHP_FE_END }; @@ -581,11 +241,11 @@ int php_date_global_timezone_db_enabled; #define DATE_DEFAULT_LATITUDE "31.7667" #define DATE_DEFAULT_LONGITUDE "35.2333" -/* on 90'35; common sunset declaration (start of sun body appear) */ -#define DATE_SUNSET_ZENITH "90.583333" +/* on 90'50; common sunset declaration (start of sun body appear) */ +#define DATE_SUNSET_ZENITH "90.833333" -/* on 90'35; common sunrise declaration (sun body disappeared) */ -#define DATE_SUNRISE_ZENITH "90.583333" +/* on 90'50; common sunrise declaration (sun body disappeared) */ +#define DATE_SUNRISE_ZENITH "90.833333" static PHP_INI_MH(OnUpdate_date_timezone); @@ -641,8 +301,8 @@ static zend_object_handlers date_object_handlers_period; #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"); \ - RETURN_FALSE; \ + zend_throw_error(NULL, "The " #class_name " object has not been correctly initialized by its constructor"); \ + return; \ } static void date_object_free_storage_date(zend_object *object); @@ -655,30 +315,30 @@ static zend_object *date_object_new_timezone(zend_class_entry *class_type); static zend_object *date_object_new_interval(zend_class_entry *class_type); static zend_object *date_object_new_period(zend_class_entry *class_type); -static zend_object *date_object_clone_date(zval *this_ptr); -static zend_object *date_object_clone_timezone(zval *this_ptr); -static zend_object *date_object_clone_interval(zval *this_ptr); -static zend_object *date_object_clone_period(zval *this_ptr); +static zend_object *date_object_clone_date(zend_object *this_ptr); +static zend_object *date_object_clone_timezone(zend_object *this_ptr); +static zend_object *date_object_clone_interval(zend_object *this_ptr); +static zend_object *date_object_clone_period(zend_object *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_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_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 HashTable *date_object_get_gc(zend_object *object, zval **table, int *n); +static HashTable *date_object_get_properties_for(zend_object *object, zend_prop_purpose purpose); +static HashTable *date_object_get_gc_interval(zend_object *object, zval **table, int *n); +static HashTable *date_object_get_properties_interval(zend_object *object); +static HashTable *date_object_get_gc_period(zend_object *object, zval **table, int *n); +static HashTable *date_object_get_properties_period(zend_object *object); +static HashTable *date_object_get_properties_for_timezone(zend_object *object, zend_prop_purpose purpose); +static HashTable *date_object_get_gc_timezone(zend_object *object, zval **table, int *n); +static HashTable *date_object_get_debug_info_timezone(zend_object *object, int *is_temp); static void php_timezone_to_string(php_timezone_obj *tzobj, zval *zv); static int date_interval_compare_objects(zval *o1, zval *o2); -static zval *date_interval_read_property(zval *object, zval *member, int type, void **cache_slot, zval *rv); -static 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 zval *date_period_write_property(zval *object, zval *member, zval *value, void **cache_slot); -static zval *date_period_get_property_ptr_ptr(zval *object, zval *member, int type, void **cache_slot); +static zval *date_interval_read_property(zend_object *object, zend_string *member, int type, void **cache_slot, zval *rv); +static zval *date_interval_write_property(zend_object *object, zend_string *member, zval *value, void **cache_slot); +static zval *date_interval_get_property_ptr_ptr(zend_object *object, zend_string *member, int type, void **cache_slot); +static zval *date_period_read_property(zend_object *object, zend_string *name, int type, void **cache_slot, zval *rv); +static zval *date_period_write_property(zend_object *object, zend_string *name, zval *value, void **cache_slot); +static zval *date_period_get_property_ptr_ptr(zend_object *object, zend_string *name, int type, void **cache_slot); /* {{{ Module struct */ zend_module_entry date_module_entry = { @@ -1546,9 +1206,9 @@ PHPAPI void php_mktime(INTERNAL_FUNCTION_PARAMETERS, int gmt) zend_long ts, adjust_seconds = 0; int error; - ZEND_PARSE_PARAMETERS_START(0, 6) - Z_PARAM_OPTIONAL + ZEND_PARSE_PARAMETERS_START(1, 6) Z_PARAM_LONG(hou) + Z_PARAM_OPTIONAL Z_PARAM_LONG(min) Z_PARAM_LONG(sec) Z_PARAM_LONG(mon) @@ -1568,8 +1228,6 @@ PHPAPI void php_mktime(INTERNAL_FUNCTION_PARAMETERS, int gmt) } /* Fill in the new data */ switch (ZEND_NUM_ARGS()) { - case 7: - /* break intentionally missing */ case 6: if (yea >= 0 && yea < 70) { yea += 2000; @@ -1593,8 +1251,7 @@ PHPAPI void php_mktime(INTERNAL_FUNCTION_PARAMETERS, int gmt) case 1: now->h = hou; break; - default: - php_error_docref(NULL, E_DEPRECATED, "You should be using the time() function instead"); + EMPTY_SWITCH_DEFAULT_CASE() } /* Update the timestamp */ if (gmt) { @@ -1616,7 +1273,7 @@ PHPAPI void php_mktime(INTERNAL_FUNCTION_PARAMETERS, int gmt) } /* }}} */ -/* {{{ proto int mktime([int hour [, int min [, int sec [, int mon [, int day [, int year]]]]]]) +/* {{{ proto int mktime(int hour [, int min [, int sec [, int mon [, int day [, int year]]]]]) Get UNIX timestamp for a date */ PHP_FUNCTION(mktime) { @@ -1624,7 +1281,7 @@ PHP_FUNCTION(mktime) } /* }}} */ -/* {{{ proto int gmmktime([int hour [, int min [, int sec [, int mon [, int day [, int year]]]]]]) +/* {{{ proto int gmmktime(int hour [, int min [, int sec [, int mon [, int day [, int year]]]]]) Get UNIX timestamp for a GMT date */ PHP_FUNCTION(gmmktime) { @@ -2047,35 +1704,21 @@ static int implement_date_interface_handler(zend_class_entry *interface, zend_cl return SUCCESS; } /* }}} */ -static int date_interval_has_property(zval *object, zval *member, int type, void **cache_slot) /* {{{ */ +static int date_interval_has_property(zend_object *object, zend_string *name, int type, void **cache_slot) /* {{{ */ { php_interval_obj *obj; - zval tmp_member; zval rv; zval *prop; int retval = 0; - if (UNEXPECTED(Z_TYPE_P(member) != IS_STRING)) { - zend_string *str = zval_try_get_string_func(member); - if (UNEXPECTED(!str)) { - return 0; - } - ZVAL_STR(&tmp_member, str); - member = &tmp_member; - cache_slot = NULL; - } - - obj = Z_PHPINTERVAL_P(object); + obj = php_interval_obj_from_obj(object); if (!obj->initialized) { - retval = zend_std_has_property(object, member, type, cache_slot); - if (member == &tmp_member) { - zval_ptr_dtor_str(&tmp_member); - } + retval = zend_std_has_property(object, name, type, cache_slot); return retval; } - prop = date_interval_read_property(object, member, BP_VAR_IS, cache_slot, &rv); + prop = date_interval_read_property(object, name, BP_VAR_IS, cache_slot, &rv); if (prop != &EG(uninitialized_zval)) { if (type == 2) { @@ -2086,11 +1729,7 @@ static int date_interval_has_property(zval *object, zval *member, int type, void retval = (Z_TYPE_P(prop) != IS_NULL); } } else { - retval = zend_std_has_property(object, member, type, cache_slot); - } - - if (member == &tmp_member) { - zval_ptr_dtor_str(&tmp_member); + retval = zend_std_has_property(object, name, type, cache_slot); } return retval; @@ -2221,9 +1860,9 @@ static zend_object *date_object_new_date(zend_class_entry *class_type) /* {{{ */ return &intern->std; } /* }}} */ -static zend_object *date_object_clone_date(zval *this_ptr) /* {{{ */ +static zend_object *date_object_clone_date(zend_object *this_ptr) /* {{{ */ { - php_date_obj *old_obj = Z_PHPDATE_P(this_ptr); + php_date_obj *old_obj = php_date_obj_from_obj(this_ptr); php_date_obj *new_obj = php_date_obj_from_obj(date_object_new_date(old_obj->std.ce)); zend_objects_clone_members(&new_obj->std, &old_obj->std); @@ -2246,7 +1885,7 @@ static zend_object *date_object_clone_date(zval *this_ptr) /* {{{ */ static void date_clone_immutable(zval *object, zval *new_object) /* {{{ */ { - ZVAL_OBJ(new_object, date_object_clone_date(object)); + ZVAL_OBJ(new_object, date_object_clone_date(Z_OBJ_P(object))); } /* }}} */ static int date_object_compare_date(zval *d1, zval *d2) /* {{{ */ @@ -2268,21 +1907,21 @@ static int date_object_compare_date(zval *d1, zval *d2) /* {{{ */ return timelib_time_compare(o1->time, o2->time); } /* }}} */ -static HashTable *date_object_get_gc(zval *object, zval **table, int *n) /* {{{ */ +static HashTable *date_object_get_gc(zend_object *object, zval **table, int *n) /* {{{ */ { *table = NULL; *n = 0; return zend_std_get_properties(object); } /* }}} */ -static HashTable *date_object_get_gc_timezone(zval *object, zval **table, int *n) /* {{{ */ +static HashTable *date_object_get_gc_timezone(zend_object *object, zval **table, int *n) /* {{{ */ { *table = NULL; *n = 0; return zend_std_get_properties(object); } /* }}} */ -static HashTable *date_object_get_properties_for(zval *object, zend_prop_purpose purpose) /* {{{ */ +static HashTable *date_object_get_properties_for(zend_object *object, zend_prop_purpose purpose) /* {{{ */ { HashTable *props; zval zv; @@ -2299,7 +1938,7 @@ static HashTable *date_object_get_properties_for(zval *object, zend_prop_purpose return zend_std_get_properties_for(object, purpose); } - dateobj = Z_PHPDATE_P(object); + dateobj = php_date_obj_from_obj(object); props = zend_array_dup(zend_std_get_properties(object)); if (!dateobj->time) { return props; @@ -2351,9 +1990,9 @@ static zend_object *date_object_new_timezone(zend_class_entry *class_type) /* {{ return &intern->std; } /* }}} */ -static zend_object *date_object_clone_timezone(zval *this_ptr) /* {{{ */ +static zend_object *date_object_clone_timezone(zend_object *this_ptr) /* {{{ */ { - php_timezone_obj *old_obj = Z_PHPTIMEZONE_P(this_ptr); + php_timezone_obj *old_obj = php_timezone_obj_from_obj(this_ptr); php_timezone_obj *new_obj = php_timezone_obj_from_obj(date_object_new_timezone(old_obj->std.ce)); zend_objects_clone_members(&new_obj->std, &old_obj->std); @@ -2404,7 +2043,7 @@ static void php_timezone_to_string(php_timezone_obj *tzobj, zval *zv) } } -static HashTable *date_object_get_properties_for_timezone(zval *object, zend_prop_purpose purpose) /* {{{ */ +static HashTable *date_object_get_properties_for_timezone(zend_object *object, zend_prop_purpose purpose) /* {{{ */ { HashTable *props; zval zv; @@ -2421,7 +2060,7 @@ static HashTable *date_object_get_properties_for_timezone(zval *object, zend_pro return zend_std_get_properties_for(object, purpose); } - tzobj = Z_PHPTIMEZONE_P(object); + tzobj = php_timezone_obj_from_obj(object); props = zend_array_dup(zend_std_get_properties(object)); if (!tzobj->initialized) { return props; @@ -2436,13 +2075,13 @@ static HashTable *date_object_get_properties_for_timezone(zval *object, zend_pro return props; } /* }}} */ -static HashTable *date_object_get_debug_info_timezone(zval *object, int *is_temp) /* {{{ */ +static HashTable *date_object_get_debug_info_timezone(zend_object *object, int *is_temp) /* {{{ */ { HashTable *ht, *props; zval zv; php_timezone_obj *tzobj; - tzobj = Z_PHPTIMEZONE_P(object); + tzobj = php_timezone_obj_from_obj(object); props = zend_std_get_properties(object); *is_temp = 1; @@ -2468,9 +2107,9 @@ static zend_object *date_object_new_interval(zend_class_entry *class_type) /* {{ return &intern->std; } /* }}} */ -static zend_object *date_object_clone_interval(zval *this_ptr) /* {{{ */ +static zend_object *date_object_clone_interval(zend_object *this_ptr) /* {{{ */ { - php_interval_obj *old_obj = Z_PHPINTERVAL_P(this_ptr); + php_interval_obj *old_obj = php_interval_obj_from_obj(this_ptr); php_interval_obj *new_obj = php_interval_obj_from_obj(date_object_new_interval(old_obj->std.ce)); zend_objects_clone_members(&new_obj->std, &old_obj->std); @@ -2482,7 +2121,7 @@ static zend_object *date_object_clone_interval(zval *this_ptr) /* {{{ */ return &new_obj->std; } /* }}} */ -static HashTable *date_object_get_gc_interval(zval *object, zval **table, int *n) /* {{{ */ +static HashTable *date_object_get_gc_interval(zend_object *object, zval **table, int *n) /* {{{ */ { *table = NULL; @@ -2490,13 +2129,13 @@ static HashTable *date_object_get_gc_interval(zval *object, zval **table, int *n return zend_std_get_properties(object); } /* }}} */ -static HashTable *date_object_get_properties_interval(zval *object) /* {{{ */ +static HashTable *date_object_get_properties_interval(zend_object *object) /* {{{ */ { HashTable *props; zval zv; php_interval_obj *intervalobj; - intervalobj = Z_PHPINTERVAL_P(object); + intervalobj = php_interval_obj_from_obj(object); props = zend_std_get_properties(object); if (!intervalobj->initialized) { return props; @@ -2544,9 +2183,9 @@ static zend_object *date_object_new_period(zend_class_entry *class_type) /* {{{ return &intern->std; } /* }}} */ -static zend_object *date_object_clone_period(zval *this_ptr) /* {{{ */ +static zend_object *date_object_clone_period(zend_object *this_ptr) /* {{{ */ { - php_period_obj *old_obj = Z_PHPPERIOD_P(this_ptr); + php_period_obj *old_obj = php_period_obj_from_obj(this_ptr); php_period_obj *new_obj = php_period_obj_from_obj(date_object_new_period(old_obj->std.ce)); zend_objects_clone_members(&new_obj->std, &old_obj->std); @@ -2848,7 +2487,7 @@ PHP_METHOD(DateTime, __construct) size_t time_str_len = 0; zend_error_handling error_handling; - ZEND_PARSE_PARAMETERS_START_EX(ZEND_PARSE_PARAMS_THROW, 0, 2) + ZEND_PARSE_PARAMETERS_START(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) @@ -2870,7 +2509,7 @@ PHP_METHOD(DateTimeImmutable, __construct) size_t time_str_len = 0; zend_error_handling error_handling; - ZEND_PARSE_PARAMETERS_START_EX(ZEND_PARSE_PARAMS_THROW, 0, 2) + ZEND_PARSE_PARAMETERS_START(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) @@ -3875,7 +3514,7 @@ PHP_METHOD(DateTimeZone, __construct) php_timezone_obj *tzobj; zend_error_handling error_handling; - ZEND_PARSE_PARAMETERS_START_EX(ZEND_PARSE_PARAMS_THROW, 1, 1) + ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_STR(tz) ZEND_PARSE_PARAMETERS_END(); @@ -4177,38 +3816,24 @@ static int date_interval_compare_objects(zval *o1, zval *o2) { } /* {{{ date_interval_read_property */ -static zval *date_interval_read_property(zval *object, zval *member, int type, void **cache_slot, zval *rv) +static zval *date_interval_read_property(zend_object *object, zend_string *name, int type, void **cache_slot, zval *rv) { php_interval_obj *obj; zval *retval; - zval tmp_member; timelib_sll value = -1; double fvalue = -1; - if (Z_TYPE_P(member) != IS_STRING) { - zend_string *str = zval_try_get_string_func(member); - if (UNEXPECTED(!str)) { - return &EG(uninitialized_zval); - } - ZVAL_STR(&tmp_member, str); - member = &tmp_member; - cache_slot = NULL; - } - - obj = Z_PHPINTERVAL_P(object); + obj = php_interval_obj_from_obj(object); if (!obj->initialized) { - retval = zend_std_read_property(object, member, type, cache_slot, rv); - if (member == &tmp_member) { - zval_ptr_dtor_str(&tmp_member); - } + retval = zend_std_read_property(object, name, type, cache_slot, rv); return retval; } #define GET_VALUE_FROM_STRUCT(n,m) \ - if (strcmp(Z_STRVAL_P(member), m) == 0) { \ - value = obj->diff->n; \ - break; \ + if (strcmp(ZSTR_VAL(name), m) == 0) { \ + value = obj->diff->n; \ + break; \ } do { GET_VALUE_FROM_STRUCT(y, "y"); @@ -4217,18 +3842,14 @@ static zval *date_interval_read_property(zval *object, zval *member, int type, v GET_VALUE_FROM_STRUCT(h, "h"); GET_VALUE_FROM_STRUCT(i, "i"); GET_VALUE_FROM_STRUCT(s, "s"); - if (strcmp(Z_STRVAL_P(member), "f") == 0) { + if (strcmp(ZSTR_VAL(name), "f") == 0) { fvalue = obj->diff->us / 1000000.0; break; } GET_VALUE_FROM_STRUCT(invert, "invert"); GET_VALUE_FROM_STRUCT(days, "days"); /* didn't find any */ - retval = zend_std_read_property(object, member, type, cache_slot, rv); - - if (member == &tmp_member) { - zval_ptr_dtor_str(&tmp_member); - } + retval = zend_std_read_property(object, name, type, cache_slot, rv); return retval; } while(0); @@ -4243,42 +3864,23 @@ static zval *date_interval_read_property(zval *object, zval *member, int type, v ZVAL_FALSE(retval); } - if (member == &tmp_member) { - zval_ptr_dtor_str(&tmp_member); - } - return retval; } /* }}} */ /* {{{ date_interval_write_property */ -static zval *date_interval_write_property(zval *object, zval *member, zval *value, void **cache_slot) +static zval *date_interval_write_property(zend_object *object, zend_string *name, zval *value, void **cache_slot) { php_interval_obj *obj; - zval tmp_member; - if (Z_TYPE_P(member) != IS_STRING) { - zend_string *str = zval_try_get_string_func(member); - if (UNEXPECTED(!str)) { - return value; - } - ZVAL_STR(&tmp_member, str); - member = &tmp_member; - cache_slot = NULL; - } - - obj = Z_PHPINTERVAL_P(object); + obj = php_interval_obj_from_obj(object); if (!obj->initialized) { - value = zend_std_write_property(object, member, value, cache_slot); - if (member == &tmp_member) { - zval_ptr_dtor_str(&tmp_member); - } - return value; + return zend_std_write_property(object, name, value, cache_slot); } -#define SET_VALUE_FROM_STRUCT(n,m) \ - if (strcmp(Z_STRVAL_P(member), m) == 0) { \ +#define SET_VALUE_FROM_STRUCT(n,m) \ + if (strcmp(ZSTR_VAL(name), m) == 0) { \ obj->diff->n = zval_get_long(value); \ break; \ } @@ -4290,55 +3892,37 @@ static zval *date_interval_write_property(zval *object, zval *member, zval *valu SET_VALUE_FROM_STRUCT(h, "h"); SET_VALUE_FROM_STRUCT(i, "i"); SET_VALUE_FROM_STRUCT(s, "s"); - if (strcmp(Z_STRVAL_P(member), "f") == 0) { + if (strcmp(ZSTR_VAL(name), "f") == 0) { obj->diff->us = zval_get_double(value) * 1000000; break; } SET_VALUE_FROM_STRUCT(invert, "invert"); /* didn't find any */ - value = zend_std_write_property(object, member, value, cache_slot); + value = zend_std_write_property(object, name, value, cache_slot); } while(0); - if (member == &tmp_member) { - zval_ptr_dtor_str(&tmp_member); - } - return value; } /* }}} */ /* {{{ date_interval_get_property_ptr_ptr */ -static zval *date_interval_get_property_ptr_ptr(zval *object, zval *member, int type, void **cache_slot) -{ - zval tmp_member, *ret; - - if (Z_TYPE_P(member) != IS_STRING) { - zend_string *str = zval_try_get_string_func(member); - if (UNEXPECTED(!str)) { - return NULL; - } - ZVAL_STR(&tmp_member, str); - member = &tmp_member; - cache_slot = NULL; - } - - if(zend_binary_strcmp("y", sizeof("y") - 1, Z_STRVAL_P(member), Z_STRLEN_P(member)) == 0 || - zend_binary_strcmp("m", sizeof("m") - 1, Z_STRVAL_P(member), Z_STRLEN_P(member)) == 0 || - zend_binary_strcmp("d", sizeof("d") - 1, Z_STRVAL_P(member), Z_STRLEN_P(member)) == 0 || - zend_binary_strcmp("h", sizeof("h") - 1, Z_STRVAL_P(member), Z_STRLEN_P(member)) == 0 || - zend_binary_strcmp("i", sizeof("i") - 1, Z_STRVAL_P(member), Z_STRLEN_P(member)) == 0 || - zend_binary_strcmp("s", sizeof("s") - 1, Z_STRVAL_P(member), Z_STRLEN_P(member)) == 0 || - zend_binary_strcmp("f", sizeof("f") - 1, Z_STRVAL_P(member), Z_STRLEN_P(member)) == 0 || - zend_binary_strcmp("days", sizeof("days") - 1, Z_STRVAL_P(member), Z_STRLEN_P(member)) == 0 || - zend_binary_strcmp("invert", sizeof("invert") - 1, Z_STRVAL_P(member), Z_STRLEN_P(member)) == 0) { +static zval *date_interval_get_property_ptr_ptr(zend_object *object, zend_string *name, int type, void **cache_slot) +{ + zval *ret; + + if(zend_binary_strcmp("y", sizeof("y") - 1, ZSTR_VAL(name), ZSTR_LEN(name)) == 0 || + zend_binary_strcmp("m", sizeof("m") - 1, ZSTR_VAL(name), ZSTR_LEN(name)) == 0 || + zend_binary_strcmp("d", sizeof("d") - 1, ZSTR_VAL(name), ZSTR_LEN(name)) == 0 || + zend_binary_strcmp("h", sizeof("h") - 1, ZSTR_VAL(name), ZSTR_LEN(name)) == 0 || + zend_binary_strcmp("i", sizeof("i") - 1, ZSTR_VAL(name), ZSTR_LEN(name)) == 0 || + zend_binary_strcmp("s", sizeof("s") - 1, ZSTR_VAL(name), ZSTR_LEN(name)) == 0 || + zend_binary_strcmp("f", sizeof("f") - 1, ZSTR_VAL(name), ZSTR_LEN(name)) == 0 || + zend_binary_strcmp("days", sizeof("days") - 1, ZSTR_VAL(name), ZSTR_LEN(name)) == 0 || + zend_binary_strcmp("invert", sizeof("invert") - 1, ZSTR_VAL(name), ZSTR_LEN(name)) == 0) { /* Fallback to read_property. */ ret = NULL; } else { - ret = zend_std_get_property_ptr_ptr(object, member, type, cache_slot); - } - - if (member == &tmp_member) { - zval_ptr_dtor_str(&tmp_member); + ret = zend_std_get_property_ptr_ptr(object, name, type, cache_slot); } return ret; @@ -4354,7 +3938,7 @@ PHP_METHOD(DateInterval, __construct) timelib_rel_time *reltime; zend_error_handling error_handling; - ZEND_PARSE_PARAMETERS_START_EX(ZEND_PARSE_PARAMS_THROW, 1, 1) + ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_STR(interval_string) ZEND_PARSE_PARAMETERS_END(); @@ -4723,7 +4307,7 @@ PHP_METHOD(DatePeriod, getStartDate) dpobj = Z_PHPPERIOD_P(ZEND_THIS); - php_date_instantiate(dpobj->start_ce, return_value); + php_date_instantiate(dpobj->start_ce, return_value); dateobj = Z_PHPDATE_P(return_value); dateobj->time = timelib_time_ctor(); *dateobj->time = *dpobj->start; @@ -4775,9 +4359,9 @@ PHP_METHOD(DatePeriod, getDateInterval) php_period_obj *dpobj; php_interval_obj *diobj; - if (zend_parse_parameters_none() == FAILURE) { - return; - } + if (zend_parse_parameters_none() == FAILURE) { + return; + } dpobj = Z_PHPPERIOD_P(ZEND_THIS); @@ -4796,13 +4380,13 @@ PHP_METHOD(DatePeriod, getRecurrences) php_period_obj *dpobj; if (zend_parse_parameters_none() == FAILURE) { - return; + return; } dpobj = Z_PHPPERIOD_P(ZEND_THIS); if (0 == dpobj->recurrences - dpobj->include_start_date) { - return; + return; } RETURN_LONG(dpobj->recurrences - dpobj->include_start_date); @@ -4866,7 +4450,7 @@ PHP_FUNCTION(timezone_identifiers_list) } /* }}} */ -/* {{{ proto array timezone_version_get() +/* {{{ proto string timezone_version_get() Returns the Olson database version number. */ PHP_FUNCTION(timezone_version_get) @@ -5091,7 +4675,7 @@ PHP_FUNCTION(date_sun_info) array_init(return_value); /* Get sun up/down and transit */ - rs = timelib_astro_rise_set_altitude(t, longitude, latitude, -35.0/60, 1, &ddummy, &ddummy, &rise, &set, &transit); + rs = timelib_astro_rise_set_altitude(t, longitude, latitude, -50.0/60, 1, &ddummy, &ddummy, &rise, &set, &transit); switch (rs) { case -1: /* always below */ add_assoc_bool(return_value, "sunrise", 0); @@ -5168,20 +4752,20 @@ PHP_FUNCTION(date_sun_info) } /* }}} */ -static HashTable *date_object_get_gc_period(zval *object, zval **table, int *n) /* {{{ */ +static HashTable *date_object_get_gc_period(zend_object *object, zval **table, int *n) /* {{{ */ { *table = NULL; *n = 0; return zend_std_get_properties(object); } /* }}} */ -static HashTable *date_object_get_properties_period(zval *object) /* {{{ */ +static HashTable *date_object_get_properties_period(zend_object *object) /* {{{ */ { HashTable *props; zval zv; php_period_obj *period_obj; - period_obj = Z_PHPPERIOD_P(object); + period_obj = php_period_obj_from_obj(object); props = zend_std_get_properties(object); if (!period_obj->start) { return props; @@ -5377,42 +4961,36 @@ static int date_period_is_magic_property(zend_string *name) /* }}} */ /* {{{ date_period_read_property */ -static zval *date_period_read_property(zval *object, zval *member, int type, void **cache_slot, zval *rv) +static zval *date_period_read_property(zend_object *object, zend_string *name, int type, void **cache_slot, zval *rv) { if (type != BP_VAR_IS && type != BP_VAR_R) { - zend_string *name = zval_get_string(member); if (date_period_is_magic_property(name)) { zend_throw_error(NULL, "Retrieval of DatePeriod->%s for modification is unsupported", ZSTR_VAL(name)); - zend_string_release(name); return &EG(uninitialized_zval); } - zend_string_release(name); } - Z_OBJPROP_P(object); /* build properties hash table */ + object->handlers->get_properties(object); /* build properties hash table */ - return zend_std_read_property(object, member, type, cache_slot, rv); + return zend_std_read_property(object, name, type, cache_slot, rv); } /* }}} */ /* {{{ date_period_write_property */ -static zval *date_period_write_property(zval *object, zval *member, zval *value, void **cache_slot) +static zval *date_period_write_property(zend_object *object, zend_string *name, zval *value, void **cache_slot) { - zend_string *name = zval_get_string(member); if (date_period_is_magic_property(name)) { zend_throw_error(NULL, "Writing to DatePeriod->%s is unsupported", ZSTR_VAL(name)); - zend_string_release(name); return value; } - zend_string_release(name); - std_object_handlers.write_property(object, member, value, cache_slot); + std_object_handlers.write_property(object, name, value, cache_slot); return value; } /* }}} */ /* {{{ date_period_get_property_ptr_ptr */ -static zval *date_period_get_property_ptr_ptr(zval *object, zval *member, int type, void **cache_slot) +static zval *date_period_get_property_ptr_ptr(zend_object *object, zend_string *member, int type, void **cache_slot) { /* Fall back to read_property handler. */ return NULL; |
