Skip to content

Commit ce9c736

Browse files
committed
Promote IntlGregorianCalendar warnings to Error
Seems no test are covering these cases
1 parent 9595640 commit ce9c736

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

ext/intl/calendar/gregoriancalendar_methods.cpp

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ static void _php_intlgregcal_constructor_body(
107107

108108
gcal = new GregorianCalendar(tz, Locale::createFromName(locale),
109109
status);
110+
// Should this throw?
110111
if (U_FAILURE(status)) {
111112
intl_error_set(NULL, status, "intlgregcal_create_instance: error "
112113
"creating ICU GregorianCalendar from time zone and locale", 0);
@@ -124,14 +125,9 @@ static void _php_intlgregcal_constructor_body(
124125
// From date/time (3, 5 or 6 arguments)
125126
for (int i = 0; i < variant; i++) {
126127
if (largs[i] < INT32_MIN || largs[i] > INT32_MAX) {
127-
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
128-
"intlgregcal_create_instance: at least one of the arguments"
129-
" has an absolute value that is too large", 0);
130-
if (!is_constructor) {
131-
zval_ptr_dtor(return_value);
132-
RETVAL_NULL();
133-
}
134-
return;
128+
zend_argument_value_error(getThis() ? (i-1):i,
129+
"must be between %d and %d", INT32_MIN, INT32_MAX);
130+
RETURN_THROWS();
135131
}
136132
}
137133

@@ -244,9 +240,8 @@ U_CFUNC PHP_FUNCTION(intlgregcal_is_leap_year)
244240
}
245241

246242
if (year < INT32_MIN || year > INT32_MAX) {
247-
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
248-
"intlgregcal_is_leap_year: year out of bounds", 0);
249-
RETURN_FALSE;
243+
zend_argument_value_error(getThis() ? 1:2, "must be between %d and %d", INT32_MIN, INT32_MAX);
244+
RETURN_THROWS();
250245
}
251246

252247
CALENDAR_METHOD_FETCH_OBJECT;

0 commit comments

Comments
 (0)