From e79b57035899f14d062d1f896fa392629fca806d Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Sun, 27 Jul 2025 21:19:31 +0100 Subject: [PATCH] ext/intl: Refactor error handling --- .../breakiterator/breakiterator_iterators.cpp | 2 +- .../breakiterator/breakiterator_methods.cpp | 34 ++++----- .../rulebasedbreakiterator_methods.cpp | 9 +-- ext/intl/calendar/calendar_methods.cpp | 73 ++++++++----------- .../calendar/gregoriancalendar_methods.cpp | 63 +++++++--------- ext/intl/collator/collator_class.h | 2 +- ext/intl/collator/collator_compare.c | 9 +-- ext/intl/collator/collator_create.c | 28 +++---- ext/intl/collator/collator_locale.c | 3 +- ext/intl/collator/collator_sort.c | 11 +-- ext/intl/common/common_date.cpp | 72 +++++++----------- ext/intl/common/common_date.h | 6 +- ext/intl/common/common_enum.cpp | 8 +- ext/intl/converter/converter.c | 42 +++++------ ext/intl/dateformat/dateformat_attrcpp.cpp | 16 ++-- ext/intl/dateformat/dateformat_create.cpp | 49 +++++-------- ext/intl/dateformat/dateformat_format.c | 18 ++--- .../dateformat/dateformat_format_object.cpp | 47 +++++------- ext/intl/dateformat/dateformat_helpers.cpp | 32 +++----- ext/intl/dateformat/dateformat_helpers.h | 4 +- ext/intl/dateformat/dateformat_parse.c | 6 +- .../datepatterngenerator_methods.cpp | 33 +++------ ext/intl/formatter/formatter_attr.c | 6 +- ext/intl/formatter/formatter_format.c | 2 +- ext/intl/formatter/formatter_main.c | 30 +++----- ext/intl/grapheme/grapheme_string.c | 32 ++++---- ext/intl/grapheme/grapheme_util.c | 2 +- ext/intl/idn/idn.cpp | 7 +- ext/intl/intl_data.h | 16 ++-- ext/intl/intl_error.c | 73 +++++++++++-------- ext/intl/intl_error.h | 15 ++-- ext/intl/listformatter/listformatter_class.c | 10 +-- ext/intl/locale/locale_methods.cpp | 52 ++++++------- ext/intl/msgformat/msgformat.c | 34 ++++----- ext/intl/msgformat/msgformat_attr.c | 2 +- ext/intl/msgformat/msgformat_format.c | 8 +- ext/intl/msgformat/msgformat_helpers.cpp | 38 +++++----- ext/intl/msgformat/msgformat_parse.c | 2 +- ext/intl/normalizer/normalizer_normalize.c | 16 ++-- .../resourcebundle/resourcebundle_class.c | 38 ++++------ ext/intl/spoofchecker/spoofchecker_class.h | 2 +- ext/intl/spoofchecker/spoofchecker_create.c | 9 +-- ext/intl/tests/bug53512.phpt | 8 +- ext/intl/tests/bug62017.phpt | 19 ++--- ext/intl/tests/bug62081.phpt | 14 ++-- ext/intl/tests/bug67397.phpt | 4 +- ext/intl/tests/bug72533.phpt | 8 +- .../tests/calendar_createInstance_error.phpt | 2 +- .../tests/calendar_fieldDifference_error.phpt | 2 +- .../tests/calendar_fromDateTime_error.phpt | 6 +- ...ar_getErrorCode_getErrorMessage_basic.phpt | 6 +- .../tests/calendar_setTimeZone_error2.phpt | 4 +- ext/intl/tests/calendar_toDateTime_error.phpt | 8 +- ext/intl/tests/collator_create_errors.phpt | 12 +-- .../tests/collator_get_invalid_attribute.phpt | 4 +- .../dateformat___construct_bad_tz_cal.phpt | 29 +++----- ext/intl/tests/dateformat_bug68893.phpt | 4 +- ext/intl/tests/dateformat_errors.phpt | 6 +- .../tests/dateformat_formatObject_error.phpt | 16 ++-- ext/intl/tests/dateformat_format_error.phpt | 4 +- .../tests/dateformat_setTimeZone_error.phpt | 4 +- ext/intl/tests/formatter_fail.phpt | 45 ++++++------ ext/intl/tests/formatter_get_error.phpt | 8 +- .../tests/formatter_set_invalid_pattern.phpt | 4 +- ext/intl/tests/gh12020.phpt | 8 +- ext/intl/tests/gh12243.phpt | 2 +- ext/intl/tests/gh17469.phpt | 4 +- ext/intl/tests/ini_use_exceptions_basic.phpt | 4 +- ext/intl/tests/intl_get_error_message.phpt | 2 +- .../tests/locale_compose_locale_errors.phpt | 8 +- ext/intl/tests/locale_subtags.phpt | 8 +- ext/intl/tests/msgfmt_errors.phpt | 6 +- ext/intl/tests/msgfmt_fail2.phpt | 40 +++++----- ext/intl/tests/msgfmt_format_error2.phpt | 2 +- ext/intl/tests/msgfmt_format_error3.phpt | 2 +- ext/intl/tests/msgfmt_format_error4.phpt | 4 +- ext/intl/tests/msgfmt_format_error5.phpt | 2 +- ext/intl/tests/msgfmt_format_error6.phpt | 2 +- .../tests/msgfmt_format_message_errors.phpt | 4 +- .../tests/msgfmt_parse_message_errors.phpt | 4 +- .../msgfmt_set_pattern_syntax_error.phpt | 4 +- .../normalizer_get_raw_decomposition.phpt | 12 +-- .../tests/resourcebundle_arrayaccess.phpt | 2 +- .../tests/resourcebundle_create_error.phpt | 8 +- ext/intl/tests/resourcebundle_get_errors.phpt | 4 +- .../tests/timezone_IDforWindowsID_error.phpt | 2 +- .../timezone_fromDateTimeZone_error.phpt | 7 +- .../timezone_getErrorCodeMessage_basic.phpt | 2 +- .../tests/timezone_toDateTimeZone_error.phpt | 2 +- ext/intl/tests/timezone_windowsID_basic2.phpt | 2 +- .../tests/transliterator_create_error.phpt | 18 ++--- ...transliterator_create_from_rule_error.phpt | 10 +-- ...ransliterator_get_error_message_basic.phpt | 4 +- .../transliterator_transliterate_error.phpt | 2 +- ...transliterator_transliterate_variant1.phpt | 8 +- .../tests/uconverter___construct_error.phpt | 2 +- ext/intl/tests/uconverter_func_subst.phpt | 8 +- ext/intl/timezone/timezone_class.cpp | 50 ++++++------- ext/intl/timezone/timezone_class.h | 4 +- ext/intl/timezone/timezone_methods.cpp | 48 ++++++------ .../transliterator/transliterator_methods.c | 36 ++++----- ext/intl/uchar/uchar.cpp | 16 ++-- 102 files changed, 684 insertions(+), 847 deletions(-) diff --git a/ext/intl/breakiterator/breakiterator_iterators.cpp b/ext/intl/breakiterator/breakiterator_iterators.cpp index 6817f52ffb020..34176bf90e528 100644 --- a/ext/intl/breakiterator/breakiterator_iterators.cpp +++ b/ext/intl/breakiterator/breakiterator_iterators.cpp @@ -43,7 +43,7 @@ inline BreakIterator *_breakiter_prolog(zend_object_iterator *iter) if (bio->biter == NULL) { intl_errors_set(BREAKITER_ERROR_P(bio), U_INVALID_STATE_ERROR, "The BreakIterator object backing the PHP iterator is not " - "properly constructed", 0); + "properly constructed"); } return bio->biter; } diff --git a/ext/intl/breakiterator/breakiterator_methods.cpp b/ext/intl/breakiterator/breakiterator_methods.cpp index 56a3a35c97f81..c9791d4b23ae6 100644 --- a/ext/intl/breakiterator/breakiterator_methods.cpp +++ b/ext/intl/breakiterator/breakiterator_methods.cpp @@ -41,14 +41,13 @@ U_CFUNC PHP_METHOD(IntlBreakIterator, __construct) 0 ); } -static void _breakiter_factory(const char *func_name, - BreakIterator *(*func)(const Locale&, UErrorCode&), - INTERNAL_FUNCTION_PARAMETERS) +static void _breakiter_factory( + BreakIterator *(*func)(const Locale&, UErrorCode&), + INTERNAL_FUNCTION_PARAMETERS) { BreakIterator *biter; char *locale_str = NULL; size_t dummy; - char *msg; UErrorCode status = UErrorCode(); intl_error_reset(NULL); @@ -64,10 +63,7 @@ static void _breakiter_factory(const char *func_name, biter = func(Locale::createFromName(locale_str), status); intl_error_set_code(NULL, status); if (U_FAILURE(status)) { - spprintf(&msg, 0, "%s: error creating BreakIterator", - func_name); - intl_error_set_custom_msg(NULL, msg, 1); - efree(msg); + intl_error_set_custom_msg(NULL, "error creating BreakIterator"); RETURN_NULL(); } @@ -76,35 +72,35 @@ static void _breakiter_factory(const char *func_name, U_CFUNC PHP_METHOD(IntlBreakIterator, createWordInstance) { - _breakiter_factory("breakiter_create_word_instance", + _breakiter_factory( &BreakIterator::createWordInstance, INTERNAL_FUNCTION_PARAM_PASSTHRU); } U_CFUNC PHP_METHOD(IntlBreakIterator, createLineInstance) { - _breakiter_factory("breakiter_create_line_instance", + _breakiter_factory( &BreakIterator::createLineInstance, INTERNAL_FUNCTION_PARAM_PASSTHRU); } U_CFUNC PHP_METHOD(IntlBreakIterator, createCharacterInstance) { - _breakiter_factory("breakiter_create_character_instance", + _breakiter_factory( &BreakIterator::createCharacterInstance, INTERNAL_FUNCTION_PARAM_PASSTHRU); } U_CFUNC PHP_METHOD(IntlBreakIterator, createSentenceInstance) { - _breakiter_factory("breakiter_create_sentence_instance", + _breakiter_factory( &BreakIterator::createSentenceInstance, INTERNAL_FUNCTION_PARAM_PASSTHRU); } U_CFUNC PHP_METHOD(IntlBreakIterator, createTitleInstance) { - _breakiter_factory("breakiter_create_title_instance", + _breakiter_factory( &BreakIterator::createTitleInstance, INTERNAL_FUNCTION_PARAM_PASSTHRU); } @@ -149,12 +145,11 @@ U_CFUNC PHP_METHOD(IntlBreakIterator, setText) BREAKITER_METHOD_FETCH_OBJECT; ut = utext_openUTF8(ut, ZSTR_VAL(text), ZSTR_LEN(text), BREAKITER_ERROR_CODE_P(bio)); - INTL_METHOD_CHECK_STATUS(bio, "breakiter_set_text: error opening UText"); + INTL_METHOD_CHECK_STATUS(bio, "error opening UText"); bio->biter->setText(ut, BREAKITER_ERROR_CODE(bio)); utext_close(ut); /* ICU shallow clones the UText */ - INTL_METHOD_CHECK_STATUS(bio, "breakiter_set_text: error calling " - "BreakIterator::setText()"); + INTL_METHOD_CHECK_STATUS(bio, "error calling BreakIterator::setText()"); /* When ICU clones the UText, it does not copy the buffer, so we have to * keep the string buffer around by holding a reference to its zval. This @@ -302,10 +297,10 @@ U_CFUNC PHP_METHOD(IntlBreakIterator, getLocale) Z_PARAM_LONG(locale_type) ZEND_PARSE_PARAMETERS_END(); - /* Change to ValueError? */ + /* TODO: Change to ValueError? */ if (locale_type != ULOC_ACTUAL_LOCALE && locale_type != ULOC_VALID_LOCALE) { intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, - "breakiter_get_locale: invalid locale type", 0); + "invalid locale type"); RETURN_FALSE; } @@ -313,8 +308,7 @@ U_CFUNC PHP_METHOD(IntlBreakIterator, getLocale) Locale locale = bio->biter->getLocale((ULocDataLocaleType)locale_type, BREAKITER_ERROR_CODE(bio)); - INTL_METHOD_CHECK_STATUS(bio, - "breakiter_get_locale: Call to ICU method has failed"); + INTL_METHOD_CHECK_STATUS(bio, "Call to ICU method has failed"); RETURN_STRING(locale.getName()); } diff --git a/ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp b/ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp index e26b4c07ac33f..a7c322b1d8169 100644 --- a/ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp +++ b/ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp @@ -105,8 +105,7 @@ U_CFUNC PHP_METHOD(IntlRuleBasedBreakIterator, getRules) if (!u8str) { intl_errors_set(BREAKITER_ERROR_P(bio), BREAKITER_ERROR_CODE(bio), - "rbbi_hash_code: Error converting result to UTF-8 string", - 0); + "Error converting result to UTF-8 string"); RETURN_FALSE; } RETVAL_STR(u8str); @@ -144,8 +143,7 @@ U_CFUNC PHP_METHOD(IntlRuleBasedBreakIterator, getRuleStatusVec) BREAKITER_ERROR_CODE(bio)); if (U_FAILURE(BREAKITER_ERROR_CODE(bio))) { intl_errors_set(BREAKITER_ERROR_P(bio), BREAKITER_ERROR_CODE(bio), - "rbbi_get_rule_status_vec: failed obtaining the status values", - 0); + "failed obtaining the status values"); RETURN_FALSE; } @@ -169,8 +167,7 @@ U_CFUNC PHP_METHOD(IntlRuleBasedBreakIterator, getBinaryRules) if (rules_len > INT_MAX - 1) { intl_errors_set(BREAKITER_ERROR_P(bio), BREAKITER_ERROR_CODE(bio), - "rbbi_get_binary_rules: the rules are too large", - 0); + "the rules are too large"); RETURN_FALSE; } diff --git a/ext/intl/calendar/calendar_methods.cpp b/ext/intl/calendar/calendar_methods.cpp index 9b7a37c0df523..d668cd66df9a6 100644 --- a/ext/intl/calendar/calendar_methods.cpp +++ b/ext/intl/calendar/calendar_methods.cpp @@ -85,8 +85,7 @@ U_CFUNC PHP_FUNCTION(intlcal_create_instance) Z_PARAM_STRING_OR_NULL(locale_str, locale_len) ZEND_PARSE_PARAMETERS_END(); - timeZone = timezone_process_timezone_argument(zv_timezone, NULL, - "intlcal_create_instance"); + timeZone = timezone_process_timezone_argument(zv_timezone, NULL); if (timeZone == NULL) { RETURN_NULL(); } @@ -99,7 +98,7 @@ U_CFUNC PHP_FUNCTION(intlcal_create_instance) Locale::createFromName(locale_str), status); if (UNEXPECTED(cal == NULL)) { delete timeZone; - intl_error_set(NULL, status, "Error creating ICU Calendar object", 0); + intl_error_set(NULL, status, "Error creating ICU Calendar object"); RETURN_NULL(); } @@ -179,8 +178,8 @@ U_CFUNC PHP_FUNCTION(intlcal_get_keyword_values_for_locale) Locale::createFromName(locale), (UBool)commonly_used, status); if (se == NULL) { - intl_error_set(NULL, status, "intlcal_get_keyword_values_for_locale: " - "error calling underlying method", 0); + intl_error_set(NULL, status, + "error calling underlying method"); RETURN_FALSE; } @@ -252,8 +251,7 @@ U_CFUNC PHP_FUNCTION(intlcal_get_time) CALENDAR_METHOD_FETCH_OBJECT; UDate result = co->ucal->getTime(CALENDAR_ERROR_CODE(co)); - INTL_METHOD_CHECK_STATUS(co, - "intlcal_get_time: error calling ICU Calendar::getTime"); + INTL_METHOD_CHECK_STATUS(co, "error calling ICU Calendar::getTime"); RETURN_DOUBLE((double)result); } @@ -293,7 +291,7 @@ U_CFUNC PHP_FUNCTION(intlcal_add) CALENDAR_METHOD_FETCH_OBJECT; co->ucal->add((UCalendarDateFields)field, (int32_t)amount, CALENDAR_ERROR_CODE(co)); - INTL_METHOD_CHECK_STATUS(co, "intlcal_add: Call to underlying method failed"); + INTL_METHOD_CHECK_STATUS(co, "Call to underlying method failed"); RETURN_TRUE; } @@ -316,7 +314,7 @@ U_CFUNC PHP_FUNCTION(intlcal_set_time_zone) } timeZone = timezone_process_timezone_argument(zv_timezone, - CALENDAR_ERROR_P(co), "intlcal_set_time_zone"); + CALENDAR_ERROR_P(co)); if (timeZone == NULL) { RETURN_FALSE; } @@ -350,7 +348,7 @@ static void _php_intlcal_before_after( } UBool res = (co->ucal->*func)(*when_co->ucal, CALENDAR_ERROR_CODE(co)); - INTL_METHOD_CHECK_STATUS(co, "intlcal_before/after: Error calling ICU method"); + INTL_METHOD_CHECK_STATUS(co, "Error calling ICU method"); RETURN_BOOL((int)res); } @@ -490,7 +488,7 @@ U_CFUNC PHP_FUNCTION(intlcal_roll) co->ucal->roll((UCalendarDateFields)field, (int32_t)value, CALENDAR_ERROR_CODE(co)); - INTL_METHOD_CHECK_STATUS(co, "intlcal_roll: Error calling ICU Calendar::roll"); + INTL_METHOD_CHECK_STATUS(co, "Error calling ICU Calendar::roll"); RETURN_TRUE; } @@ -536,8 +534,7 @@ U_CFUNC PHP_FUNCTION(intlcal_field_difference) int32_t result = co->ucal->fieldDifference((UDate)when, (UCalendarDateFields)field, CALENDAR_ERROR_CODE(co)); - INTL_METHOD_CHECK_STATUS(co, - "intlcal_field_difference: Call to ICU method has failed"); + INTL_METHOD_CHECK_STATUS(co, "Call to ICU method has failed"); RETURN_LONG((zend_long)result); } @@ -570,8 +567,7 @@ U_CFUNC PHP_FUNCTION(intlcal_get_day_of_week_type) int32_t result = co->ucal->getDayOfWeekType( (UCalendarDaysOfWeek)dow, CALENDAR_ERROR_CODE(co)); - INTL_METHOD_CHECK_STATUS(co, - "intlcal_get_day_of_week_type: Call to ICU method has failed"); + INTL_METHOD_CHECK_STATUS(co, "Call to ICU method has failed"); RETURN_LONG((zend_long)result); } @@ -588,8 +584,7 @@ U_CFUNC PHP_FUNCTION(intlcal_get_first_day_of_week) CALENDAR_METHOD_FETCH_OBJECT; int32_t result = co->ucal->getFirstDayOfWeek(CALENDAR_ERROR_CODE(co)); - INTL_METHOD_CHECK_STATUS(co, - "intlcal_get_first_day_of_week: Call to ICU method has failed"); + INTL_METHOD_CHECK_STATUS(co, "Call to ICU method has failed"); RETURN_LONG((zend_long)result); } @@ -647,8 +642,7 @@ U_CFUNC PHP_FUNCTION(intlcal_get_locale) Locale locale = co->ucal->getLocale((ULocDataLocaleType)locale_type, CALENDAR_ERROR_CODE(co)); - INTL_METHOD_CHECK_STATUS(co, - "intlcal_get_locale: Call to ICU method has failed"); + INTL_METHOD_CHECK_STATUS(co, "Call to ICU method has failed"); RETURN_STRING(locale.getName()); } @@ -671,8 +665,8 @@ U_CFUNC PHP_FUNCTION(intlcal_get_minimal_days_in_first_week) CALENDAR_METHOD_FETCH_OBJECT; uint8_t result = co->ucal->getMinimalDaysInFirstWeek(); - INTL_METHOD_CHECK_STATUS(co, - "intlcal_get_first_day_of_week: Call to ICU method has failed"); /* TODO Is it really a failure? */ + /* TODO Is it really a failure? */ + INTL_METHOD_CHECK_STATUS(co, "Call to ICU method has failed"); RETURN_LONG((zend_long)result); } @@ -697,7 +691,7 @@ U_CFUNC PHP_FUNCTION(intlcal_get_time_zone) TimeZone *tz = co->ucal->getTimeZone().clone(); if (UNEXPECTED(tz == NULL)) { intl_errors_set(CALENDAR_ERROR_P(co), U_MEMORY_ALLOCATION_ERROR, - "intlcal_get_time_zone: could not clone TimeZone", 0); + "could not clone TimeZone"); RETURN_FALSE; } @@ -734,8 +728,7 @@ U_CFUNC PHP_FUNCTION(intlcal_get_weekend_transition) int32_t res = co->ucal->getWeekendTransition((UCalendarDaysOfWeek)dow, CALENDAR_ERROR_CODE(co)); - INTL_METHOD_CHECK_STATUS(co, "intlcal_get_weekend_transition: " - "Error calling ICU method"); + INTL_METHOD_CHECK_STATUS(co, "Error calling ICU method"); RETURN_LONG((zend_long)res); } @@ -752,8 +745,7 @@ U_CFUNC PHP_FUNCTION(intlcal_in_daylight_time) CALENDAR_METHOD_FETCH_OBJECT; UBool ret = co->ucal->inDaylightTime(CALENDAR_ERROR_CODE(co)); - INTL_METHOD_CHECK_STATUS(co, "intlcal_in_daylight_time: " - "Error calling ICU method"); + INTL_METHOD_CHECK_STATUS(co, "Error calling ICU method"); RETURN_BOOL((int)ret); } @@ -829,8 +821,7 @@ U_CFUNC PHP_FUNCTION(intlcal_is_weekend) RETURN_BOOL((int)co->ucal->isWeekend()); } else { UBool ret = co->ucal->isWeekend((UDate)date, CALENDAR_ERROR_CODE(co)); - INTL_METHOD_CHECK_STATUS(co, "intlcal_is_weekend: " - "Error calling ICU method"); + INTL_METHOD_CHECK_STATUS(co, "Error calling ICU method"); RETURN_BOOL((int)ret); } } @@ -915,7 +906,7 @@ U_CFUNC PHP_FUNCTION(intlcal_equals) } UBool result = co->ucal->equals(*other_co->ucal, CALENDAR_ERROR_CODE(co)); - INTL_METHOD_CHECK_STATUS(co, "intlcal_equals: error calling ICU Calendar::equals"); + INTL_METHOD_CHECK_STATUS(co, "error calling ICU Calendar::equals"); RETURN_BOOL((int)result); } @@ -1028,16 +1019,14 @@ U_CFUNC PHP_FUNCTION(intlcal_from_date_time) datetime = php_date_obj_from_obj(date_obj); if (!datetime->time) { intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, - "intlcal_from_date_time: DateTime object is unconstructed", - 0); + "DateTime object is unconstructed"); goto error; } zend_call_method_with_0_params(date_obj, php_date_get_date_ce(), NULL, "gettimestamp", &zv_timestamp); if (Z_TYPE(zv_timestamp) != IS_LONG) { intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, - "intlcal_from_date_time: bad DateTime; call to " - "DateTime::getTimestamp() failed", 0); + "bad DateTime; call to DateTime::getTimestamp() failed"); zval_ptr_dtor(&zv_timestamp); goto error; } @@ -1046,7 +1035,7 @@ U_CFUNC PHP_FUNCTION(intlcal_from_date_time) timeZone = TimeZone::getGMT()->clone(); } else { timeZone = timezone_convert_datetimezone(datetime->time->zone_type, - datetime, 1, NULL, "intlcal_from_date_time"); + datetime, 1, NULL); if (timeZone == NULL) { goto error; } @@ -1060,16 +1049,16 @@ U_CFUNC PHP_FUNCTION(intlcal_from_date_time) Locale::createFromName(locale_str), status); if (UNEXPECTED(cal == NULL)) { delete timeZone; - intl_error_set(NULL, status, "intlcal_from_date_time: " - "error creating ICU Calendar object", 0); + intl_error_set(NULL, status, + "error creating ICU Calendar object"); goto error; } cal->setTime(((UDate)Z_LVAL(zv_timestamp)) * 1000., status); if (U_FAILURE(status)) { /* time zone was adopted by cal; should not be deleted here */ delete cal; - intl_error_set(NULL, status, "intlcal_from_date_time: " - "error creating ICU Calendar::setTime()", 0); + intl_error_set(NULL, status, + "error creating ICU Calendar::setTime()"); goto error; } @@ -1105,8 +1094,7 @@ U_CFUNC PHP_FUNCTION(intlcal_to_date_time) if (UNEXPECTED(date > (double)U_INT64_MAX || date < (double)U_INT64_MIN)) { intl_errors_set(CALENDAR_ERROR_P(co), U_ILLEGAL_ARGUMENT_ERROR, - "intlcal_to_date_time: The calendar date is out of the " - "range for a 64-bit integer", 0); + "The calendar date is out of the range for a 64-bit integer"); RETURN_FALSE; } @@ -1119,7 +1107,7 @@ U_CFUNC PHP_FUNCTION(intlcal_to_date_time) /* Now get the time zone */ const TimeZone& tz = co->ucal->getTimeZone(); zval *timezone_zval = timezone_convert_to_datetimezone( - &tz, CALENDAR_ERROR_P(co), "intlcal_to_date_time", &tmp); + &tz, CALENDAR_ERROR_P(co), &tmp); if (timezone_zval == NULL) { zval_ptr_dtor(&ts_zval); RETURN_FALSE; @@ -1146,8 +1134,7 @@ U_CFUNC PHP_FUNCTION(intlcal_to_date_time) &retval, timezone_zval); if (Z_ISUNDEF(retval) || Z_TYPE(retval) == IS_FALSE) { intl_errors_set(CALENDAR_ERROR_P(co), U_ILLEGAL_ARGUMENT_ERROR, - "intlcal_to_date_time: call to DateTime::setTimeZone has failed", - 1); + "call to DateTime::setTimeZone has failed"); zval_ptr_dtor(return_value); RETVAL_FALSE; goto error; diff --git a/ext/intl/calendar/gregoriancalendar_methods.cpp b/ext/intl/calendar/gregoriancalendar_methods.cpp index d1d3e2ceb14e2..46c34b5efe6af 100644 --- a/ext/intl/calendar/gregoriancalendar_methods.cpp +++ b/ext/intl/calendar/gregoriancalendar_methods.cpp @@ -53,9 +53,7 @@ static bool set_gregorian_calendar_time_zone(GregorianCalendar *gcal, UErrorCode { if (U_FAILURE(status)) { intl_error_set(NULL, status, - "IntlGregorianCalendar: Error creating ICU GregorianCalendar from date", - 0 - ); + "Error creating ICU GregorianCalendar from date"); return false; } @@ -64,10 +62,8 @@ static bool set_gregorian_calendar_time_zone(GregorianCalendar *gcal, UErrorCode UnicodeString tzstr = UnicodeString::fromUTF8(StringPiece(tzinfo->name)); if (tzstr.isBogus()) { intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, - "IntlGregorianCalendar: Could not create UTF-8 string " - "from PHP's default timezone name (see date_default_timezone_get())", - 0 - ); + "Could not create UTF-8 string from PHP's default timezone " + "name (see date_default_timezone_get())"); return false; } @@ -78,8 +74,7 @@ static bool set_gregorian_calendar_time_zone(GregorianCalendar *gcal, UErrorCode return true; } -static void _php_intlgregcal_constructor_body( - INTERNAL_FUNCTION_PARAMETERS, bool is_constructor, zend_error_handling *error_handling, bool *error_handling_replaced) +static void _php_intlgregcal_constructor_body(INTERNAL_FUNCTION_PARAMETERS, bool is_constructor) { zval *tz_object = NULL; zval args_a[6], @@ -127,11 +122,6 @@ static void _php_intlgregcal_constructor_body( RETURN_THROWS(); } - if (error_handling != NULL) { - zend_replace_error_handling(EH_THROW, IntlException_ce_ptr, error_handling); - *error_handling_replaced = 1; - } - // instantion of ICU object Calendar_object *co = Z_INTL_CALENDAR_P(return_value); std::unique_ptr gcal; @@ -143,9 +133,9 @@ static void _php_intlgregcal_constructor_body( if (variant <= 2) { // From timezone and locale (0 to 2 arguments) - TimeZone *tz = timezone_process_timezone_argument(tz_object, NULL, - "intlgregcal_create_instance"); + TimeZone *tz = timezone_process_timezone_argument(tz_object, NULL); if (tz == NULL) { + // TODO: Exception should always occur already? if (!EG(exception)) { zend_throw_exception(IntlException_ce_ptr, "Constructor failed", 0); } @@ -163,8 +153,8 @@ static void _php_intlgregcal_constructor_body( 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); + intl_error_set(NULL, status, "error creating ICU " + "GregorianCalendar from time zone and locale"); delete tz; if (!is_constructor) { zval_ptr_dtor(return_value); @@ -209,29 +199,27 @@ static void _php_intlgregcal_constructor_body( U_CFUNC PHP_FUNCTION(intlgregcal_create_instance) { - intl_error_reset(NULL); - object_init_ex(return_value, GregorianCalendar_ce_ptr); - _php_intlgregcal_constructor_body(INTERNAL_FUNCTION_PARAM_PASSTHRU, /* is_constructor */ 0, NULL, NULL); + _php_intlgregcal_constructor_body(INTERNAL_FUNCTION_PARAM_PASSTHRU, /* is_constructor */ false); } U_CFUNC PHP_METHOD(IntlGregorianCalendar, __construct) { - zend_error_handling error_handling; - bool error_handling_replaced = 0; + const bool old_use_exception = INTL_G(use_exceptions); + const zend_long old_error_level = INTL_G(error_level); + INTL_G(use_exceptions) = true; + INTL_G(error_level) = 0; return_value = ZEND_THIS; - _php_intlgregcal_constructor_body(INTERNAL_FUNCTION_PARAM_PASSTHRU, /* is_constructor */ 1, &error_handling, &error_handling_replaced); - if (error_handling_replaced) { - zend_restore_error_handling(&error_handling); - } + _php_intlgregcal_constructor_body(INTERNAL_FUNCTION_PARAM_PASSTHRU, /* is_constructor */ true); + INTL_G(use_exceptions) = old_use_exception; + INTL_G(error_level) = old_error_level; } U_CFUNC PHP_METHOD(IntlGregorianCalendar, createFromDate) { zend_long year, month, day; UErrorCode status = U_ZERO_ERROR; - zend_error_handling error_handling; Calendar_object *co; std::unique_ptr gcal; @@ -247,10 +235,12 @@ U_CFUNC PHP_METHOD(IntlGregorianCalendar, createFromDate) ZEND_VALUE_ERROR_OUT_OF_BOUND_VALUE(month, 2); ZEND_VALUE_ERROR_OUT_OF_BOUND_VALUE(day, 3); - zend_replace_error_handling(EH_THROW, IntlException_ce_ptr, &error_handling); + const bool old_use_exception = INTL_G(use_exceptions); + const zend_long old_error_level = INTL_G(error_level); gcal = std::unique_ptr(new GregorianCalendar((int32_t) year, (int32_t) month, (int32_t) day, status)); if (!set_gregorian_calendar_time_zone(gcal.get(), status)) { + ZEND_ASSERT(EG(exception)); goto cleanup; } @@ -259,7 +249,8 @@ U_CFUNC PHP_METHOD(IntlGregorianCalendar, createFromDate) co->ucal = gcal.release(); cleanup: - zend_restore_error_handling(&error_handling); + INTL_G(use_exceptions) = old_use_exception; + INTL_G(error_level) = old_error_level; } U_CFUNC PHP_METHOD(IntlGregorianCalendar, createFromDateTime) @@ -267,7 +258,6 @@ U_CFUNC PHP_METHOD(IntlGregorianCalendar, createFromDateTime) zend_long year, month, day, hour, minute, second; bool second_is_null = 1; UErrorCode status = U_ZERO_ERROR; - zend_error_handling error_handling; Calendar_object *co; GregorianCalendar *tmp; @@ -289,8 +279,6 @@ U_CFUNC PHP_METHOD(IntlGregorianCalendar, createFromDateTime) ZEND_VALUE_ERROR_OUT_OF_BOUND_VALUE(hour, 4); ZEND_VALUE_ERROR_OUT_OF_BOUND_VALUE(minute, 5); - zend_replace_error_handling(EH_THROW, IntlException_ce_ptr, &error_handling); - if (second_is_null) { tmp = new GregorianCalendar((int32_t) year, (int32_t) month, (int32_t) day, (int32_t) hour, (int32_t) minute, status); } else { @@ -298,7 +286,10 @@ U_CFUNC PHP_METHOD(IntlGregorianCalendar, createFromDateTime) tmp = new GregorianCalendar((int32_t) year, (int32_t) month, (int32_t) day, (int32_t) hour, (int32_t) minute, (int32_t) second, status); } auto gcal = std::unique_ptr(tmp); + const bool old_use_exception = INTL_G(use_exceptions); + const zend_long old_error_level = INTL_G(error_level); if (!set_gregorian_calendar_time_zone(gcal.get(), status)) { + ZEND_ASSERT(EG(exception)); goto cleanup; } @@ -308,7 +299,8 @@ U_CFUNC PHP_METHOD(IntlGregorianCalendar, createFromDateTime) co->ucal = gcal.release(); cleanup: - zend_restore_error_handling(&error_handling); + INTL_G(use_exceptions) = old_use_exception; + INTL_G(error_level) = old_error_level; } U_CFUNC PHP_FUNCTION(intlgregcal_set_gregorian_change) @@ -325,8 +317,7 @@ U_CFUNC PHP_FUNCTION(intlgregcal_set_gregorian_change) CALENDAR_METHOD_FETCH_OBJECT; fetch_greg(co)->setGregorianChange(date, CALENDAR_ERROR_CODE(co)); - INTL_METHOD_CHECK_STATUS(co, "intlgregcal_set_gregorian_change: error " - "calling ICU method"); + INTL_METHOD_CHECK_STATUS(co, "error calling ICU method"); RETURN_TRUE; } diff --git a/ext/intl/collator/collator_class.h b/ext/intl/collator/collator_class.h index 5c69c2e5affb2..311ab5623db4e 100644 --- a/ext/intl/collator/collator_class.h +++ b/ext/intl/collator/collator_class.h @@ -66,7 +66,7 @@ extern zend_class_entry *Collator_ce_ptr; intl_error_set_code( NULL, COLLATOR_ERROR_CODE( co ) ); \ if( U_FAILURE( COLLATOR_ERROR_CODE( co ) ) ) \ { \ - intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ), msg, 0 ); \ + intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ), msg); \ RETURN_FALSE; \ } \ diff --git a/ext/intl/collator/collator_compare.c b/ext/intl/collator/collator_compare.c index f71d57f74f86a..bafaf166ac7a6 100644 --- a/ext/intl/collator/collator_compare.c +++ b/ext/intl/collator/collator_compare.c @@ -50,8 +50,7 @@ PHP_FUNCTION( collator_compare ) if (!co || !co->ucoll) { intl_error_set_code( NULL, COLLATOR_ERROR_CODE( co ) ); - intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ), - "Object not initialized", 0 ); + intl_errors_set_custom_msg(COLLATOR_ERROR_P( co ), "Object not initialized"); zend_throw_error(NULL, "Object not initialized"); RETURN_THROWS(); @@ -70,8 +69,7 @@ PHP_FUNCTION( collator_compare ) intl_error_set_code( NULL, COLLATOR_ERROR_CODE( co ) ); /* Set error messages. */ - intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ), - "Error converting first argument to UTF-16", 0 ); + intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ), "Error converting first argument to UTF-16"); if (ustr1) { efree( ustr1 ); } @@ -86,8 +84,7 @@ PHP_FUNCTION( collator_compare ) intl_error_set_code( NULL, COLLATOR_ERROR_CODE( co ) ); /* Set error messages. */ - intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ), - "Error converting second argument to UTF-16", 0 ); + intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ), "Error converting second argument to UTF-16"); if (ustr1) { efree( ustr1 ); } diff --git a/ext/intl/collator/collator_create.c b/ext/intl/collator/collator_create.c index 88dacc1c1db4e..5e6b0dee9ce6e 100644 --- a/ext/intl/collator/collator_create.c +++ b/ext/intl/collator/collator_create.c @@ -22,7 +22,7 @@ #include "intl_data.h" /* {{{ */ -static int collator_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handling *error_handling, bool *error_handling_replaced) +static int collator_ctor(INTERNAL_FUNCTION_PARAMETERS) { char* locale; size_t locale_len = 0; @@ -35,11 +35,6 @@ static int collator_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handling *erro Z_PARAM_STRING(locale, locale_len) ZEND_PARSE_PARAMETERS_END_EX(return FAILURE); - if (error_handling != NULL) { - zend_replace_error_handling(EH_THROW, IntlException_ce_ptr, error_handling); - *error_handling_replaced = 1; - } - INTL_CHECK_LOCALE_LEN_OR_FAILURE(locale_len); COLLATOR_METHOD_FETCH_OBJECT; @@ -49,7 +44,7 @@ static int collator_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handling *erro /* Open ICU collator. */ co->ucoll = ucol_open( locale, COLLATOR_ERROR_CODE_P( co ) ); - INTL_CTOR_CHECK_STATUS(co, "collator_create: unable to open ICU collator"); + INTL_CTOR_CHECK_STATUS(co, "unable to open ICU collator"); return SUCCESS; } /* }}} */ @@ -58,7 +53,7 @@ static int collator_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handling *erro PHP_FUNCTION( collator_create ) { object_init_ex( return_value, Collator_ce_ptr ); - if (collator_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, NULL, NULL) == FAILURE) { + if (collator_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU) == FAILURE) { zval_ptr_dtor(return_value); RETURN_NULL(); } @@ -68,17 +63,16 @@ PHP_FUNCTION( collator_create ) /* {{{ Collator object constructor. */ PHP_METHOD( Collator, __construct ) { - zend_error_handling error_handling; - bool error_handling_replaced = 0; + const bool old_use_exception = INTL_G(use_exceptions); + const zend_long old_error_level = INTL_G(error_level); + INTL_G(use_exceptions) = true; + INTL_G(error_level) = 0; return_value = ZEND_THIS; - if (collator_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, &error_handling, &error_handling_replaced) == FAILURE) { - if (!EG(exception)) { - zend_throw_exception(IntlException_ce_ptr, "Constructor failed", 0); - } - } - if (error_handling_replaced) { - zend_restore_error_handling(&error_handling); + if (collator_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU) == FAILURE) { + ZEND_ASSERT(EG(exception)); } + INTL_G(use_exceptions) = old_use_exception; + INTL_G(error_level) = old_error_level; } /* }}} */ diff --git a/ext/intl/collator/collator_locale.c b/ext/intl/collator/collator_locale.c index e1cdcdf2a6091..a7aafa74c26bd 100644 --- a/ext/intl/collator/collator_locale.c +++ b/ext/intl/collator/collator_locale.c @@ -43,8 +43,7 @@ PHP_FUNCTION( collator_get_locale ) if (!co || !co->ucoll) { intl_error_set_code( NULL, COLLATOR_ERROR_CODE( co ) ); - intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ), - "Object not initialized", 0 ); + intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ), "Object not initialized"); zend_throw_error(NULL, "Object not initialized"); RETURN_THROWS(); diff --git a/ext/intl/collator/collator_sort.c b/ext/intl/collator/collator_sort.c index 215f150c4faf9..99b75aa0ef2be 100644 --- a/ext/intl/collator/collator_sort.c +++ b/ext/intl/collator/collator_sort.c @@ -359,8 +359,7 @@ PHP_FUNCTION( collator_sort_with_sort_keys ) if (!co || !co->ucoll) { intl_error_set_code( NULL, COLLATOR_ERROR_CODE( co ) ); - intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ), - "Object not initialized", 0 ); + intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ), "Object not initialized"); zend_throw_error(NULL, "Object not initialized"); RETURN_THROWS(); @@ -393,7 +392,7 @@ PHP_FUNCTION( collator_sort_with_sort_keys ) if( U_FAILURE( COLLATOR_ERROR_CODE( co ) ) ) { intl_error_set_code( NULL, COLLATOR_ERROR_CODE( co ) ); - intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ), "Sort with sort keys failed", 0 ); + intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ), "Sort with sort keys failed"); if( utf16_buf ) efree( utf16_buf ); @@ -516,8 +515,7 @@ PHP_FUNCTION( collator_get_sort_key ) if (!co || !co->ucoll) { intl_error_set_code( NULL, COLLATOR_ERROR_CODE( co ) ); - intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ), - "Object not initialized", 0 ); + intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ), "Object not initialized"); zend_throw_error(NULL, "Object not initialized"); RETURN_THROWS(); @@ -536,8 +534,7 @@ PHP_FUNCTION( collator_get_sort_key ) intl_error_set_code( NULL, COLLATOR_ERROR_CODE( co ) ); /* Set error messages. */ - intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ), - "Error converting first argument to UTF-16", 0 ); + intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ), "Error converting first argument to UTF-16"); efree( ustr ); RETURN_FALSE; } diff --git a/ext/intl/common/common_date.cpp b/ext/intl/common/common_date.cpp index e27a67ec55ad2..f2ca077554b49 100644 --- a/ext/intl/common/common_date.cpp +++ b/ext/intl/common/common_date.cpp @@ -30,11 +30,9 @@ using icu::UnicodeString; /* {{{ timezone_convert_datetimezone * The timezone in DateTime and DateTimeZone is not unified. */ -U_CFUNC TimeZone *timezone_convert_datetimezone(int type, - void *object, - int is_datetime, - intl_error *outside_error, - const char *func) +U_CFUNC TimeZone *timezone_convert_datetimezone( + int type, void *object, bool is_datetime, + intl_error *outside_error) { char *id = NULL, offset_id[] = "GMT+00:00"; @@ -58,11 +56,8 @@ U_CFUNC TimeZone *timezone_convert_datetimezone(int type, minutes *= minutes > 0 ? 1 : -1; if (offset_mins <= -24 * 60 || offset_mins >= 24 * 60) { - spprintf(&message, 0, "%s: object has an time zone offset " - "that's too large", func); intl_errors_set(outside_error, U_ILLEGAL_ARGUMENT_ERROR, - message, 1); - efree(message); + "object has an time zone offset that's too large"); return NULL; } @@ -82,10 +77,9 @@ U_CFUNC TimeZone *timezone_convert_datetimezone(int type, UnicodeString s = UnicodeString(id, id_len, US_INV); timeZone = TimeZone::createTimeZone(s); if (*timeZone == TimeZone::getUnknown()) { - spprintf(&message, 0, "%s: time zone id '%s' " - "extracted from ext/date DateTimeZone not recognized", func, id); - intl_errors_set(outside_error, U_ILLEGAL_ARGUMENT_ERROR, - message, 1); + spprintf(&message, 0, "time zone id '%s' " + "extracted from ext/date DateTimeZone not recognized", id); + intl_errors_set(outside_error, U_ILLEGAL_ARGUMENT_ERROR, message); efree(message); delete timeZone; return NULL; @@ -95,7 +89,7 @@ U_CFUNC TimeZone *timezone_convert_datetimezone(int type, /* }}} */ U_CFUNC zend_result intl_datetime_decompose(zend_object *obj, double *millis, TimeZone **tz, - intl_error *err, const char *func) + intl_error *err) { char *message; php_date_obj *datetime = php_date_obj_from_obj(obj); @@ -125,8 +119,8 @@ U_CFUNC zend_result intl_datetime_decompose(zend_object *obj, double *millis, Ti // TODO: Remove this when DateTimeInterface::getTimestamp() no longer has a tentative return type if (Z_TYPE(retval) != IS_LONG) { zval_ptr_dtor(&retval); - spprintf(&message, 0, "%s: %s::getTimestamp() did not return an int", func, ZSTR_VAL(obj->ce->name)); - intl_errors_set(err, U_INTERNAL_PROGRAM_ERROR, message, 1); + spprintf(&message, 0, "%s::getTimestamp() did not return an int", ZSTR_VAL(obj->ce->name)); + intl_errors_set(err, U_INTERNAL_PROGRAM_ERROR, message); efree(message); return FAILURE; } @@ -136,10 +130,9 @@ U_CFUNC zend_result intl_datetime_decompose(zend_object *obj, double *millis, Ti if (tz) { if (!datetime->time) { - spprintf(&message, 0, "%s: the %s object is not properly " - "initialized", func, ZSTR_VAL(obj->ce->name)); - intl_errors_set(err, U_ILLEGAL_ARGUMENT_ERROR, - message, 1); + spprintf(&message, 0, "the %s object is not properly " + "initialized", ZSTR_VAL(obj->ce->name)); + intl_errors_set(err, U_ILLEGAL_ARGUMENT_ERROR, message); efree(message); return FAILURE; } @@ -147,13 +140,10 @@ U_CFUNC zend_result intl_datetime_decompose(zend_object *obj, double *millis, Ti *tz = TimeZone::getGMT()->clone(); } else { *tz = timezone_convert_datetimezone(datetime->time->zone_type, - datetime, 1, NULL, func); + datetime, 1, NULL); if (*tz == NULL) { - spprintf(&message, 0, "%s: could not convert DateTime's " - "time zone", func); intl_errors_set(err, U_ILLEGAL_ARGUMENT_ERROR, - message, 1); - efree(message); + "could not convert DateTime's time zone"); return FAILURE; } } @@ -162,12 +152,11 @@ U_CFUNC zend_result intl_datetime_decompose(zend_object *obj, double *millis, Ti return SUCCESS; } -U_CFUNC double intl_zval_to_millis(zval *z, intl_error *err, const char *func) +U_CFUNC double intl_zval_to_millis(zval *z, intl_error *err) { double rv = ZEND_NAN; zend_long lv; int type; - char *message; if (err && U_FAILURE(err->code)) { return ZEND_NAN; @@ -182,11 +171,12 @@ U_CFUNC double intl_zval_to_millis(zval *z, intl_error *err, const char *func) } else if (type == IS_LONG) { rv = U_MILLIS_PER_SECOND * (double)lv; } else { - spprintf(&message, 0, "%s: string '%s' is not numeric, " - "which would be required for it to be a valid date", func, + char *message; + spprintf(&message, 0, "string '%s' is not numeric, " + "which would be required for it to be a valid date", Z_STRVAL_P(z)); intl_errors_set(err, U_ILLEGAL_ARGUMENT_ERROR, - message, 1); + message); efree(message); } break; @@ -198,42 +188,32 @@ U_CFUNC double intl_zval_to_millis(zval *z, intl_error *err, const char *func) break; case IS_OBJECT: if (instanceof_function(Z_OBJCE_P(z), php_date_get_interface_ce())) { - intl_datetime_decompose(Z_OBJ_P(z), &rv, nullptr, err, func); + intl_datetime_decompose(Z_OBJ_P(z), &rv, nullptr, err); } else if (instanceof_function(Z_OBJCE_P(z), Calendar_ce_ptr)) { Calendar_object *co = Z_INTL_CALENDAR_P(z); if (co->ucal == NULL) { - spprintf(&message, 0, "%s: IntlCalendar object is not properly " - "constructed", func); intl_errors_set(err, U_ILLEGAL_ARGUMENT_ERROR, - message, 1); - efree(message); + "IntlCalendar object is not properly constructed"); } else { UErrorCode status = UErrorCode(); rv = (double)co->ucal->getTime(status); if (U_FAILURE(status)) { - spprintf(&message, 0, "%s: call to internal " - "Calendar::getTime() has failed", func); - intl_errors_set(err, status, message, 1); - efree(message); + intl_errors_set(err, status, "call to internal Calendar::getTime() has failed"); } } } else { /* TODO: try with cast(), get() to obtain a number */ - spprintf(&message, 0, "%s: invalid object type for date/time " - "(only IntlCalendar and DateTimeInterface permitted)", func); intl_errors_set(err, U_ILLEGAL_ARGUMENT_ERROR, - message, 1); - efree(message); + "invalid object type for date/time " + "(only IntlCalendar and DateTimeInterface permitted)"); } break; case IS_REFERENCE: z = Z_REFVAL_P(z); goto try_again; default: - spprintf(&message, 0, "%s: invalid PHP type for date", func); intl_errors_set(err, U_ILLEGAL_ARGUMENT_ERROR, - message, 1); - efree(message); + "invalid PHP type for date"); break; } diff --git a/ext/intl/common/common_date.h b/ext/intl/common/common_date.h index e9fac3a02bd57..ef007c8eee687 100644 --- a/ext/intl/common/common_date.h +++ b/ext/intl/common/common_date.h @@ -28,11 +28,11 @@ U_CDECL_END using icu::TimeZone; -U_CFUNC TimeZone *timezone_convert_datetimezone(int type, void *object, int is_datetime, intl_error *outside_error, const char *func); -U_CFUNC zend_result intl_datetime_decompose(zend_object *obj, double *millis, TimeZone **tz, intl_error *err, const char *func); +U_CFUNC TimeZone *timezone_convert_datetimezone(int type, void *object, bool is_datetime, intl_error *outside_error); +U_CFUNC zend_result intl_datetime_decompose(zend_object *obj, double *millis, TimeZone **tz, intl_error *err); #endif -U_CFUNC double intl_zval_to_millis(zval *z, intl_error *err, const char *func); +U_CFUNC double intl_zval_to_millis(zval *z, intl_error *err); #endif /* COMMON_DATE_H */ diff --git a/ext/intl/common/common_enum.cpp b/ext/intl/common/common_enum.cpp index 4585a60f077aa..c2ab946f85852 100644 --- a/ext/intl/common/common_enum.cpp +++ b/ext/intl/common/common_enum.cpp @@ -74,8 +74,7 @@ static void string_enum_current_move_forward(zend_object_iterator *iter) intl_error_set_code(NULL, INTLITERATOR_ERROR_CODE(ii)); if (U_FAILURE(INTLITERATOR_ERROR_CODE(ii))) { - intl_errors_set_custom_msg(INTL_DATA_ERROR_P(ii), - "Error fetching next iteration element", 0); + intl_errors_set_custom_msg(INTL_DATA_ERROR_P(ii), "Error fetching next iteration element"); } else if (result) { ZVAL_STRINGL(&zoi_iter->current, result, result_length); } //else we've reached the end of the enum, nothing more is required @@ -105,8 +104,7 @@ static void string_enum_rewind(zend_object_iterator *iter) intl_error_set_code(NULL, INTLITERATOR_ERROR_CODE(ii)); if (U_FAILURE(INTLITERATOR_ERROR_CODE(ii))) { - intl_errors_set_custom_msg(INTL_DATA_ERROR_P(ii), - "Error resetting enumeration", 0); + intl_errors_set_custom_msg(INTL_DATA_ERROR_P(ii), "Error resetting enumeration"); } else { iter->funcs->move_forward(iter); } @@ -268,7 +266,7 @@ PHP_METHOD(IntlIterator, rewind) ii->iterator->funcs->rewind(ii->iterator); } else { intl_errors_set(INTLITERATOR_ERROR_P(ii), U_UNSUPPORTED_ERROR, - "IntlIterator::rewind: rewind not supported", 0); + "rewind not supported"); } } diff --git a/ext/intl/converter/converter.c b/ext/intl/converter/converter.c index 3aa7a53aa485b..6fa654aaa876b 100644 --- a/ext/intl/converter/converter.c +++ b/ext/intl/converter/converter.c @@ -42,8 +42,8 @@ static zend_class_entry *php_converter_ce; static zend_object_handlers php_converter_object_handlers; #define CONV_GET(pzv) (Z_INTL_CONVERTER_P((pzv))) -#define THROW_UFAILURE(obj, fname, error) php_converter_throw_failure(obj, error, \ - fname "() returned error " ZEND_LONG_FMT ": %s", (zend_long)error, u_errorName(error)) +#define THROW_UFAILURE(obj, error) php_converter_throw_failure(obj, error, \ + "returned error " ZEND_LONG_FMT ": %s", (zend_long)error, u_errorName(error)) /* {{{ php_converter_throw_failure */ static inline void php_converter_throw_failure(php_converter_object *objval, UErrorCode error, const char *format, ...) { @@ -55,7 +55,7 @@ static inline void php_converter_throw_failure(php_converter_object *objval, UEr vsnprintf(message, sizeof(message), format, vargs); va_end(vargs); - intl_errors_set(err, error, message, 1); + intl_errors_set(err, error, message); } /* }}} */ @@ -90,7 +90,7 @@ static void php_converter_default_callback(zval *return_value, zval *zobj, zend_ */ ucnv_getSubstChars(objval->src, chars, &chars_len, &uerror); if (U_FAILURE(uerror)) { - THROW_UFAILURE(objval, "ucnv_getSubstChars", uerror); + THROW_UFAILURE(objval, uerror); chars[0] = 0x1A; chars[1] = 0; chars_len = 1; @@ -341,7 +341,7 @@ static inline bool php_converter_set_callbacks(php_converter_object *objval, UCo ucnv_setToUCallBack(cnv, (UConverterToUCallback)php_converter_to_u_callback, (const void*)objval, NULL, NULL, &error); if (U_FAILURE(error)) { - THROW_UFAILURE(objval, "ucnv_setToUCallBack", error); + THROW_UFAILURE(objval, error); ret = 0; } @@ -349,7 +349,7 @@ static inline bool php_converter_set_callbacks(php_converter_object *objval, UCo ucnv_setFromUCallBack(cnv, (UConverterFromUCallback)php_converter_from_u_callback, (const void*)objval, NULL, NULL, &error); if (U_FAILURE(error)) { - THROW_UFAILURE(objval, "ucnv_setFromUCallBack", error); + THROW_UFAILURE(objval, error); ret = 0; } return ret; @@ -373,11 +373,11 @@ static bool php_converter_set_encoding(php_converter_object *objval, php_error_docref(NULL, E_WARNING, "Ambiguous encoding specified, using %s", actual_encoding); } else if (U_FAILURE(error)) { if (objval) { - THROW_UFAILURE(objval, "ucnv_open", error); + THROW_UFAILURE(objval, error); } else { char *msg; spprintf(&msg, 0, "Error setting encoding: %d - %s", (int)error, u_errorName(error)); - intl_error_set(NULL, error, msg, 1); + intl_error_set(NULL, error, msg); efree(msg); } return false; @@ -439,7 +439,7 @@ static void php_converter_do_get_encoding(php_converter_object *objval, UConvert name = ucnv_getName(cnv, &objval->error.code); if (U_FAILURE(objval->error.code)) { - THROW_UFAILURE(objval, "ucnv_getName()", objval->error.code); + THROW_UFAILURE(objval, objval->error.code); RETURN_FALSE; } @@ -474,7 +474,7 @@ static void php_converter_do_get_type(php_converter_object *objval, UConverter * t = ucnv_getType(cnv); if (U_FAILURE(objval->error.code)) { - THROW_UFAILURE(objval, "ucnv_getType", objval->error.code); + THROW_UFAILURE(objval, objval->error.code); RETURN_FALSE; } @@ -554,7 +554,7 @@ PHP_METHOD(UConverter, setSubstChars) { UErrorCode error = U_ZERO_ERROR; ucnv_setSubstChars(objval->src, chars, chars_len, &error); if (U_FAILURE(error)) { - THROW_UFAILURE(objval, "ucnv_setSubstChars", error); + THROW_UFAILURE(objval, error); ret = 0; } } else { @@ -566,7 +566,7 @@ PHP_METHOD(UConverter, setSubstChars) { UErrorCode error = U_ZERO_ERROR; ucnv_setSubstChars(objval->dest, chars, chars_len, &error); if (U_FAILURE(error)) { - THROW_UFAILURE(objval, "ucnv_setSubstChars", error); + THROW_UFAILURE(objval, error); ret = 0; } } else { @@ -597,7 +597,7 @@ PHP_METHOD(UConverter, getSubstChars) { */ ucnv_getSubstChars(objval->src, chars, &chars_len, &error); if (U_FAILURE(error)) { - THROW_UFAILURE(objval, "ucnv_getSubstChars", error); + THROW_UFAILURE(objval, error); RETURN_FALSE; } @@ -624,7 +624,7 @@ static zend_string* php_converter_do_convert(UConverter *dest_cnv, /* Get necessary buffer size first */ temp_len = 1 + ucnv_toUChars(src_cnv, NULL, 0, src, src_len, &error); if (U_FAILURE(error) && error != U_BUFFER_OVERFLOW_ERROR) { - THROW_UFAILURE(objval, "ucnv_toUChars", error); + THROW_UFAILURE(objval, error); return NULL; } temp = safe_emalloc(sizeof(UChar), temp_len, sizeof(UChar)); @@ -633,7 +633,7 @@ static zend_string* php_converter_do_convert(UConverter *dest_cnv, error = U_ZERO_ERROR; temp_len = ucnv_toUChars(src_cnv, temp, temp_len, src, src_len, &error); if (U_FAILURE(error)) { - THROW_UFAILURE(objval, "ucnv_toUChars", error); + THROW_UFAILURE(objval, error); efree(temp); return NULL; } @@ -642,7 +642,7 @@ static zend_string* php_converter_do_convert(UConverter *dest_cnv, /* Get necessary output buffer size */ ret_len = ucnv_fromUChars(dest_cnv, NULL, 0, temp, temp_len, &error); if (U_FAILURE(error) && error != U_BUFFER_OVERFLOW_ERROR) { - THROW_UFAILURE(objval, "ucnv_fromUChars", error); + THROW_UFAILURE(objval, error); efree(temp); return NULL; } @@ -654,7 +654,7 @@ static zend_string* php_converter_do_convert(UConverter *dest_cnv, ZSTR_LEN(ret) = ucnv_fromUChars(dest_cnv, ZSTR_VAL(ret), ret_len+1, temp, temp_len, &error); efree(temp); if (U_FAILURE(error)) { - THROW_UFAILURE(objval, "ucnv_fromUChars", error); + THROW_UFAILURE(objval, error); zend_string_efree(ret); return NULL; } @@ -758,7 +758,7 @@ PHP_METHOD(UConverter, transcode) { } if (U_FAILURE(error)) { - THROW_UFAILURE(NULL, "transcode", error); + THROW_UFAILURE(NULL, error); RETVAL_FALSE; } } else { @@ -831,7 +831,7 @@ PHP_METHOD(UConverter, getAliases) { count = ucnv_countAliases(name, &error); if (U_FAILURE(error)) { - THROW_UFAILURE(NULL, "ucnv_countAliases", error); + THROW_UFAILURE(NULL, error); RETURN_FALSE; } @@ -843,7 +843,7 @@ PHP_METHOD(UConverter, getAliases) { error = U_ZERO_ERROR; alias = ucnv_getAlias(name, i, &error); if (U_FAILURE(error)) { - THROW_UFAILURE(NULL, "ucnv_getAlias", error); + THROW_UFAILURE(NULL, error); zend_array_destroy(Z_ARR_P(return_value)); RETURN_NULL(); } @@ -866,7 +866,7 @@ PHP_METHOD(UConverter, getStandards) { UErrorCode error = U_ZERO_ERROR; const char *name = ucnv_getStandard(i, &error); if (U_FAILURE(error)) { - THROW_UFAILURE(NULL, "ucnv_getStandard", error); + THROW_UFAILURE(NULL, error); zend_array_destroy(Z_ARR_P(return_value)); RETURN_NULL(); } diff --git a/ext/intl/dateformat/dateformat_attrcpp.cpp b/ext/intl/dateformat/dateformat_attrcpp.cpp index 1fb5b514bc6a3..f95cc0f8de5be 100644 --- a/ext/intl/dateformat/dateformat_attrcpp.cpp +++ b/ext/intl/dateformat/dateformat_attrcpp.cpp @@ -71,8 +71,7 @@ U_CFUNC PHP_FUNCTION(datefmt_get_timezone) TimeZone *tz_clone = tz.clone(); if (UNEXPECTED(tz_clone == NULL)) { intl_errors_set(INTL_DATA_ERROR_P(dfo), U_MEMORY_ALLOCATION_ERROR, - "datefmt_get_timezone: Out of memory when cloning time zone", - 0); + "Out of memory when cloning time zone"); RETURN_FALSE; } @@ -95,7 +94,7 @@ U_CFUNC PHP_FUNCTION(datefmt_set_timezone) DATE_FORMAT_METHOD_FETCH_OBJECT; timezone = timezone_process_timezone_argument(timezone_zv, - INTL_DATA_ERROR_P(dfo), "datefmt_set_timezone"); + INTL_DATA_ERROR_P(dfo)); if (timezone == NULL) { RETURN_FALSE; } @@ -146,8 +145,7 @@ U_CFUNC PHP_FUNCTION(datefmt_get_calendar_object) Calendar *cal_clone = cal->clone(); if (UNEXPECTED(cal_clone == NULL)) { intl_errors_set(INTL_DATA_ERROR_P(dfo), U_MEMORY_ALLOCATION_ERROR, - "datefmt_get_calendar_object: Out of memory when cloning " - "calendar", 0); + "Out of memory when cloning calendar"); RETURN_FALSE; } @@ -187,7 +185,7 @@ U_CFUNC PHP_FUNCTION(datefmt_set_calendar) // must store the requested locale on object creation if (datefmt_process_calendar_arg(calendar_obj, calendar_long, calendar_is_null, locale, - "datefmt_set_calendar", INTL_DATA_ERROR_P(dfo), cal, cal_type, cal_owned) == FAILURE + INTL_DATA_ERROR_P(dfo), cal, cal_type, cal_owned) == FAILURE ) { RETURN_FALSE; } @@ -197,8 +195,7 @@ U_CFUNC PHP_FUNCTION(datefmt_set_calendar) TimeZone *old_timezone = fetch_datefmt(dfo)->getTimeZone().clone(); if (UNEXPECTED(old_timezone == NULL)) { intl_errors_set(INTL_DATA_ERROR_P(dfo), U_MEMORY_ALLOCATION_ERROR, - "datefmt_set_calendar: Out of memory when cloning calendar", - 0); + "Out of memory when cloning calendar"); delete cal; RETURN_FALSE; } @@ -207,8 +204,7 @@ U_CFUNC PHP_FUNCTION(datefmt_set_calendar) cal = cal->clone(); if (UNEXPECTED(cal == NULL)) { intl_errors_set(INTL_DATA_ERROR_P(dfo), U_MEMORY_ALLOCATION_ERROR, - "datefmt_set_calendar: Out of memory when cloning calendar", - 0); + "Out of memory when cloning calendar"); RETURN_FALSE; } } diff --git a/ext/intl/dateformat/dateformat_create.cpp b/ext/intl/dateformat/dateformat_create.cpp index d071c7d9d2ed7..2be1d81637419 100644 --- a/ext/intl/dateformat/dateformat_create.cpp +++ b/ext/intl/dateformat/dateformat_create.cpp @@ -45,7 +45,7 @@ extern "C" { UDAT_PATTERN == (i)) /* {{{ */ -static zend_result datefmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handling *error_handling, bool *error_handling_replaced) +static zend_result datefmt_ctor(INTERNAL_FUNCTION_PARAMETERS) { zval *object; char *locale_str; @@ -81,28 +81,23 @@ static zend_result datefmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handlin Z_PARAM_STRING_OR_NULL(pattern_str, pattern_str_len) ZEND_PARSE_PARAMETERS_END_EX(return FAILURE); - if (error_handling != NULL) { - zend_replace_error_handling(EH_THROW, IntlException_ce_ptr, error_handling); - *error_handling_replaced = 1; - } - DATE_FORMAT_METHOD_FETCH_OBJECT_NO_CHECK; if (DATE_FORMAT_OBJECT(dfo) != NULL) { - intl_errors_set(INTL_DATA_ERROR_P(dfo), U_ILLEGAL_ARGUMENT_ERROR, "datefmt_create: cannot call constructor twice", 0); + intl_errors_set(INTL_DATA_ERROR_P(dfo), U_ILLEGAL_ARGUMENT_ERROR, "cannot call constructor twice"); return FAILURE; } if (!INTL_UDATE_FMT_OK(date_type)) { - intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "datefmt_create: invalid date format style", 0); + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "invalid date format style"); return FAILURE; } if (!INTL_UDATE_FMT_OK(time_type)) { - intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "datefmt_create: invalid time format style", 0); + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "invalid time format style"); return FAILURE; } if (date_type == UDAT_PATTERN && time_type != UDAT_PATTERN) { - intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "datefmt_create: time format must be UDAT_PATTERN if date format is UDAT_PATTERN", 0); + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "time format must be UDAT_PATTERN if date format is UDAT_PATTERN"); return FAILURE; } @@ -118,7 +113,7 @@ static zend_result datefmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handlin } /* process calendar */ - if (datefmt_process_calendar_arg(calendar_obj, calendar_long, calendar_is_null, locale, "datefmt_create", + if (datefmt_process_calendar_arg(calendar_obj, calendar_long, calendar_is_null, locale, INTL_DATA_ERROR_P(dfo), cal, calendar_type, calendar_owned) == FAILURE ) { goto error; @@ -130,7 +125,7 @@ static zend_result datefmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handlin if (explicit_tz || calendar_owned ) { //we have an explicit time zone or a non-object calendar timezone = timezone_process_timezone_argument(timezone_zv, - INTL_DATA_ERROR_P(dfo), "datefmt_create"); + INTL_DATA_ERROR_P(dfo)); if (timezone == NULL) { goto error; } @@ -142,8 +137,8 @@ static zend_result datefmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handlin pattern_str, pattern_str_len, &INTL_DATA_ERROR_CODE(dfo)); if (U_FAILURE(INTL_DATA_ERROR_CODE(dfo))) { /* object construction -> only set global error */ - intl_error_set(NULL, INTL_DATA_ERROR_CODE(dfo), "datefmt_create: " - "error converting pattern to UTF-16", 0); + intl_error_set(NULL, INTL_DATA_ERROR_CODE(dfo), + "error converting pattern to UTF-16"); goto error; } } @@ -155,7 +150,7 @@ static zend_result datefmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handlin if (pattern_str && pattern_str_len > 0) { udat_applyPattern(DATE_FORMAT_OBJECT(dfo), true, svalue, slength); if (U_FAILURE(INTL_DATA_ERROR_CODE(dfo))) { - intl_error_set(NULL, INTL_DATA_ERROR_CODE(dfo), "datefmt_create: error applying pattern", 0); + intl_error_set(NULL, INTL_DATA_ERROR_CODE(dfo), "error applying pattern"); goto error; } } @@ -173,8 +168,7 @@ static zend_result datefmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handlin df->adoptTimeZone(timezone); } } else { - intl_error_set(NULL, INTL_DATA_ERROR_CODE(dfo), "datefmt_create: date " - "formatter creation failed", 0); + intl_error_set(NULL, INTL_DATA_ERROR_CODE(dfo), "date formatter creation failed"); goto error; } @@ -203,7 +197,7 @@ static zend_result datefmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handlin U_CFUNC PHP_FUNCTION( datefmt_create ) { object_init_ex( return_value, IntlDateFormatter_ce_ptr ); - if (datefmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, NULL, NULL) == FAILURE) { + if (datefmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU) == FAILURE) { zval_ptr_dtor(return_value); RETURN_NULL(); } @@ -213,21 +207,18 @@ U_CFUNC PHP_FUNCTION( datefmt_create ) /* {{{ IntlDateFormatter object constructor. */ U_CFUNC PHP_METHOD( IntlDateFormatter, __construct ) { - zend_error_handling error_handling; - bool error_handling_replaced = 0; + const bool old_use_exception = INTL_G(use_exceptions); + const zend_long old_error_level = INTL_G(error_level); + INTL_G(use_exceptions) = true; + INTL_G(error_level) = 0; /* return_value param is being changed, therefore we will always return * NULL here */ return_value = ZEND_THIS; - if (datefmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, &error_handling, &error_handling_replaced) == FAILURE) { - if (!EG(exception)) { - zend_string *err = intl_error_get_message(NULL); - zend_throw_exception(IntlException_ce_ptr, ZSTR_VAL(err), intl_error_get_code(NULL)); - zend_string_release_ex(err, 0); - } - } - if (error_handling_replaced) { - zend_restore_error_handling(&error_handling); + if (datefmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU) == FAILURE) { + ZEND_ASSERT(EG(exception)); } + INTL_G(use_exceptions) = old_use_exception; + INTL_G(error_level) = old_error_level; } /* }}} */ diff --git a/ext/intl/dateformat/dateformat_format.c b/ext/intl/dateformat/dateformat_format.c index f4ef8a40d6458..ee3abd052d669 100644 --- a/ext/intl/dateformat/dateformat_format.c +++ b/ext/intl/dateformat/dateformat_format.c @@ -66,17 +66,17 @@ static int32_t internal_get_arr_ele(IntlDateFormatter_object *dfo, if ((ele_value = zend_hash_str_find_deref(hash_arr, key_name, strlen(key_name))) != NULL) { if(Z_TYPE_P(ele_value) != IS_LONG) { - spprintf(&message, 0, "datefmt_format: parameter array contains " + spprintf(&message, 0, "parameter array contains " "a non-integer element for key '%s'", key_name); - intl_errors_set(err, U_ILLEGAL_ARGUMENT_ERROR, message, 1); + intl_errors_set(err, U_ILLEGAL_ARGUMENT_ERROR, message); efree(message); } else { if (Z_LVAL_P(ele_value) > INT32_MAX || Z_LVAL_P(ele_value) < INT32_MIN) { - spprintf(&message, 0, "datefmt_format: value " ZEND_LONG_FMT " is out of " + spprintf(&message, 0, "value " ZEND_LONG_FMT " is out of " "bounds for a 32-bit integer in key '%s'", Z_LVAL_P(ele_value), key_name); - intl_errors_set(err, U_ILLEGAL_ARGUMENT_ERROR, message, 1); + intl_errors_set(err, U_ILLEGAL_ARGUMENT_ERROR, message); efree(message); } else { result = Z_LVAL_P(ele_value); @@ -121,8 +121,7 @@ static UDate internal_get_timestamp(IntlDateFormatter_object *dfo, &INTL_DATA_ERROR_CODE(dfo)); if (INTL_DATA_ERROR_CODE(dfo) != U_ZERO_ERROR) { - intl_errors_set(err, INTL_DATA_ERROR_CODE(dfo), "datefmt_format: " - "error cloning calendar", 0); + intl_errors_set(err, INTL_DATA_ERROR_CODE(dfo), "error cloning calendar"); return 0; } @@ -149,8 +148,6 @@ PHP_FUNCTION(datefmt_format) /* Parse parameters. */ if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz", &object, IntlDateFormatter_ce_ptr, &zarg) == FAILURE) { - intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "datefmt_format: unable " - "to parse input params", 0 ); RETURN_THROWS(); } @@ -163,10 +160,9 @@ PHP_FUNCTION(datefmt_format) } timestamp = internal_get_timestamp(dfo, hash_arr); - INTL_METHOD_CHECK_STATUS(dfo, "datefmt_format: date formatting failed") + INTL_METHOD_CHECK_STATUS(dfo, "date formatting failed") } else { - timestamp = intl_zval_to_millis(zarg, INTL_DATA_ERROR_P(dfo), - "datefmt_format"); + timestamp = intl_zval_to_millis(zarg, INTL_DATA_ERROR_P(dfo)); if (U_FAILURE(INTL_DATA_ERROR_CODE(dfo))) { RETURN_FALSE; } diff --git a/ext/intl/dateformat/dateformat_format_object.cpp b/ext/intl/dateformat/dateformat_format_object.cpp index e60b16c1c2b6e..da306c5896be2 100644 --- a/ext/intl/dateformat/dateformat_format_object.cpp +++ b/ext/intl/dateformat/dateformat_format_object.cpp @@ -94,8 +94,8 @@ U_CFUNC PHP_FUNCTION(datefmt_format_object) HashTable *ht = Z_ARRVAL_P(format); if (zend_hash_num_elements(ht) != 2) { intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, - "datefmt_format_object: bad format; if array, it must have " - "two elements", 0); + "bad format; if array, it must have " + "two elements"); RETURN_FALSE; } @@ -105,13 +105,13 @@ U_CFUNC PHP_FUNCTION(datefmt_format_object) if (!valid_format(z)) { if (idx == 0) { intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, - "datefmt_format_object: bad format; the date format (first " - "element of the array) is not valid", 0); + "bad format; the date format (first " + "element of the array) is not valid"); } else { ZEND_ASSERT(idx == 1 && "We checked that there are two elements above"); intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, - "datefmt_format_object: bad format; the time format (second " - "element of the array) is not valid", 0); + "bad format; the time format (second " + "element of the array) is not valid"); } RETURN_FALSE; } @@ -127,8 +127,7 @@ U_CFUNC PHP_FUNCTION(datefmt_format_object) } else if (Z_TYPE_P(format) == IS_LONG) { if (!valid_format(format)) { intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, - "datefmt_format_object: the date/time format type is invalid", - 0); + "the date/time format type is invalid"); RETURN_FALSE; } dateStyle = timeStyle = (DateFormat::EStyle)Z_LVAL_P(format); @@ -138,7 +137,7 @@ U_CFUNC PHP_FUNCTION(datefmt_format_object) } if (Z_STRLEN_P(format) == 0) { intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, - "datefmt_format_object: the format is empty", 0); + "the format is empty"); RETURN_FALSE; } pattern = true; @@ -154,37 +153,31 @@ U_CFUNC PHP_FUNCTION(datefmt_format_object) Calendar *obj_cal = calendar_fetch_native_calendar(object); if (obj_cal == NULL) { intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, - "datefmt_format_object: bad IntlCalendar instance: " - "not initialized properly", 0); + "bad IntlCalendar instance: not initialized properly"); RETURN_FALSE; } timeZone = std::unique_ptr(obj_cal->getTimeZone().clone()); date = obj_cal->getTime(status); if (U_FAILURE(status)) { intl_error_set(NULL, status, - "datefmt_format_object: error obtaining instant from " - "IntlCalendar", 0); + "error obtaining instant from IntlCalendar"); RETURN_FALSE; } cal = std::unique_ptr(obj_cal->clone()); } else if (instanceof_function(instance_ce, php_date_get_interface_ce())) { TimeZone *tz; - if (intl_datetime_decompose(object, &date, &tz, NULL, - "datefmt_format_object") == FAILURE) { + if (intl_datetime_decompose(object, &date, &tz, NULL) == FAILURE) { RETURN_FALSE; } timeZone = std::unique_ptr(tz); cal = std::unique_ptr(new GregorianCalendar(Locale::createFromName(locale_str), status)); if (U_FAILURE(status)) { - intl_error_set(NULL, status, - "datefmt_format_object: could not create GregorianCalendar", - 0); + intl_error_set(NULL, status, "could not create GregorianCalendar"); RETURN_FALSE; } } else { - intl_error_set(NULL, status, "datefmt_format_object: the passed object " - "must be an instance of either IntlCalendar or DateTimeInterface", - 0); + intl_error_set(NULL, status, "the passed object must be an instance " + "of either IntlCalendar or DateTimeInterface"); RETURN_FALSE; } @@ -196,9 +189,7 @@ U_CFUNC PHP_FUNCTION(datefmt_format_object) status)); if (U_FAILURE(status)) { - intl_error_set(NULL, status, - "datefmt_format_object: could not create SimpleDateFormat", - 0); + intl_error_set(NULL, status, "could not create SimpleDateFormat"); RETURN_FALSE; } } else { @@ -206,9 +197,7 @@ U_CFUNC PHP_FUNCTION(datefmt_format_object) Locale::createFromName(locale_str))); if (df == NULL) { /* according to ICU sources, this should never happen */ - intl_error_set(NULL, status, - "datefmt_format_object: could not create DateFormat", - 0); + intl_error_set(NULL, status, "could not create DateFormat"); RETURN_FALSE; } } @@ -224,9 +213,7 @@ U_CFUNC PHP_FUNCTION(datefmt_format_object) u8str = intl_charFromString(result, &status); if (!u8str) { - intl_error_set(NULL, status, - "datefmt_format_object: error converting result to UTF-8", - 0); + intl_error_set(NULL, status, "error converting result to UTF-8"); RETURN_FALSE; } RETVAL_STR(u8str); diff --git a/ext/intl/dateformat/dateformat_helpers.cpp b/ext/intl/dateformat/dateformat_helpers.cpp index 2842c520a3092..18dc594dedddc 100644 --- a/ext/intl/dateformat/dateformat_helpers.cpp +++ b/ext/intl/dateformat/dateformat_helpers.cpp @@ -28,11 +28,10 @@ extern "C" { using icu::GregorianCalendar; -int datefmt_process_calendar_arg( +zend_result datefmt_process_calendar_arg( zend_object *calendar_obj, zend_long calendar_long, bool calendar_is_null, Locale const& locale, - const char *func_name, intl_error *err, Calendar*& cal, zend_long& cal_int_type, bool& calendar_owned + intl_error *err, Calendar*& cal, zend_long& cal_int_type, bool& calendar_owned ) { - char *msg; UErrorCode status = UErrorCode(); if (calendar_is_null) { @@ -45,13 +44,11 @@ int datefmt_process_calendar_arg( } else if (!calendar_obj) { zend_long v = calendar_long; if (v != (zend_long)UCAL_TRADITIONAL && v != (zend_long)UCAL_GREGORIAN) { - spprintf(&msg, 0, "%s: Invalid value for calendar type; it must be " - "one of IntlDateFormatter::TRADITIONAL (locale's default " - "calendar) or IntlDateFormatter::GREGORIAN. " - "Alternatively, it can be an IntlCalendar object", - func_name); - intl_errors_set(err, U_ILLEGAL_ARGUMENT_ERROR, msg, 1); - efree(msg); + intl_errors_set(err, U_ILLEGAL_ARGUMENT_ERROR, + "Invalid value for calendar type; it must be one of " + "IntlDateFormatter::TRADITIONAL (locale's default calendar) or" + " IntlDateFormatter::GREGORIAN. Alternatively, it can be an " + "IntlCalendar object"); return FAILURE; } else if (v == (zend_long)UCAL_TRADITIONAL) { cal = Calendar::createInstance(locale, status); @@ -65,10 +62,7 @@ int datefmt_process_calendar_arg( } else if (calendar_obj) { cal = calendar_fetch_native_calendar(calendar_obj); if (cal == NULL) { - spprintf(&msg, 0, "%s: Found unconstructed IntlCalendar object", - func_name); - intl_errors_set(err, U_ILLEGAL_ARGUMENT_ERROR, msg, 1); - efree(msg); + intl_errors_set(err, U_ILLEGAL_ARGUMENT_ERROR, "Found unconstructed IntlCalendar object"); return FAILURE; } calendar_owned = false; @@ -76,10 +70,8 @@ int datefmt_process_calendar_arg( cal_int_type = -1; } else { - spprintf(&msg, 0, "%s: Invalid calendar argument; should be an integer " - "or an IntlCalendar instance", func_name); - intl_errors_set(err, U_ILLEGAL_ARGUMENT_ERROR, msg, 1); - efree(msg); + intl_errors_set(err, U_ILLEGAL_ARGUMENT_ERROR, + "Invalid calendar argument; should be an integer or an IntlCalendar instance"); return FAILURE; } @@ -87,9 +79,7 @@ int datefmt_process_calendar_arg( status = U_MEMORY_ALLOCATION_ERROR; } if (U_FAILURE(status)) { - spprintf(&msg, 0, "%s: Failure instantiating calendar", func_name); - intl_errors_set(err, U_ILLEGAL_ARGUMENT_ERROR, msg, 1); - efree(msg); + intl_errors_set(err, U_ILLEGAL_ARGUMENT_ERROR, "Failure instantiating calendar"); return FAILURE; } diff --git a/ext/intl/dateformat/dateformat_helpers.h b/ext/intl/dateformat/dateformat_helpers.h index 4140eb730a2c6..b931d9667e5f1 100644 --- a/ext/intl/dateformat/dateformat_helpers.h +++ b/ext/intl/dateformat/dateformat_helpers.h @@ -30,9 +30,9 @@ using icu::Locale; using icu::Calendar; using icu::DateFormat; -int datefmt_process_calendar_arg( +zend_result datefmt_process_calendar_arg( zend_object *calendar_obj, zend_long calendar_long, bool calendar_is_null, Locale const& locale, - const char *func_name, intl_error *err, Calendar*& cal, zend_long& cal_int_type, bool& calendar_owned + intl_error *err, Calendar*& cal, zend_long& cal_int_type, bool& calendar_owned ); #endif /* DATEFORMAT_HELPERS_H */ diff --git a/ext/intl/dateformat/dateformat_parse.c b/ext/intl/dateformat/dateformat_parse.c index 2bdde08bcaced..b6e9f7c92eb6f 100644 --- a/ext/intl/dateformat/dateformat_parse.c +++ b/ext/intl/dateformat/dateformat_parse.c @@ -150,7 +150,7 @@ PHP_FUNCTION(datefmt_parse) zend_long long_parse_pos = zval_get_long(z_parse_pos_tmp); if (ZEND_LONG_INT_OVFL(long_parse_pos)) { intl_error_set_code(NULL, U_ILLEGAL_ARGUMENT_ERROR); - intl_error_set_custom_msg(NULL, "String index is out of valid range.", 0); + intl_error_set_custom_msg(NULL, "String index is out of valid range."); RETURN_FALSE; } parse_pos = (int32_t)long_parse_pos; @@ -193,7 +193,7 @@ PHP_METHOD(IntlDateFormatter, parseToCalendar) } if (ZEND_LONG_INT_OVFL(long_parse_pos)) { intl_error_set_code(NULL, U_ILLEGAL_ARGUMENT_ERROR); - intl_error_set_custom_msg(NULL, "String index is out of valid range.", 0); + intl_error_set_custom_msg(NULL, "String index is out of valid range."); RETURN_FALSE; } parse_pos = (int32_t)long_parse_pos; @@ -232,7 +232,7 @@ PHP_FUNCTION(datefmt_localtime) zend_long long_parse_pos = zval_get_long(z_parse_pos_tmp); if (ZEND_LONG_INT_OVFL(long_parse_pos)) { intl_error_set_code(NULL, U_ILLEGAL_ARGUMENT_ERROR); - intl_error_set_custom_msg(NULL, "String index is out of valid range.", 0); + intl_error_set_custom_msg(NULL, "String index is out of valid range."); RETURN_FALSE; } parse_pos = (int32_t)long_parse_pos; diff --git a/ext/intl/dateformat/datepatterngenerator_methods.cpp b/ext/intl/dateformat/datepatterngenerator_methods.cpp index 1b659c7aa20ce..beaf10d9f5079 100644 --- a/ext/intl/dateformat/datepatterngenerator_methods.cpp +++ b/ext/intl/dateformat/datepatterngenerator_methods.cpp @@ -30,7 +30,7 @@ using icu::DateTimePatternGenerator; using icu::Locale; using icu::StringPiece; -static zend_result dtpg_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handling *error_handling, bool *error_handling_replaced) +static zend_result dtpg_ctor(INTERNAL_FUNCTION_PARAMETERS) { char *locale_str; size_t locale_len = 0; @@ -44,15 +44,10 @@ static zend_result dtpg_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handling * Z_PARAM_STRING_OR_NULL(locale_str, locale_len) ZEND_PARSE_PARAMETERS_END_EX(return FAILURE); - if (error_handling != NULL) { - zend_replace_error_handling(EH_THROW, IntlException_ce_ptr, error_handling); - *error_handling_replaced = 1; - } - DTPATTERNGEN_METHOD_FETCH_OBJECT_NO_CHECK; if (dtpgo->dtpg != NULL) { - intl_errors_set(DTPATTERNGEN_ERROR_P(dtpgo), U_ILLEGAL_ARGUMENT_ERROR, "Cannot call constructor twice", 0); + intl_errors_set(DTPATTERNGEN_ERROR_P(dtpgo), U_ILLEGAL_ARGUMENT_ERROR, "Cannot call constructor twice"); return FAILURE; } @@ -68,8 +63,7 @@ static zend_result dtpg_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handling * if (U_FAILURE(DTPATTERNGEN_ERROR_CODE(dtpgo))) { intl_error_set(NULL, DTPATTERNGEN_ERROR_CODE(dtpgo), - "Error creating DateTimePatternGenerator", - 0); + "Error creating DateTimePatternGenerator"); return FAILURE; } @@ -79,7 +73,7 @@ static zend_result dtpg_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handling * U_CFUNC PHP_METHOD( IntlDatePatternGenerator, create ) { object_init_ex( return_value, IntlDatePatternGenerator_ce_ptr ); - if (dtpg_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, NULL, NULL) == FAILURE) { + if (dtpg_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU) == FAILURE) { zval_ptr_dtor(return_value); RETURN_NULL(); } @@ -87,22 +81,19 @@ U_CFUNC PHP_METHOD( IntlDatePatternGenerator, create ) U_CFUNC PHP_METHOD( IntlDatePatternGenerator, __construct ) { - zend_error_handling error_handling; - bool error_handling_replaced = 0; + const bool old_use_exception = INTL_G(use_exceptions); + const zend_long old_error_level = INTL_G(error_level); + INTL_G(use_exceptions) = true; + INTL_G(error_level) = 0; /* return_value param is being changed, therefore we will always return * NULL here */ return_value = ZEND_THIS; - if (dtpg_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, &error_handling, &error_handling_replaced) == FAILURE) { - if (!EG(exception)) { - zend_string *err = intl_error_get_message(NULL); - zend_throw_exception(IntlException_ce_ptr, ZSTR_VAL(err), intl_error_get_code(NULL)); - zend_string_release_ex(err, 0); - } - } - if (error_handling_replaced) { - zend_restore_error_handling(&error_handling); + if (dtpg_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU) == FAILURE) { + ZEND_ASSERT(EG(exception)); } + INTL_G(use_exceptions) = old_use_exception; + INTL_G(error_level) = old_error_level; } diff --git a/ext/intl/formatter/formatter_attr.c b/ext/intl/formatter/formatter_attr.c index 874984f5405f0..a7cafcf5f9733 100644 --- a/ext/intl/formatter/formatter_attr.c +++ b/ext/intl/formatter/formatter_attr.c @@ -226,7 +226,7 @@ PHP_FUNCTION( numfmt_get_symbol ) } if(symbol >= UNUM_FORMAT_SYMBOL_COUNT || symbol < 0) { - intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "numfmt_get_symbol: invalid symbol value", 0 ); + intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "invalid symbol value"); RETURN_FALSE; } @@ -268,7 +268,7 @@ PHP_FUNCTION( numfmt_set_symbol ) } if (symbol >= UNUM_FORMAT_SYMBOL_COUNT || symbol < 0) { - intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "numfmt_set_symbol: invalid symbol value", 0 ); + intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "invalid symbol value"); RETURN_FALSE; } @@ -355,7 +355,7 @@ PHP_FUNCTION( numfmt_set_pattern ) if (U_FAILURE(INTL_DATA_ERROR_CODE(nfo))) { char *msg; spprintf(&msg, 0, "Error setting pattern value at line %d, offset %d", spattern_error.line, spattern_error.offset); - intl_errors_set_custom_msg(INTL_DATA_ERROR_P(nfo), msg, 1); + intl_errors_set_custom_msg(INTL_DATA_ERROR_P(nfo), msg); efree(msg); RETURN_FALSE; } diff --git a/ext/intl/formatter/formatter_format.c b/ext/intl/formatter/formatter_format.c index 54c5d92fe18a1..5be732dde77e8 100644 --- a/ext/intl/formatter/formatter_format.c +++ b/ext/intl/formatter/formatter_format.c @@ -164,7 +164,7 @@ PHP_FUNCTION( numfmt_format_currency ) if( U_FAILURE( INTL_DATA_ERROR_CODE((nfo)) ) ) { intl_error_set_code( NULL, INTL_DATA_ERROR_CODE((nfo)) ); - intl_errors_set_custom_msg( INTL_DATA_ERROR_P(nfo), "Number formatting failed", 0 ); + intl_errors_set_custom_msg( INTL_DATA_ERROR_P(nfo), "Number formatting failed"); RETVAL_FALSE; if (formatted != format_buf) { efree(formatted); diff --git a/ext/intl/formatter/formatter_main.c b/ext/intl/formatter/formatter_main.c index 6f8fb98d21434..6f92b7e787be4 100644 --- a/ext/intl/formatter/formatter_main.c +++ b/ext/intl/formatter/formatter_main.c @@ -24,7 +24,7 @@ #include "intl_convert.h" /* {{{ */ -static int numfmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handling *error_handling, bool *error_handling_replaced) +static int numfmt_ctor(INTERNAL_FUNCTION_PARAMETERS) { char* locale; char* pattern = NULL; @@ -41,11 +41,6 @@ static int numfmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handling *error_ Z_PARAM_STRING_OR_NULL(pattern, pattern_len) ZEND_PARSE_PARAMETERS_END_EX(return FAILURE); - if (error_handling != NULL) { - zend_replace_error_handling(EH_THROW, IntlException_ce_ptr, error_handling); - *error_handling_replaced = 1; - } - INTL_CHECK_LOCALE_LEN_OR_FAILURE(locale_len); object = return_value; FORMATTER_METHOD_FETCH_OBJECT_NO_CHECK; @@ -57,7 +52,7 @@ static int numfmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handling *error_ /* Convert pattern (if specified) to UTF-16. */ if(pattern && pattern_len) { intl_convert_utf8_to_utf16(&spattern, &spattern_len, pattern, pattern_len, &INTL_DATA_ERROR_CODE(nfo)); - INTL_CTOR_CHECK_STATUS(nfo, "numfmt_create: error converting pattern to UTF-16"); + INTL_CTOR_CHECK_STATUS(nfo, "error converting pattern to UTF-16"); } if(locale_len == 0) { @@ -76,7 +71,7 @@ static int numfmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handling *error_ efree(spattern); } - INTL_CTOR_CHECK_STATUS(nfo, "numfmt_create: number formatter creation failed"); + INTL_CTOR_CHECK_STATUS(nfo, "number formatter creation failed"); return SUCCESS; } /* }}} */ @@ -85,7 +80,7 @@ static int numfmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handling *error_ PHP_FUNCTION( numfmt_create ) { object_init_ex( return_value, NumberFormatter_ce_ptr ); - if (numfmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, NULL, NULL) == FAILURE) { + if (numfmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU) == FAILURE) { zval_ptr_dtor(return_value); RETURN_NULL(); } @@ -95,18 +90,17 @@ PHP_FUNCTION( numfmt_create ) /* {{{ NumberFormatter object constructor. */ PHP_METHOD( NumberFormatter, __construct ) { - zend_error_handling error_handling; - bool error_handling_replaced = 0; + const bool old_use_exception = INTL_G(use_exceptions); + const zend_long old_error_level = INTL_G(error_level); + INTL_G(use_exceptions) = true; + INTL_G(error_level) = 0; return_value = ZEND_THIS; - if (numfmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, &error_handling, &error_handling_replaced) == FAILURE) { - if (!EG(exception)) { - zend_throw_exception(IntlException_ce_ptr, "Constructor failed", 0); - } - } - if (error_handling_replaced) { - zend_restore_error_handling(&error_handling); + if (numfmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU) == FAILURE) { + ZEND_ASSERT(EG(exception)); } + INTL_G(use_exceptions) = old_use_exception; + INTL_G(error_level) = old_error_level; } /* }}} */ diff --git a/ext/intl/grapheme/grapheme_string.c b/ext/intl/grapheme/grapheme_string.c index 34dd2ed369cfc..8abef7dd560aa 100644 --- a/ext/intl/grapheme/grapheme_string.c +++ b/ext/intl/grapheme/grapheme_string.c @@ -57,7 +57,7 @@ PHP_FUNCTION(grapheme_strlen) intl_error_set_code( NULL, status ); /* Set error messages. */ - intl_error_set_custom_msg( NULL, "Error converting input string to UTF-16", 0 ); + intl_error_set_custom_msg( NULL, "Error converting input string to UTF-16"); if (ustring) { efree( ustring ); } @@ -370,7 +370,7 @@ PHP_FUNCTION(grapheme_substr) grapheme_substr_ascii(str, str_len, start, (int32_t)length, &sub_str, &asub_str_len); if ( NULL == sub_str ) { - intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "grapheme_substr: invalid parameters", 1 ); + intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "invalid parameters"); RETURN_FALSE; } @@ -387,7 +387,7 @@ PHP_FUNCTION(grapheme_substr) intl_error_set_code( NULL, status ); /* Set error messages. */ - intl_error_set_custom_msg( NULL, "Error converting input string to UTF-16", 0 ); + intl_error_set_custom_msg( NULL, "Error converting input string to UTF-16"); if (ustr) { efree( ustr ); } @@ -455,7 +455,7 @@ PHP_FUNCTION(grapheme_substr) intl_error_set_code( NULL, status ); /* Set error messages. */ - intl_error_set_custom_msg( NULL, "Error converting output string to UTF-8", 0 ); + intl_error_set_custom_msg( NULL, "Error converting output string to UTF-8"); RETURN_FALSE; } @@ -524,7 +524,7 @@ PHP_FUNCTION(grapheme_substr) intl_error_set_code( NULL, status ); /* Set error messages. */ - intl_error_set_custom_msg( NULL, "Error converting output string to UTF-8", 0 ); + intl_error_set_custom_msg( NULL, "Error converting output string to UTF-8"); RETURN_FALSE; } @@ -747,7 +747,7 @@ PHP_FUNCTION(grapheme_extract) } if ( lstart > INT32_MAX || lstart < 0 || (size_t)lstart >= str_len ) { - intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "grapheme_extract: start not contained in string", 0 ); + intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "start not contained in string"); RETURN_FALSE; } @@ -779,7 +779,7 @@ PHP_FUNCTION(grapheme_extract) start++; if ( pstr >= str_end ) { intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, - "grapheme_extract: invalid input string", 0 ); + "grapheme_extract: invalid input string"); RETURN_FALSE; } @@ -808,7 +808,7 @@ PHP_FUNCTION(grapheme_extract) intl_error_set_code( NULL, status ); /* Set error messages. */ - intl_error_set_custom_msg( NULL, "Error opening UTF-8 text", 0 ); + intl_error_set_custom_msg( NULL, "Error opening UTF-8 text"); RETURN_FALSE; } @@ -870,7 +870,7 @@ PHP_FUNCTION(grapheme_str_split) intl_error_set_code( NULL, ustatus ); /* Set error messages. */ - intl_error_set_custom_msg( NULL, "Error opening UTF-8 text", 0 ); + intl_error_set_custom_msg( NULL, "Error opening UTF-8 text"); RETURN_FALSE; } @@ -974,7 +974,7 @@ PHP_FUNCTION(grapheme_levenshtein) if (U_FAILURE(ustatus)) { intl_error_set_code(NULL, ustatus); - intl_error_set_custom_msg(NULL, "Error converting input string to UTF-16", 0); + intl_error_set_custom_msg(NULL, "Error converting input string to UTF-16"); RETVAL_FALSE; goto out_ustring1; } @@ -984,7 +984,7 @@ PHP_FUNCTION(grapheme_levenshtein) if (U_FAILURE(ustatus)) { intl_error_set_code(NULL, ustatus); - intl_error_set_custom_msg(NULL, "Error converting input string to UTF-16", 0); + intl_error_set_custom_msg(NULL, "Error converting input string to UTF-16"); RETVAL_FALSE; goto out_ustring2; } @@ -1013,7 +1013,7 @@ PHP_FUNCTION(grapheme_levenshtein) bi1 = grapheme_get_break_iterator(u_break_iterator_buffer1, &ustatus); if (U_FAILURE(ustatus)) { intl_error_set_code(NULL, ustatus); - intl_error_set_custom_msg(NULL, "Error on grapheme_get_break_iterator for argument #1 ($string1)", 0); + intl_error_set_custom_msg(NULL, "Error on grapheme_get_break_iterator for argument #1 ($string1)"); RETVAL_FALSE; goto out_bi1; } @@ -1021,7 +1021,7 @@ PHP_FUNCTION(grapheme_levenshtein) bi2 = grapheme_get_break_iterator(u_break_iterator_buffer2, &ustatus); if (U_FAILURE(ustatus)) { intl_error_set_code(NULL, ustatus); - intl_error_set_custom_msg(NULL, "Error on grapheme_get_break_iterator for argument #2 ($string2)", 0); + intl_error_set_custom_msg(NULL, "Error on grapheme_get_break_iterator for argument #2 ($string2)"); RETVAL_FALSE; goto out_bi2; } @@ -1030,7 +1030,7 @@ PHP_FUNCTION(grapheme_levenshtein) if (U_FAILURE(ustatus)) { intl_error_set_code(NULL, ustatus); - intl_error_set_custom_msg(NULL, "Error on ubrk_setText for argument #1 ($string1)", 0); + intl_error_set_custom_msg(NULL, "Error on ubrk_setText for argument #1 ($string1)"); RETVAL_FALSE; goto out_bi2; } @@ -1039,7 +1039,7 @@ PHP_FUNCTION(grapheme_levenshtein) if (U_FAILURE(ustatus)) { intl_error_set_code(NULL, ustatus); - intl_error_set_custom_msg(NULL, "Error on ubrk_setText for argument #2 ($string2)", 0); + intl_error_set_custom_msg(NULL, "Error on ubrk_setText for argument #2 ($string2)"); RETVAL_FALSE; goto out_bi2; } @@ -1047,7 +1047,7 @@ PHP_FUNCTION(grapheme_levenshtein) if (U_FAILURE(ustatus)) { intl_error_set_code(NULL, ustatus); - intl_error_set_custom_msg(NULL, "Error on ucol_open", 0); + intl_error_set_custom_msg(NULL, "Error on ucol_open"); RETVAL_FALSE; goto out_collator; } diff --git a/ext/intl/grapheme/grapheme_util.c b/ext/intl/grapheme/grapheme_util.c index 501b9dfb221d0..d4b6c1cbfd89a 100644 --- a/ext/intl/grapheme/grapheme_util.c +++ b/ext/intl/grapheme/grapheme_util.c @@ -87,7 +87,7 @@ void grapheme_substr_ascii(char *str, size_t str_len, int32_t f, int32_t l, char #define STRPOS_CHECK_STATUS(status, error) \ if ( U_FAILURE( (status) ) ) { \ intl_error_set_code( NULL, (status) ); \ - intl_error_set_custom_msg( NULL, (error), 0 ); \ + intl_error_set_custom_msg( NULL, (error)); \ ret_pos = -1; \ goto finish; \ } diff --git a/ext/intl/idn/idn.cpp b/ext/intl/idn/idn.cpp index 94990baff4832..b2a2b03ee02e7 100644 --- a/ext/intl/idn/idn.cpp +++ b/ext/intl/idn/idn.cpp @@ -42,12 +42,7 @@ static zend_result php_intl_idn_check_status(UErrorCode err, const char *msg) { intl_error_set_code(NULL, err); if (U_FAILURE(err)) { - char *buff; - spprintf(&buff, 0, "%s: %s", - get_active_function_name(), - msg); - intl_error_set_custom_msg(NULL, buff, 1); - efree(buff); + intl_error_set_custom_msg(NULL, msg); return FAILURE; } diff --git a/ext/intl/intl_data.h b/ext/intl/intl_data.h index 23320a9ff113e..c818427e07e1e 100644 --- a/ext/intl/intl_data.h +++ b/ext/intl/intl_data.h @@ -48,7 +48,7 @@ typedef struct _intl_data { intl_error_set_code( NULL, (err) ); \ if( U_FAILURE((err)) ) \ { \ - intl_error_set_custom_msg( NULL, msg, 0 ); \ + intl_error_set_custom_msg( NULL, msg); \ RETURN_FALSE; \ } @@ -57,7 +57,7 @@ typedef struct _intl_data { intl_error_set_code( NULL, (err) ); \ if( U_FAILURE((err)) ) \ { \ - intl_error_set_custom_msg( NULL, msg, 0 ); \ + intl_error_set_custom_msg( NULL, msg); \ RETURN_NULL(); \ } @@ -67,7 +67,7 @@ typedef struct _intl_data { intl_error_set_code( NULL, INTL_DATA_ERROR_CODE((obj)) ); \ if( U_FAILURE( INTL_DATA_ERROR_CODE((obj)) ) ) \ { \ - intl_errors_set_custom_msg( INTL_DATA_ERROR_P((obj)), msg, 0 ); \ + intl_errors_set_custom_msg( INTL_DATA_ERROR_P((obj)), msg); \ RETURN_FALSE; \ } @@ -76,7 +76,7 @@ typedef struct _intl_data { intl_error_set_code( NULL, INTL_DATA_ERROR_CODE((obj)) ); \ if( U_FAILURE( INTL_DATA_ERROR_CODE((obj)) ) ) \ { \ - intl_errors_set_custom_msg( INTL_DATA_ERROR_P((obj)), msg, 0 ); \ + intl_errors_set_custom_msg( INTL_DATA_ERROR_P((obj)), msg); \ RETVAL_FALSE; \ goto label; \ } @@ -86,7 +86,7 @@ typedef struct _intl_data { intl_error_set_code( NULL, INTL_DATA_ERROR_CODE((obj)) ); \ if( U_FAILURE( INTL_DATA_ERROR_CODE((obj)) ) ) \ { \ - intl_errors_set_custom_msg( INTL_DATA_ERROR_P((obj)), msg, 0 ); \ + intl_errors_set_custom_msg( INTL_DATA_ERROR_P((obj)), msg); \ zval_ptr_dtor(return_value); \ RETURN_NULL(); \ } @@ -96,7 +96,7 @@ typedef struct _intl_data { intl_error_set_code( NULL, INTL_DATA_ERROR_CODE((obj)) ); \ if( U_FAILURE( INTL_DATA_ERROR_CODE((obj)) ) ) \ { \ - intl_errors_set_custom_msg( INTL_DATA_ERROR_P((obj)), msg, 0 ); \ + intl_errors_set_custom_msg( INTL_DATA_ERROR_P((obj)), msg); \ return FAILURE; \ } @@ -117,7 +117,7 @@ typedef struct _intl_data { if((locale_len) > INTL_MAX_LOCALE_LEN) { \ char *_msg; \ spprintf(&_msg, 0, "Locale string too long, should be no longer than %d characters", INTL_MAX_LOCALE_LEN); \ - intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, _msg, 1); \ + intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, _msg); \ efree(_msg); \ RETURN_NULL(); \ } @@ -126,7 +126,7 @@ typedef struct _intl_data { if((locale_len) > INTL_MAX_LOCALE_LEN) { \ char *_msg; \ spprintf(&_msg, 0, "Locale string too long, should be no longer than %d characters", INTL_MAX_LOCALE_LEN); \ - intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, _msg, 1); \ + intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, _msg); \ efree(_msg); \ return FAILURE; \ } diff --git a/ext/intl/intl_error.c b/ext/intl/intl_error.c index a1c3a9efb2d4b..be6e53fb5439a 100644 --- a/ext/intl/intl_error.c +++ b/ext/intl/intl_error.c @@ -42,12 +42,10 @@ static void intl_free_custom_error_msg( intl_error* err ) if( !err && !( err = intl_g_error_get( ) ) ) return; - if(err->free_custom_error_message ) { - efree( err->custom_error_message ); + if (err->custom_error_message) { + zend_string_release_ex(err->custom_error_message, false); + err->custom_error_message = NULL; } - - err->custom_error_message = NULL; - err->free_custom_error_message = 0; } /* }}} */ @@ -70,7 +68,6 @@ void intl_error_init( intl_error* err ) err->code = U_ZERO_ERROR; err->custom_error_message = NULL; - err->free_custom_error_message = 0; } /* }}} */ @@ -87,28 +84,41 @@ void intl_error_reset( intl_error* err ) /* }}} */ /* {{{ Set last error message to msg copying it if needed. */ -void intl_error_set_custom_msg( intl_error* err, const char* msg, int copyMsg ) +void intl_error_set_custom_msg( intl_error* err, const char* msg) { - if( !msg ) + /* See ext/intl/tests/bug70451.phpt and uchar.c:zif_IntlChar_charFromName */ + if (UNEXPECTED(msg == NULL)) { return; + } + + zend_string *method_or_func = get_active_function_or_method_name(); + zend_string *prefixed_message = zend_string_concat3( + ZSTR_VAL(method_or_func), ZSTR_LEN(method_or_func), + ZEND_STRL("(): "), + msg, strlen(msg) + ); + zend_string_release_ex(method_or_func, false); if( !err ) { - if( INTL_G( error_level ) ) + if (INTL_G(error_level)) { + /* Docref will prefix the function/method for us, so use original message */ php_error_docref( NULL, INTL_G( error_level ), "%s", msg ); - if( INTL_G( use_exceptions ) ) - zend_throw_exception_ex( IntlException_ce_ptr, 0, "%s", msg ); + } + if (INTL_G(use_exceptions)) { + /* Use this variant as we have a zend_string already */ + zend_throw_error_exception(IntlException_ce_ptr, prefixed_message, 0, 0); + } } - if( !err && !( err = intl_g_error_get( ) ) ) + if (!err && !(err = intl_g_error_get() )) { + zend_string_release_ex(prefixed_message, false); return; + } /* Free previous message if any */ intl_free_custom_error_msg( err ); - /* Mark message copied if any */ - err->free_custom_error_message = copyMsg; - /* Set user's error text message */ - err->custom_error_message = copyMsg ? estrdup( msg ) : (char *) msg; + err->custom_error_message = prefixed_message; } /* }}} */ @@ -116,21 +126,22 @@ void intl_error_set_custom_msg( intl_error* err, const char* msg, int copyMsg ) zend_string * intl_error_get_message( intl_error* err ) { const char *uErrorName = NULL; - zend_string *errMessage = 0; + zend_string *errMessage = NULL; if( !err && !( err = intl_g_error_get( ) ) ) return ZSTR_EMPTY_ALLOC(); uErrorName = u_errorName( err->code ); + size_t uErrorLen = strlen(uErrorName); /* Format output string */ - if( err->custom_error_message ) - { - errMessage = strpprintf(0, "%s: %s", err->custom_error_message, uErrorName ); - } - else - { - errMessage = strpprintf(0, "%s", uErrorName ); + if (err->custom_error_message) { + errMessage = zend_string_concat3( + ZSTR_VAL(err->custom_error_message), ZSTR_LEN(err->custom_error_message), + ZEND_STRL(": "), + uErrorName, uErrorLen); + } else { + errMessage = zend_string_init(uErrorName, strlen(uErrorName), false); } return errMessage; @@ -158,18 +169,18 @@ UErrorCode intl_error_get_code( intl_error* err ) /* }}} */ /* {{{ Set error code and message. */ -void intl_error_set( intl_error* err, UErrorCode code, const char* msg, int copyMsg ) +void intl_error_set( intl_error* err, UErrorCode code, const char* msg) { intl_error_set_code( err, code ); - intl_error_set_custom_msg( err, msg, copyMsg ); + intl_error_set_custom_msg( err, msg); } /* }}} */ /* {{{ Set error code and message. */ -void intl_errors_set( intl_error* err, UErrorCode code, const char* msg, int copyMsg ) +void intl_errors_set( intl_error* err, UErrorCode code, const char* msg) { intl_errors_set_code( err, code ); - intl_errors_set_custom_msg( err, msg, copyMsg ); + intl_errors_set_custom_msg( err, msg); } /* }}} */ @@ -184,12 +195,12 @@ void intl_errors_reset( intl_error* err ) /* }}} */ /* {{{ */ -void intl_errors_set_custom_msg( intl_error* err, const char* msg, int copyMsg ) +void intl_errors_set_custom_msg(intl_error* err, const char* msg) { if(err) { - intl_error_set_custom_msg( err, msg, copyMsg ); + intl_error_set_custom_msg( err, msg); } - intl_error_set_custom_msg( NULL, msg, copyMsg ); + intl_error_set_custom_msg( NULL, msg); } /* }}} */ diff --git a/ext/intl/intl_error.h b/ext/intl/intl_error.h index 74bf0d8a43eee..8a9bff0b271c0 100644 --- a/ext/intl/intl_error.h +++ b/ext/intl/intl_error.h @@ -23,26 +23,25 @@ #define INTL_ERROR_CODE(e) (e).code -typedef struct _intl_error { - UErrorCode code; - int free_custom_error_message; - char* custom_error_message; +typedef struct { + zend_string *custom_error_message; + UErrorCode code; } intl_error; intl_error* intl_error_create( void ); void intl_error_init( intl_error* err ); void intl_error_reset( intl_error* err ); void intl_error_set_code( intl_error* err, UErrorCode err_code ); -void intl_error_set_custom_msg( intl_error* err, const char* msg, int copyMsg ); -void intl_error_set( intl_error* err, UErrorCode code, const char* msg, int copyMsg ); +void intl_error_set_custom_msg( intl_error* err, const char* msg); +void intl_error_set( intl_error* err, UErrorCode code, const char* msg); UErrorCode intl_error_get_code( intl_error* err ); zend_string* intl_error_get_message( intl_error* err ); // Wrappers to synchonize object's and global error structures. void intl_errors_reset( intl_error* err ); -void intl_errors_set_custom_msg( intl_error* err, const char* msg, int copyMsg ); +void intl_errors_set_custom_msg( intl_error* err, const char* msg); void intl_errors_set_code( intl_error* err, UErrorCode err_code ); -void intl_errors_set( intl_error* err, UErrorCode code, const char* msg, int copyMsg ); +void intl_errors_set( intl_error* err, UErrorCode code, const char* msg); // Other error helpers smart_str intl_parse_error_to_string( UParseError* pe ); diff --git a/ext/intl/listformatter/listformatter_class.c b/ext/intl/listformatter/listformatter_class.c index c087d75d4e0a2..1aa849370ab8f 100644 --- a/ext/intl/listformatter/listformatter_class.c +++ b/ext/intl/listformatter/listformatter_class.c @@ -109,7 +109,7 @@ PHP_METHOD(IntlListFormatter, __construct) #endif if (U_FAILURE(status)) { - intl_error_set(NULL, status, "Constructor failed", 0); + intl_error_set(NULL, status, "Constructor failed"); zend_throw_exception(IntlException_ce_ptr, "Constructor failed", 0); RETURN_THROWS(); } @@ -154,7 +154,7 @@ PHP_METHOD(IntlListFormatter, format) } efree(items); efree(itemLengths); - intl_error_set(NULL, status, "Failed to convert string to UTF-16", 0); + intl_error_set(NULL, status, "Failed to convert string to UTF-16"); RETURN_FALSE; } @@ -170,7 +170,7 @@ PHP_METHOD(IntlListFormatter, format) resultLength = ulistfmt_format(LISTFORMATTER_OBJECT(obj), items, itemLengths, count, NULL, 0, &status); if (U_FAILURE(status) && status != U_BUFFER_OVERFLOW_ERROR) { - intl_error_set(NULL, status, "Failed to format list", 0); + intl_error_set(NULL, status, "Failed to format list"); RETVAL_FALSE; goto cleanup; } @@ -184,7 +184,7 @@ PHP_METHOD(IntlListFormatter, format) if (result) { efree(result); } - intl_error_set(NULL, status, "Failed to format list", 0); + intl_error_set(NULL, status, "Failed to format list"); RETVAL_FALSE; goto cleanup; } @@ -194,7 +194,7 @@ PHP_METHOD(IntlListFormatter, format) efree(result); if (!ret) { - intl_error_set(NULL, status, "Failed to convert result to UTF-8", 0); + intl_error_set(NULL, status, "Failed to convert result to UTF-8"); RETVAL_FALSE; } else { RETVAL_NEW_STR(ret); diff --git a/ext/intl/locale/locale_methods.cpp b/ext/intl/locale/locale_methods.cpp index 716b69b034b2e..2cc47d5cc4e07 100644 --- a/ext/intl/locale/locale_methods.cpp +++ b/ext/intl/locale/locale_methods.cpp @@ -473,7 +473,6 @@ static void get_icu_value_src_php( char* tag_name, INTERNAL_FUNCTION_PARAMETERS) size_t loc_name_len = 0; zend_string* tag_value = NULL; - char* empty_result = ""; int result = 0; char* msg = NULL; @@ -501,19 +500,18 @@ static void get_icu_value_src_php( char* tag_name, INTERNAL_FUNCTION_PARAMETERS) if( tag_value){ zend_string_release_ex( tag_value, 0 ); } - RETURN_STRING( empty_result); + RETURN_EMPTY_STRING(); } /* value found */ if( tag_value){ - RETVAL_STR( tag_value ); - return; + RETURN_STR( tag_value ); } /* Error encountered while fetching the value */ if( result ==0) { - spprintf(&msg , 0, "locale_get_%s : unable to get locale %s", tag_name , tag_name ); - intl_error_set( NULL, status, msg , 1 ); + spprintf(&msg , 0, "unable to get locale %s", tag_name ); + intl_error_set( NULL, status, msg); efree(msg); RETURN_NULL(); } @@ -577,9 +575,7 @@ static void get_icu_disp_value_src_php( char* tag_name, INTERNAL_FUNCTION_PARAME if(loc_name_len > ULOC_FULLNAME_CAPACITY) { /* See bug 67397: overlong locale names cause trouble in uloc_getDisplayName */ - spprintf(&msg , 0, "locale_get_display_%s : name too long", tag_name ); - intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, msg , 1 ); - efree(msg); + intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "name too long"); RETURN_FALSE; } @@ -636,8 +632,8 @@ static void get_icu_disp_value_src_php( char* tag_name, INTERNAL_FUNCTION_PARAME continue; } - spprintf(&msg, 0, "locale_get_display_%s : unable to get locale %s", tag_name , tag_name ); - intl_error_set( NULL, status, msg , 1 ); + spprintf(&msg, 0, "unable to get locale %s", tag_name ); + intl_error_set( NULL, status, msg); efree(msg); if( disp_name){ efree( disp_name ); @@ -665,8 +661,8 @@ static void get_icu_disp_value_src_php( char* tag_name, INTERNAL_FUNCTION_PARAME efree( disp_name ); if( !u8str ) { - spprintf(&msg, 0, "locale_get_display_%s :error converting display name for %s to UTF-8", tag_name , tag_name ); - intl_error_set( NULL, status, msg , 1 ); + spprintf(&msg, 0, "error converting display name for %s to UTF-8", tag_name ); + intl_error_set( NULL, status, msg); efree(msg); RETURN_FALSE; } @@ -773,7 +769,7 @@ U_CFUNC PHP_FUNCTION( locale_get_keywords ) kw_value_str = zend_string_truncate(kw_value_str, kw_value_len, 0); } if (U_FAILURE(status)) { - intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "locale_get_keywords: Error encountered while getting the keyword value for the keyword", 0 ); + intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "Error encountered while getting the keyword value for the keyword"); if( kw_value_str){ zend_string_efree( kw_value_str ); } @@ -925,7 +921,7 @@ static int handleAppendResult( int result, smart_str* loc_name) intl_error_reset( NULL ); if( result == FAILURE) { intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, - "locale_compose: parameter array element is not a string", 0 ); + "parameter array element is not a string"); smart_str_free(loc_name); return 0; } @@ -1284,16 +1280,14 @@ U_CFUNC PHP_FUNCTION(locale_filter_matches) /* canonicalize loc_range */ can_loc_range=get_icu_value_internal( loc_range , LOC_CANONICALIZE_TAG , &result , 0); if( result <=0) { - intl_error_set( NULL, status, - "locale_filter_matches : unable to canonicalize loc_range" , 0 ); + intl_error_set(NULL, status, "unable to canonicalize loc_range"); RETURN_FALSE; } /* canonicalize lang_tag */ can_lang_tag = get_icu_value_internal( lang_tag , LOC_CANONICALIZE_TAG , &result , 0); if( result <=0) { - intl_error_set( NULL, status, - "locale_filter_matches : unable to canonicalize lang_tag" , 0 ); + intl_error_set(NULL, status, "unable to canonicalize lang_tag"); RETURN_FALSE; } @@ -1443,7 +1437,7 @@ static zend_string* lookup_loc_range(const char* loc_range, HashTable* hash_arr, cur_arr[cur_arr_len*2] = estrndup(Z_STRVAL_P(ele_value), Z_STRLEN_P(ele_value)); result = strToMatch(Z_STRVAL_P(ele_value), cur_arr[cur_arr_len*2]); if(result == 0) { - intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "lookup_loc_range: unable to canonicalize lang_tag", 0); + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "unable to canonicalize lang_tag"); LOOKUP_CLEAN_RETURN(NULL); } cur_arr[cur_arr_len*2+1] = Z_STRVAL_P(ele_value); @@ -1458,14 +1452,14 @@ static zend_string* lookup_loc_range(const char* loc_range, HashTable* hash_arr, if(lang_tag) { zend_string_release_ex(lang_tag, 0); } - intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "lookup_loc_range: unable to canonicalize lang_tag" , 0); + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "unable to canonicalize lang_tag"); LOOKUP_CLEAN_RETURN(NULL); } cur_arr[i*2] = reinterpret_cast(erealloc(cur_arr[i*2], lang_tag->len+1)); result = strToMatch(lang_tag->val, cur_arr[i*2]); zend_string_release_ex(lang_tag, 0); if(result == 0) { - intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "lookup_loc_range: unable to canonicalize lang_tag" , 0); + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "unable to canonicalize lang_tag"); LOOKUP_CLEAN_RETURN(NULL); } } @@ -1477,7 +1471,7 @@ static zend_string* lookup_loc_range(const char* loc_range, HashTable* hash_arr, can_loc_range = get_icu_value_internal(loc_range, LOC_CANONICALIZE_TAG, &result , 0); if( result != 1 || can_loc_range == NULL || !can_loc_range->val[0]) { /* Error */ - intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "lookup_loc_range: unable to canonicalize loc_range" , 0 ); + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "unable to canonicalize loc_range"); if(can_loc_range) { zend_string_release_ex(can_loc_range, 0); } @@ -1495,7 +1489,7 @@ static zend_string* lookup_loc_range(const char* loc_range, HashTable* hash_arr, } if(result == 0) { efree(cur_loc_range); - intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "lookup_loc_range: unable to canonicalize lang_tag" , 0); + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "unable to canonicalize lang_tag"); LOOKUP_CLEAN_RETURN(NULL); } @@ -1605,7 +1599,7 @@ U_CFUNC PHP_FUNCTION(locale_accept_from_http) len = end ? end-start : http_accept_len-(start-http_accept); if(len > ULOC_FULLNAME_CAPACITY) { intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, - "locale_accept_from_http: locale string too long", 0 ); + "locale string too long"); RETURN_FALSE; } if(end) { @@ -1615,11 +1609,11 @@ U_CFUNC PHP_FUNCTION(locale_accept_from_http) } available = ures_openAvailableLocales(NULL, &status); - INTL_CHECK_STATUS(status, "locale_accept_from_http: failed to retrieve locale list"); + INTL_CHECK_STATUS(status, "failed to retrieve locale list"); len = uloc_acceptLanguageFromHTTP(resultLocale, INTL_MAX_LOCALE_LEN, &outResult, http_accept, available, &status); uenum_close(available); - INTL_CHECK_STATUS(status, "locale_accept_from_http: failed to find acceptable locale"); + INTL_CHECK_STATUS(status, "failed to find acceptable locale"); if (len < 0 || outResult == ULOC_ACCEPT_FAILED) { RETURN_FALSE; } @@ -1658,7 +1652,7 @@ U_CFUNC PHP_FUNCTION(locale_add_likely_subtags) } int32_t maximized_locale_len = uloc_addLikelySubtags(locale, maximized_locale, sizeof(maximized_locale), &status); - INTL_CHECK_STATUS(status, "locale_add_likely_subtags: invalid locale"); + INTL_CHECK_STATUS(status, "invalid locale"); if (maximized_locale_len < 0) { RETURN_FALSE; } @@ -1681,7 +1675,7 @@ U_CFUNC PHP_FUNCTION(locale_minimize_subtags) } int32_t minimized_locale_len = uloc_minimizeSubtags(locale, minimized_locale, sizeof(minimized_locale), &status); - INTL_CHECK_STATUS(status, "locale_minimize_subtags: invalid locale"); + INTL_CHECK_STATUS(status, "invalid locale"); if (minimized_locale_len < 0) { RETURN_FALSE; } diff --git a/ext/intl/msgformat/msgformat.c b/ext/intl/msgformat/msgformat.c index 51643d86d458a..4f0beaf2c0528 100644 --- a/ext/intl/msgformat/msgformat.c +++ b/ext/intl/msgformat/msgformat.c @@ -25,7 +25,7 @@ #include "intl_convert.h" /* {{{ */ -static int msgfmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handling *error_handling, bool *error_handling_replaced) +static int msgfmt_ctor(INTERNAL_FUNCTION_PARAMETERS) { char* locale; char* pattern; @@ -43,18 +43,13 @@ static int msgfmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handling *error_ Z_PARAM_STRING(pattern, pattern_len) ZEND_PARSE_PARAMETERS_END_EX(return FAILURE); - if (error_handling != NULL) { - zend_replace_error_handling(EH_THROW, IntlException_ce_ptr, error_handling); - *error_handling_replaced = 1; - } - INTL_CHECK_LOCALE_LEN_OR_FAILURE(locale_len); MSG_FORMAT_METHOD_FETCH_OBJECT_NO_CHECK; /* Convert pattern (if specified) to UTF-16. */ if(pattern && pattern_len) { intl_convert_utf8_to_utf16(&spattern, &spattern_len, pattern, pattern_len, &INTL_DATA_ERROR_CODE(mfo)); - INTL_CTOR_CHECK_STATUS(mfo, "msgfmt_create: error converting pattern to UTF-16"); + INTL_CTOR_CHECK_STATUS(mfo, "error converting pattern to UTF-16"); } else { spattern_len = 0; spattern = NULL; @@ -92,13 +87,13 @@ static int msgfmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handling *error_ smart_str_free( &parse_error_str ); intl_error_set_code( NULL, INTL_DATA_ERROR_CODE( mfo ) ); - intl_errors_set_custom_msg( INTL_DATA_ERROR_P( mfo ), msg, 1 ); + intl_errors_set_custom_msg( INTL_DATA_ERROR_P( mfo ), msg); efree( msg ); return FAILURE; } - INTL_CTOR_CHECK_STATUS(mfo, "msgfmt_create: message formatter creation failed"); + INTL_CTOR_CHECK_STATUS(mfo, "message formatter creation failed"); return SUCCESS; } /* }}} */ @@ -107,7 +102,7 @@ static int msgfmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handling *error_ PHP_FUNCTION( msgfmt_create ) { object_init_ex( return_value, MessageFormatter_ce_ptr ); - if (msgfmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, NULL, NULL) == FAILURE) { + if (msgfmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU) == FAILURE) { zval_ptr_dtor(return_value); RETURN_NULL(); } @@ -117,20 +112,17 @@ PHP_FUNCTION( msgfmt_create ) /* {{{ MessageFormatter object constructor. */ PHP_METHOD( MessageFormatter, __construct ) { - zend_error_handling error_handling; - bool error_handling_replaced = 0; + const bool old_use_exception = INTL_G(use_exceptions); + const zend_long old_error_level = INTL_G(error_level); + INTL_G(use_exceptions) = true; + INTL_G(error_level) = 0; return_value = ZEND_THIS; - if (msgfmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, &error_handling, &error_handling_replaced) == FAILURE) { - if (!EG(exception)) { - zend_string *err = intl_error_get_message(NULL); - zend_throw_exception(IntlException_ce_ptr, ZSTR_VAL(err), intl_error_get_code(NULL)); - zend_string_release_ex(err, 0); - } - } - if (error_handling_replaced) { - zend_restore_error_handling(&error_handling); + if (msgfmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU) == FAILURE) { + ZEND_ASSERT(EG(exception)); } + INTL_G(use_exceptions) = old_use_exception; + INTL_G(error_level) = old_error_level; } /* }}} */ diff --git a/ext/intl/msgformat/msgformat_attr.c b/ext/intl/msgformat/msgformat_attr.c index b56bf360d114d..6d1813f4608f8 100644 --- a/ext/intl/msgformat/msgformat_attr.c +++ b/ext/intl/msgformat/msgformat_attr.c @@ -83,7 +83,7 @@ PHP_FUNCTION( msgfmt_set_pattern ) if (U_FAILURE(INTL_DATA_ERROR_CODE(mfo))) { char *msg; spprintf(&msg, 0, "Error setting symbol value at line %d, offset %d", spattern_error.line, spattern_error.offset); - intl_errors_set_custom_msg(INTL_DATA_ERROR_P(mfo), msg, 1); + intl_errors_set_custom_msg(INTL_DATA_ERROR_P(mfo), msg); efree(msg); RETURN_FALSE; } diff --git a/ext/intl/msgformat/msgformat_format.c b/ext/intl/msgformat/msgformat_format.c index 46a364c5d3a21..54babc9839648 100644 --- a/ext/intl/msgformat/msgformat_format.c +++ b/ext/intl/msgformat/msgformat_format.c @@ -99,7 +99,7 @@ PHP_FUNCTION( msgfmt_format_message ) if( U_FAILURE(INTL_DATA_ERROR_CODE((mfo))) ) { intl_error_set(/* intl_error* */ NULL, U_ILLEGAL_ARGUMENT_ERROR, - "msgfmt_format_message: error converting pattern to UTF-16", 0 ); + "error converting pattern to UTF-16"); RETURN_FALSE; } } else { @@ -114,7 +114,7 @@ PHP_FUNCTION( msgfmt_format_message ) #ifdef MSG_FORMAT_QUOTE_APOS if(msgformat_fix_quotes(&spattern, &spattern_len, &INTL_DATA_ERROR_CODE(mfo)) != SUCCESS) { intl_error_set(/* intl_error* */ NULL, U_INVALID_FORMAT_ERROR, - "msgfmt_format_message: error converting pattern to quote-friendly format", 0 ); + "msgfmt_format_message: error converting pattern to quote-friendly format"); RETURN_FALSE; } #endif @@ -136,11 +136,11 @@ PHP_FUNCTION( msgfmt_format_message ) /* Pass NULL to intl_error* parameter to store message in global Intl error msg stack */ intl_error_set_code(/* intl_error* */ NULL, INTL_DATA_ERROR_CODE( mfo ) ); - intl_errors_set_custom_msg(/* intl_error* */ NULL, msg, 1 ); + intl_errors_set_custom_msg(/* intl_error* */ NULL, msg); efree( msg ); } else { - intl_errors_set_custom_msg(/* intl_error* */ NULL, "Creating message formatter failed", 0 ); + intl_errors_set_custom_msg(/* intl_error* */ NULL, "Creating message formatter failed"); } umsg_close(MSG_FORMAT_OBJECT(mfo)); RETURN_FALSE; diff --git a/ext/intl/msgformat/msgformat_helpers.cpp b/ext/intl/msgformat/msgformat_helpers.cpp index fbd85b857f3bc..080dba6cfe2ef 100644 --- a/ext/intl/msgformat/msgformat_helpers.cpp +++ b/ext/intl/msgformat/msgformat_helpers.cpp @@ -187,7 +187,7 @@ static HashTable *umsg_parse_format(MessageFormatter_object *mfo, int32_t argNumber = name_part.getValue(); if (argNumber < 0) { intl_errors_set(&err, U_INVALID_FORMAT_ERROR, - "Found part with negative number", 0); + "Found part with negative number"); continue; } if ((storedType = (Formattable::Type*)zend_hash_index_find_ptr(ret, (zend_ulong)argNumber)) == NULL) { @@ -196,7 +196,7 @@ static HashTable *umsg_parse_format(MessageFormatter_object *mfo, storedType = (Formattable::Type*)zend_hash_index_update_mem(ret, (zend_ulong)argNumber, (void*)&bogusType, sizeof(bogusType)); } } else { - intl_errors_set(&err, U_INVALID_FORMAT_ERROR, "Invalid part type encountered", 0); + intl_errors_set(&err, U_INVALID_FORMAT_ERROR, "Invalid part type encountered"); continue; } @@ -243,7 +243,7 @@ static HashTable *umsg_parse_format(MessageFormatter_object *mfo, * is broken. */ intl_errors_set(&err, U_PARSE_ERROR, "Expected UMSGPAT_PART_TYPE_ARG_TYPE part following " - "UMSGPAT_ARG_TYPE_SIMPLE part", 0); + "UMSGPAT_ARG_TYPE_SIMPLE part"); continue; } } else if (argType == UMSGPAT_ARG_TYPE_PLURAL) { @@ -262,7 +262,7 @@ static HashTable *umsg_parse_format(MessageFormatter_object *mfo, /* We found a different type for the same arg! */ if (*storedType != Formattable::kObject && *storedType != type) { intl_errors_set(&err, U_ARGUMENT_TYPE_MISMATCH, - "Inconsistent types declared for an argument", 0); + "Inconsistent types declared for an argument"); continue; } @@ -330,7 +330,7 @@ static void umsg_set_timezone(MessageFormatter_object *mfo, if (UNEXPECTED(formats == NULL)) { intl_errors_set(&err, U_MEMORY_ALLOCATION_ERROR, - "Out of memory retrieving subformats", 0); + "Out of memory retrieving subformats"); } for (int i = 0; U_SUCCESS(err.code) && i < count; i++) { @@ -343,7 +343,7 @@ static void umsg_set_timezone(MessageFormatter_object *mfo, if (used_tz == NULL) { zval nullzv; ZVAL_NULL(&nullzv); - used_tz = timezone_process_timezone_argument(&nullzv, &err, "msgfmt_format"); + used_tz = timezone_process_timezone_argument(&nullzv, &err); if (used_tz == NULL) { continue; } @@ -405,7 +405,7 @@ U_CFUNC void umsg_format_helper(MessageFormatter_object *mfo, /* includes case where index < 0 because it's exposed as unsigned */ if (UNEXPECTED(num_index > (zend_ulong)INT32_MAX)) { intl_errors_set(&err, U_ILLEGAL_ARGUMENT_ERROR, - "Found negative or too large array key", 0); + "Found negative or too large array key"); continue; } @@ -421,7 +421,7 @@ U_CFUNC void umsg_format_helper(MessageFormatter_object *mfo, char *message; spprintf(&message, 0, "Invalid UTF-8 data in argument key: '%s'", ZSTR_VAL(str_index)); - intl_errors_set(&err, err.code, message, 1); + intl_errors_set(&err, err.code, message); efree(message); continue; } @@ -457,7 +457,7 @@ U_CFUNC void umsg_format_helper(MessageFormatter_object *mfo, char *message; spprintf(&message, 0, "Invalid UTF-8 data in string argument: " "'%s'", ZSTR_VAL(str)); - intl_errors_set(&err, err.code, message, 1); + intl_errors_set(&err, err.code, message); efree(message); delete text; continue; @@ -481,7 +481,7 @@ U_CFUNC void umsg_format_helper(MessageFormatter_object *mfo, Z_DVAL_P(elem) < (double)INT32_MIN)) { intl_errors_set(&err, U_ILLEGAL_ARGUMENT_ERROR, "Found PHP float with absolute value too large for " - "32 bit integer argument", 0); + "32 bit integer argument"); } else { tInt32 = (int32_t)Z_DVAL_P(elem); } @@ -490,7 +490,7 @@ U_CFUNC void umsg_format_helper(MessageFormatter_object *mfo, Z_LVAL_P(elem) < INT32_MIN)) { intl_errors_set(&err, U_ILLEGAL_ARGUMENT_ERROR, "Found PHP integer with absolute value too large " - "for 32 bit integer argument", 0); + "for 32 bit integer argument"); } else { tInt32 = (int32_t)Z_LVAL_P(elem); } @@ -509,7 +509,7 @@ U_CFUNC void umsg_format_helper(MessageFormatter_object *mfo, Z_DVAL_P(elem) < (double)U_INT64_MIN)) { intl_errors_set(&err, U_ILLEGAL_ARGUMENT_ERROR, "Found PHP float with absolute value too large for " - "64 bit integer argument", 0); + "64 bit integer argument"); } else { tInt64 = (int64_t)Z_DVAL_P(elem); } @@ -524,7 +524,7 @@ U_CFUNC void umsg_format_helper(MessageFormatter_object *mfo, } case Formattable::kDate: { - double dd = intl_zval_to_millis(elem, &err, "msgfmt_format"); + double dd = intl_zval_to_millis(elem, &err); if (U_FAILURE(err.code)) { char *message; zend_string *u8key; @@ -533,7 +533,7 @@ U_CFUNC void umsg_format_helper(MessageFormatter_object *mfo, if (u8key) { spprintf(&message, 0, "The argument for key '%s' " "cannot be used as a date or time", ZSTR_VAL(u8key)); - intl_errors_set(&err, err.code, message, 1); + intl_errors_set(&err, err.code, message); zend_string_release_ex(u8key, 0); efree(message); } @@ -544,7 +544,7 @@ U_CFUNC void umsg_format_helper(MessageFormatter_object *mfo, } default: intl_errors_set(&err, U_ILLEGAL_ARGUMENT_ERROR, - "Found unsupported argument type", 0); + "Found unsupported argument type"); break; } } else { @@ -578,8 +578,7 @@ U_CFUNC void umsg_format_helper(MessageFormatter_object *mfo, spprintf(&message, 0, "No strategy to convert the " "value given for the argument with key '%s' " "is available", ZSTR_VAL(u8key)); - intl_errors_set(&err, - U_ILLEGAL_ARGUMENT_ERROR, message, 1); + intl_errors_set(&err, U_ILLEGAL_ARGUMENT_ERROR, message); zend_string_release_ex(u8key, 0); efree(message); } @@ -602,7 +601,7 @@ U_CFUNC void umsg_format_helper(MessageFormatter_object *mfo, if (U_FAILURE(err.code)) { intl_errors_set(&err, err.code, - "Call to ICU MessageFormat::format() has failed", 0); + "Call to ICU MessageFormat::format() has failed"); return; } @@ -610,8 +609,7 @@ U_CFUNC void umsg_format_helper(MessageFormatter_object *mfo, *formatted = eumalloc(*formatted_len+1); resultStr.extract(*formatted, *formatted_len+1, err.code); if (U_FAILURE(err.code)) { - intl_errors_set(&err, err.code, - "Error copying format() result", 0); + intl_errors_set(&err, err.code, "Error copying format() result"); return; } } diff --git a/ext/intl/msgformat/msgformat_parse.c b/ext/intl/msgformat/msgformat_parse.c index 91416dd88b4e8..5c4f0443981f4 100644 --- a/ext/intl/msgformat/msgformat_parse.c +++ b/ext/intl/msgformat/msgformat_parse.c @@ -102,7 +102,7 @@ PHP_FUNCTION( msgfmt_parse_message ) if( U_FAILURE(INTL_DATA_ERROR_CODE((mfo))) ) { intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, - "msgfmt_parse_message: error converting pattern to UTF-16", 0 ); + "error converting pattern to UTF-16"); RETURN_FALSE; } } else { diff --git a/ext/intl/normalizer/normalizer_normalize.c b/ext/intl/normalizer/normalizer_normalize.c index 38f12134146a5..670042f34d2b0 100644 --- a/ext/intl/normalizer/normalizer_normalize.c +++ b/ext/intl/normalizer/normalizer_normalize.c @@ -130,7 +130,7 @@ PHP_FUNCTION( normalizer_normalize ) intl_error_set_code( NULL, status ); /* Set error messages. */ - intl_error_set_custom_msg( NULL, "Error converting input string to UTF-16", 0 ); + intl_error_set_custom_msg( NULL, "Error converting input string to UTF-16"); if (uinput) { efree( uinput ); } @@ -150,7 +150,7 @@ PHP_FUNCTION( normalizer_normalize ) * (U_STRING_NOT_TERMINATED_WARNING usually means that the input string is empty). */ if( U_FAILURE(status) && status != U_BUFFER_OVERFLOW_ERROR && status != U_STRING_NOT_TERMINATED_WARNING ) { - intl_error_set_custom_msg( NULL, "Error normalizing string", 0 ); + intl_error_set_custom_msg( NULL, "Error normalizing string"); efree( uret_buf ); efree( uinput ); RETURN_FALSE; @@ -172,7 +172,7 @@ PHP_FUNCTION( normalizer_normalize ) /* Bail out if an unexpected error occurred. */ if( U_FAILURE(status) ) { /* Set error messages. */ - intl_error_set_custom_msg( NULL,"Error normalizing string", 0 ); + intl_error_set_custom_msg( NULL,"Error normalizing string"); efree( uret_buf ); efree( uinput ); RETURN_FALSE; @@ -190,7 +190,7 @@ PHP_FUNCTION( normalizer_normalize ) if( !u8str ) { intl_error_set( NULL, status, - "normalizer_normalize: error converting normalized text UTF-8", 0 ); + "error converting normalized text UTF-8"); RETURN_FALSE; } @@ -248,7 +248,7 @@ PHP_FUNCTION( normalizer_is_normalized ) intl_error_set_code( NULL, status ); /* Set error messages. */ - intl_error_set_custom_msg( NULL, "Error converting string to UTF-16.", 0 ); + intl_error_set_custom_msg( NULL, "Error converting string to UTF-16."); if (uinput) { efree( uinput ); } @@ -264,7 +264,7 @@ PHP_FUNCTION( normalizer_is_normalized ) /* Bail out if an unexpected error occurred. */ if( U_FAILURE(status) ) { /* Set error messages. */ - intl_error_set_custom_msg( NULL,"Error testing if string is the given normalization form.", 0 ); + intl_error_set_custom_msg( NULL,"Error testing if string is the given normalization form."); RETURN_FALSE; } @@ -304,13 +304,13 @@ PHP_FUNCTION( normalizer_get_raw_decomposition ) U8_NEXT(input, offset, input_length, codepoint); if ((size_t)offset != input_length) { intl_error_set_code(NULL, U_ILLEGAL_ARGUMENT_ERROR); - intl_error_set_custom_msg(NULL, "Input string must be exactly one UTF-8 encoded code point long.", 0); + intl_error_set_custom_msg(NULL, "Input string must be exactly one UTF-8 encoded code point long."); return; } if ((codepoint < UCHAR_MIN_VALUE) || (codepoint > UCHAR_MAX_VALUE)) { intl_error_set_code(NULL, U_ILLEGAL_ARGUMENT_ERROR); - intl_error_set_custom_msg(NULL, "Code point out of range", 0); + intl_error_set_custom_msg(NULL, "Code point out of range"); return; } diff --git a/ext/intl/resourcebundle/resourcebundle_class.c b/ext/intl/resourcebundle/resourcebundle_class.c index 27bd3c0ffc0b8..165e60cc1d3a1 100644 --- a/ext/intl/resourcebundle/resourcebundle_class.c +++ b/ext/intl/resourcebundle/resourcebundle_class.c @@ -72,7 +72,7 @@ static zend_object *ResourceBundle_object_create( zend_class_entry *ce ) /* }}} */ /* {{{ ResourceBundle_ctor */ -static int resourcebundle_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handling *error_handling, bool *error_handling_replaced) +static zend_result resourcebundle_ctor(INTERNAL_FUNCTION_PARAMETERS) { char *bundlename; size_t bundlename_len = 0; @@ -92,11 +92,6 @@ static int resourcebundle_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handling Z_PARAM_BOOL(fallback) ZEND_PARSE_PARAMETERS_END_EX(return FAILURE); - if (error_handling != NULL) { - zend_replace_error_handling(EH_THROW, IntlException_ce_ptr, error_handling); - *error_handling_replaced = 1; - } - if (rb->me) { zend_throw_error(NULL, "ResourceBundle object is already constructed"); return FAILURE; @@ -119,18 +114,18 @@ static int resourcebundle_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handling rb->me = ures_openDirect(bundlename, locale, &INTL_DATA_ERROR_CODE(rb)); } - INTL_CTOR_CHECK_STATUS(rb, "resourcebundle_ctor: Cannot load libICU resource bundle"); + INTL_CTOR_CHECK_STATUS(rb, "Cannot load libICU resource bundle"); if (!fallback && (INTL_DATA_ERROR_CODE(rb) == U_USING_FALLBACK_WARNING || INTL_DATA_ERROR_CODE(rb) == U_USING_DEFAULT_WARNING)) { char *pbuf; intl_errors_set_code(NULL, INTL_DATA_ERROR_CODE(rb)); - spprintf(&pbuf, 0, "resourcebundle_ctor: Cannot load libICU resource " + spprintf(&pbuf, 0, "Cannot load libICU resource " "'%s' without fallback from %s to %s", bundlename ? bundlename : "(default data)", locale, ures_getLocaleByType( rb->me, ULOC_ACTUAL_LOCALE, &INTL_DATA_ERROR_CODE(rb))); - intl_errors_set_custom_msg(INTL_DATA_ERROR_P(rb), pbuf, 1); + intl_errors_set_custom_msg(INTL_DATA_ERROR_P(rb), pbuf); efree(pbuf); return FAILURE; } @@ -142,18 +137,17 @@ static int resourcebundle_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handling /* {{{ ResourceBundle object constructor */ PHP_METHOD( ResourceBundle, __construct ) { - zend_error_handling error_handling; - bool error_handling_replaced = 0; + const bool old_use_exception = INTL_G(use_exceptions); + const zend_long old_error_level = INTL_G(error_level); + INTL_G(use_exceptions) = true; + INTL_G(error_level) = 0; return_value = ZEND_THIS; - if (resourcebundle_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, &error_handling, &error_handling_replaced) == FAILURE) { - if (!EG(exception)) { - zend_throw_exception(IntlException_ce_ptr, "Constructor failed", 0); - } - } - if (error_handling_replaced) { - zend_restore_error_handling(&error_handling); + if (resourcebundle_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU) == FAILURE) { + ZEND_ASSERT(EG(exception)); } + INTL_G(use_exceptions) = old_use_exception; + INTL_G(error_level) = old_error_level; } /* }}} */ @@ -161,7 +155,7 @@ PHP_METHOD( ResourceBundle, __construct ) PHP_FUNCTION( resourcebundle_create ) { object_init_ex( return_value, ResourceBundle_ce_ptr ); - if (resourcebundle_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, NULL, NULL) == FAILURE) { + if (resourcebundle_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU) == FAILURE) { zval_ptr_dtor(return_value); RETURN_NULL(); } @@ -214,7 +208,7 @@ static zval *resource_bundle_array_fetch( } else { spprintf( &pbuf, 0, "Cannot load resource element '%s'", key ); } - intl_errors_set_custom_msg( INTL_DATA_ERROR_P(rb), pbuf, 1 ); + intl_errors_set_custom_msg( INTL_DATA_ERROR_P(rb), pbuf); efree(pbuf); RETVAL_NULL(); return return_value; @@ -228,7 +222,7 @@ static zval *resource_bundle_array_fetch( } else { spprintf(&pbuf, 0, "Cannot load element '%s' without fallback from to %s", key, locale); } - intl_errors_set_custom_msg( INTL_DATA_ERROR_P(rb), pbuf, 1); + intl_errors_set_custom_msg( INTL_DATA_ERROR_P(rb), pbuf); efree(pbuf); RETVAL_NULL(); return return_value; @@ -307,7 +301,7 @@ static zend_result resourcebundle_array_count(zend_object *object, zend_long *co if (rb->me == NULL) { intl_errors_set(&rb->error, U_ILLEGAL_ARGUMENT_ERROR, - "Found unconstructed ResourceBundle", 0); + "Found unconstructed ResourceBundle"); return FAILURE; } diff --git a/ext/intl/spoofchecker/spoofchecker_class.h b/ext/intl/spoofchecker/spoofchecker_class.h index 480eeeb476ffb..a471c055c2ce6 100644 --- a/ext/intl/spoofchecker/spoofchecker_class.h +++ b/ext/intl/spoofchecker/spoofchecker_class.h @@ -73,7 +73,7 @@ extern zend_class_entry *Spoofchecker_ce_ptr; #define SPOOFCHECKER_CHECK_STATUS(co, msg) \ intl_error_set_code(NULL, SPOOFCHECKER_ERROR_CODE(co)); \ if (U_FAILURE(SPOOFCHECKER_ERROR_CODE(co))) { \ - intl_errors_set_custom_msg(SPOOFCHECKER_ERROR_P(co), msg, 0); \ + intl_errors_set_custom_msg(SPOOFCHECKER_ERROR_P(co), msg); \ RETURN_FALSE; \ } \ diff --git a/ext/intl/spoofchecker/spoofchecker_create.c b/ext/intl/spoofchecker/spoofchecker_create.c index c1cecac8412a0..7cb51adef4e24 100644 --- a/ext/intl/spoofchecker/spoofchecker_create.c +++ b/ext/intl/spoofchecker/spoofchecker_create.c @@ -26,17 +26,17 @@ PHP_METHOD(Spoofchecker, __construct) #if U_ICU_VERSION_MAJOR_NUM < 58 int checks; #endif - zend_error_handling error_handling; SPOOFCHECKER_METHOD_INIT_VARS; ZEND_PARSE_PARAMETERS_NONE(); - zend_replace_error_handling(EH_THROW, IntlException_ce_ptr, &error_handling); - SPOOFCHECKER_METHOD_FETCH_OBJECT_NO_CHECK; co->uspoof = uspoof_open(SPOOFCHECKER_ERROR_CODE_P(co)); - INTL_METHOD_CHECK_STATUS(co, "spoofchecker: unable to open ICU Spoof Checker"); + if (U_FAILURE(INTL_DATA_ERROR_CODE(co))) { + zend_throw_exception(IntlException_ce_ptr, + "Spoofchecker::__construct(): unable to open ICU Spoof Checker", 0); + } #if U_ICU_VERSION_MAJOR_NUM >= 58 /* TODO save it into the object for further suspiction check comparison. */ @@ -56,6 +56,5 @@ PHP_METHOD(Spoofchecker, __construct) checks = uspoof_getChecks(co->uspoof, SPOOFCHECKER_ERROR_CODE_P(co)); uspoof_setChecks(co->uspoof, checks & ~USPOOF_SINGLE_SCRIPT, SPOOFCHECKER_ERROR_CODE_P(co)); #endif - zend_restore_error_handling(&error_handling); } /* }}} */ diff --git a/ext/intl/tests/bug53512.phpt b/ext/intl/tests/bug53512.phpt index eab07864864ba..9c6a128c30004 100644 --- a/ext/intl/tests/bug53512.phpt +++ b/ext/intl/tests/bug53512.phpt @@ -19,10 +19,10 @@ foreach ($badvals as $val) { ?> --EXPECT-- bool(false) -string(65) "numfmt_set_symbol: invalid symbol value: U_ILLEGAL_ARGUMENT_ERROR" +string(67) "numfmt_set_symbol(): invalid symbol value: U_ILLEGAL_ARGUMENT_ERROR" bool(false) -string(65) "numfmt_set_symbol: invalid symbol value: U_ILLEGAL_ARGUMENT_ERROR" +string(67) "numfmt_set_symbol(): invalid symbol value: U_ILLEGAL_ARGUMENT_ERROR" bool(false) -string(65) "numfmt_set_symbol: invalid symbol value: U_ILLEGAL_ARGUMENT_ERROR" +string(67) "numfmt_set_symbol(): invalid symbol value: U_ILLEGAL_ARGUMENT_ERROR" bool(false) -string(65) "numfmt_set_symbol: invalid symbol value: U_ILLEGAL_ARGUMENT_ERROR" +string(67) "numfmt_set_symbol(): invalid symbol value: U_ILLEGAL_ARGUMENT_ERROR" diff --git a/ext/intl/tests/bug62017.phpt b/ext/intl/tests/bug62017.phpt index 53b0deb4fa7d8..c149b120246d5 100644 --- a/ext/intl/tests/bug62017.phpt +++ b/ext/intl/tests/bug62017.phpt @@ -4,23 +4,20 @@ Bug #62017: datefmt_create with incorrectly encoded timezone leaks pattern intl --FILE-- getMessage() . " in " . $e->getFile() . " on line " . $e->getLine() . PHP_EOL; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { - new IntlDateFormatter('', IntlDateFormatter::NONE, IntlDateFormatter::NONE, "Europe/Lisbon", + new IntlDateFormatter('', IntlDateFormatter::NONE, IntlDateFormatter::NONE, "Europe/Lisbon", IntlDateFormatter::GREGORIAN, "\x80"); -} catch (IntlException $e) { - echo PHP_EOL."Exception: " . $e->getMessage() . " in " . $e->getFile() . " on line " . $e->getLine() . PHP_EOL; +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } ?> ---EXPECTF-- - -Exception: datefmt_create: Time zone identifier given is not a valid UTF-8 string in %s on line %d - -Exception: IntlDateFormatter::__construct(): datefmt_create: error converting pattern to UTF-16 in %s on line %d +--EXPECT-- +IntlException: datefmt_create(): Time zone identifier given is not a valid UTF-8 string +IntlException: IntlDateFormatter::__construct(): error converting pattern to UTF-16 diff --git a/ext/intl/tests/bug62081.phpt b/ext/intl/tests/bug62081.phpt index d1c066994b6e4..f99f98a8c65ab 100644 --- a/ext/intl/tests/bug62081.phpt +++ b/ext/intl/tests/bug62081.phpt @@ -8,11 +8,11 @@ intl __construct('en', 1, 1)); +try { + var_dump($x->__construct('en', 1, 1)); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} ?> ---EXPECTF-- -Fatal error: Uncaught IntlException: IntlDateFormatter::__construct(): datefmt_create: cannot call constructor twice in %sbug62081.php:4 -Stack trace: -#0 %sbug62081.php(4): IntlDateFormatter->__construct('en', 1, 1) -#1 {main} - thrown in %sbug62081.php on line 4 +--EXPECT-- +IntlException: IntlDateFormatter::__construct(): cannot call constructor twice diff --git a/ext/intl/tests/bug67397.phpt b/ext/intl/tests/bug67397.phpt index e36b5afdc8756..023f47725ab58 100644 --- a/ext/intl/tests/bug67397.phpt +++ b/ext/intl/tests/bug67397.phpt @@ -16,6 +16,6 @@ var_dump(intl_get_error_message()); ?> --EXPECT-- bool(false) -string(65) "locale_get_display_name : name too long: U_ILLEGAL_ARGUMENT_ERROR" +string(65) "Locale::getDisplayName(): name too long: U_ILLEGAL_ARGUMENT_ERROR" bool(false) -string(65) "locale_get_display_name : name too long: U_ILLEGAL_ARGUMENT_ERROR" +string(66) "locale_get_display_name(): name too long: U_ILLEGAL_ARGUMENT_ERROR" diff --git a/ext/intl/tests/bug72533.phpt b/ext/intl/tests/bug72533.phpt index 5fef8684835b2..e294f98213e96 100644 --- a/ext/intl/tests/bug72533.phpt +++ b/ext/intl/tests/bug72533.phpt @@ -25,10 +25,10 @@ var_dump(intl_get_error_message()); ?> --EXPECT-- bool(false) -string(73) "locale_accept_from_http: locale string too long: U_ILLEGAL_ARGUMENT_ERROR" +string(74) "Locale::acceptFromHttp(): locale string too long: U_ILLEGAL_ARGUMENT_ERROR" bool(false) -string(73) "locale_accept_from_http: locale string too long: U_ILLEGAL_ARGUMENT_ERROR" +string(75) "locale_accept_from_http(): locale string too long: U_ILLEGAL_ARGUMENT_ERROR" bool(false) -string(73) "locale_accept_from_http: locale string too long: U_ILLEGAL_ARGUMENT_ERROR" +string(74) "Locale::acceptFromHttp(): locale string too long: U_ILLEGAL_ARGUMENT_ERROR" bool(false) -string(73) "locale_accept_from_http: locale string too long: U_ILLEGAL_ARGUMENT_ERROR" +string(75) "locale_accept_from_http(): locale string too long: U_ILLEGAL_ARGUMENT_ERROR" diff --git a/ext/intl/tests/calendar_createInstance_error.phpt b/ext/intl/tests/calendar_createInstance_error.phpt index a48b6b12c2d13..7465e473bb318 100644 --- a/ext/intl/tests/calendar_createInstance_error.phpt +++ b/ext/intl/tests/calendar_createInstance_error.phpt @@ -17,4 +17,4 @@ try { } ?> --EXPECT-- -intlcal_create_instance: passed IntlTimeZone is not properly constructed +intlcal_create_instance(): passed IntlTimeZone is not properly constructed diff --git a/ext/intl/tests/calendar_fieldDifference_error.phpt b/ext/intl/tests/calendar_fieldDifference_error.phpt index f538a0db6625b..9844ee927d975 100644 --- a/ext/intl/tests/calendar_fieldDifference_error.phpt +++ b/ext/intl/tests/calendar_fieldDifference_error.phpt @@ -27,7 +27,7 @@ var_dump(intlcal_field_difference(1, 0, 1)); --EXPECTF-- IntlCalendar::fieldDifference() expects exactly 2 arguments, 3 given -Warning: IntlCalendar::fieldDifference(): intlcal_field_difference: Call to ICU method has failed in %s on line %d +Warning: IntlCalendar::fieldDifference(): Call to ICU method has failed in %s on line %d bool(false) intlcal_field_difference() expects exactly 3 arguments, 4 given diff --git a/ext/intl/tests/calendar_fromDateTime_error.phpt b/ext/intl/tests/calendar_fromDateTime_error.phpt index ac62fdcd5eb31..d941bf8bca317 100644 --- a/ext/intl/tests/calendar_fromDateTime_error.phpt +++ b/ext/intl/tests/calendar_fromDateTime_error.phpt @@ -27,11 +27,11 @@ var_dump(IntlCalendar::fromDateTime($date)); ?> --EXPECTF-- threw exception, OK -Warning: IntlCalendar::fromDateTime(): intlcal_from_date_time: DateTime object is unconstructed in %s on line %d +Warning: IntlCalendar::fromDateTime(): DateTime object is unconstructed in %s on line %d NULL -Warning: IntlCalendar::fromDateTime(): intlcal_from_date_time: object has an time zone offset that's too large in %s on line %d +Warning: IntlCalendar::fromDateTime(): object has an time zone offset that's too large in %s on line %d NULL -Warning: IntlCalendar::fromDateTime(): intlcal_from_date_time: time zone id 'WEST' extracted from ext/date DateTimeZone not recognized in %s on line %d +Warning: IntlCalendar::fromDateTime(): time zone id 'WEST' extracted from ext/date DateTimeZone not recognized in %s on line %d NULL diff --git a/ext/intl/tests/calendar_getErrorCode_getErrorMessage_basic.phpt b/ext/intl/tests/calendar_getErrorCode_getErrorMessage_basic.phpt index 689ec4b16a29a..3a87a8988ef6b 100644 --- a/ext/intl/tests/calendar_getErrorCode_getErrorMessage_basic.phpt +++ b/ext/intl/tests/calendar_getErrorCode_getErrorMessage_basic.phpt @@ -32,8 +32,8 @@ int(0) string(12) "U_ZERO_ERROR" string(12) "U_ZERO_ERROR" -Warning: IntlCalendar::fieldDifference(): intlcal_field_difference: Call to ICU method has failed in %s on line %d +Warning: IntlCalendar::fieldDifference(): Call to ICU method has failed in %s on line %d int(1) int(1) -string(81) "intlcal_field_difference: Call to ICU method has failed: U_ILLEGAL_ARGUMENT_ERROR" -string(81) "intlcal_field_difference: Call to ICU method has failed: U_ILLEGAL_ARGUMENT_ERROR" +string(88) "IntlCalendar::fieldDifference(): Call to ICU method has failed: U_ILLEGAL_ARGUMENT_ERROR" +string(88) "IntlCalendar::fieldDifference(): Call to ICU method has failed: U_ILLEGAL_ARGUMENT_ERROR" diff --git a/ext/intl/tests/calendar_setTimeZone_error2.phpt b/ext/intl/tests/calendar_setTimeZone_error2.phpt index c76867b695e40..8d6a5ffe5af86 100644 --- a/ext/intl/tests/calendar_setTimeZone_error2.phpt +++ b/ext/intl/tests/calendar_setTimeZone_error2.phpt @@ -19,8 +19,8 @@ $intlcal->setTimeZone($pstdate->getTimeZone()); var_dump($intlcal->getTimeZone()->getID()); ?> --EXPECTF-- -Warning: IntlCalendar::setTimeZone(): intlcal_set_time_zone: time zone id 'WEST' extracted from ext/date DateTimeZone not recognized in %s on line %d +Warning: IntlCalendar::setTimeZone(): time zone id 'WEST' extracted from ext/date DateTimeZone not recognized in %s on line %d string(16) "Europe/Amsterdam" -Warning: IntlCalendar::setTimeZone(): intlcal_set_time_zone: object has an time zone offset that's too large in %s on line %d +Warning: IntlCalendar::setTimeZone(): object has an time zone offset that's too large in %s on line %d string(16) "Europe/Amsterdam" diff --git a/ext/intl/tests/calendar_toDateTime_error.phpt b/ext/intl/tests/calendar_toDateTime_error.phpt index 23275d0fd3c84..48642f184d7be 100644 --- a/ext/intl/tests/calendar_toDateTime_error.phpt +++ b/ext/intl/tests/calendar_toDateTime_error.phpt @@ -40,15 +40,15 @@ try { } ?> --EXPECTF-- -Warning: IntlCalendar::toDateTime(): intlcal_to_date_time: DateTimeZone constructor threw exception in %s on line %d +Warning: IntlCalendar::toDateTime(): DateTimeZone constructor threw exception in %s on line %d string(77) "exception: DateTimeZone::__construct(): Unknown or bad timezone (Etc/Unknown)" -Warning: intlcal_to_date_time(): intlcal_to_date_time: DateTimeZone constructor threw exception in %s on line %d +Warning: intlcal_to_date_time(): DateTimeZone constructor threw exception in %s on line %d string(66) "DateTimeZone::__construct(): Unknown or bad timezone (Etc/Unknown)" -Warning: IntlCalendar::toDateTime(): intlcal_to_date_time: DateTimeZone constructor threw exception in %s on line %d +Warning: IntlCalendar::toDateTime(): DateTimeZone constructor threw exception in %s on line %d string(66) "DateTimeZone::__construct(): Unknown or bad timezone (Etc/Unknown)" -Warning: intlcal_to_date_time(): intlcal_to_date_time: DateTimeZone constructor threw exception in %s on line %d +Warning: intlcal_to_date_time(): DateTimeZone constructor threw exception in %s on line %d string(66) "DateTimeZone::__construct(): Unknown or bad timezone (Etc/Unknown)" intlcal_to_date_time(): Argument #1 ($calendar) must be of type IntlCalendar, int given diff --git a/ext/intl/tests/collator_create_errors.phpt b/ext/intl/tests/collator_create_errors.phpt index 26c2193234490..41fc794f67c17 100644 --- a/ext/intl/tests/collator_create_errors.phpt +++ b/ext/intl/tests/collator_create_errors.phpt @@ -28,13 +28,13 @@ foreach ($locales as $locale) { ?> --EXPECT-- -IntlException: Constructor failed +IntlException: Collator::__construct(): unable to open ICU collator NULL -string(70) "collator_create: unable to open ICU collator: U_ILLEGAL_ARGUMENT_ERROR" +string(73) "Collator::create(): unable to open ICU collator: U_ILLEGAL_ARGUMENT_ERROR" NULL -string(70) "collator_create: unable to open ICU collator: U_ILLEGAL_ARGUMENT_ERROR" -IntlException: Constructor failed +string(72) "collator_create(): unable to open ICU collator: U_ILLEGAL_ARGUMENT_ERROR" +IntlException: Collator::__construct(): Locale string too long, should be no longer than 156 characters NULL -string(89) "Locale string too long, should be no longer than 156 characters: U_ILLEGAL_ARGUMENT_ERROR" +string(109) "Collator::create(): Locale string too long, should be no longer than 156 characters: U_ILLEGAL_ARGUMENT_ERROR" NULL -string(89) "Locale string too long, should be no longer than 156 characters: U_ILLEGAL_ARGUMENT_ERROR" \ No newline at end of file +string(108) "collator_create(): Locale string too long, should be no longer than 156 characters: U_ILLEGAL_ARGUMENT_ERROR" diff --git a/ext/intl/tests/collator_get_invalid_attribute.phpt b/ext/intl/tests/collator_get_invalid_attribute.phpt index 26bcb664880e6..11a1e0ef9b646 100644 --- a/ext/intl/tests/collator_get_invalid_attribute.phpt +++ b/ext/intl/tests/collator_get_invalid_attribute.phpt @@ -18,6 +18,6 @@ var_dump(collator_get_error_message($coll)); ?> --EXPECT-- bool(false) -string(55) "Error getting attribute value: U_ILLEGAL_ARGUMENT_ERROR" +string(81) "Collator::getAttribute(): Error getting attribute value: U_ILLEGAL_ARGUMENT_ERROR" bool(false) -string(55) "Error getting attribute value: U_ILLEGAL_ARGUMENT_ERROR" +string(81) "collator_get_attribute(): Error getting attribute value: U_ILLEGAL_ARGUMENT_ERROR" diff --git a/ext/intl/tests/dateformat___construct_bad_tz_cal.phpt b/ext/intl/tests/dateformat___construct_bad_tz_cal.phpt index ca7cd5a13dee4..e33464a40a446 100644 --- a/ext/intl/tests/dateformat___construct_bad_tz_cal.phpt +++ b/ext/intl/tests/dateformat___construct_bad_tz_cal.phpt @@ -4,34 +4,25 @@ IntlDateFormatter::__construct(): bad timezone or calendar intl --FILE-- getMessage() . " in " . $e->getFile() . " on line " . $e->getLine() . "\n"; -} try { var_dump(new IntlDateFormatter(NULL, 0, 0, 'bad timezone')); -} catch (IntlException $e) { - print_exception($e); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { var_dump(new IntlDateFormatter(NULL, 0, 0, NULL, 3)); -} catch (IntlException $e) { - print_exception($e); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } try { var_dump(new IntlDateFormatter(NULL, 0, 0, NULL, new stdclass)); -} catch (TypeError $e) { - print_exception($e); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> ---EXPECTF-- - -Exception: datefmt_create: No such time zone: 'bad timezone' in %s on line %d - -Exception: IntlDateFormatter::__construct(): datefmt_create: Invalid value for calendar type; it must be one of IntlDateFormatter::TRADITIONAL (locale's default calendar) or IntlDateFormatter::GREGORIAN. Alternatively, it can be an IntlCalendar object in %s on line %d +--EXPECT-- +IntlException: IntlDateFormatter::__construct(): No such time zone: "bad timezone" +IntlException: IntlDateFormatter::__construct(): Invalid value for calendar type; it must be one of IntlDateFormatter::TRADITIONAL (locale's default calendar) or IntlDateFormatter::GREGORIAN. Alternatively, it can be an IntlCalendar object +TypeError: IntlDateFormatter::__construct(): Argument #5 ($calendar) must be of type IntlCalendar|int|null, stdClass given -Exception: IntlDateFormatter::__construct(): Argument #5 ($calendar) must be of type IntlCalendar|int|null, stdClass given in %s on line %d diff --git a/ext/intl/tests/dateformat_bug68893.phpt b/ext/intl/tests/dateformat_bug68893.phpt index 341acd49a6db4..b0510097fc501 100644 --- a/ext/intl/tests/dateformat_bug68893.phpt +++ b/ext/intl/tests/dateformat_bug68893.phpt @@ -14,6 +14,6 @@ var_dump($f, intl_get_error_message()); ?> --EXPECT-- NULL -string(67) "datefmt_create: invalid date format style: U_ILLEGAL_ARGUMENT_ERROR" +string(69) "datefmt_create(): invalid date format style: U_ILLEGAL_ARGUMENT_ERROR" NULL -string(67) "datefmt_create: invalid time format style: U_ILLEGAL_ARGUMENT_ERROR" +string(69) "datefmt_create(): invalid time format style: U_ILLEGAL_ARGUMENT_ERROR" diff --git a/ext/intl/tests/dateformat_errors.phpt b/ext/intl/tests/dateformat_errors.phpt index e02d5e800cbc8..2c14c559b69a9 100644 --- a/ext/intl/tests/dateformat_errors.phpt +++ b/ext/intl/tests/dateformat_errors.phpt @@ -26,8 +26,8 @@ var_dump(intl_get_error_message()); ?> --EXPECT-- -IntlException: datefmt_create: Invalid value for calendar type; it must be one of IntlDateFormatter::TRADITIONAL (locale's default calendar) or IntlDateFormatter::GREGORIAN. Alternatively, it can be an IntlCalendar object: U_ILLEGAL_ARGUMENT_ERROR +IntlException: IntlDateFormatter::__construct(): Invalid value for calendar type; it must be one of IntlDateFormatter::TRADITIONAL (locale's default calendar) or IntlDateFormatter::GREGORIAN. Alternatively, it can be an IntlCalendar object NULL -string(232) "datefmt_create: Invalid value for calendar type; it must be one of IntlDateFormatter::TRADITIONAL (locale's default calendar) or IntlDateFormatter::GREGORIAN. Alternatively, it can be an IntlCalendar object: U_ILLEGAL_ARGUMENT_ERROR" +string(245) "IntlDateFormatter::create(): Invalid value for calendar type; it must be one of IntlDateFormatter::TRADITIONAL (locale's default calendar) or IntlDateFormatter::GREGORIAN. Alternatively, it can be an IntlCalendar object: U_ILLEGAL_ARGUMENT_ERROR" NULL -string(232) "datefmt_create: Invalid value for calendar type; it must be one of IntlDateFormatter::TRADITIONAL (locale's default calendar) or IntlDateFormatter::GREGORIAN. Alternatively, it can be an IntlCalendar object: U_ILLEGAL_ARGUMENT_ERROR" +string(234) "datefmt_create(): Invalid value for calendar type; it must be one of IntlDateFormatter::TRADITIONAL (locale's default calendar) or IntlDateFormatter::GREGORIAN. Alternatively, it can be an IntlCalendar object: U_ILLEGAL_ARGUMENT_ERROR" diff --git a/ext/intl/tests/dateformat_formatObject_error.phpt b/ext/intl/tests/dateformat_formatObject_error.phpt index 19c88edb4c43b..b38a379b9f5ae 100644 --- a/ext/intl/tests/dateformat_formatObject_error.phpt +++ b/ext/intl/tests/dateformat_formatObject_error.phpt @@ -43,18 +43,18 @@ var_dump(intl_get_error_message()); --EXPECT-- DateObjectError: Object of type B (inheriting DateTime) has not been correctly initialized by calling parent::__construct() in its constructor bool(false) -string(118) "datefmt_format_object: the passed object must be an instance of either IntlCalendar or DateTimeInterface: U_ZERO_ERROR" +string(130) "IntlDateFormatter::formatObject(): the passed object must be an instance of either IntlCalendar or DateTimeInterface: U_ZERO_ERROR" bool(false) -string(100) "datefmt_format_object: bad IntlCalendar instance: not initialized properly: U_ILLEGAL_ARGUMENT_ERROR" +string(112) "IntlDateFormatter::formatObject(): bad IntlCalendar instance: not initialized properly: U_ILLEGAL_ARGUMENT_ERROR" bool(false) -string(85) "datefmt_format_object: the date/time format type is invalid: U_ILLEGAL_ARGUMENT_ERROR" +string(97) "IntlDateFormatter::formatObject(): the date/time format type is invalid: U_ILLEGAL_ARGUMENT_ERROR" bool(false) -string(96) "datefmt_format_object: bad format; if array, it must have two elements: U_ILLEGAL_ARGUMENT_ERROR" +string(108) "IntlDateFormatter::formatObject(): bad format; if array, it must have two elements: U_ILLEGAL_ARGUMENT_ERROR" bool(false) -string(96) "datefmt_format_object: bad format; if array, it must have two elements: U_ILLEGAL_ARGUMENT_ERROR" +string(108) "IntlDateFormatter::formatObject(): bad format; if array, it must have two elements: U_ILLEGAL_ARGUMENT_ERROR" bool(false) -string(118) "datefmt_format_object: bad format; the date format (first element of the array) is not valid: U_ILLEGAL_ARGUMENT_ERROR" +string(130) "IntlDateFormatter::formatObject(): bad format; the date format (first element of the array) is not valid: U_ILLEGAL_ARGUMENT_ERROR" bool(false) -string(119) "datefmt_format_object: bad format; the time format (second element of the array) is not valid: U_ILLEGAL_ARGUMENT_ERROR" +string(131) "IntlDateFormatter::formatObject(): bad format; the time format (second element of the array) is not valid: U_ILLEGAL_ARGUMENT_ERROR" bool(false) -string(68) "datefmt_format_object: the format is empty: U_ILLEGAL_ARGUMENT_ERROR" +string(80) "IntlDateFormatter::formatObject(): the format is empty: U_ILLEGAL_ARGUMENT_ERROR" diff --git a/ext/intl/tests/dateformat_format_error.phpt b/ext/intl/tests/dateformat_format_error.phpt index fb6da6862141f..4358271efd08c 100644 --- a/ext/intl/tests/dateformat_format_error.phpt +++ b/ext/intl/tests/dateformat_format_error.phpt @@ -21,6 +21,6 @@ var_dump(intl_get_error_message()); ?> --EXPECT-- bool(false) -string(127) "datefmt_format: invalid object type for date/time (only IntlCalendar and DateTimeInterface permitted): U_ILLEGAL_ARGUMENT_ERROR" +string(140) "IntlDateFormatter::format(): invalid object type for date/time (only IntlCalendar and DateTimeInterface permitted): U_ILLEGAL_ARGUMENT_ERROR" bool(false) -string(127) "datefmt_format: invalid object type for date/time (only IntlCalendar and DateTimeInterface permitted): U_ILLEGAL_ARGUMENT_ERROR" +string(129) "datefmt_format(): invalid object type for date/time (only IntlCalendar and DateTimeInterface permitted): U_ILLEGAL_ARGUMENT_ERROR" diff --git a/ext/intl/tests/dateformat_setTimeZone_error.phpt b/ext/intl/tests/dateformat_setTimeZone_error.phpt index b911c4b41ec0c..eca1bc54852ec 100644 --- a/ext/intl/tests/dateformat_setTimeZone_error.phpt +++ b/ext/intl/tests/dateformat_setTimeZone_error.phpt @@ -24,5 +24,5 @@ try { ?> --EXPECTF-- Warning: Array to string conversion in %s on line %d -datefmt_set_timezone: No such time zone: 'Array' -datefmt_set_timezone: No such time zone: 'non existing timezone' +IntlDateFormatter::setTimeZone(): No such time zone: "Array" +IntlDateFormatter::setTimeZone(): No such time zone: "non existing timezone" diff --git a/ext/intl/tests/formatter_fail.phpt b/ext/intl/tests/formatter_fail.phpt index c9c621c6b7626..53f6b4ac7c7b0 100644 --- a/ext/intl/tests/formatter_fail.phpt +++ b/ext/intl/tests/formatter_fail.phpt @@ -12,8 +12,7 @@ function err($fmt) { } function print_exception($e) { - echo "\n" . get_class($e) . ": " . $e->getMessage() - . " in " . $e->getFile() . " on line " . $e->getLine() . "\n"; + echo "\n", $e::class, ": ", $e->getMessage(), "\n"; } function crt($t, $l, $s) { @@ -62,14 +61,14 @@ try { err($fmt); try { $fmt = numfmt_create(); -} catch (TypeError $e) { +} catch (Throwable $e) { print_exception($e); $fmt = null; } err($fmt); try { $fmt = NumberFormatter::create(); -} catch (TypeError $e) { +} catch (Throwable $e) { print_exception($e); $fmt = null; } @@ -78,7 +77,7 @@ err($fmt); $fmt = new NumberFormatter('en_US', NumberFormatter::DECIMAL); try { $fmt->__construct('en_US', NumberFormatter::DECIMAL); -} catch (Error $e) { +} catch (Throwable $e) { print_exception($e); $fmt = null; } @@ -95,16 +94,16 @@ foreach($args as $arg) { ?> --EXPECTF-- -ArgumentCountError: NumberFormatter::__construct() expects at least 2 arguments, 0 given in %s on line %d +ArgumentCountError: NumberFormatter::__construct() expects at least 2 arguments, 0 given 'U_ZERO_ERROR' -ArgumentCountError: numfmt_create() expects at least 2 arguments, 0 given in %s on line %d +ArgumentCountError: numfmt_create() expects at least 2 arguments, 0 given 'U_ZERO_ERROR' -ArgumentCountError: NumberFormatter::create() expects at least 2 arguments, 0 given in %s on line %d +ArgumentCountError: NumberFormatter::create() expects at least 2 arguments, 0 given 'U_ZERO_ERROR' -Error: NumberFormatter object is already constructed in %s on line %d +Error: NumberFormatter object is already constructed 'U_ZERO_ERROR' Deprecated: NumberFormatter::__construct(): Passing null to parameter #1 ($locale) of type string is deprecated in %s on line %d @@ -119,30 +118,30 @@ Deprecated: numfmt_create(): Passing null to parameter #1 ($locale) of type stri Deprecated: numfmt_create(): Passing null to parameter #2 ($style) of type int is deprecated in %s on line %d -ValueError: NumberFormatter::__construct(): Argument #1 ($locale) "%s" is invalid in %s on line %d +ValueError: NumberFormatter::__construct(): Argument #1 ($locale) "whatever" is invalid 'U_ZERO_ERROR' -ValueError: NumberFormatter::create(): Argument #1 ($locale) "%s" is invalid in %s on line %d +ValueError: NumberFormatter::create(): Argument #1 ($locale) "whatever" is invalid 'U_ZERO_ERROR' -ValueError: numfmt_create(): Argument #1 ($locale) "%s" is invalid in %s on line %d +ValueError: numfmt_create(): Argument #1 ($locale) "whatever" is invalid 'U_ZERO_ERROR' -TypeError: NumberFormatter::__construct(): Argument #1 ($locale) must be of type string, array given in %s on line %d +TypeError: NumberFormatter::__construct(): Argument #1 ($locale) must be of type string, array given 'U_ZERO_ERROR' -TypeError: NumberFormatter::create(): Argument #1 ($locale) must be of type string, array given in %s on line %d +TypeError: NumberFormatter::create(): Argument #1 ($locale) must be of type string, array given 'U_ZERO_ERROR' -TypeError: numfmt_create(): Argument #1 ($locale) must be of type string, array given in %s on line %d +TypeError: numfmt_create(): Argument #1 ($locale) must be of type string, array given 'U_ZERO_ERROR' -IntlException: Constructor failed in %s on line %d -'numfmt_create: number formatter creation failed: U_UNSUPPORTED_ERROR' -'numfmt_create: number formatter creation failed: U_UNSUPPORTED_ERROR' -'numfmt_create: number formatter creation failed: U_UNSUPPORTED_ERROR' +IntlException: NumberFormatter::__construct(): number formatter creation failed +'NumberFormatter::__construct(): number formatter creation failed: U_UNSUPPORTED_ERROR' +'NumberFormatter::create(): number formatter creation failed: U_UNSUPPORTED_ERROR' +'numfmt_create(): number formatter creation failed: U_UNSUPPORTED_ERROR' -IntlException: Constructor failed in %s on line %d -'numfmt_create: number formatter creation failed: U_MEMORY_ALLOCATION_ERROR' -'numfmt_create: number formatter creation failed: U_MEMORY_ALLOCATION_ERROR' -'numfmt_create: number formatter creation failed: U_MEMORY_ALLOCATION_ERROR' +IntlException: NumberFormatter::__construct(): number formatter creation failed +'NumberFormatter::__construct(): number formatter creation failed: U_MEMORY_ALLOCATION_ERROR' +'NumberFormatter::create(): number formatter creation failed: U_MEMORY_ALLOCATION_ERROR' +'numfmt_create(): number formatter creation failed: U_MEMORY_ALLOCATION_ERROR' diff --git a/ext/intl/tests/formatter_get_error.phpt b/ext/intl/tests/formatter_get_error.phpt index efe4d9f626faa..16a1c1db47662 100644 --- a/ext/intl/tests/formatter_get_error.phpt +++ b/ext/intl/tests/formatter_get_error.phpt @@ -32,16 +32,16 @@ var_dump($nf->getErrorCode()); ?> --EXPECT-- NULL -string(36) "Number parsing failed: U_PARSE_ERROR" +string(70) "NumberFormatter::parseCurrency(): Number parsing failed: U_PARSE_ERROR" int(9) NULL -string(36) "Number parsing failed: U_PARSE_ERROR" +string(70) "NumberFormatter::parseCurrency(): Number parsing failed: U_PARSE_ERROR" int(9) bool(false) NULL -string(36) "Number parsing failed: U_PARSE_ERROR" +string(61) "numfmt_parse_currency(): Number parsing failed: U_PARSE_ERROR" int(9) bool(false) NULL -string(36) "Number parsing failed: U_PARSE_ERROR" +string(61) "numfmt_parse_currency(): Number parsing failed: U_PARSE_ERROR" int(9) diff --git a/ext/intl/tests/formatter_set_invalid_pattern.phpt b/ext/intl/tests/formatter_set_invalid_pattern.phpt index ba2cf8026bc9c..2e94719e7568b 100644 --- a/ext/intl/tests/formatter_set_invalid_pattern.phpt +++ b/ext/intl/tests/formatter_set_invalid_pattern.phpt @@ -16,6 +16,6 @@ var_dump(numfmt_get_error_message($fmt)); ?> --EXPECT-- bool(false) -string(67) "Error setting pattern value at line 0, offset 0: U_UNQUOTED_SPECIAL" +string(98) "NumberFormatter::setPattern(): Error setting pattern value at line 0, offset 0: U_UNQUOTED_SPECIAL" bool(false) -string(67) "Error setting pattern value at line 0, offset 0: U_UNQUOTED_SPECIAL" +string(89) "numfmt_set_pattern(): Error setting pattern value at line 0, offset 0: U_UNQUOTED_SPECIAL" diff --git a/ext/intl/tests/gh12020.phpt b/ext/intl/tests/gh12020.phpt index e4102606ca54e..c9fe55fa3cdd3 100644 --- a/ext/intl/tests/gh12020.phpt +++ b/ext/intl/tests/gh12020.phpt @@ -13,10 +13,10 @@ var_dump(msgfmt_format_message('en', 'some {wrong.format}', []), intl_get_error_ ?> --EXPECT-- bool(false) -string(128) "pattern syntax error (parse error at offset 19, after " message with {", before or at "invalid format}"): U_PATTERN_SYNTAX_ERROR" +string(163) "MessageFormatter::formatMessage(): pattern syntax error (parse error at offset 19, after " message with {", before or at "invalid format}"): U_PATTERN_SYNTAX_ERROR" bool(false) -string(116) "pattern syntax error (parse error at offset 6, after "some {", before or at "wrong.format}"): U_PATTERN_SYNTAX_ERROR" +string(151) "MessageFormatter::formatMessage(): pattern syntax error (parse error at offset 6, after "some {", before or at "wrong.format}"): U_PATTERN_SYNTAX_ERROR" bool(false) -string(128) "pattern syntax error (parse error at offset 19, after " message with {", before or at "invalid format}"): U_PATTERN_SYNTAX_ERROR" +string(153) "msgfmt_format_message(): pattern syntax error (parse error at offset 19, after " message with {", before or at "invalid format}"): U_PATTERN_SYNTAX_ERROR" bool(false) -string(116) "pattern syntax error (parse error at offset 6, after "some {", before or at "wrong.format}"): U_PATTERN_SYNTAX_ERROR" +string(141) "msgfmt_format_message(): pattern syntax error (parse error at offset 6, after "some {", before or at "wrong.format}"): U_PATTERN_SYNTAX_ERROR" diff --git a/ext/intl/tests/gh12243.phpt b/ext/intl/tests/gh12243.phpt index cb2b177603907..786a9bd1ee8f0 100644 --- a/ext/intl/tests/gh12243.phpt +++ b/ext/intl/tests/gh12243.phpt @@ -21,4 +21,4 @@ try { ?> --EXPECT-- -datefmt_create: time format must be UDAT_PATTERN if date format is UDAT_PATTERN: U_ILLEGAL_ARGUMENT_ERROR +IntlDateFormatter::__construct(): time format must be UDAT_PATTERN if date format is UDAT_PATTERN diff --git a/ext/intl/tests/gh17469.phpt b/ext/intl/tests/gh17469.phpt index bb0c7aaf73fdf..ab222ff89f428 100644 --- a/ext/intl/tests/gh17469.phpt +++ b/ext/intl/tests/gh17469.phpt @@ -32,5 +32,5 @@ try { Warning: UConverter::transcode(): Error setting encoding: 4 - U_FILE_ACCESS_ERROR in %s on line %d Warning: UConverter::transcode(): Error setting encoding: 4 - U_FILE_ACCESS_ERROR in %s on line 5 -Error setting encoding: 4 - U_FILE_ACCESS_ERROR -Error setting encoding: 4 - U_FILE_ACCESS_ERROR +UConverter::transcode(): Error setting encoding: 4 - U_FILE_ACCESS_ERROR +UConverter::transcode(): Error setting encoding: 4 - U_FILE_ACCESS_ERROR diff --git a/ext/intl/tests/ini_use_exceptions_basic.phpt b/ext/intl/tests/ini_use_exceptions_basic.phpt index c2aabfbe63f43..b6471795dd7be 100644 --- a/ext/intl/tests/ini_use_exceptions_basic.phpt +++ b/ext/intl/tests/ini_use_exceptions_basic.phpt @@ -16,7 +16,7 @@ ini_set("intl.error_level", E_NOTICE); var_dump($t->transliterate('a', 3)); ?> --EXPECTF-- -string(130) "transliterator_transliterate: Neither "start" nor the "end" arguments can exceed the number of UTF-16 code units (in this case, 1)" +string(133) "Transliterator::transliterate(): Neither "start" nor the "end" arguments can exceed the number of UTF-16 code units (in this case, 1)" -Notice: Transliterator::transliterate(): transliterator_transliterate: Neither "start" nor the "end" arguments can exceed the number of UTF-16 code units (in this case, 1) in %s on line %d +Notice: Transliterator::transliterate(): Neither "start" nor the "end" arguments can exceed the number of UTF-16 code units (in this case, 1) in %s on line %d bool(false) diff --git a/ext/intl/tests/intl_get_error_message.phpt b/ext/intl/tests/intl_get_error_message.phpt index 93d2e5c653afa..83130e549dcad 100644 --- a/ext/intl/tests/intl_get_error_message.phpt +++ b/ext/intl/tests/intl_get_error_message.phpt @@ -15,4 +15,4 @@ else ?> --EXPECT-- -Error getting locale by type: U_ILLEGAL_ARGUMENT_ERROR +collator_get_locale(): Error getting locale by type: U_ILLEGAL_ARGUMENT_ERROR diff --git a/ext/intl/tests/locale_compose_locale_errors.phpt b/ext/intl/tests/locale_compose_locale_errors.phpt index 2188738288052..b0d68aae73cee 100644 --- a/ext/intl/tests/locale_compose_locale_errors.phpt +++ b/ext/intl/tests/locale_compose_locale_errors.phpt @@ -47,12 +47,12 @@ try { ?> --EXPECT-- bool(false) -string(81) "locale_compose: parameter array element is not a string: U_ILLEGAL_ARGUMENT_ERROR" +string(90) "Locale::composeLocale(): parameter array element is not a string: U_ILLEGAL_ARGUMENT_ERROR" bool(false) -string(81) "locale_compose: parameter array element is not a string: U_ILLEGAL_ARGUMENT_ERROR" +string(83) "locale_compose(): parameter array element is not a string: U_ILLEGAL_ARGUMENT_ERROR" bool(false) -string(81) "locale_compose: parameter array element is not a string: U_ILLEGAL_ARGUMENT_ERROR" +string(90) "Locale::composeLocale(): parameter array element is not a string: U_ILLEGAL_ARGUMENT_ERROR" bool(false) -string(81) "locale_compose: parameter array element is not a string: U_ILLEGAL_ARGUMENT_ERROR" +string(83) "locale_compose(): parameter array element is not a string: U_ILLEGAL_ARGUMENT_ERROR" ValueError: Locale::composeLocale(): Argument #1 ($subtags) must contain a "language" key ValueError: locale_compose(): Argument #1 ($subtags) must contain a "language" key diff --git a/ext/intl/tests/locale_subtags.phpt b/ext/intl/tests/locale_subtags.phpt index 0c454706225b5..f6cb7d1e957de 100644 --- a/ext/intl/tests/locale_subtags.phpt +++ b/ext/intl/tests/locale_subtags.phpt @@ -26,10 +26,10 @@ bool(true) bool(true) bool(true) bool(false) -string(67) "locale_add_likely_subtags: invalid locale: U_ILLEGAL_ARGUMENT_ERROR" +string(68) "Locale::addLikelySubtags(): invalid locale: U_ILLEGAL_ARGUMENT_ERROR" bool(false) -string(65) "locale_minimize_subtags: invalid locale: U_ILLEGAL_ARGUMENT_ERROR" +string(67) "Locale::minimizeSubtags(): invalid locale: U_ILLEGAL_ARGUMENT_ERROR" bool(false) -string(%d) "locale_add_likely_subtags: invalid locale: %s" +string(68) "Locale::addLikelySubtags(): invalid locale: U_ILLEGAL_ARGUMENT_ERROR" bool(false) -string(%d) "locale_minimize_subtags: invalid locale: %s" +string(%d) "Locale::minimizeSubtags(): invalid locale: %s" diff --git a/ext/intl/tests/msgfmt_errors.phpt b/ext/intl/tests/msgfmt_errors.phpt index a3f06d4211d53..78264c22b3ad3 100644 --- a/ext/intl/tests/msgfmt_errors.phpt +++ b/ext/intl/tests/msgfmt_errors.phpt @@ -23,8 +23,8 @@ var_dump(intl_get_error_message()); ?> --EXPECT-- -IntlException: msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR +IntlException: MessageFormatter::__construct(): message formatter creation failed NULL -string(74) "msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR" +string(87) "MessageFormatter::create(): message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR" NULL -string(74) "msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR" +string(76) "msgfmt_create(): message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR" diff --git a/ext/intl/tests/msgfmt_fail2.phpt b/ext/intl/tests/msgfmt_fail2.phpt index a5256e724a02d..de592e7b798c7 100644 --- a/ext/intl/tests/msgfmt_fail2.phpt +++ b/ext/intl/tests/msgfmt_fail2.phpt @@ -130,23 +130,23 @@ Deprecated: MessageFormatter::__construct(): Passing null to parameter #1 ($loca Deprecated: MessageFormatter::__construct(): Passing null to parameter #2 ($pattern) of type string is deprecated in %s on line %d -IntlException: msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR in %s on line %d -'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR' +IntlException: MessageFormatter::__construct(): message formatter creation failed in %s on line %d +'MessageFormatter::__construct(): message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR' Deprecated: MessageFormatter::create(): Passing null to parameter #1 ($locale) of type string is deprecated in %s on line %d Deprecated: MessageFormatter::create(): Passing null to parameter #2 ($pattern) of type string is deprecated in %s on line %d -'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR' +'MessageFormatter::create(): message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR' Deprecated: msgfmt_create(): Passing null to parameter #1 ($locale) of type string is deprecated in %s on line %d Deprecated: msgfmt_create(): Passing null to parameter #2 ($pattern) of type string is deprecated in %s on line %d -'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR' +'msgfmt_create(): message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR' -IntlException: msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR in %s on line %d -'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR' -'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR' -'msgfmt_create: message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR' +IntlException: MessageFormatter::__construct(): message formatter creation failed in %s on line %d +'MessageFormatter::__construct(): message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR' +'MessageFormatter::create(): message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR' +'msgfmt_create(): message formatter creation failed: U_ILLEGAL_ARGUMENT_ERROR' TypeError: MessageFormatter::__construct(): Argument #1 ($locale) must be of type string, array given in %s on line %d 'U_ZERO_ERROR' @@ -157,17 +157,17 @@ TypeError: MessageFormatter::create(): Argument #1 ($locale) must be of type str TypeError: msgfmt_create(): Argument #1 ($locale) must be of type string, array given in %s on line %d 'U_ZERO_ERROR' -IntlException: pattern syntax error (parse error at offset 1, after "{", before or at "0,choice}"): U_PATTERN_SYNTAX_ERROR in %s on line %d -'pattern syntax error (parse error at offset 1, after "{", before or at "0,choice}"): U_PATTERN_SYNTAX_ERROR' -'pattern syntax error (parse error at offset 1, after "{", before or at "0,choice}"): U_PATTERN_SYNTAX_ERROR' -'pattern syntax error (parse error at offset 1, after "{", before or at "0,choice}"): U_PATTERN_SYNTAX_ERROR' +IntlException: MessageFormatter::__construct(): pattern syntax error (parse error at offset 1, after "{", before or at "0,choice}") in %s on line %d +'MessageFormatter::__construct(): pattern syntax error (parse error at offset 1, after "{", before or at "0,choice}"): U_PATTERN_SYNTAX_ERROR' +'MessageFormatter::create(): pattern syntax error (parse error at offset 1, after "{", before or at "0,choice}"): U_PATTERN_SYNTAX_ERROR' +'msgfmt_create(): pattern syntax error (parse error at offset 1, after "{", before or at "0,choice}"): U_PATTERN_SYNTAX_ERROR' -IntlException: msgfmt_create: message formatter creation failed: U_UNMATCHED_BRACES in %s on line %d -'msgfmt_create: message formatter creation failed: U_UNMATCHED_BRACES' -'msgfmt_create: message formatter creation failed: U_UNMATCHED_BRACES' -'msgfmt_create: message formatter creation failed: U_UNMATCHED_BRACES' +IntlException: MessageFormatter::__construct(): message formatter creation failed in %s on line %d +'MessageFormatter::__construct(): message formatter creation failed: U_UNMATCHED_BRACES' +'MessageFormatter::create(): message formatter creation failed: U_UNMATCHED_BRACES' +'msgfmt_create(): message formatter creation failed: U_UNMATCHED_BRACES' -IntlException: msgfmt_create: error converting pattern to UTF-16: U_INVALID_CHAR_FOUND in %s on line %d -'msgfmt_create: error converting pattern to UTF-16: U_INVALID_CHAR_FOUND' -'msgfmt_create: error converting pattern to UTF-16: U_INVALID_CHAR_FOUND' -'msgfmt_create: error converting pattern to UTF-16: U_INVALID_CHAR_FOUND' +IntlException: MessageFormatter::__construct(): error converting pattern to UTF-16 in %s on line %d +'MessageFormatter::__construct(): error converting pattern to UTF-16: U_INVALID_CHAR_FOUND' +'MessageFormatter::create(): error converting pattern to UTF-16: U_INVALID_CHAR_FOUND' +'msgfmt_create(): error converting pattern to UTF-16: U_INVALID_CHAR_FOUND' diff --git a/ext/intl/tests/msgfmt_format_error2.phpt b/ext/intl/tests/msgfmt_format_error2.phpt index 7428ab70a2233..4048f2b69e77a 100644 --- a/ext/intl/tests/msgfmt_format_error2.phpt +++ b/ext/intl/tests/msgfmt_format_error2.phpt @@ -19,4 +19,4 @@ try { } ?> --EXPECT-- -IntlException: Inconsistent types declared for an argument +IntlException: MessageFormatter::format(): Inconsistent types declared for an argument diff --git a/ext/intl/tests/msgfmt_format_error3.phpt b/ext/intl/tests/msgfmt_format_error3.phpt index f03beb98ad41c..a03b0a21ecc42 100644 --- a/ext/intl/tests/msgfmt_format_error3.phpt +++ b/ext/intl/tests/msgfmt_format_error3.phpt @@ -19,4 +19,4 @@ try { } ?> --EXPECT-- -IntlException: Found negative or too large array key +IntlException: MessageFormatter::format(): Found negative or too large array key diff --git a/ext/intl/tests/msgfmt_format_error4.phpt b/ext/intl/tests/msgfmt_format_error4.phpt index cfa91dff3f982..451a55ad9da94 100644 --- a/ext/intl/tests/msgfmt_format_error4.phpt +++ b/ext/intl/tests/msgfmt_format_error4.phpt @@ -16,14 +16,14 @@ try { var_dump($mf->format(array("foo" => 7, "\x80" => "bar"))); } catch (Throwable $e) { var_dump($e::class === 'IntlException'); - var_dump("Invalid UTF-8 data in argument key: '\x80'" === $e->getMessage()); + var_dump("MessageFormatter::format(): Invalid UTF-8 data in argument key: '\x80'" === $e->getMessage()); } try { var_dump($mf->format(array("foo" => "\x80"))); } catch (Throwable $e) { var_dump($e::class === 'IntlException'); - var_dump("Invalid UTF-8 data in string argument: '\x80'" === $e->getMessage()); + var_dump("MessageFormatter::format(): Invalid UTF-8 data in string argument: '\x80'" === $e->getMessage()); } ?> --EXPECT-- diff --git a/ext/intl/tests/msgfmt_format_error5.phpt b/ext/intl/tests/msgfmt_format_error5.phpt index f9a64f5ebf088..d5d7e6a4dc8e6 100644 --- a/ext/intl/tests/msgfmt_format_error5.phpt +++ b/ext/intl/tests/msgfmt_format_error5.phpt @@ -20,4 +20,4 @@ try { } ?> --EXPECT-- -IntlException: The argument for key 'foo' cannot be used as a date or time +IntlException: MessageFormatter::format(): The argument for key 'foo' cannot be used as a date or time diff --git a/ext/intl/tests/msgfmt_format_error6.phpt b/ext/intl/tests/msgfmt_format_error6.phpt index 72a748a82fc8e..9320194be6f3f 100644 --- a/ext/intl/tests/msgfmt_format_error6.phpt +++ b/ext/intl/tests/msgfmt_format_error6.phpt @@ -19,4 +19,4 @@ try { } ?> --EXPECT-- -IntlException: No strategy to convert the value given for the argument with key '7' is available +IntlException: MessageFormatter::format(): No strategy to convert the value given for the argument with key '7' is available diff --git a/ext/intl/tests/msgfmt_format_message_errors.phpt b/ext/intl/tests/msgfmt_format_message_errors.phpt index f3d6575ab372c..8a5ee8ea2ea35 100644 --- a/ext/intl/tests/msgfmt_format_message_errors.phpt +++ b/ext/intl/tests/msgfmt_format_message_errors.phpt @@ -22,6 +22,6 @@ var_dump(intl_get_error_message()); ?> --EXPECT-- bool(false) -string(47) "Creating message formatter failed: U_ZERO_ERROR" +string(82) "MessageFormatter::formatMessage(): Creating message formatter failed: U_ZERO_ERROR" bool(false) -string(47) "Creating message formatter failed: U_ZERO_ERROR" +string(72) "msgfmt_format_message(): Creating message formatter failed: U_ZERO_ERROR" diff --git a/ext/intl/tests/msgfmt_parse_message_errors.phpt b/ext/intl/tests/msgfmt_parse_message_errors.phpt index 9402b8e2b5418..7bd0780fa6420 100644 --- a/ext/intl/tests/msgfmt_parse_message_errors.phpt +++ b/ext/intl/tests/msgfmt_parse_message_errors.phpt @@ -22,6 +22,6 @@ var_dump(intl_get_error_message()); ?> --EXPECT-- bool(false) -string(59) "Creating message formatter failed: U_ILLEGAL_ARGUMENT_ERROR" +string(93) "MessageFormatter::parseMessage(): Creating message formatter failed: U_ILLEGAL_ARGUMENT_ERROR" bool(false) -string(59) "Creating message formatter failed: U_ILLEGAL_ARGUMENT_ERROR" +string(83) "msgfmt_parse_message(): Creating message formatter failed: U_ILLEGAL_ARGUMENT_ERROR" diff --git a/ext/intl/tests/msgfmt_set_pattern_syntax_error.phpt b/ext/intl/tests/msgfmt_set_pattern_syntax_error.phpt index c53cf43f748c3..9f8c5ffc1befe 100644 --- a/ext/intl/tests/msgfmt_set_pattern_syntax_error.phpt +++ b/ext/intl/tests/msgfmt_set_pattern_syntax_error.phpt @@ -18,5 +18,5 @@ var_dump($mf->getErrorMessage()); ?> --EXPECT-- -string(71) "Error setting symbol value at line 0, offset 26: U_PATTERN_SYNTAX_ERROR" -string(71) "Error setting symbol value at line 0, offset 26: U_PATTERN_SYNTAX_ERROR" +string(103) "MessageFormatter::setPattern(): Error setting symbol value at line 0, offset 26: U_PATTERN_SYNTAX_ERROR" +string(93) "msgfmt_set_pattern(): Error setting symbol value at line 0, offset 26: U_PATTERN_SYNTAX_ERROR" diff --git a/ext/intl/tests/normalizer_get_raw_decomposition.phpt b/ext/intl/tests/normalizer_get_raw_decomposition.phpt index 7085cfa4a7ec7..678a85491fdce 100644 --- a/ext/intl/tests/normalizer_get_raw_decomposition.phpt +++ b/ext/intl/tests/normalizer_get_raw_decomposition.phpt @@ -45,9 +45,9 @@ string(3) "ㅡ" string(3) "ㅡ" string(33) "صلى الله عليه وسلم" string(33) "صلى الله عليه وسلم" -string(89) "Input string must be exactly one UTF-8 encoded code point long.: U_ILLEGAL_ARGUMENT_ERROR" -string(89) "Input string must be exactly one UTF-8 encoded code point long.: U_ILLEGAL_ARGUMENT_ERROR" -string(89) "Input string must be exactly one UTF-8 encoded code point long.: U_ILLEGAL_ARGUMENT_ERROR" -string(89) "Input string must be exactly one UTF-8 encoded code point long.: U_ILLEGAL_ARGUMENT_ERROR" -string(49) "Code point out of range: U_ILLEGAL_ARGUMENT_ERROR" -string(49) "Code point out of range: U_ILLEGAL_ARGUMENT_ERROR" +string(124) "Normalizer::getRawDecomposition(): Input string must be exactly one UTF-8 encoded code point long.: U_ILLEGAL_ARGUMENT_ERROR" +string(125) "normalizer_get_raw_decomposition(): Input string must be exactly one UTF-8 encoded code point long.: U_ILLEGAL_ARGUMENT_ERROR" +string(124) "Normalizer::getRawDecomposition(): Input string must be exactly one UTF-8 encoded code point long.: U_ILLEGAL_ARGUMENT_ERROR" +string(125) "normalizer_get_raw_decomposition(): Input string must be exactly one UTF-8 encoded code point long.: U_ILLEGAL_ARGUMENT_ERROR" +string(84) "Normalizer::getRawDecomposition(): Code point out of range: U_ILLEGAL_ARGUMENT_ERROR" +string(85) "normalizer_get_raw_decomposition(): Code point out of range: U_ILLEGAL_ARGUMENT_ERROR" diff --git a/ext/intl/tests/resourcebundle_arrayaccess.phpt b/ext/intl/tests/resourcebundle_arrayaccess.phpt index 49ad46fbe3509..af9c6aa6cdf5c 100644 --- a/ext/intl/tests/resourcebundle_arrayaccess.phpt +++ b/ext/intl/tests/resourcebundle_arrayaccess.phpt @@ -54,4 +54,4 @@ testarray: string 3 Using a reference as an offset: string(12) "Hello World!" NULL - 2: Cannot load resource element 'nonexisting': U_MISSING_RESOURCE_ERROR + 2: main(): Cannot load resource element 'nonexisting': U_MISSING_RESOURCE_ERROR diff --git a/ext/intl/tests/resourcebundle_create_error.phpt b/ext/intl/tests/resourcebundle_create_error.phpt index 92e08313df260..daa3734348afa 100644 --- a/ext/intl/tests/resourcebundle_create_error.phpt +++ b/ext/intl/tests/resourcebundle_create_error.phpt @@ -33,9 +33,9 @@ var_dump(intl_get_error_message()); ?> --EXPECT-- -IntlException: Constructor failed +IntlException: ResourceBundle::__construct(): Cannot load libICU resource bundle NULL -string(81) "resourcebundle_ctor: Cannot load libICU resource bundle: U_MISSING_RESOURCE_ERROR" -IntlException: Constructor failed +string(85) "resourcebundle_create(): Cannot load libICU resource bundle: U_MISSING_RESOURCE_ERROR" +IntlException: ResourceBundle::__construct(): Cannot load libICU resource bundle NULL -string(81) "resourcebundle_ctor: Cannot load libICU resource bundle: U_MISSING_RESOURCE_ERROR" +string(85) "resourcebundle_create(): Cannot load libICU resource bundle: U_MISSING_RESOURCE_ERROR" diff --git a/ext/intl/tests/resourcebundle_get_errors.phpt b/ext/intl/tests/resourcebundle_get_errors.phpt index aaae32a1bcd68..28952b816107a 100644 --- a/ext/intl/tests/resourcebundle_get_errors.phpt +++ b/ext/intl/tests/resourcebundle_get_errors.phpt @@ -19,7 +19,7 @@ var_dump($bundle->get('teststring')); ?> --EXPECT-- NULL -string(68) "Cannot load resource element 'nonexisting': U_MISSING_RESOURCE_ERROR" +string(91) "ResourceBundle::get(): Cannot load resource element 'nonexisting': U_MISSING_RESOURCE_ERROR" NULL -string(68) "Cannot load resource element 'nonexisting': U_MISSING_RESOURCE_ERROR" +string(90) "resourcebundle_get(): Cannot load resource element 'nonexisting': U_MISSING_RESOURCE_ERROR" string(12) "Hello World!" diff --git a/ext/intl/tests/timezone_IDforWindowsID_error.phpt b/ext/intl/tests/timezone_IDforWindowsID_error.phpt index f25f7b99e8626..1160ce9f91a0f 100644 --- a/ext/intl/tests/timezone_IDforWindowsID_error.phpt +++ b/ext/intl/tests/timezone_IDforWindowsID_error.phpt @@ -11,4 +11,4 @@ var_dump(intl_get_error_message()); ?> --EXPECT-- bool(false) -string(50) "unknown windows timezone: U_ILLEGAL_ARGUMENT_ERROR" +string(85) "IntlTimeZone::getIDForWindowsID(): unknown windows timezone: U_ILLEGAL_ARGUMENT_ERROR" diff --git a/ext/intl/tests/timezone_fromDateTimeZone_error.phpt b/ext/intl/tests/timezone_fromDateTimeZone_error.phpt index fe2a04453033a..acd608bc376c1 100644 --- a/ext/intl/tests/timezone_fromDateTimeZone_error.phpt +++ b/ext/intl/tests/timezone_fromDateTimeZone_error.phpt @@ -6,11 +6,12 @@ date.timezone=Atlantic/Azores intl --FILE-- getTimeZone())); +var_dump(intl_get_error_message()); + ?> ---EXPECTF-- -Warning: IntlTimeZone::fromDateTimeZone(): intltz_from_date_time_zone: time zone id 'WEST' extracted from ext/date DateTimeZone not recognized in %s on line %d +--EXPECT-- NULL +string(131) "IntlTimeZone::fromDateTimeZone(): time zone id 'WEST' extracted from ext/date DateTimeZone not recognized: U_ILLEGAL_ARGUMENT_ERROR" diff --git a/ext/intl/tests/timezone_getErrorCodeMessage_basic.phpt b/ext/intl/tests/timezone_getErrorCodeMessage_basic.phpt index 597e9b51a0fce..f207bdbeb9ba5 100644 --- a/ext/intl/tests/timezone_getErrorCodeMessage_basic.phpt +++ b/ext/intl/tests/timezone_getErrorCodeMessage_basic.phpt @@ -31,4 +31,4 @@ string(12) "U_ZERO_ERROR" Warning: IntlTimeZone::getOffset(): error obtaining offset in %s on line %d bool(false) int(1) -string(48) "error obtaining offset: U_ILLEGAL_ARGUMENT_ERROR" +string(75) "IntlTimeZone::getOffset(): error obtaining offset: U_ILLEGAL_ARGUMENT_ERROR" diff --git a/ext/intl/tests/timezone_toDateTimeZone_error.phpt b/ext/intl/tests/timezone_toDateTimeZone_error.phpt index 7355185541bc8..1ce040a0516fd 100644 --- a/ext/intl/tests/timezone_toDateTimeZone_error.phpt +++ b/ext/intl/tests/timezone_toDateTimeZone_error.phpt @@ -17,7 +17,7 @@ try { var_dump(intltz_to_date_time_zone(1)); ?> --EXPECTF-- -Warning: IntlTimeZone::toDateTimeZone(): intltz_to_date_time_zone: DateTimeZone constructor threw exception in %s on line %d +Warning: IntlTimeZone::toDateTimeZone(): DateTimeZone constructor threw exception in %s on line %d string(66) "DateTimeZone::__construct(): Unknown or bad timezone (Etc/Unknown)" Fatal error: Uncaught TypeError: intltz_to_date_time_zone(): Argument #1 ($timezone) must be of type IntlTimeZone, int given in %s:%d diff --git a/ext/intl/tests/timezone_windowsID_basic2.phpt b/ext/intl/tests/timezone_windowsID_basic2.phpt index aa1ce7f886c4c..0db032207fa9d 100644 --- a/ext/intl/tests/timezone_windowsID_basic2.phpt +++ b/ext/intl/tests/timezone_windowsID_basic2.phpt @@ -33,7 +33,7 @@ string(18) "Cuba Standard Time" string(21) "Central Standard Time" string(21) "Pacific Standard Time" bool(false) -Error: unknown system timezone: U_ILLEGAL_ARGUMENT_ERROR +Error: IntlTimeZone::getWindowsID(): unknown system timezone: U_ILLEGAL_ARGUMENT_ERROR string(21) "Morocco Standard Time" string(23) "Singapore Standard Time" string(26) "W. Australia Standard Time" diff --git a/ext/intl/tests/transliterator_create_error.phpt b/ext/intl/tests/transliterator_create_error.phpt index b554fb0dce5cf..fd7db47a42eff 100644 --- a/ext/intl/tests/transliterator_create_error.phpt +++ b/ext/intl/tests/transliterator_create_error.phpt @@ -5,18 +5,14 @@ intl --FILE-- ---EXPECTF-- -Warning: Transliterator::create(): transliterator_create: unable to open ICU transliterator with id "inexistent id" in %s on line %d -transliterator_create: unable to open ICU transliterator with id "inexistent id": U_INVALID_ID - -Warning: Transliterator::create(): String conversion of id to UTF-16 failed in %s on line %d -String conversion of id to UTF-16 failed: U_INVALID_CHAR_FOUND -Done. +--EXPECT-- +NULL +Transliterator::create(): unable to open ICU transliterator with id "inexistent id": U_INVALID_ID +NULL +Transliterator::create(): String conversion of id to UTF-16 failed: U_INVALID_CHAR_FOUND diff --git a/ext/intl/tests/transliterator_create_from_rule_error.phpt b/ext/intl/tests/transliterator_create_from_rule_error.phpt index 9a3b86944c8e3..51ea0dac03e5c 100644 --- a/ext/intl/tests/transliterator_create_from_rule_error.phpt +++ b/ext/intl/tests/transliterator_create_from_rule_error.phpt @@ -27,11 +27,11 @@ echo "Done.\n"; ?> --EXPECTF-- Warning: Transliterator::createFromRules(): String conversion of rules to UTF-16 failed in %s on line %d -String conversion of rules to UTF-16 failed: U_INVALID_CHAR_FOUND +Transliterator::createFromRules(): String conversion of rules to UTF-16 failed: U_INVALID_CHAR_FOUND -Warning: Transliterator::createFromRules(): transliterator_create_from_rules: unable to create ICU transliterator from rules (parse error after "{'``'}a > “;", before or at "{'``'}a > b;") in %s on line %d -transliterator_create_from_rules: unable to create ICU transliterator from rules (parse error after "{'``'}a > “;", before or at "{'``'}a > b;"): U_RULE_MASK_ERROR +Warning: Transliterator::createFromRules(): unable to create ICU transliterator from rules (parse error after "{'``'}a > “;", before or at "{'``'}a > b;") in %s on line %d +Transliterator::createFromRules(): unable to create ICU transliterator from rules (parse error after "{'``'}a > “;", before or at "{'``'}a > b;"): U_RULE_MASK_ERROR -Warning: Transliterator::createFromRules(): transliterator_create_from_rules: unable to create ICU transliterator from rules (parse error at offset 0, before or at "ffff") in %s on line %d -transliterator_create_from_rules: unable to create ICU transliterator from rules (parse error at offset 0, before or at "ffff"): U_MISSING_OPERATOR +Warning: Transliterator::createFromRules(): unable to create ICU transliterator from rules (parse error at offset 0, before or at "ffff") in %s on line %d +Transliterator::createFromRules(): unable to create ICU transliterator from rules (parse error at offset 0, before or at "ffff"): U_MISSING_OPERATOR Done. diff --git a/ext/intl/tests/transliterator_get_error_message_basic.phpt b/ext/intl/tests/transliterator_get_error_message_basic.phpt index 3c4c9eca513fd..eb862b75b399d 100644 --- a/ext/intl/tests/transliterator_get_error_message_basic.phpt +++ b/ext/intl/tests/transliterator_get_error_message_basic.phpt @@ -19,8 +19,8 @@ echo "Done.\n"; --EXPECTF-- Warning: Transliterator::transliterate(): String conversion of string to UTF-16 failed in %s on line %d bool(false) -String conversion of string to UTF-16 failed: U_INVALID_CHAR_FOUND -String conversion of string to UTF-16 failed: U_INVALID_CHAR_FOUND +Transliterator::transliterate(): String conversion of string to UTF-16 failed: U_INVALID_CHAR_FOUND +Transliterator::transliterate(): String conversion of string to UTF-16 failed: U_INVALID_CHAR_FOUND string(0) "" U_ZERO_ERROR Done. diff --git a/ext/intl/tests/transliterator_transliterate_error.phpt b/ext/intl/tests/transliterator_transliterate_error.phpt index 4a354465bf21d..774c61c44f827 100644 --- a/ext/intl/tests/transliterator_transliterate_error.phpt +++ b/ext/intl/tests/transliterator_transliterate_error.phpt @@ -24,7 +24,7 @@ transliterator_transliterate($tr, "\x80\x03"); echo "Done.\n"; ?> --EXPECTF-- -Warning: transliterator_transliterate(): transliterator_transliterate: Neither "start" nor the "end" arguments can exceed the number of UTF-16 code units (in this case, 3) in %s on line %d +Warning: transliterator_transliterate(): Neither "start" nor the "end" arguments can exceed the number of UTF-16 code units (in this case, 3) in %s on line %d bool(false) transliterator_transliterate(): Argument #2 ($string) must be less than or equal to argument #3 ($end) diff --git a/ext/intl/tests/transliterator_transliterate_variant1.phpt b/ext/intl/tests/transliterator_transliterate_variant1.phpt index 0e288ee63d254..3ec4b2ab682be 100644 --- a/ext/intl/tests/transliterator_transliterate_variant1.phpt +++ b/ext/intl/tests/transliterator_transliterate_variant1.phpt @@ -28,11 +28,11 @@ Warning: transliterator_transliterate(): String conversion of id to UTF-16 faile Warning: transliterator_transliterate(): Could not create transliterator with ID %s -String conversion of id to UTF-16 failed: U_INVALID_CHAR_FOUND +transliterator_transliterate(): String conversion of id to UTF-16 failed: U_INVALID_CHAR_FOUND -Warning: transliterator_transliterate(): transliterator_create: unable to open ICU transliterator with id "inexistent id" in %s on line %d +Warning: transliterator_transliterate(): unable to open ICU transliterator with id "inexistent id" in %s on line %d -Warning: transliterator_transliterate(): Could not create transliterator with ID "inexistent id" (transliterator_create: unable to open ICU transliterator with id "inexistent id": U_INVALID_ID) in %s on line %d +Warning: transliterator_transliterate(): Could not create transliterator with ID "inexistent id" (transliterator_transliterate(): unable to open ICU transliterator with id "inexistent id": U_INVALID_ID) in %s on line %d -transliterator_create: unable to open ICU transliterator with id "inexistent id": U_INVALID_ID +transliterator_transliterate(): unable to open ICU transliterator with id "inexistent id": U_INVALID_ID Done. diff --git a/ext/intl/tests/uconverter___construct_error.phpt b/ext/intl/tests/uconverter___construct_error.phpt index 92adc4a718622..f47ed8b508b3c 100644 --- a/ext/intl/tests/uconverter___construct_error.phpt +++ b/ext/intl/tests/uconverter___construct_error.phpt @@ -10,6 +10,6 @@ $c = new UConverter('utf-8', "\x80"); var_dump($c); ?> --EXPECTF-- -Warning: UConverter::__construct(): ucnv_open() returned error 4: U_FILE_ACCESS_ERROR in %s on line %d +Warning: UConverter::__construct(): returned error 4: U_FILE_ACCESS_ERROR in %s on line %d object(UConverter)#%d (0) { } diff --git a/ext/intl/tests/uconverter_func_subst.phpt b/ext/intl/tests/uconverter_func_subst.phpt index f8a32e814bb44..4e4e39f9386b6 100644 --- a/ext/intl/tests/uconverter_func_subst.phpt +++ b/ext/intl/tests/uconverter_func_subst.phpt @@ -25,7 +25,7 @@ foreach(array('?','','??') as $subst) { --EXPECT-- string(23) "This is an ascii string" string(12) "Snowman: (?)" -Error: transcode() returned error 1: U_ILLEGAL_ARGUMENT_ERROR: U_ILLEGAL_ARGUMENT_ERROR -Error: transcode() returned error 1: U_ILLEGAL_ARGUMENT_ERROR: U_ILLEGAL_ARGUMENT_ERROR -Error: transcode() returned error 1: U_ILLEGAL_ARGUMENT_ERROR: U_ILLEGAL_ARGUMENT_ERROR -Error: transcode() returned error 1: U_ILLEGAL_ARGUMENT_ERROR: U_ILLEGAL_ARGUMENT_ERROR +Error: UConverter::transcode(): returned error 1: U_ILLEGAL_ARGUMENT_ERROR: U_ILLEGAL_ARGUMENT_ERROR +Error: UConverter::transcode(): returned error 1: U_ILLEGAL_ARGUMENT_ERROR: U_ILLEGAL_ARGUMENT_ERROR +Error: UConverter::transcode(): returned error 1: U_ILLEGAL_ARGUMENT_ERROR: U_ILLEGAL_ARGUMENT_ERROR +Error: UConverter::transcode(): returned error 1: U_ILLEGAL_ARGUMENT_ERROR: U_ILLEGAL_ARGUMENT_ERROR diff --git a/ext/intl/timezone/timezone_class.cpp b/ext/intl/timezone/timezone_class.cpp index a39c2cc32305a..0cc6e1378729f 100644 --- a/ext/intl/timezone/timezone_class.cpp +++ b/ext/intl/timezone/timezone_class.cpp @@ -61,18 +61,16 @@ U_CFUNC void timezone_object_construct(const TimeZone *zone, zval *object, int o * Convert from TimeZone to DateTimeZone object */ U_CFUNC zval *timezone_convert_to_datetimezone(const TimeZone *timeZone, intl_error *outside_error, - const char *func, zval *ret) + zval *ret) { UnicodeString id; - char *message = NULL; php_timezone_obj *tzobj; zval arg; timeZone->getID(id); if (id.isBogus()) { - spprintf(&message, 0, "%s: could not obtain TimeZone id", func); intl_errors_set(outside_error, U_ILLEGAL_ARGUMENT_ERROR, - message, 1); + "could not obtain TimeZone id"); goto error; } @@ -91,19 +89,16 @@ U_CFUNC zval *timezone_convert_to_datetimezone(const TimeZone *timeZone, /* Call the constructor! */ u8str = intl_charFromString(id, &INTL_ERROR_CODE(*outside_error)); if (!u8str) { - spprintf(&message, 0, "%s: could not convert id to UTF-8", func); intl_errors_set(outside_error, INTL_ERROR_CODE(*outside_error), - message, 1); + "could not convert id to UTF-8"); goto error; } ZVAL_STR(&arg, u8str); zend_call_known_instance_method_with_1_params( Z_OBJCE_P(ret)->constructor, Z_OBJ_P(ret), NULL, &arg); if (EG(exception)) { - spprintf(&message, 0, - "%s: DateTimeZone constructor threw exception", func); intl_errors_set(outside_error, U_ILLEGAL_ARGUMENT_ERROR, - message, 1); + "DateTimeZone constructor threw exception"); zend_object_store_ctor_failed(Z_OBJ_P(ret)); zval_ptr_dtor(&arg); goto error; @@ -118,19 +113,26 @@ U_CFUNC zval *timezone_convert_to_datetimezone(const TimeZone *timeZone, } ret = NULL; } - - if (message) { - efree(message); - } return ret; } /* }}} */ +static void timezone_throw_exception_with_call_location(const char *msg, const char *add_info) +{ + zend_string *fn = get_active_function_or_method_name(); + zend_throw_error(IntlException_ce_ptr, "%s(): %s%s%s%s", + ZSTR_VAL(fn), msg, + add_info ? "\"" : "", + add_info ? add_info : "", + add_info ? "\"" : "" + ); + zend_string_release_ex(fn, false); +} + /* {{{ timezone_process_timezone_argument * TimeZone argument processor. outside_error may be NULL (for static functions/constructors) */ U_CFUNC TimeZone *timezone_process_timezone_argument(zval *zv_timezone, - intl_error *outside_error, - const char *func) + intl_error *outside_error) { zval local_zv_tz; std::unique_ptr timeZone; @@ -148,14 +150,14 @@ U_CFUNC TimeZone *timezone_process_timezone_argument(zval *zv_timezone, TimeZone_object *to = Z_INTL_TIMEZONE_P(zv_timezone); if (to->utimezone == NULL) { - zend_throw_error(IntlException_ce_ptr, "%s: passed IntlTimeZone is not " - "properly constructed", func); + timezone_throw_exception_with_call_location("passed IntlTimeZone is not " + "properly constructed", NULL); zval_ptr_dtor_str(&local_zv_tz); return NULL; } timeZone = std::unique_ptr(to->utimezone->clone()); if (UNEXPECTED(timeZone == NULL)) { - zend_throw_error(IntlException_ce_ptr, "%s: could not clone TimeZone", func); + timezone_throw_exception_with_call_location("could not clone TimeZone", NULL); zval_ptr_dtor_str(&local_zv_tz); return NULL; } @@ -165,8 +167,7 @@ U_CFUNC TimeZone *timezone_process_timezone_argument(zval *zv_timezone, php_timezone_obj *tzobj = Z_PHPTIMEZONE_P(zv_timezone); zval_ptr_dtor_str(&local_zv_tz); - return timezone_convert_datetimezone(tzobj->type, tzobj, 0, - outside_error, func); + return timezone_convert_datetimezone(tzobj->type, tzobj, 0, outside_error); } else { UnicodeString id; UErrorCode status = U_ZERO_ERROR; /* outside_error may be NULL */ @@ -176,20 +177,19 @@ U_CFUNC TimeZone *timezone_process_timezone_argument(zval *zv_timezone, } if (intl_stringFromChar(id, Z_STRVAL_P(zv_timezone), Z_STRLEN_P(zv_timezone), &status) == FAILURE) { - zend_throw_error(IntlException_ce_ptr, "%s: Time zone identifier given is not a " - "valid UTF-8 string", func); + timezone_throw_exception_with_call_location("Time zone identifier given is not a " + "valid UTF-8 string", NULL); zval_ptr_dtor_str(&local_zv_tz); return NULL; } timeZone = std::unique_ptr(TimeZone::createTimeZone(id)); if (UNEXPECTED(timeZone == NULL)) { - zend_throw_error(IntlException_ce_ptr, "%s: Could not create time zone", func); + timezone_throw_exception_with_call_location("Could not create time zone", NULL); zval_ptr_dtor_str(&local_zv_tz); return NULL; } if (*timeZone == TimeZone::getUnknown()) { - zend_throw_error(IntlException_ce_ptr, "%s: No such time zone: '%s'", - func, Z_STRVAL_P(zv_timezone)); + timezone_throw_exception_with_call_location("No such time zone: ", Z_STRVAL_P(zv_timezone)); zval_ptr_dtor_str(&local_zv_tz); return NULL; } diff --git a/ext/intl/timezone/timezone_class.h b/ext/intl/timezone/timezone_class.h index ac8a250e40724..08b78369e6fc5 100644 --- a/ext/intl/timezone/timezone_class.h +++ b/ext/intl/timezone/timezone_class.h @@ -66,8 +66,8 @@ static inline TimeZone_object *php_intl_timezone_fetch_object(zend_object *obj) RETURN_THROWS(); \ } -zval *timezone_convert_to_datetimezone(const TimeZone *timeZone, intl_error *outside_error, const char *func, zval *ret); -TimeZone *timezone_process_timezone_argument(zval *zv_timezone, intl_error *error, const char *func); +zval *timezone_convert_to_datetimezone(const TimeZone *timeZone, intl_error *outside_error, zval *ret); +TimeZone *timezone_process_timezone_argument(zval *zv_timezone, intl_error *error); void timezone_object_construct(const TimeZone *zone, zval *object, int owned); diff --git a/ext/intl/timezone/timezone_methods.cpp b/ext/intl/timezone/timezone_methods.cpp index 6ff0cf5137790..d01bdadd743d5 100644 --- a/ext/intl/timezone/timezone_methods.cpp +++ b/ext/intl/timezone/timezone_methods.cpp @@ -60,7 +60,7 @@ U_CFUNC PHP_FUNCTION(intltz_create_time_zone) UnicodeString id = UnicodeString(); if (intl_stringFromChar(id, str_id, str_id_len, &status) == FAILURE) { intl_error_set(NULL, status, - "could not convert time zone id to UTF-16", 0); + "could not convert time zone id to UTF-16"); RETURN_NULL(); } @@ -83,13 +83,11 @@ 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", - 0); + "DateTimeZone object is unconstructed"); RETURN_NULL(); } - tz = timezone_convert_datetimezone(tzobj->type, tzobj, false, NULL, - "intltz_from_date_time_zone"); + tz = timezone_convert_datetimezone(tzobj->type, tzobj, false, NULL); if (tz == NULL) { RETURN_NULL(); } @@ -145,7 +143,7 @@ U_CFUNC PHP_FUNCTION(intltz_create_enumeration) if (UNEXPECTED(Z_LVAL_P(arg) < (zend_long)INT32_MIN || Z_LVAL_P(arg) > (zend_long)INT32_MAX)) { intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, - "value is out of range", 0); + "value is out of range"); RETURN_FALSE; } else { se = TimeZone::createEnumeration((int32_t) Z_LVAL_P(arg)); @@ -173,8 +171,9 @@ U_CFUNC PHP_FUNCTION(intltz_create_enumeration) /* else call string version */ se = TimeZone::createEnumeration(Z_STRVAL_P(arg)); } else { + // TODO Should be a TypeError intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, - "invalid argument type", 0); + "invalid argument type"); RETURN_FALSE; } @@ -182,7 +181,7 @@ U_CFUNC PHP_FUNCTION(intltz_create_enumeration) IntlIterator_from_StringEnumeration(se, return_value); } else { intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, - "error obtaining enumeration", 0); + "error obtaining enumeration"); RETVAL_FALSE; } } @@ -201,7 +200,7 @@ U_CFUNC PHP_FUNCTION(intltz_count_equivalent_ids) UnicodeString id = UnicodeString(); if (intl_stringFromChar(id, str_id, str_id_len, &status) == FAILURE) { intl_error_set(NULL, status, - "could not convert time zone id to UTF-16", 0); + "could not convert time zone id to UTF-16"); RETURN_FALSE; } @@ -230,15 +229,14 @@ 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", 0); + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "bad zone type"); RETURN_FALSE; } 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", 0); + "offset out of bounds"); RETURN_FALSE; } offset = (int32_t)offset_arg; @@ -271,7 +269,7 @@ U_CFUNC PHP_FUNCTION(intltz_get_canonical_id) UnicodeString id; if (intl_stringFromChar(id, str_id, str_id_len, &status) == FAILURE) { intl_error_set(NULL, status, - "could not convert time zone id to UTF-16", 0); + "could not convert time zone id to UTF-16"); RETURN_FALSE; } @@ -305,7 +303,7 @@ U_CFUNC PHP_FUNCTION(intltz_get_region) UnicodeString id; if (intl_stringFromChar(id, str_id, str_id_len, &status) == FAILURE) { intl_error_set(NULL, status, - "could not convert time zone id to UTF-16", 0); + "could not convert time zone id to UTF-16"); RETURN_FALSE; } @@ -348,7 +346,7 @@ U_CFUNC PHP_FUNCTION(intltz_get_equivalent_id) UnicodeString id; if (intl_stringFromChar(id, str_id, str_id_len, &status) == FAILURE) { intl_error_set(NULL, status, - "could not convert time zone id to UTF-16", 0); + "could not convert time zone id to UTF-16"); RETURN_FALSE; } @@ -375,7 +373,7 @@ U_CFUNC PHP_FUNCTION(intltz_get_iana_id) UnicodeString id; if (intl_stringFromChar(id, str_id, str_id_len, &status) == FAILURE) { intl_error_set(NULL, status, - "could not convert time zone id to UTF-16", 0); + "could not convert time zone id to UTF-16"); RETURN_FALSE; } @@ -484,8 +482,7 @@ U_CFUNC PHP_FUNCTION(intltz_has_same_rules) TIMEZONE_METHOD_FETCH_OBJECT; other_to = Z_INTL_TIMEZONE_P(other_object); if (other_to->utimezone == NULL) { - intl_errors_set(&to->err, U_ILLEGAL_ARGUMENT_ERROR, - "The second IntlTimeZone is unconstructed", 0); + intl_errors_set(&to->err, U_ILLEGAL_ARGUMENT_ERROR, "The second IntlTimeZone is unconstructed"); RETURN_FALSE; } @@ -519,8 +516,7 @@ U_CFUNC PHP_FUNCTION(intltz_get_display_name) found = true; } if (!found) { - intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, - "wrong display type", 0); + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "wrong display type"); RETURN_FALSE; } @@ -567,7 +563,7 @@ U_CFUNC PHP_FUNCTION(intltz_to_date_time_zone) TIMEZONE_METHOD_FETCH_OBJECT; zval *ret = timezone_convert_to_datetimezone(to->utimezone, - &TIMEZONE_ERROR(to), "intltz_to_date_time_zone", &tmp); + &TIMEZONE_ERROR(to), &tmp); if (ret) { ZVAL_COPY_VALUE(return_value, ret); @@ -630,16 +626,16 @@ U_CFUNC PHP_FUNCTION(intltz_get_windows_id) error = U_ZERO_ERROR; if (intl_stringFromChar(uID, id->val, id->len, &error) == FAILURE) { intl_error_set(NULL, error, - "could not convert time zone id to UTF-16", 0); + "could not convert time zone id to UTF-16"); RETURN_FALSE; } error = U_ZERO_ERROR; TimeZone::getWindowsID(uID, uWinID, error); - INTL_CHECK_STATUS(error, "intltz_get_windows_id: Unable to get timezone from windows ID"); + INTL_CHECK_STATUS(error, "Unable to get timezone from windows ID"); if (uWinID.length() == 0) { intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, - "unknown system timezone", 0); + "unknown system timezone"); RETURN_FALSE; } @@ -668,7 +664,7 @@ U_CFUNC PHP_FUNCTION(intltz_get_id_for_windows_id) error = U_ZERO_ERROR; if (intl_stringFromChar(uWinID, winID->val, winID->len, &error) == FAILURE) { intl_error_set(NULL, error, - "could not convert time zone id to UTF-16", 0); + "could not convert time zone id to UTF-16"); RETURN_FALSE; } @@ -677,7 +673,7 @@ U_CFUNC PHP_FUNCTION(intltz_get_id_for_windows_id) INTL_CHECK_STATUS(error, "unable to get windows ID for timezone"); if (uID.length() == 0) { intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, - "unknown windows timezone", 0); + "unknown windows timezone"); RETURN_FALSE; } diff --git a/ext/intl/transliterator/transliterator_methods.c b/ext/intl/transliterator/transliterator_methods.c index ff3ddf5161377..9c1f48608cf21 100644 --- a/ext/intl/transliterator/transliterator_methods.c +++ b/ext/intl/transliterator/transliterator_methods.c @@ -48,7 +48,7 @@ static int create_transliterator( char *str_id, size_t str_id_len, zend_long dir if( U_FAILURE( TRANSLITERATOR_ERROR_CODE( to ) ) ) { intl_error_set_code( NULL, TRANSLITERATOR_ERROR_CODE( to ) ); - intl_error_set_custom_msg( NULL, "String conversion of id to UTF-16 failed", 0 ); + intl_error_set_custom_msg( NULL, "String conversion of id to UTF-16 failed"); zval_ptr_dtor( object ); return FAILURE; } @@ -64,15 +64,14 @@ static int create_transliterator( char *str_id, size_t str_id_len, zend_long dir { char *buf = NULL; intl_error_set_code( NULL, TRANSLITERATOR_ERROR_CODE( to ) ); - spprintf( &buf, 0, "transliterator_create: unable to open ICU transliterator" + spprintf( &buf, 0, "unable to open ICU transliterator" " with id \"%s\"", str_id ); if( buf == NULL ) { - intl_error_set_custom_msg( NULL, - "transliterator_create: unable to open ICU transliterator", 0 ); + intl_error_set_custom_msg(NULL, "unable to open ICU transliterator"); } else { - intl_error_set_custom_msg( NULL, buf, /* copy message */ 1 ); + intl_error_set_custom_msg(NULL, buf); efree( buf ); } zval_ptr_dtor( object ); @@ -84,8 +83,7 @@ static int create_transliterator( char *str_id, size_t str_id_len, zend_long dir if( U_FAILURE( TRANSLITERATOR_ERROR_CODE( to ) ) ) { intl_error_set_code( NULL, TRANSLITERATOR_ERROR_CODE( to ) ); - intl_error_set_custom_msg( NULL, - "transliterator_create: internal constructor call failed", 0 ); + intl_error_set_custom_msg(NULL, "internal constructor call failed"); zval_ptr_dtor( object ); return FAILURE; } @@ -169,12 +167,12 @@ PHP_FUNCTION( transliterator_create_from_rules ) char *msg = NULL; smart_str parse_error_str; parse_error_str = intl_parse_error_to_string( &parse_error ); - spprintf( &msg, 0, "transliterator_create_from_rules: unable to " + spprintf( &msg, 0, "unable to " "create ICU transliterator from rules (%s)", parse_error_str.s? ZSTR_VAL(parse_error_str.s) : "" ); smart_str_free( &parse_error_str ); if( msg != NULL ) { - intl_errors_set_custom_msg( INTL_DATA_ERROR_P( to ), msg, 1 ); + intl_errors_set_custom_msg( INTL_DATA_ERROR_P( to ), msg); efree( msg ); } zval_ptr_dtor( return_value ); @@ -182,7 +180,7 @@ PHP_FUNCTION( transliterator_create_from_rules ) } transliterator_object_construct( object, utrans, TRANSLITERATOR_ERROR_CODE_P( to ) ); /* no need to close the transliterator manually on construction error */ - INTL_METHOD_CHECK_STATUS_OR_NULL( to, "transliterator_create_from_rules: internal constructor call failed" ); + INTL_METHOD_CHECK_STATUS_OR_NULL( to, "internal constructor call failed" ); } /* }}} */ @@ -207,11 +205,11 @@ PHP_FUNCTION( transliterator_create_inverse ) TRANSLITERATOR_METHOD_FETCH_OBJECT_NO_CHECK; /* change "to" into new object (from "object" ) */ utrans = utrans_openInverse( to_orig->utrans, TRANSLITERATOR_ERROR_CODE_P( to ) ); - INTL_METHOD_CHECK_STATUS_OR_NULL( to, "transliterator_create_inverse: could not create " + INTL_METHOD_CHECK_STATUS_OR_NULL( to, "could not create " "inverse ICU transliterator" ); transliterator_object_construct( object, utrans, TRANSLITERATOR_ERROR_CODE_P( to ) ); /* no need to close the transliterator manually on construction error */ - INTL_METHOD_CHECK_STATUS_OR_NULL( to, "transliterator_create: internal constructor call failed" ); + INTL_METHOD_CHECK_STATUS_OR_NULL( to, "internal constructor call failed" ); } /* }}} */ @@ -229,7 +227,7 @@ PHP_FUNCTION( transliterator_list_ids ) en = utrans_openIDs( &status ); INTL_CHECK_STATUS( status, - "transliterator_list_ids: Failed to obtain registered transliterators" ); + "Failed to obtain registered transliterators" ); array_init( return_value ); while( (elem = uenum_unext( en, &elem_len, &status )) ) @@ -252,8 +250,8 @@ PHP_FUNCTION( transliterator_list_ids ) { zend_array_destroy( Z_ARR_P(return_value) ); RETVAL_FALSE; - intl_error_set_custom_msg( NULL, "transliterator_list_ids: " - "Failed to build array of registered transliterators", 0 ); + intl_error_set_custom_msg( NULL, + "Failed to build array of registered transliterators"); } } /* }}} */ @@ -342,13 +340,12 @@ PHP_FUNCTION( transliterator_transliterate ) { char *msg; spprintf( &msg, 0, - "transliterator_transliterate: Neither \"start\" nor the \"end\" " + "Neither \"start\" nor the \"end\" " "arguments can exceed the number of UTF-16 code units " "(in this case, %d)", (int) ustr_len ); if(msg != NULL ) { - intl_errors_set( TRANSLITERATOR_ERROR_P( to ), U_ILLEGAL_ARGUMENT_ERROR, - msg, 1 ); + intl_errors_set(TRANSLITERATOR_ERROR_P(to), U_ILLEGAL_ARGUMENT_ERROR, msg); efree( msg ); } goto cleanup; @@ -384,8 +381,7 @@ PHP_FUNCTION( transliterator_transliterate ) else if( U_FAILURE( TRANSLITERATOR_ERROR_CODE( to ) ) ) { intl_error_set_code( NULL, TRANSLITERATOR_ERROR_CODE( to ) ); - intl_errors_set_custom_msg( TRANSLITERATOR_ERROR_P( to ), - "transliterator_transliterate: transliteration failed", 0 ); + intl_errors_set_custom_msg( TRANSLITERATOR_ERROR_P( to ), "transliteration failed"); goto cleanup; } else diff --git a/ext/intl/uchar/uchar.cpp b/ext/intl/uchar/uchar.cpp index 88cab368b69ab..f1f777f0ea3eb 100644 --- a/ext/intl/uchar/uchar.cpp +++ b/ext/intl/uchar/uchar.cpp @@ -18,21 +18,21 @@ static inline int convert_cp(UChar32* pcp, zend_string *string_codepoint, zend_l if (ZEND_SIZE_T_INT_OVFL(string_codepoint_length)) { intl_error_set_code(NULL, U_ILLEGAL_ARGUMENT_ERROR); - intl_error_set_custom_msg(NULL, "Input string is too long.", 0); + intl_error_set_custom_msg(NULL, "Input string is too long."); return FAILURE; } U8_NEXT(ZSTR_VAL(string_codepoint), i, string_codepoint_length, int_codepoint); if ((size_t)i != string_codepoint_length) { intl_error_set_code(NULL, U_ILLEGAL_ARGUMENT_ERROR); - intl_error_set_custom_msg(NULL, "Passing a UTF-8 character for codepoint requires a string which is exactly one UTF-8 codepoint long.", 0); + intl_error_set_custom_msg(NULL, "Passing a UTF-8 character for codepoint requires a string which is exactly one UTF-8 codepoint long."); return FAILURE; } } if ((int_codepoint < UCHAR_MIN_VALUE) || (int_codepoint > UCHAR_MAX_VALUE)) { intl_error_set_code(NULL, U_ILLEGAL_ARGUMENT_ERROR); - intl_error_set_custom_msg(NULL, "Codepoint out of range", 0); + intl_error_set_custom_msg(NULL, "Codepoint out of range"); return FAILURE; } *pcp = (UChar32)int_codepoint; @@ -183,7 +183,7 @@ static UBool enumCharType_callback(enumCharType_data *context, if (zend_call_function(&context->fci, &context->fci_cache) == FAILURE) { intl_error_set_code(NULL, U_INTERNAL_PROGRAM_ERROR); - intl_errors_set_custom_msg(NULL, "enumCharTypes callback failed", 0); + intl_errors_set_custom_msg(NULL, "enumCharTypes callback failed"); zval_ptr_dtor(&retval); return 0; } @@ -286,7 +286,7 @@ static UBool enumCharNames_callback(enumCharNames_data *context, if (zend_call_function(&context->fci, &context->fci_cache) == FAILURE) { intl_error_set_code(NULL, U_INTERNAL_PROGRAM_ERROR); - intl_error_set_custom_msg(NULL, "enumCharNames callback failed", 0); + intl_error_set_custom_msg(NULL, "enumCharNames callback failed"); zval_ptr_dtor(&retval); zval_ptr_dtor_str(&args[2]); return 0; @@ -339,7 +339,7 @@ IC_METHOD(getPropertyName) { RETURN_STRING(ret); } else { intl_error_set_code(NULL, U_ILLEGAL_ARGUMENT_ERROR); - intl_error_set_custom_msg(NULL, "Failed to get property name", 0); + intl_error_set_custom_msg(NULL, "Failed to get property name"); RETURN_FALSE; } } @@ -375,7 +375,7 @@ IC_METHOD(getPropertyValueName) { RETURN_STRING(ret); } else { intl_error_set_code(NULL, U_ILLEGAL_ARGUMENT_ERROR); - intl_error_set_custom_msg(NULL, "Failed to get property name", 0); + intl_error_set_custom_msg(NULL, "Failed to get property name"); RETURN_FALSE; } } @@ -447,7 +447,7 @@ IC_METHOD(digit) { ret = u_digit(cp, radix); if (ret < 0) { intl_error_set_code(NULL, U_ILLEGAL_ARGUMENT_ERROR); - intl_error_set_custom_msg(NULL, "Invalid digit", 0); + intl_error_set_custom_msg(NULL, "Invalid digit"); RETURN_FALSE; } RETURN_LONG(ret);