summaryrefslogtreecommitdiff
path: root/ext/intl
diff options
context:
space:
mode:
Diffstat (limited to 'ext/intl')
-rw-r--r--ext/intl/calendar/calendar_methods.cpp44
-rw-r--r--ext/intl/tests/calendar_clear_error.phpt3
-rw-r--r--ext/intl/timezone/timezone_methods.cpp4
3 files changed, 16 insertions, 35 deletions
diff --git a/ext/intl/calendar/calendar_methods.cpp b/ext/intl/calendar/calendar_methods.cpp
index adeae6b222..155ed5f7f4 100644
--- a/ext/intl/calendar/calendar_methods.cpp
+++ b/ext/intl/calendar/calendar_methods.cpp
@@ -522,48 +522,28 @@ U_CFUNC PHP_FUNCTION(intlcal_roll)
U_CFUNC PHP_FUNCTION(intlcal_clear)
{
- zval args_a[2] = {0},
- *args = &args_a[0];
- zend_long field;
- int variant;
+ zend_long field;
+ zend_bool field_is_null = 1;
CALENDAR_METHOD_INIT_VARS;
- if (ZEND_NUM_ARGS() > (getThis() ? 1 : 2) ||
- zend_get_parameters_array_ex(ZEND_NUM_ARGS(), args) == FAILURE) {
- intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
- "intlcal_clear: too many arguments", 0);
- RETURN_FALSE;
- }
- if (!getThis()) {
- args++;
- }
- if (Z_ISUNDEF(args[0]) || Z_TYPE(args[0]) == IS_NULL) {
- zval *dummy; /* we know it's null */
- if (zend_parse_method_parameters(ZEND_NUM_ARGS(),
- getThis(), "O|z", &object, Calendar_ce_ptr, &dummy) == FAILURE) {
- intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
- "intlcal_clear: bad arguments", 0);
- RETURN_FALSE;
- }
- variant = 0;
- } else if (zend_parse_method_parameters(ZEND_NUM_ARGS(),
- getThis(), "Ol", &object, Calendar_ce_ptr, &field) == FAILURE) {
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS(),
+ getThis(), "O|l!", &object, Calendar_ce_ptr, &field, &field_is_null) == FAILURE) {
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
"intlcal_clear: bad arguments", 0);
RETURN_FALSE;
- } else if (field < 0 || field >= UCAL_FIELD_COUNT) {
- intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
- "intlcal_clear: invalid field", 0);
- RETURN_FALSE;
- } else {
- variant = 1;
}
CALENDAR_METHOD_FETCH_OBJECT;
- if (variant == 0) {
+ if (field_is_null) {
co->ucal->clear();
} else {
+ if (field < 0 || field >= UCAL_FIELD_COUNT) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlcal_clear: invalid field", 0);
+ RETURN_FALSE;
+ }
+
co->ucal->clear((UCalendarDateFields)field);
}
@@ -614,7 +594,7 @@ U_CFUNC PHP_FUNCTION(intlcal_get_actual_minimum)
#if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 44
U_CFUNC PHP_FUNCTION(intlcal_get_day_of_week_type)
{
- zend_ulong dow;
+ zend_long dow;
CALENDAR_METHOD_INIT_VARS;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(),
diff --git a/ext/intl/tests/calendar_clear_error.phpt b/ext/intl/tests/calendar_clear_error.phpt
index 7e9c52b2a5..7ff2ff0867 100644
--- a/ext/intl/tests/calendar_clear_error.phpt
+++ b/ext/intl/tests/calendar_clear_error.phpt
@@ -18,8 +18,9 @@ var_dump($c->clear(-1));
var_dump(intlcal_clear($c, -1));
var_dump(intlcal_clear(1, 2));
--EXPECTF--
+Warning: IntlCalendar::clear() expects at most 1 parameter, 2 given in %s on line %d
-Warning: IntlCalendar::clear(): intlcal_clear: too many arguments in %s on line %d
+Warning: IntlCalendar::clear(): intlcal_clear: bad arguments in %s on line %d
bool(false)
Warning: IntlCalendar::clear(): intlcal_clear: invalid field in %s on line %d
diff --git a/ext/intl/timezone/timezone_methods.cpp b/ext/intl/timezone/timezone_methods.cpp
index c46b448bbe..a35174d3da 100644
--- a/ext/intl/timezone/timezone_methods.cpp
+++ b/ext/intl/timezone/timezone_methods.cpp
@@ -440,7 +440,7 @@ U_CFUNC PHP_FUNCTION(intltz_use_daylight_time)
U_CFUNC PHP_FUNCTION(intltz_get_offset)
{
- UDate date;
+ double date;
zend_bool local;
zval *rawOffsetArg,
*dstOffsetArg;
@@ -458,7 +458,7 @@ U_CFUNC PHP_FUNCTION(intltz_get_offset)
TIMEZONE_METHOD_FETCH_OBJECT;
- to->utimezone->getOffset(date, (UBool) local, rawOffset, dstOffset,
+ to->utimezone->getOffset((UDate) date, (UBool) local, rawOffset, dstOffset,
TIMEZONE_ERROR_CODE(to));
INTL_METHOD_CHECK_STATUS(to, "intltz_get_offset: error obtaining offset");