Skip to content

Commit 2bb98cd

Browse files
authored
ext/int: IntlTimeZone converting few intl error to exceptions. (#13477)
1 parent 74c006f commit 2bb98cd

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

ext/intl/tests/timezone_createTimeZoneIDEnumeration_error_64bit.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ try {
1414
}
1515
?>
1616
--EXPECT--
17-
ValueError: IntlTimeZone::createTimeZoneIDEnumeration(): Argument #1 ($type) must be between -2147483648 and 2147483647
17+
ValueError: IntlTimeZone::createTimeZoneIDEnumeration(): Argument #3 ($rawOffset) must be between -2147483648 and 2147483647

ext/intl/timezone/timezone_methods.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,8 @@ U_CFUNC PHP_FUNCTION(intltz_from_date_time_zone)
8282

8383
tzobj = Z_PHPTIMEZONE_P(zv_timezone);
8484
if (!tzobj->initialized) {
85-
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
86-
"DateTimeZone object is unconstructed");
87-
RETURN_NULL();
85+
zend_throw_error(NULL, "DateTimeZone object is unconstructed");
86+
RETURN_THROWS();
8887
}
8988

9089
tz = timezone_convert_datetimezone(tzobj->type, tzobj, false, NULL);
@@ -209,7 +208,7 @@ U_CFUNC PHP_FUNCTION(intltz_create_time_zone_id_enumeration)
209208

210209
if (!arg3isnull) {
211210
if (UNEXPECTED(ZEND_LONG_EXCEEDS_INT(offset_arg))) {
212-
zend_argument_value_error(1, "must be between %d and %d", INT32_MIN, INT32_MAX);
211+
zend_argument_value_error(3, "must be between %d and %d", INT32_MIN, INT32_MAX);
213212
RETURN_THROWS();
214213
}
215214
offset = static_cast<int32_t>(offset_arg);
@@ -311,8 +310,9 @@ U_CFUNC PHP_FUNCTION(intltz_get_equivalent_id)
311310
Z_PARAM_LONG(index)
312311
ZEND_PARSE_PARAMETERS_END();
313312

314-
if (UNEXPECTED(index < (zend_long)INT32_MIN || index > (zend_long)INT32_MAX)) {
315-
RETURN_FALSE;
313+
if (UNEXPECTED(ZEND_LONG_EXCEEDS_INT(index))) {
314+
zend_argument_value_error(2, "must be between %d and %d", INT32_MIN, INT32_MAX);
315+
RETURN_THROWS();
316316
}
317317

318318
UErrorCode status = UErrorCode();

0 commit comments

Comments
 (0)