From 2bb98cd8c8f502eeeb0a63a5750a0f624a352190 Mon Sep 17 00:00:00 2001 From: David CARLIER Date: Sat, 9 Aug 2025 12:50:35 +0100 Subject: [PATCH] ext/int: IntlTimeZone converting few intl error to exceptions. (#13477) --- ...zone_createTimeZoneIDEnumeration_error_64bit.phpt | 2 +- ext/intl/timezone/timezone_methods.cpp | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ext/intl/tests/timezone_createTimeZoneIDEnumeration_error_64bit.phpt b/ext/intl/tests/timezone_createTimeZoneIDEnumeration_error_64bit.phpt index 62e68938ae8..1e6791a172c 100644 --- a/ext/intl/tests/timezone_createTimeZoneIDEnumeration_error_64bit.phpt +++ b/ext/intl/tests/timezone_createTimeZoneIDEnumeration_error_64bit.phpt @@ -14,4 +14,4 @@ try { } ?> --EXPECT-- -ValueError: IntlTimeZone::createTimeZoneIDEnumeration(): Argument #1 ($type) must be between -2147483648 and 2147483647 +ValueError: IntlTimeZone::createTimeZoneIDEnumeration(): Argument #3 ($rawOffset) must be between -2147483648 and 2147483647 diff --git a/ext/intl/timezone/timezone_methods.cpp b/ext/intl/timezone/timezone_methods.cpp index e9b48273dd2..3de186a9ca0 100644 --- a/ext/intl/timezone/timezone_methods.cpp +++ b/ext/intl/timezone/timezone_methods.cpp @@ -82,9 +82,8 @@ U_CFUNC PHP_FUNCTION(intltz_from_date_time_zone) tzobj = Z_PHPTIMEZONE_P(zv_timezone); if (!tzobj->initialized) { - intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, - "DateTimeZone object is unconstructed"); - RETURN_NULL(); + zend_throw_error(NULL, "DateTimeZone object is unconstructed"); + RETURN_THROWS(); } tz = timezone_convert_datetimezone(tzobj->type, tzobj, false, NULL); @@ -209,7 +208,7 @@ U_CFUNC PHP_FUNCTION(intltz_create_time_zone_id_enumeration) if (!arg3isnull) { if (UNEXPECTED(ZEND_LONG_EXCEEDS_INT(offset_arg))) { - zend_argument_value_error(1, "must be between %d and %d", INT32_MIN, INT32_MAX); + zend_argument_value_error(3, "must be between %d and %d", INT32_MIN, INT32_MAX); RETURN_THROWS(); } offset = static_cast(offset_arg); @@ -311,8 +310,9 @@ U_CFUNC PHP_FUNCTION(intltz_get_equivalent_id) Z_PARAM_LONG(index) ZEND_PARSE_PARAMETERS_END(); - if (UNEXPECTED(index < (zend_long)INT32_MIN || index > (zend_long)INT32_MAX)) { - RETURN_FALSE; + if (UNEXPECTED(ZEND_LONG_EXCEEDS_INT(index))) { + zend_argument_value_error(2, "must be between %d and %d", INT32_MIN, INT32_MAX); + RETURN_THROWS(); } UErrorCode status = UErrorCode();