diff --git a/ext/intl/tests/timezone_createTimeZoneIDEnumeration_error.phpt b/ext/intl/tests/timezone_createTimeZoneIDEnumeration_error.phpt index 2173c4a5cd12a..0eb26b826a347 100644 --- a/ext/intl/tests/timezone_createTimeZoneIDEnumeration_error.phpt +++ b/ext/intl/tests/timezone_createTimeZoneIDEnumeration_error.phpt @@ -1,13 +1,16 @@ --TEST-- -IntlTimeZone::createTimeZoneIDEnumeration(): errors +IntlTimeZone::createTimeZoneIDEnumeration() invalid zone type --EXTENSIONS-- intl --FILE-- getMessage(), PHP_EOL; +} + ?> ---EXPECTF-- -Warning: IntlTimeZone::createTimeZoneIDEnumeration(): bad zone type in %s on line %d -bool(false) +--EXPECT-- +ValueError: IntlTimeZone::createTimeZoneIDEnumeration(): Argument #1 ($type) must be one of IntlTimeZone::TYPE_ANY, IntlTimeZone::TYPE_CANONICAL, or IntlTimeZone::TYPE_CANONICAL_LOCATION diff --git a/ext/intl/tests/timezone_createTimeZoneIDEnumeration_error_64bit.phpt b/ext/intl/tests/timezone_createTimeZoneIDEnumeration_error_64bit.phpt new file mode 100644 index 0000000000000..62e68938ae845 --- /dev/null +++ b/ext/intl/tests/timezone_createTimeZoneIDEnumeration_error_64bit.phpt @@ -0,0 +1,17 @@ +--TEST-- +IntlTimeZone::createTimeZoneIDEnumeration() offset out of range +--EXTENSIONS-- +intl +--SKIPIF-- + +--FILE-- +getMessage(), PHP_EOL; +} +?> +--EXPECT-- +ValueError: IntlTimeZone::createTimeZoneIDEnumeration(): Argument #1 ($type) must be between -2147483648 and 2147483647 diff --git a/ext/intl/timezone/timezone_methods.cpp b/ext/intl/timezone/timezone_methods.cpp index d01bdadd743d5..3fdfbb9ac8074 100644 --- a/ext/intl/timezone/timezone_methods.cpp +++ b/ext/intl/timezone/timezone_methods.cpp @@ -229,17 +229,17 @@ U_CFUNC PHP_FUNCTION(intltz_create_time_zone_id_enumeration) if (zoneType != UCAL_ZONE_TYPE_ANY && zoneType != UCAL_ZONE_TYPE_CANONICAL && zoneType != UCAL_ZONE_TYPE_CANONICAL_LOCATION) { - intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "bad zone type"); - RETURN_FALSE; + zend_argument_value_error(1, "must be one of IntlTimeZone::TYPE_ANY," + " IntlTimeZone::TYPE_CANONICAL, or IntlTimeZone::TYPE_CANONICAL_LOCATION"); + RETURN_THROWS(); } if (!arg3isnull) { - if (UNEXPECTED(offset_arg < (zend_long)INT32_MIN || offset_arg > (zend_long)INT32_MAX)) { - intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, - "offset out of bounds"); - RETURN_FALSE; + if (UNEXPECTED(ZEND_LONG_EXCEEDS_INT(offset_arg))) { + zend_argument_value_error(1, "must be between %d and %d", INT32_MIN, INT32_MAX); + RETURN_THROWS(); } - offset = (int32_t)offset_arg; + offset = static_cast(offset_arg); offsetp = &offset; } //else leave offsetp NULL