Skip to content

Promote Intl warnings to standard ValueError #5669

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 8 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Promote IntlGregorianCalendar warnings to Error
Seems no test are covering these cases
  • Loading branch information
Girgias committed Jul 29, 2020
commit 7d2e249588c2400309629cce1ada554637113ee4
17 changes: 6 additions & 11 deletions ext/intl/calendar/gregoriancalendar_methods.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ static void _php_intlgregcal_constructor_body(

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

Expand Down Expand Up @@ -244,9 +240,8 @@ U_CFUNC PHP_FUNCTION(intlgregcal_is_leap_year)
}

if (year < INT32_MIN || year > INT32_MAX) {
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
"intlgregcal_is_leap_year: year out of bounds", 0);
RETURN_FALSE;
zend_argument_value_error(getThis() ? 1:2, "must be between %d and %d", INT32_MIN, INT32_MAX);
RETURN_THROWS();
}

CALENDAR_METHOD_FETCH_OBJECT;
Expand Down