]> granicus.if.org Git - php/commitdiff
Warning to ValueError promotion in Intl extension Part 1
authorGeorge Peter Banyard <girgias@php.net>
Fri, 31 Jul 2020 12:27:22 +0000 (13:27 +0100)
committerGeorge Peter Banyard <girgias@php.net>
Fri, 31 Jul 2020 12:27:22 +0000 (13:27 +0100)
Affects:
- IntlCalendar
- IntlGregorianCalendar
- IntlBreakIterator

Closes GH-5669

24 files changed:
ext/intl/breakiterator/breakiterator.stub.php
ext/intl/breakiterator/breakiterator_arginfo.h
ext/intl/breakiterator/breakiterator_methods.cpp
ext/intl/calendar/calendar.stub.php
ext/intl/calendar/calendar_arginfo.h
ext/intl/calendar/calendar_methods.cpp
ext/intl/calendar/gregoriancalendar_methods.cpp
ext/intl/collator/collator_convert.c
ext/intl/php_intl.stub.php
ext/intl/php_intl_arginfo.h
ext/intl/tests/breakiter_getPartsIterator_error.phpt
ext/intl/tests/calendar_clear_error.phpt
ext/intl/tests/calendar_getDayOfWeekType_error.phpt
ext/intl/tests/calendar_getWeekendTransition_error.phpt
ext/intl/tests/calendar_get_Least_Greatest_Minimum_Maximum_error.phpt
ext/intl/tests/calendar_get_getActualMaximum_Minumum_error.phpt
ext/intl/tests/calendar_get_getActualMaximum_Minumum_error2.phpt
ext/intl/tests/calendar_isSet_error.phpt
ext/intl/tests/calendar_roll_error.phpt
ext/intl/tests/calendar_setFirstDayOfWeek_error.phpt
ext/intl/tests/calendar_setMinimalDaysInFirstWeek_error.phpt
ext/intl/tests/calendar_setSkipped_RepeatedWallTimeOption_error.phpt
ext/intl/tests/calendar_set_error.phpt
ext/intl/tests/calendar_toDateTime_error.phpt

index 341e9df1f3569c10ef4b6c1e57fdd85af4c1eb8f..fda35217dfcb28f59670ba0351fc5be58bc5a9f4 100644 (file)
@@ -30,7 +30,7 @@ class IntlBreakIterator implements IteratorAggregate
     /** @return int */
     public function first() {}
 
-    /** @return int|false */
+    /** @return int */
     public function following(int $offset) {}
 
     /** @return int */
@@ -42,7 +42,7 @@ class IntlBreakIterator implements IteratorAggregate
     /** @return string */
     public function getLocale(int $locale_type) {}
 
-    /** @return IntlPartsIterator|false */
+    /** @return IntlPartsIterator */
     public function getPartsIterator(string $key_type = IntlPartsIterator::KEY_SEQUENTIAL) {}
 
     /** @return string|null */
@@ -54,10 +54,10 @@ class IntlBreakIterator implements IteratorAggregate
     /** @return int */
     public function last() {}
 
-    /** @return int|false */
+    /** @return int */
     public function next(?int $offset = null) {}
 
-    /** @return int|false */
+    /** @return int */
     public function preceding(int $offset) {}
 
     /** @return int */
index 98a22a4dde8c08ed8f5d5f11ee646b2038f7dc07..ee0d3fc27dc635b46c2ee7685018ab3ddeedbd99 100644 (file)
@@ -1,5 +1,5 @@
 /* This is a generated file, edit the .stub.php file instead.
- * Stub hash: 7180c7b167edb3aa8580ae4a600627f28636ac38 */
+ * Stub hash: 5eeedbbb7d07b0063d7bc19842b863a2c6d6898b */
 
 ZEND_BEGIN_ARG_INFO_EX(arginfo_class_IntlBreakIterator_createCharacterInstance, 0, 0, 0)
        ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, locale, IS_STRING, 1, "null")
index 393290b66e5d94da11fb83c5229fa5ab0c056f68..c389fe80ef9fa142a48e35ad700e1309191abf79 100644 (file)
@@ -63,6 +63,7 @@ static void _breakiter_factory(const char *func_name,
 
        biter = func(Locale::createFromName(locale_str), status);
        intl_error_set_code(NULL, status);
+       // Todo check if this can happen?
        if (U_FAILURE(status)) {
                spprintf(&msg, 0, "%s: error creating BreakIterator",
                                func_name);
@@ -170,7 +171,6 @@ U_CFUNC PHP_METHOD(IntlBreakIterator, setText)
 }
 
 static void _breakiter_no_args_ret_int32(
-               const char *func_name,
                int32_t (BreakIterator::*func)(),
                INTERNAL_FUNCTION_PARAMETERS)
 {
@@ -190,11 +190,9 @@ static void _breakiter_no_args_ret_int32(
 }
 
 static void _breakiter_int32_ret_int32(
-               const char *func_name,
                int32_t (BreakIterator::*func)(int32_t),
                INTERNAL_FUNCTION_PARAMETERS)
 {
-       char    *msg;
        zend_long       arg;
        BREAKITER_METHOD_INIT_VARS;
        object = ZEND_THIS;
@@ -206,11 +204,8 @@ static void _breakiter_int32_ret_int32(
        BREAKITER_METHOD_FETCH_OBJECT;
 
        if (arg < INT32_MIN || arg > INT32_MAX) {
-               spprintf(&msg, 0, "%s: offset argument is outside bounds of "
-                               "a 32-bit wide integer", func_name);
-               intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, msg, 1);
-               efree(msg);
-               RETURN_FALSE;
+               zend_argument_value_error(1, "must be between %d and %d", INT32_MIN, INT32_MAX);
+               RETURN_THROWS();
        }
 
        int32_t res = (bio->biter->*func)((int32_t)arg);
@@ -220,22 +215,19 @@ static void _breakiter_int32_ret_int32(
 
 U_CFUNC PHP_METHOD(IntlBreakIterator, first)
 {
-       _breakiter_no_args_ret_int32("breakiter_first",
-                       &BreakIterator::first,
+       _breakiter_no_args_ret_int32(&BreakIterator::first,
                        INTERNAL_FUNCTION_PARAM_PASSTHRU);
 }
 
 U_CFUNC PHP_METHOD(IntlBreakIterator, last)
 {
-       _breakiter_no_args_ret_int32("breakiter_last",
-                       &BreakIterator::last,
+       _breakiter_no_args_ret_int32(&BreakIterator::last,
                        INTERNAL_FUNCTION_PARAM_PASSTHRU);
 }
 
 U_CFUNC PHP_METHOD(IntlBreakIterator, previous)
 {
-       _breakiter_no_args_ret_int32("breakiter_previous",
-                       &BreakIterator::previous,
+       _breakiter_no_args_ret_int32(&BreakIterator::previous,
                        INTERNAL_FUNCTION_PARAM_PASSTHRU);
 }
 
@@ -253,12 +245,10 @@ U_CFUNC PHP_METHOD(IntlBreakIterator, next)
        if (arg == NULL) {
                ZEND_NUM_ARGS() = 0; /* pretend we don't have any argument */
                no_arg_version:
-               _breakiter_no_args_ret_int32("breakiter_next",
-                               &BreakIterator::next,
+               _breakiter_no_args_ret_int32(&BreakIterator::next,
                                INTERNAL_FUNCTION_PARAM_PASSTHRU);
        } else {
-               _breakiter_int32_ret_int32("breakiter_next",
-                               &BreakIterator::next,
+               _breakiter_int32_ret_int32(&BreakIterator::next,
                                INTERNAL_FUNCTION_PARAM_PASSTHRU);
        }
 }
@@ -281,14 +271,14 @@ U_CFUNC PHP_METHOD(IntlBreakIterator, current)
 
 U_CFUNC PHP_METHOD(IntlBreakIterator, following)
 {
-       _breakiter_int32_ret_int32("breakiter_following",
+       _breakiter_int32_ret_int32(
                        &BreakIterator::following,
                        INTERNAL_FUNCTION_PARAM_PASSTHRU);
 }
 
 U_CFUNC PHP_METHOD(IntlBreakIterator, preceding)
 {
-       _breakiter_int32_ret_int32("breakiter_preceding",
+       _breakiter_int32_ret_int32(
                        &BreakIterator::preceding,
                        INTERNAL_FUNCTION_PARAM_PASSTHRU);
 }
@@ -305,10 +295,8 @@ U_CFUNC PHP_METHOD(IntlBreakIterator, isBoundary)
        }
 
        if (offset < INT32_MIN || offset > INT32_MAX) {
-               intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
-                               "breakiter_is_boundary: offset argument is outside bounds of "
-                               "a 32-bit wide integer", 0);
-               RETURN_FALSE;
+               zend_argument_value_error(1, "must be between %d and %d", INT32_MIN, INT32_MAX);
+               RETURN_THROWS();
        }
 
        BREAKITER_METHOD_FETCH_OBJECT;
@@ -328,6 +316,7 @@ U_CFUNC PHP_METHOD(IntlBreakIterator, getLocale)
                RETURN_THROWS();
        }
 
+       /* 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);
@@ -357,9 +346,9 @@ U_CFUNC PHP_METHOD(IntlBreakIterator, getPartsIterator)
        if (key_type != PARTS_ITERATOR_KEY_SEQUENTIAL
                        && key_type != PARTS_ITERATOR_KEY_LEFT
                        && key_type != PARTS_ITERATOR_KEY_RIGHT) {
-               intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
-                       "breakiter_get_parts_iterator: bad key type", 0);
-               RETURN_FALSE;
+               zend_argument_value_error(1, "must be one of IntlPartsIterator::KEY_SEQUENTIAL, "
+                       "IntlPartsIterator::KEY_LEFT, or IntlPartsIterator::KEY_RIGHT");
+               RETURN_THROWS();
        }
 
        BREAKITER_METHOD_FETCH_OBJECT;
index d704ab77c93468c2cda0fca72bcecb46cfda724c..d3a7958ee94c81112a42899e2be4001ef199e7a2 100644 (file)
@@ -20,7 +20,7 @@ class IntlCalendar
     public function equals(IntlCalendar $calendar) {}
 
     /**
-     * @return int|false
+     * @return int
      * @alias intlcal_field_difference
      */
     public function fieldDifference(float $when, int $field) {}
@@ -57,19 +57,19 @@ class IntlCalendar
     public static function fromDateTime($dateTime, ?string $locale = null) {}
 
     /**
-     * @return int|false
+     * @return int
      * @alias intlcal_get
      */
     public function get(int $field) {}
 
     /**
-     * @return int|false
+     * @return int
      * @alias intlcal_get_actual_maximum
      */
     public function getActualMaximum(int $field) {}
 
     /**
-     * @return int|false
+     * @return int
      * @alias intlcal_get_actual_minimum
      */
     public function getActualMinimum(int $field) {}
@@ -81,7 +81,7 @@ class IntlCalendar
     public static function getAvailableLocales() {}
 
     /**
-     * @return int|false
+     * @return int
      * @alias intlcal_get_day_of_week_type
      */
     public function getDayOfWeekType(int $dayOfWeek) {}
@@ -99,13 +99,13 @@ class IntlCalendar
     public function getErrorMessage() {}
 
     /**
-     * @return int|false
+     * @return int
      * @alias intlcal_get_first_day_of_week
      */
     public function getFirstDayOfWeek() {}
 
     /**
-     * @return int|false
+     * @return int
      * @alias intlcal_get_greatest_minimum
      */
     public function getGreatestMinimum(int $field) {}
@@ -117,25 +117,25 @@ class IntlCalendar
     public static function getKeywordValuesForLocale(string $key, string $locale, bool $commonlyUsed) {}
 
     /**
-     * @return int|false
+     * @return int
      * @alias intlcal_get_least_maximum
      */
     public function getLeastMaximum(int $field) {}
 
     /**
-     * @return string|false
+     * @return string
      * @alias intlcal_get_locale
      */
     public function getLocale(int $localeType) {}
 
     /**
-     * @return int|false
+     * @return int
      * @alias intlcal_get_maximum
      */
     public function getMaximum(int $field) {}
 
     /**
-     * @return int|false
+     * @return int
      * @alias intlcal_get_minimal_days_in_first_week
      */
     public function getMinimalDaysInFirstWeek() {}
@@ -147,7 +147,7 @@ class IntlCalendar
     public function setMinimalDaysInFirstWeek(int $numberOfDays) {}
 
     /**
-     * @return int|false
+     * @return int
      * @alias intlcal_get_minimum
      */
     public function getMinimum(int $field) {}
@@ -171,7 +171,7 @@ class IntlCalendar
     public function getSkippedWallTimeOption() {}
 
     /**
-     * @return float|false
+     * @return float
      * @alias intlcal_get_time
      */
     public function getTime() {}
@@ -189,7 +189,7 @@ class IntlCalendar
     public function getType() {}
 
     /**
-     * @return int|false
+     * @return int
      * @alias intlcal_get_weekend_transition
      */
     public function getWeekendTransition(int $dayOfWeek) {}
@@ -292,7 +292,7 @@ class IntlGregorianCalendar extends IntlCalendar
     public function setGregorianChange(float $change) {}
 
     /**
-     * @return float|false
+     * @return float
      * @alias intlgregcal_get_gregorian_change
      */
     public function getGregorianChange() {}
index 5802d9f690e0a2f0b9c5a3abe18fb97762355054..47ea9200fe33ae828fb54b1607df354077306170 100644 (file)
@@ -1,5 +1,5 @@
 /* This is a generated file, edit the .stub.php file instead.
- * Stub hash: 7261d52837a7ac393453511d2c29ee9106407236 */
+ * Stub hash: 8b8a98d5035880031ac42fda5e58bde54c1d85fc */
 
 ZEND_BEGIN_ARG_INFO_EX(arginfo_class_IntlCalendar___construct, 0, 0, 0)
 ZEND_END_ARG_INFO()
index 186c2597f427d8a94af67e17a0668c9383fb9f1d..b6ef461e9e8fd76691f87fed20acd0b12721df1b 100644 (file)
@@ -43,6 +43,27 @@ extern "C" {
 
 using icu::Locale;
 
+#define ZEND_VALUE_ERROR_INVALID_FIELD(argument, zpp_arg_position) \
+       if (argument < 0 || argument >= UCAL_FIELD_COUNT) { \
+               zend_argument_value_error(getThis() ? ((zpp_arg_position)-1) : zpp_arg_position, \
+                       "must be a valid field"); \
+               RETURN_THROWS(); \
+       }
+
+#define ZEND_VALUE_ERROR_OUT_OF_BOUND_VALUE(argument, zpp_arg_position) \
+       if (argument < INT32_MIN || argument > INT32_MAX) { \
+               zend_argument_value_error(getThis() ? ((zpp_arg_position)-1) : zpp_arg_position, \
+                       "must be between %d and %d", INT32_MIN, INT32_MAX); \
+               RETURN_THROWS(); \
+       }
+
+#define ZEND_VALUE_ERROR_INVALID_DAY_OF_WEEK(argument, zpp_arg_position) \
+       if (argument < UCAL_SUNDAY || argument > UCAL_SATURDAY) { \
+               zend_argument_value_error(getThis() ? ((zpp_arg_position)-1) : zpp_arg_position, \
+                       "must be a valid day of the week"); \
+               RETURN_THROWS(); \
+       }
+
 U_CFUNC PHP_METHOD(IntlCalendar, __construct)
 {
        zend_throw_exception( NULL,
@@ -153,8 +174,6 @@ U_CFUNC PHP_FUNCTION(intlcal_get_keyword_values_for_locale)
                RETURN_THROWS();
        }
 
-       //does not work; see ICU bug 9194
-#if 0
        StringEnumeration *se = Calendar::getKeywordValuesForLocale(key,
                Locale::createFromName(locale), (UBool)commonly_used,
                status);
@@ -163,18 +182,6 @@ U_CFUNC PHP_FUNCTION(intlcal_get_keyword_values_for_locale)
                        "error calling underlying method", 0);
                RETURN_FALSE;
        }
-#else
-    UEnumeration *uenum = ucal_getKeywordValuesForLocale(
-               key, locale, !!commonly_used, &status);
-    if (U_FAILURE(status)) {
-        uenum_close(uenum);
-               intl_error_set(NULL, status, "intlcal_get_keyword_values_for_locale: "
-                       "error calling underlying method", 0);
-        RETURN_FALSE;
-    }
-
-    StringEnumeration *se = new BugStringCharEnumeration(uenum);
-#endif
 
        IntlIterator_from_StringEnumeration(se, return_value);
 }
@@ -209,11 +216,9 @@ U_CFUNC PHP_FUNCTION(intlcal_get_available_locales)
 
 static void _php_intlcal_field_uec_ret_in32t_method(
                int32_t (Calendar::*func)(UCalendarDateFields, UErrorCode&) const,
-               const char *method_name,
                INTERNAL_FUNCTION_PARAMETERS)
 {
        zend_long       field;
-       char    *message;
        CALENDAR_METHOD_INIT_VARS;
 
        if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(),
@@ -221,12 +226,7 @@ static void _php_intlcal_field_uec_ret_in32t_method(
                RETURN_THROWS();
        }
 
-       if (field < 0 || field >= UCAL_FIELD_COUNT) {
-               spprintf(&message, 0, "%s: invalid field", method_name);
-               intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, message, 1);
-               efree(message);
-               RETURN_FALSE;
-       }
+       ZEND_VALUE_ERROR_INVALID_FIELD(field, 2);
 
        CALENDAR_METHOD_FETCH_OBJECT;
 
@@ -240,7 +240,7 @@ static void _php_intlcal_field_uec_ret_in32t_method(
 U_CFUNC PHP_FUNCTION(intlcal_get)
 {
        _php_intlcal_field_uec_ret_in32t_method(&Calendar::get,
-               "intlcal_get", INTERNAL_FUNCTION_PARAM_PASSTHRU);
+               INTERNAL_FUNCTION_PARAM_PASSTHRU);
 }
 
 U_CFUNC PHP_FUNCTION(intlcal_get_time)
@@ -290,16 +290,8 @@ U_CFUNC PHP_FUNCTION(intlcal_add)
                RETURN_THROWS();
        }
 
-       if (field < 0 || field >= UCAL_FIELD_COUNT) {
-               intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
-                       "intlcal_add: invalid field", 0);
-               RETURN_FALSE;
-       }
-       if (amount < INT32_MIN || amount > INT32_MAX) {
-               intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
-                       "intlcal_add: amount out of bounds", 0);
-               RETURN_FALSE;
-       }
+       ZEND_VALUE_ERROR_INVALID_FIELD(field, 2);
+       ZEND_VALUE_ERROR_OUT_OF_BOUND_VALUE(amount, 3);
 
        CALENDAR_METHOD_FETCH_OBJECT;
 
@@ -356,9 +348,8 @@ static void _php_intlcal_before_after(
 
        when_co = Z_INTL_CALENDAR_P(when_object);
        if (when_co->ucal == NULL) {
-               intl_errors_set(&co->err, U_ILLEGAL_ARGUMENT_ERROR,
-                       "intlcal_before/after: Other IntlCalendar was unconstructed", 0);
-               RETURN_FALSE;
+               zend_argument_error(NULL, 2, "is uninitialized");
+               RETURN_THROWS();
        }
 
        UBool res = (co->ucal->*func)(*when_co->ucal, CALENDAR_ERROR_CODE(co));
@@ -395,25 +386,19 @@ U_CFUNC PHP_FUNCTION(intlcal_set)
        }
 
        for (int i = 0; i < arg_num; i++) {
-               if (args[i] < INT32_MIN || args[i] > INT32_MAX) {
-                       intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
-                               "intlcal_set: at least one of the arguments has an absolute value that is too large", 0);
-                       RETURN_FALSE;
-               }
+               /* Arguments start at 1 */
+               ZEND_VALUE_ERROR_OUT_OF_BOUND_VALUE(args[i], i + 1);
        }
 
        CALENDAR_METHOD_FETCH_OBJECT;
 
        if (arg_num == 2) {
-               if (args[0] < 0 || args[0] >= UCAL_FIELD_COUNT) {
-                       intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "intlcal_set: invalid field", 0);
-                       RETURN_FALSE;
-               }
+               ZEND_VALUE_ERROR_INVALID_FIELD(args[0], 2);
                co->ucal->set((UCalendarDateFields)args[0], (int32_t)args[1]);
        } else if (arg_num == 3) {
                co->ucal->set((int32_t)args[0], (int32_t)args[1], (int32_t)args[2]);
        } else if (arg_num == 4) {
-               zend_argument_count_error("No variant with 4 arguments");
+               zend_argument_count_error("IntlCalendar::set() has no variant with exactly 4 parameters");
                RETURN_THROWS();
        } else if (arg_num == 5) {
                co->ucal->set((int32_t)args[0], (int32_t)args[1], (int32_t)args[2], (int32_t)args[3], (int32_t)args[4]);
@@ -421,6 +406,7 @@ U_CFUNC PHP_FUNCTION(intlcal_set)
                co->ucal->set((int32_t)args[0], (int32_t)args[1], (int32_t)args[2], (int32_t)args[3], (int32_t)args[4], (int32_t)args[5]);
        }
 
+       // TODO Make void?
        RETURN_TRUE;
 }
 
@@ -436,20 +422,13 @@ U_CFUNC PHP_FUNCTION(intlcal_roll)
 
        CALENDAR_METHOD_FETCH_OBJECT;
 
-       if (field < 0 || field >= UCAL_FIELD_COUNT) {
-               intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "intlcal_roll: invalid field", 0);
-               RETURN_FALSE;
-       }
+       ZEND_VALUE_ERROR_INVALID_FIELD(field, 2);
 
        if (Z_TYPE_P(zvalue) == IS_FALSE || Z_TYPE_P(zvalue) == IS_TRUE) {
                value = Z_TYPE_P(zvalue) == IS_TRUE ? 1 : -1;
        } else {
                value = zval_get_long(zvalue);
-
-               if (value < INT32_MIN || value > INT32_MAX) {
-                       intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "intlcal_roll: value out of bounds", 0);
-                       RETURN_FALSE;
-               }
+               ZEND_VALUE_ERROR_OUT_OF_BOUND_VALUE(value, 3);
        }
 
        co->ucal->roll((UCalendarDateFields)field, (int32_t)value, CALENDAR_ERROR_CODE(co));
@@ -475,11 +454,7 @@ U_CFUNC PHP_FUNCTION(intlcal_clear)
        if (field_is_null) {
                co->ucal->clear();
        } else {
-               if (field < 0 || field >= UCAL_FIELD_COUNT) {
-                       intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
-                               "intlcal_clear: invalid field", 0);
-                       RETURN_FALSE;
-               }
+               ZEND_VALUE_ERROR_INVALID_FIELD(field, 2);
 
                co->ucal->clear((UCalendarDateFields)field);
        }
@@ -498,11 +473,7 @@ U_CFUNC PHP_FUNCTION(intlcal_field_difference)
                RETURN_THROWS();
        }
 
-       if (field < 0 || field >= UCAL_FIELD_COUNT) {
-               intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
-                       "intlcal_field_difference: invalid field", 0);
-               RETURN_FALSE;
-       }
+       ZEND_VALUE_ERROR_INVALID_FIELD(field, 3);
 
        CALENDAR_METHOD_FETCH_OBJECT;
 
@@ -517,13 +488,13 @@ U_CFUNC PHP_FUNCTION(intlcal_field_difference)
 U_CFUNC PHP_FUNCTION(intlcal_get_actual_maximum)
 {
        _php_intlcal_field_uec_ret_in32t_method(&Calendar::getActualMaximum,
-               "intlcal_get_actual_maximum", INTERNAL_FUNCTION_PARAM_PASSTHRU);
+               INTERNAL_FUNCTION_PARAM_PASSTHRU);
 }
 
 U_CFUNC PHP_FUNCTION(intlcal_get_actual_minimum)
 {
        _php_intlcal_field_uec_ret_in32t_method(&Calendar::getActualMinimum,
-               "intlcal_get_actual_minimum", INTERNAL_FUNCTION_PARAM_PASSTHRU);
+               INTERNAL_FUNCTION_PARAM_PASSTHRU);
 }
 
 U_CFUNC PHP_FUNCTION(intlcal_get_day_of_week_type)
@@ -536,11 +507,7 @@ U_CFUNC PHP_FUNCTION(intlcal_get_day_of_week_type)
                RETURN_THROWS();
        }
 
-       if (dow < UCAL_SUNDAY || dow > UCAL_SATURDAY) {
-               intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
-                       "intlcal_get_day_of_week_type: invalid day of week", 0);
-               RETURN_FALSE;
-       }
+       ZEND_VALUE_ERROR_INVALID_DAY_OF_WEEK(dow, 2);
 
        CALENDAR_METHOD_FETCH_OBJECT;
 
@@ -572,11 +539,9 @@ U_CFUNC PHP_FUNCTION(intlcal_get_first_day_of_week)
 
 static void _php_intlcal_field_ret_in32t_method(
                int32_t (Calendar::*func)(UCalendarDateFields) const,
-               const char *method_name,
                INTERNAL_FUNCTION_PARAMETERS)
 {
        zend_long       field;
-       char    *message;
        CALENDAR_METHOD_INIT_VARS;
 
        if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(),
@@ -584,12 +549,7 @@ static void _php_intlcal_field_ret_in32t_method(
                RETURN_THROWS();
        }
 
-       if (field < 0 || field >= UCAL_FIELD_COUNT) {
-               spprintf(&message, 0, "%s: invalid field", method_name);
-               intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, message, 1);
-               efree(message);
-               RETURN_FALSE;
-       }
+       ZEND_VALUE_ERROR_INVALID_FIELD(field, 2);
 
        CALENDAR_METHOD_FETCH_OBJECT;
 
@@ -602,13 +562,13 @@ static void _php_intlcal_field_ret_in32t_method(
 U_CFUNC PHP_FUNCTION(intlcal_get_greatest_minimum)
 {
        _php_intlcal_field_ret_in32t_method(&Calendar::getGreatestMinimum,
-               "intlcal_get_greatest_minimum", INTERNAL_FUNCTION_PARAM_PASSTHRU);
+               INTERNAL_FUNCTION_PARAM_PASSTHRU);
 }
 
 U_CFUNC PHP_FUNCTION(intlcal_get_least_maximum)
 {
        _php_intlcal_field_ret_in32t_method(&Calendar::getLeastMaximum,
-               "intlcal_get_least_maximum", INTERNAL_FUNCTION_PARAM_PASSTHRU);
+               INTERNAL_FUNCTION_PARAM_PASSTHRU);
 }
 
 U_CFUNC PHP_FUNCTION(intlcal_get_locale)
@@ -622,9 +582,8 @@ U_CFUNC PHP_FUNCTION(intlcal_get_locale)
        }
 
        if (locale_type != ULOC_ACTUAL_LOCALE && locale_type != ULOC_VALID_LOCALE) {
-               intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
-                       "intlcal_get_locale: invalid locale type", 0);
-               RETURN_FALSE;
+               zend_argument_value_error(getThis() ? 1 : 2, "must be either Locale::ACTUAL_LOCALE or Locale::VALID_LOCALE");
+               RETURN_THROWS();
        }
 
        CALENDAR_METHOD_FETCH_OBJECT;
@@ -640,7 +599,7 @@ U_CFUNC PHP_FUNCTION(intlcal_get_locale)
 U_CFUNC PHP_FUNCTION(intlcal_get_maximum)
 {
        _php_intlcal_field_ret_in32t_method(&Calendar::getMaximum,
-               "intlcal_get_maximum", INTERNAL_FUNCTION_PARAM_PASSTHRU);
+               INTERNAL_FUNCTION_PARAM_PASSTHRU);
 }
 
 U_CFUNC PHP_FUNCTION(intlcal_get_minimal_days_in_first_week)
@@ -664,7 +623,7 @@ U_CFUNC PHP_FUNCTION(intlcal_get_minimal_days_in_first_week)
 U_CFUNC PHP_FUNCTION(intlcal_get_minimum)
 {
        _php_intlcal_field_ret_in32t_method(&Calendar::getMinimum,
-               "intlcal_get_minimum", INTERNAL_FUNCTION_PARAM_PASSTHRU);
+               INTERNAL_FUNCTION_PARAM_PASSTHRU);
 }
 
 U_CFUNC PHP_FUNCTION(intlcal_get_time_zone)
@@ -712,11 +671,7 @@ U_CFUNC PHP_FUNCTION(intlcal_get_weekend_transition)
                RETURN_THROWS();
        }
 
-       if (dow < UCAL_SUNDAY || dow > UCAL_SATURDAY) {
-               intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
-                       "intlcal_get_weekend_transition: invalid day of week", 0);
-               RETURN_FALSE;
-       }
+       ZEND_VALUE_ERROR_INVALID_DAY_OF_WEEK(dow, 2);
 
        CALENDAR_METHOD_FETCH_OBJECT;
 
@@ -760,9 +715,8 @@ U_CFUNC PHP_FUNCTION(intlcal_is_equivalent_to)
 
        other_co = Z_INTL_CALENDAR_P(other_object);
        if (other_co->ucal == NULL) {
-               intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "intlcal_is_equivalent_to:"
-                       " Other IntlCalendar is unconstructed", 0);
-               RETURN_FALSE;
+               zend_argument_error(NULL, 2, "is uninitialized");
+               RETURN_THROWS();
        }
 
        CALENDAR_METHOD_FETCH_OBJECT;
@@ -794,11 +748,7 @@ U_CFUNC PHP_FUNCTION(intlcal_is_set)
                RETURN_THROWS();
        }
 
-       if (field < 0 || field >= UCAL_FIELD_COUNT) {
-               intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
-                       "intlcal_is_set: invalid field", 0);
-               RETURN_FALSE;
-       }
+       ZEND_VALUE_ERROR_INVALID_FIELD(field, 2);
 
        CALENDAR_METHOD_FETCH_OBJECT;
 
@@ -839,11 +789,7 @@ U_CFUNC PHP_FUNCTION(intlcal_set_first_day_of_week)
                RETURN_THROWS();
        }
 
-       if (dow < UCAL_SUNDAY || dow > UCAL_SATURDAY) {
-               intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
-                       "intlcal_set_first_day_of_week: invalid day of week", 0);
-               RETURN_FALSE;
-       }
+       ZEND_VALUE_ERROR_INVALID_DAY_OF_WEEK(dow, 2);
 
        CALENDAR_METHOD_FETCH_OBJECT;
 
@@ -879,11 +825,10 @@ U_CFUNC PHP_FUNCTION(intlcal_set_minimal_days_in_first_week)
                RETURN_THROWS();
        }
 
+       // Use ZEND_VALUE_ERROR_INVALID_DAY_OF_WEEK ?
        if (num_days < 1 || num_days > 7) {
-               intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
-                       "intlcal_set_minimal_days_in_first_week: invalid number of days; "
-                       "must be between 1 and 7", 0);
-               RETURN_FALSE;
+               zend_argument_value_error(getThis() ? 1 : 2, "must be between 1 and 7");
+               RETURN_THROWS();
        }
 
        CALENDAR_METHOD_FETCH_OBJECT;
@@ -908,9 +853,8 @@ U_CFUNC PHP_FUNCTION(intlcal_equals)
        CALENDAR_METHOD_FETCH_OBJECT;
        other_co = Z_INTL_CALENDAR_P(other_object);
        if (other_co->ucal == NULL) {
-               intl_errors_set(&co->err, U_ILLEGAL_ARGUMENT_ERROR,
-                       "intlcal_equals: The second IntlCalendar is unconstructed", 0);
-               RETURN_FALSE;
+               zend_argument_error(NULL, 2, "is uninitialized");
+               RETURN_THROWS();
        }
 
        UBool result = co->ucal->equals(*other_co->ucal, CALENDAR_ERROR_CODE(co));
@@ -958,15 +902,16 @@ U_CFUNC PHP_FUNCTION(intlcal_set_repeated_wall_time_option)
        }
 
        if (option != UCAL_WALLTIME_FIRST && option != UCAL_WALLTIME_LAST) {
-               intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
-                       "intlcal_set_repeated_wall_time_option: invalid option", 0);
-               RETURN_FALSE;
+               zend_argument_value_error(getThis() ? 1 : 2, "must be either IntlCalendar::WALLTIME_FIRST or "
+                       "IntlCalendar::WALLTIME_LAST");
+               RETURN_THROWS();
        }
 
        CALENDAR_METHOD_FETCH_OBJECT;
 
        co->ucal->setRepeatedWallTimeOption((UCalendarWallTimeOption)option);
 
+       // TODO Return void?
        RETURN_TRUE;
 }
 
@@ -982,15 +927,16 @@ U_CFUNC PHP_FUNCTION(intlcal_set_skipped_wall_time_option)
 
        if (option != UCAL_WALLTIME_FIRST && option != UCAL_WALLTIME_LAST
                        && option != UCAL_WALLTIME_NEXT_VALID) {
-               intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
-                       "intlcal_set_skipped_wall_time_option: invalid option", 0);
-               RETURN_FALSE;
+               zend_argument_value_error(getThis() ? 1 : 2, "must be one of IntlCalendar::WALLTIME_FIRST, "
+                       "IntlCalendar::WALLTIME_LAST, or IntlCalendar::WALLTIME_NEXT_VALID");
+               RETURN_THROWS();
        }
 
        CALENDAR_METHOD_FETCH_OBJECT;
 
        co->ucal->setSkippedWallTimeOption((UCalendarWallTimeOption)option);
 
+       // TODO Return void?
        RETURN_TRUE;
 }
 
@@ -1134,9 +1080,6 @@ U_CFUNC PHP_FUNCTION(intlcal_to_date_time)
        zend_call_known_instance_method_with_2_params(
                Z_OBJCE_P(return_value)->constructor, Z_OBJ_P(return_value), NULL, &ts_zval, timezone_zval);
        if (EG(exception)) {
-               intl_errors_set(CALENDAR_ERROR_P(co), U_ILLEGAL_ARGUMENT_ERROR,
-                       "intlcal_to_date_time: DateTime constructor has thrown exception",
-                       1);
                zend_object_store_ctor_failed(Z_OBJ_P(return_value));
                zval_ptr_dtor(return_value);
                zval_ptr_dtor(&ts_zval);
index 3a4d75965a0e2f86339de761584ee2bf1ac14473..84d594185c46fe7b2ad15766c6db5f844cc4b617 100644 (file)
@@ -107,6 +107,7 @@ static void _php_intlgregcal_constructor_body(
 
                gcal = new GregorianCalendar(tz, Locale::createFromName(locale),
                        status);
+                       // Should this throw?
                if (U_FAILURE(status)) {
                        intl_error_set(NULL, status, "intlgregcal_create_instance: error "
                                "creating ICU GregorianCalendar from time zone and locale", 0);
@@ -124,14 +125,9 @@ static void _php_intlgregcal_constructor_body(
                // From date/time (3, 5 or 6 arguments)
                for (int i = 0; i < variant; i++) {
                        if (largs[i] < INT32_MIN || largs[i] > INT32_MAX) {
-                               intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
-                                       "intlgregcal_create_instance: at least one of the arguments"
-                                       " has an absolute value that is too large", 0);
-                               if (!is_constructor) {
-                                       zval_ptr_dtor(return_value);
-                                       RETVAL_NULL();
-                               }
-                               return;
+                               zend_argument_value_error(getThis() ? (i-1) : i,
+                                       "must be between %d and %d", INT32_MIN, INT32_MAX);
+                               RETURN_THROWS();
                        }
                }
 
@@ -244,9 +240,8 @@ U_CFUNC PHP_FUNCTION(intlgregcal_is_leap_year)
        }
 
        if (year < INT32_MIN || year > INT32_MAX) {
-               intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
-                       "intlgregcal_is_leap_year: year out of bounds", 0);
-               RETURN_FALSE;
+               zend_argument_value_error(getThis() ? 1 : 2, "must be between %d and %d", INT32_MIN, INT32_MAX);
+               RETURN_THROWS();
        }
 
        CALENDAR_METHOD_FETCH_OBJECT;
index 88177a04f6497477c5fd5d49055dbc776640f4ee..da2cb85673b5c036f18acd24ba6646a658f56b49 100644 (file)
@@ -194,6 +194,7 @@ zval* collator_convert_zstr_utf8_to_utf16( zval* utf8_zval, zval *rv )
                        &ustr, &ustr_len,
                        Z_STRVAL_P( utf8_zval ), Z_STRLEN_P( utf8_zval ),
                        &status );
+       // FIXME Or throw error or use intl internal error handler
        if( U_FAILURE( status ) )
                php_error( E_WARNING, "Error casting object to string in collator_convert_zstr_utf8_to_utf16()" );
 
@@ -244,6 +245,7 @@ zval* collator_convert_object_to_string( zval* obj, zval *rv )
                        &ustr, &ustr_len,
                        Z_STRVAL_P( zstr ), Z_STRLEN_P( zstr ),
                        &status );
+       // FIXME Or throw error or use intl internal error handler
        if( U_FAILURE( status ) )
                php_error( E_WARNING, "Error casting object to string in collator_convert_object_to_string()" );
 
index aa86364e60c6c76cf2f2a3b4dac5bd19eefb6273..5aff42bbe3d688ba02089423386e5a5cdfb837cd 100644 (file)
@@ -13,9 +13,9 @@ function intlcal_get_now(): float {}
 
 function intlcal_get_available_locales(): array {}
 
-function intlcal_get(IntlCalendar $calendar, int $field): int|false {}
+function intlcal_get(IntlCalendar $calendar, int $field): int {}
 
-function intlcal_get_time(IntlCalendar $calendar): float|false {}
+function intlcal_get_time(IntlCalendar $calendar): float {}
 
 function intlcal_set_time(IntlCalendar $calendar, float $date): bool {}
 
@@ -35,35 +35,35 @@ function intlcal_roll(IntlCalendar $calendar, int $field, $amountOrUpOrDown): bo
 
 function intlcal_clear(IntlCalendar $calendar, ?int $field = null): bool {}
 
-function intlcal_field_difference(IntlCalendar $calendar, float $when, int $field): int|false {}
+function intlcal_field_difference(IntlCalendar $calendar, float $when, int $field): int {}
 
-function intlcal_get_actual_maximum(IntlCalendar $calendar, int $field): int|false {}
+function intlcal_get_actual_maximum(IntlCalendar $calendar, int $field): int {}
 
-function intlcal_get_actual_minimum(IntlCalendar $calendar, int $field): int|false {}
+function intlcal_get_actual_minimum(IntlCalendar $calendar, int $field): int {}
 
-function intlcal_get_day_of_week_type(IntlCalendar $calendar, int $dayOfWeek): int|false {}
+function intlcal_get_day_of_week_type(IntlCalendar $calendar, int $dayOfWeek): int {}
 
-function intlcal_get_first_day_of_week(IntlCalendar $calendar): int|false {}
+function intlcal_get_first_day_of_week(IntlCalendar $calendar): int {}
 
-function intlcal_get_least_maximum(IntlCalendar $calendar, int $field): int|false {}
+function intlcal_get_least_maximum(IntlCalendar $calendar, int $field): int {}
 
-function intlcal_get_greatest_minimum(IntlCalendar $calendar, int $field): int|false {}
+function intlcal_get_greatest_minimum(IntlCalendar $calendar, int $field): int {}
 
-function intlcal_get_locale(IntlCalendar $calendar, int $localeType): string|false {}
+function intlcal_get_locale(IntlCalendar $calendar, int $localeType): string {}
 
-function intlcal_get_maximum(IntlCalendar $calendar, int $field): int|false {}
+function intlcal_get_maximum(IntlCalendar $calendar, int $field): int {}
 
-function intlcal_get_minimal_days_in_first_week(IntlCalendar $calendar): int|false {}
+function intlcal_get_minimal_days_in_first_week(IntlCalendar $calendar): int {}
 
 function intlcal_set_minimal_days_in_first_week(IntlCalendar $calendar, int $numberOfDays): bool {}
 
-function intlcal_get_minimum(IntlCalendar $calendar, int $field): int|false {}
+function intlcal_get_minimum(IntlCalendar $calendar, int $field): int {}
 
 function intlcal_get_time_zone(IntlCalendar $calendar): IntlTimeZone|false {}
 
 function intlcal_get_type(IntlCalendar $calendar): string {}
 
-function intlcal_get_weekend_transition(IntlCalendar $calendar, int $dayOfWeek): int|false {}
+function intlcal_get_weekend_transition(IntlCalendar $calendar, int $dayOfWeek): int {}
 
 function intlcal_in_daylight_time(IntlCalendar $calendar): bool {}
 
@@ -103,7 +103,7 @@ function intlgregcal_create_instance($timeZoneOrYear = UNKNOWN, $localeOrMonth =
 
 function intlgregcal_set_gregorian_change(IntlGregorianCalendar $calendar, float $change): bool {}
 
-function intlgregcal_get_gregorian_change(IntlGregorianCalendar $calendar): float|false {}
+function intlgregcal_get_gregorian_change(IntlGregorianCalendar $calendar): float {}
 
 function intlgregcal_is_leap_year(IntlGregorianCalendar $calendar, int $year): bool {}
 
index 463c36c7b2629a6dc164e62fb170a8b223dd7bdc..4c91c671c2196c6688b2c23c4842ddd4de44e93e 100644 (file)
@@ -1,5 +1,5 @@
 /* This is a generated file, edit the .stub.php file instead.
- * Stub hash: a90502c989d9c9b41753def3e00b953e0cbe660d */
+ * Stub hash: a41f168369315619a8cf4bd3ed341b90b455ea1d */
 
 ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_intlcal_create_instance, 0, 0, IntlCalendar, 1)
        ZEND_ARG_INFO_WITH_DEFAULT_VALUE(0, timeZone, "null")
@@ -18,12 +18,12 @@ ZEND_END_ARG_INFO()
 ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_intlcal_get_available_locales, 0, 0, IS_ARRAY, 0)
 ZEND_END_ARG_INFO()
 
-ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_intlcal_get, 0, 2, MAY_BE_LONG|MAY_BE_FALSE)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_intlcal_get, 0, 2, IS_LONG, 0)
        ZEND_ARG_OBJ_INFO(0, calendar, IntlCalendar, 0)
        ZEND_ARG_TYPE_INFO(0, field, IS_LONG, 0)
 ZEND_END_ARG_INFO()
 
-ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_intlcal_get_time, 0, 1, MAY_BE_DOUBLE|MAY_BE_FALSE)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_intlcal_get_time, 0, 1, IS_DOUBLE, 0)
        ZEND_ARG_OBJ_INFO(0, calendar, IntlCalendar, 0)
 ZEND_END_ARG_INFO()
 
@@ -71,7 +71,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_intlcal_clear, 0, 1, _IS_BOOL, 0
        ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, field, IS_LONG, 1, "null")
 ZEND_END_ARG_INFO()
 
-ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_intlcal_field_difference, 0, 3, MAY_BE_LONG|MAY_BE_FALSE)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_intlcal_field_difference, 0, 3, IS_LONG, 0)
        ZEND_ARG_OBJ_INFO(0, calendar, IntlCalendar, 0)
        ZEND_ARG_TYPE_INFO(0, when, IS_DOUBLE, 0)
        ZEND_ARG_TYPE_INFO(0, field, IS_LONG, 0)
@@ -81,12 +81,12 @@ ZEND_END_ARG_INFO()
 
 #define arginfo_intlcal_get_actual_minimum arginfo_intlcal_get
 
-ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_intlcal_get_day_of_week_type, 0, 2, MAY_BE_LONG|MAY_BE_FALSE)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_intlcal_get_day_of_week_type, 0, 2, IS_LONG, 0)
        ZEND_ARG_OBJ_INFO(0, calendar, IntlCalendar, 0)
        ZEND_ARG_TYPE_INFO(0, dayOfWeek, IS_LONG, 0)
 ZEND_END_ARG_INFO()
 
-ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_intlcal_get_first_day_of_week, 0, 1, MAY_BE_LONG|MAY_BE_FALSE)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_intlcal_get_first_day_of_week, 0, 1, IS_LONG, 0)
        ZEND_ARG_OBJ_INFO(0, calendar, IntlCalendar, 0)
 ZEND_END_ARG_INFO()
 
@@ -94,7 +94,7 @@ ZEND_END_ARG_INFO()
 
 #define arginfo_intlcal_get_greatest_minimum arginfo_intlcal_get
 
-ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_intlcal_get_locale, 0, 2, MAY_BE_STRING|MAY_BE_FALSE)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_intlcal_get_locale, 0, 2, IS_STRING, 0)
        ZEND_ARG_OBJ_INFO(0, calendar, IntlCalendar, 0)
        ZEND_ARG_TYPE_INFO(0, localeType, IS_LONG, 0)
 ZEND_END_ARG_INFO()
@@ -148,13 +148,11 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_intlcal_set_lenient, 0, 2, _IS_B
        ZEND_ARG_TYPE_INFO(0, isLenient, _IS_BOOL, 0)
 ZEND_END_ARG_INFO()
 
-ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_intlcal_get_repeated_wall_time_option, 0, 1, IS_LONG, 0)
-       ZEND_ARG_OBJ_INFO(0, calendar, IntlCalendar, 0)
-ZEND_END_ARG_INFO()
+#define arginfo_intlcal_get_repeated_wall_time_option arginfo_intlcal_get_first_day_of_week
 
 #define arginfo_intlcal_equals arginfo_intlcal_after
 
-#define arginfo_intlcal_get_skipped_wall_time_option arginfo_intlcal_get_repeated_wall_time_option
+#define arginfo_intlcal_get_skipped_wall_time_option arginfo_intlcal_get_first_day_of_week
 
 ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_intlcal_set_repeated_wall_time_option, 0, 2, _IS_BOOL, 0)
        ZEND_ARG_OBJ_INFO(0, calendar, IntlCalendar, 0)
@@ -172,7 +170,9 @@ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_intlcal_to_date_time, 0, 1,
        ZEND_ARG_OBJ_INFO(0, calendar, IntlCalendar, 0)
 ZEND_END_ARG_INFO()
 
-#define arginfo_intlcal_get_error_code arginfo_intlcal_get_first_day_of_week
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_intlcal_get_error_code, 0, 1, MAY_BE_LONG|MAY_BE_FALSE)
+       ZEND_ARG_OBJ_INFO(0, calendar, IntlCalendar, 0)
+ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_intlcal_get_error_message, 0, 1, MAY_BE_STRING|MAY_BE_FALSE)
        ZEND_ARG_OBJ_INFO(0, calendar, IntlCalendar, 0)
@@ -192,7 +192,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_intlgregcal_set_gregorian_change
        ZEND_ARG_TYPE_INFO(0, change, IS_DOUBLE, 0)
 ZEND_END_ARG_INFO()
 
-ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_intlgregcal_get_gregorian_change, 0, 1, MAY_BE_DOUBLE|MAY_BE_FALSE)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_intlgregcal_get_gregorian_change, 0, 1, IS_DOUBLE, 0)
        ZEND_ARG_OBJ_INFO(0, calendar, IntlGregorianCalendar, 0)
 ZEND_END_ARG_INFO()
 
index b2931a000d7de01d39ab61d4d73155d299a0edcd..f86e64d4ccdd78f44ba51e359992779faf9fe49c 100644 (file)
@@ -6,13 +6,16 @@ if (!extension_loaded('intl'))
        die('skip intl extension not enabled');
 --FILE--
 <?php
-ini_set("intl.error_level", E_WARNING);
 ini_set("intl.default_locale", "pt_PT");
 
 $it = IntlBreakIterator::createWordInstance(NULL);
-var_dump($it->getPartsIterator(-1));
+
+try {
+    var_dump($it->getPartsIterator(-1));
+} catch(\ValueError $e) {
+    echo $e->getMessage() . \PHP_EOL;
+}
 
 ?>
---EXPECTF--
-Warning: IntlBreakIterator::getPartsIterator(): breakiter_get_parts_iterator: bad key type in %s on line %d
-bool(false)
+--EXPECT--
+IntlBreakIterator::getPartsIterator(): Argument #1 ($key_type) must be one of IntlPartsIterator::KEY_SEQUENTIAL, IntlPartsIterator::KEY_LEFT, or IntlPartsIterator::KEY_RIGHT
index dd2c1e0e75b6fa0251a29f06f59b977409c8c20c..12e5098ec5a4d11d6a213e67dddfdf9d96053098 100644 (file)
@@ -8,23 +8,26 @@ if (!extension_loaded('intl'))
        die('skip intl extension not enabled');
 --FILE--
 <?php
-ini_set("intl.error_level", E_WARNING);
 
 $c = new IntlGregorianCalendar(NULL, 'pt_PT');
 
-var_dump($c->clear(-1));
+try {
+    var_dump($c->clear(-1));
+} catch (\ValueError $e) {
+    echo $e->getMessage() . \PHP_EOL;
+}
+try {
+    var_dump(intlcal_clear($c, -1));
+} catch (\ValueError $e) {
+    echo $e->getMessage() . \PHP_EOL;
+}
 
-var_dump(intlcal_clear($c, -1));
-var_dump(intlcal_clear(1, 2));
---EXPECTF--
-Warning: IntlCalendar::clear(): intlcal_clear: invalid field in %s on line %d
-bool(false)
-
-Warning: intlcal_clear(): intlcal_clear: invalid field in %s on line %d
-bool(false)
-
-Fatal error: Uncaught TypeError: intlcal_clear(): Argument #1 ($calendar) must be of type IntlCalendar, int given in %s:%d
-Stack trace:
-#0 %s(%d): intlcal_clear(1, 2)
-#1 {main}
-  thrown in %s on line %d
+try {
+    var_dump(intlcal_clear(1, 2));
+} catch (\TypeError $e) {
+    echo $e->getMessage() . \PHP_EOL;
+}
+--EXPECT--
+IntlCalendar::clear(): Argument #1 ($field) must be a valid field
+intlcal_clear(): Argument #2 ($field) must be a valid field
+intlcal_clear(): Argument #1 ($calendar) must be of type IntlCalendar, int given
index 5408f966e2d6e5de6f518446c80bd8e311e024a9..9fee8999012e2ab0702699aace62de3a5813c66b 100644 (file)
@@ -8,19 +8,20 @@ if (!extension_loaded('intl'))
        die('skip intl extension not enabled');
 --FILE--
 <?php
-ini_set("intl.error_level", E_WARNING);
-
 $c = new IntlGregorianCalendar(NULL, 'pt_PT');
 
-var_dump($c->getDayOfWeekType(0));
+try {
+    var_dump($c->getDayOfWeekType(0));
+} catch (\ValueError $e) {
+    echo $e->getMessage() . \PHP_EOL;
+}
 
-var_dump(intlcal_get_day_of_week_type(1, 1));
---EXPECTF--
-Warning: IntlCalendar::getDayOfWeekType(): intlcal_get_day_of_week_type: invalid day of week in %s on line %d
-bool(false)
+try {
+    var_dump(intlcal_get_day_of_week_type(1, 1));
+} catch (\TypeError $e) {
+    echo $e->getMessage() . \PHP_EOL;
+}
 
-Fatal error: Uncaught TypeError: intlcal_get_day_of_week_type(): Argument #1 ($calendar) must be of type IntlCalendar, int given in %s:%d
-Stack trace:
-#0 %s(%d): intlcal_get_day_of_week_type(1, 1)
-#1 {main}
-  thrown in %s on line %d
+--EXPECT--
+IntlCalendar::getDayOfWeekType(): Argument #1 ($dayOfWeek) must be a valid day of the week
+intlcal_get_day_of_week_type(): Argument #1 ($calendar) must be of type IntlCalendar, int given
index 3be22cfc9c872658943cbb8ab1e440ee9fe8b736..63a1e7d07bf532b2c0c7e8586c2c3ffcea4acfdc 100644 (file)
@@ -11,15 +11,19 @@ if (!extension_loaded('intl'))
 ini_set("intl.error_level", E_WARNING);
 
 $c = new IntlGregorianCalendar(NULL, 'pt_PT');
-var_dump($c->getWeekendTransition(0));
 
-var_dump(intlcal_get_weekend_transition(1, 1));
---EXPECTF--
-Warning: IntlCalendar::getWeekendTransition(): intlcal_get_weekend_transition: invalid day of week in %s on line %d
-bool(false)
+try {
+    var_dump($c->getWeekendTransition(0));
+} catch (\ValueError $e) {
+    echo $e->getMessage() . \PHP_EOL;
+}
 
-Fatal error: Uncaught TypeError: intlcal_get_weekend_transition(): Argument #1 ($calendar) must be of type IntlCalendar, int given in %s:%d
-Stack trace:
-#0 %s(%d): intlcal_get_weekend_transition(1, 1)
-#1 {main}
-  thrown in %s on line %d
+try {
+    var_dump(intlcal_get_weekend_transition(1, 1));
+} catch (\TypeError $e) {
+    echo $e->getMessage() . \PHP_EOL;
+}
+
+--EXPECT--
+IntlCalendar::getWeekendTransition(): Argument #1 ($dayOfWeek) must be a valid day of the week
+intlcal_get_weekend_transition(): Argument #1 ($calendar) must be of type IntlCalendar, int given
index 318738f0941f5881952eadeba63d038daf31afd5..0199573178dd47b1234abdc7730263baaa186e43 100644 (file)
@@ -8,73 +8,81 @@ if (!extension_loaded('intl'))
        die('skip intl extension not enabled');
 --FILE--
 <?php
-ini_set("intl.error_level", E_WARNING);
 
 $c = new IntlGregorianCalendar(NULL, 'pt_PT');
 
-var_dump($c->getLeastMaximum(-1));
-var_dump($c->getMaximum(-1));
-var_dump($c->getGreatestMinimum(-1));
-var_dump($c->getMinimum(-1));
-
-var_dump(intlcal_get_least_maximum($c, -1));
-var_dump(intlcal_get_maximum($c, -1));
-var_dump(intlcal_get_greatest_minimum($c, -1));
-var_dump(intlcal_get_minimum($c, -1));
+try {
+    var_dump($c->getLeastMaximum(-1));
+} catch (Error $e) {
+    echo get_class($e) . ': ' . $e->getCode() . ', ' . $e->getMessage() . \PHP_EOL;
+}
+try {
+    var_dump($c->getMaximum(-1));
+} catch (Error $e) {
+    echo get_class($e) . ': ' . $e->getCode() . ', ' . $e->getMessage() . \PHP_EOL;
+}
+try {
+    var_dump($c->getGreatestMinimum(-1));
+} catch (Error $e) {
+    echo get_class($e) . ': ' . $e->getCode() . ', ' . $e->getMessage() . \PHP_EOL;
+}
+try {
+    var_dump($c->getMinimum(-1));
+} catch (Error $e) {
+    echo get_class($e) . ': ' . $e->getCode() . ', ' . $e->getMessage() . \PHP_EOL;
+}
 
-function eh($errno, $errstr) {
-echo "error: $errno, $errstr\n";
+try {
+    var_dump(intlcal_get_least_maximum($c, -1));
+} catch (Error $e) {
+    echo get_class($e) . ': ' . $e->getCode() . ', ' . $e->getMessage() . \PHP_EOL;
+}
+try {
+    var_dump(intlcal_get_maximum($c, -1));
+} catch (Error $e) {
+    echo get_class($e) . ': ' . $e->getCode() . ', ' . $e->getMessage() . \PHP_EOL;
+}
+try {
+    var_dump(intlcal_get_greatest_minimum($c, -1));
+} catch (Error $e) {
+    echo get_class($e) . ': ' . $e->getCode() . ', ' . $e->getMessage() . \PHP_EOL;
+}
+try {
+    var_dump(intlcal_get_minimum($c, -1));
+} catch (Error $e) {
+    echo get_class($e) . ': ' . $e->getCode() . ', ' . $e->getMessage() . \PHP_EOL;
 }
-set_error_handler('eh');
 
 try {
     var_dump(intlcal_get_least_maximum(1, 1));
-} catch (Error $ex) {
-    echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n";
+} catch (Error $e) {
+    echo get_class($e) . ': ' . $e->getCode() . ', ' . $e->getMessage() . \PHP_EOL;
 }
 try {
     var_dump(intlcal_get_maximum(1, 1));
-} catch (Error $ex) {
-    echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n";
+} catch (Error $e) {
+    echo get_class($e) . ': ' . $e->getCode() . ', ' . $e->getMessage() . \PHP_EOL;
 }
 try {
     var_dump(intlcal_get_greatest_minimum(1, -1));
-} catch (Error $ex) {
-    echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n";
+} catch (Error $e) {
+    echo get_class($e) . ': ' . $e->getCode() . ', ' . $e->getMessage() . \PHP_EOL;
 }
 try {
     var_dump(intlcal_get_minimum(1, -1));
-} catch (Error $ex) {
-    echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n";
+} catch (Error $e) {
+    echo get_class($e) . ': ' . $e->getCode() . ', ' . $e->getMessage() . \PHP_EOL;
 }
---EXPECTF--
-Warning: IntlCalendar::getLeastMaximum(): intlcal_get_least_maximum: invalid field in %s on line %d
-bool(false)
-
-Warning: IntlCalendar::getMaximum(): intlcal_get_maximum: invalid field in %s on line %d
-bool(false)
-
-Warning: IntlCalendar::getGreatestMinimum(): intlcal_get_greatest_minimum: invalid field in %s on line %d
-bool(false)
-
-Warning: IntlCalendar::getMinimum(): intlcal_get_minimum: invalid field in %s on line %d
-bool(false)
-
-Warning: intlcal_get_least_maximum(): intlcal_get_least_maximum: invalid field in %s on line %d
-bool(false)
-
-Warning: intlcal_get_maximum(): intlcal_get_maximum: invalid field in %s on line %d
-bool(false)
-
-Warning: intlcal_get_greatest_minimum(): intlcal_get_greatest_minimum: invalid field in %s on line %d
-bool(false)
-
-Warning: intlcal_get_minimum(): intlcal_get_minimum: invalid field in %s on line %d
-bool(false)
-error: 0, intlcal_get_least_maximum(): Argument #1 ($calendar) must be of type IntlCalendar, int given
-
-error: 0, intlcal_get_maximum(): Argument #1 ($calendar) must be of type IntlCalendar, int given
-
-error: 0, intlcal_get_greatest_minimum(): Argument #1 ($calendar) must be of type IntlCalendar, int given
-
-error: 0, intlcal_get_minimum(): Argument #1 ($calendar) must be of type IntlCalendar, int given
+--EXPECT--
+ValueError: 0, IntlCalendar::getLeastMaximum(): Argument #1 ($field) must be a valid field
+ValueError: 0, IntlCalendar::getMaximum(): Argument #1 ($field) must be a valid field
+ValueError: 0, IntlCalendar::getGreatestMinimum(): Argument #1 ($field) must be a valid field
+ValueError: 0, IntlCalendar::getMinimum(): Argument #1 ($field) must be a valid field
+ValueError: 0, intlcal_get_least_maximum(): Argument #2 ($field) must be a valid field
+ValueError: 0, intlcal_get_maximum(): Argument #2 ($field) must be a valid field
+ValueError: 0, intlcal_get_greatest_minimum(): Argument #2 ($field) must be a valid field
+ValueError: 0, intlcal_get_minimum(): Argument #2 ($field) must be a valid field
+TypeError: 0, intlcal_get_least_maximum(): Argument #1 ($calendar) must be of type IntlCalendar, int given
+TypeError: 0, intlcal_get_maximum(): Argument #1 ($calendar) must be of type IntlCalendar, int given
+TypeError: 0, intlcal_get_greatest_minimum(): Argument #1 ($calendar) must be of type IntlCalendar, int given
+TypeError: 0, intlcal_get_minimum(): Argument #1 ($calendar) must be of type IntlCalendar, int given
index 3853d612a3358873cdcece823d63a6af685437cb..2b5f344cb14e279be1bb873b44af68ab64e7fab0 100644 (file)
@@ -8,21 +8,27 @@ if (!extension_loaded('intl'))
        die('skip intl extension not enabled');
 --FILE--
 <?php
-ini_set("intl.error_level", E_WARNING);
 
 $c = new IntlGregorianCalendar(NULL, 'pt_PT');
 
-var_dump($c->get(-1));
-var_dump($c->getActualMaximum(-1));
-var_dump($c->getActualMinimum(-1));
+try {
+    var_dump($c->get(-1));
+} catch (\ValueError $e) {
+    echo $e->getMessage() . \PHP_EOL;
+}
+try {
+    var_dump($c->getActualMaximum(-1));
+} catch (\ValueError $e) {
+    echo $e->getMessage() . \PHP_EOL;
+}
+try {
+    var_dump($c->getActualMinimum(-1));
+} catch (\ValueError $e) {
+    echo $e->getMessage() . \PHP_EOL;
+}
 
 ?>
---EXPECTF--
-Warning: IntlCalendar::get(): intlcal_get: invalid field in %s on line %d
-bool(false)
-
-Warning: IntlCalendar::getActualMaximum(): intlcal_get_actual_maximum: invalid field in %s on line %d
-bool(false)
-
-Warning: IntlCalendar::getActualMinimum(): intlcal_get_actual_minimum: invalid field in %s on line %d
-bool(false)
+--EXPECT--
+IntlCalendar::get(): Argument #1 ($field) must be a valid field
+IntlCalendar::getActualMaximum(): Argument #1 ($field) must be a valid field
+IntlCalendar::getActualMinimum(): Argument #1 ($field) must be a valid field
index 207d9e5cdb795e6d5643174649de49ce874c5cdd..95ecf0e08fd92c64779d3f37edeb41bb73b6ff52 100644 (file)
@@ -8,99 +8,82 @@ if (!extension_loaded('intl'))
        die('skip intl extension not enabled');
 --FILE--
 <?php
-ini_set("intl.error_level", E_WARNING);
 
 $c = new IntlGregorianCalendar(NULL, 'pt_PT');
 
-function eh($errno, $errstr) {
-echo "error: $errno, $errstr\n";
-}
-set_error_handler('eh');
-
 try {
     var_dump(intlcal_get($c));
-} catch (Error $ex) {
-    echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n";
+} catch (Error $e) {
+    echo get_class($e) . ': ' . $e->getCode() . ', ' . $e->getMessage() . \PHP_EOL;
 }
 try {
     var_dump(intlcal_get_actual_maximum($c));
-} catch (Error $ex) {
-    echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n";
+} catch (Error $e) {
+    echo get_class($e) . ': ' . $e->getCode() . ', ' . $e->getMessage() . \PHP_EOL;
 }
 try {
     var_dump(intlcal_get_actual_minimum($c));
-} catch (Error $ex) {
-    echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n";
+} catch (Error $e) {
+    echo get_class($e) . ': ' . $e->getCode() . ', ' . $e->getMessage() . \PHP_EOL;
 }
 
 try {
     var_dump(intlcal_get($c, -1));
-} catch (Error $ex) {
-    echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n";
+} catch (Error $e) {
+    echo get_class($e) . ': ' . $e->getCode() . ', ' . $e->getMessage() . \PHP_EOL;
 }
 try {
     var_dump(intlcal_get_actual_maximum($c, -1));
-} catch (Error $ex) {
-    echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n";
+} catch (Error $e) {
+    echo get_class($e) . ': ' . $e->getCode() . ', ' . $e->getMessage() . \PHP_EOL;
 }
 try {
     var_dump(intlcal_get_actual_minimum($c, -1));
-} catch (Error $ex) {
-    echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n";
+} catch (Error $e) {
+    echo get_class($e) . ': ' . $e->getCode() . ', ' . $e->getMessage() . \PHP_EOL;
 }
 
 try {
     var_dump(intlcal_get($c, "s"));
-} catch (Error $ex) {
-    echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n";
+} catch (Error $e) {
+    echo get_class($e) . ': ' . $e->getCode() . ', ' . $e->getMessage() . \PHP_EOL;
 }
 try {
     var_dump(intlcal_get_actual_maximum($c, "s"));
-} catch (Error $ex) {
-    echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n";
+} catch (Error $e) {
+    echo get_class($e) . ': ' . $e->getCode() . ', ' . $e->getMessage() . \PHP_EOL;
 }
 try {
     var_dump(intlcal_get_actual_minimum($c, "s"));
-} catch (Error $ex) {
-    echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n";
+} catch (Error $e) {
+    echo get_class($e) . ': ' . $e->getCode() . ', ' . $e->getMessage() . \PHP_EOL;
 }
 
 try {
     var_dump(intlcal_get(1));
-} catch (Error $ex) {
-    echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n";
+} catch (Error $e) {
+    echo get_class($e) . ': ' . $e->getCode() . ', ' . $e->getMessage() . \PHP_EOL;
 }
 try {
     var_dump(intlcal_get_actual_maximum(1));
-} catch (Error $ex) {
-    echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n";
+} catch (Error $e) {
+    echo get_class($e) . ': ' . $e->getCode() . ', ' . $e->getMessage() . \PHP_EOL;
 }
 try {
     var_dump(intlcal_get_actual_minimum(1));
-} catch (Error $ex) {
-    echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n";
+} catch (Error $e) {
+    echo get_class($e) . ': ' . $e->getCode() . ', ' . $e->getMessage() . \PHP_EOL;
 }
 --EXPECT--
-error: 0, intlcal_get() expects exactly 2 parameters, 1 given
-
-error: 0, intlcal_get_actual_maximum() expects exactly 2 parameters, 1 given
-
-error: 0, intlcal_get_actual_minimum() expects exactly 2 parameters, 1 given
-
-error: 2, intlcal_get(): intlcal_get: invalid field
-bool(false)
-error: 2, intlcal_get_actual_maximum(): intlcal_get_actual_maximum: invalid field
-bool(false)
-error: 2, intlcal_get_actual_minimum(): intlcal_get_actual_minimum: invalid field
-bool(false)
-error: 0, intlcal_get(): Argument #2 ($field) must be of type int, string given
-
-error: 0, intlcal_get_actual_maximum(): Argument #2 ($field) must be of type int, string given
-
-error: 0, intlcal_get_actual_minimum(): Argument #2 ($field) must be of type int, string given
-
-error: 0, intlcal_get() expects exactly 2 parameters, 1 given
-
-error: 0, intlcal_get_actual_maximum() expects exactly 2 parameters, 1 given
-
-error: 0, intlcal_get_actual_minimum() expects exactly 2 parameters, 1 given
+ArgumentCountError: 0, intlcal_get() expects exactly 2 parameters, 1 given
+ArgumentCountError: 0, intlcal_get_actual_maximum() expects exactly 2 parameters, 1 given
+ArgumentCountError: 0, intlcal_get_actual_minimum() expects exactly 2 parameters, 1 given
+ValueError: 0, intlcal_get(): Argument #2 ($field) must be a valid field
+ValueError: 0, intlcal_get_actual_maximum(): Argument #2 ($field) must be a valid field
+ValueError: 0, intlcal_get_actual_minimum(): Argument #2 ($field) must be a valid field
+TypeError: 0, intlcal_get(): Argument #2 ($field) must be of type int, string given
+TypeError: 0, intlcal_get_actual_maximum(): Argument #2 ($field) must be of type int, string given
+TypeError: 0, intlcal_get_actual_minimum(): Argument #2 ($field) must be of type int, string given
+ArgumentCountError: 0, intlcal_get() expects exactly 2 parameters, 1 given
+ArgumentCountError: 0, intlcal_get_actual_maximum() expects exactly 2 parameters, 1 given
+ArgumentCountError: 0, intlcal_get_actual_minimum() expects exactly 2 parameters, 1 given
index 969a5130a599de8920ab12c4996e1b209934dd6e..ccd25f621a9c81b7a67e6683d3c96fa4a7de7812 100644 (file)
@@ -8,19 +8,21 @@ if (!extension_loaded('intl'))
        die('skip intl extension not enabled');
 --FILE--
 <?php
-ini_set("intl.error_level", E_WARNING);
 
 $c = new IntlGregorianCalendar(NULL, 'pt_PT');
 
-var_dump($c->isSet(-1));
+try {
+    var_dump($c->isSet(-1));
+} catch (\ValueError $e) {
+    echo $e->getMessage() . \PHP_EOL;
+}
 
-var_dump(intlcal_is_set(1, 2));
---EXPECTF--
-Warning: IntlCalendar::isSet(): intlcal_is_set: invalid field in %s on line %d
-bool(false)
+try {
+    var_dump(intlcal_is_set(1, 2));
+} catch (\TypeError $e) {
+    echo $e->getMessage() . \PHP_EOL;
+}
 
-Fatal error: Uncaught TypeError: intlcal_is_set(): Argument #1 ($calendar) must be of type IntlCalendar, int given in %s:%d
-Stack trace:
-#0 %s(%d): intlcal_is_set(1, 2)
-#1 {main}
-  thrown in %s on line %d
+--EXPECT--
+IntlCalendar::isSet(): Argument #1 ($field) must be a valid field
+intlcal_is_set(): Argument #1 ($calendar) must be of type IntlCalendar, int given
index de110a864cb054b1afd0a1e36dd05c6bb7169588..77ce6e16a8c189cea8dd144fc2a7213e5c2bfd3c 100644 (file)
@@ -8,19 +8,20 @@ if (!extension_loaded('intl'))
        die('skip intl extension not enabled');
 --FILE--
 <?php
-ini_set("intl.error_level", E_WARNING);
 
 $c = new IntlGregorianCalendar(NULL, 'pt_PT');
 
-var_dump($c->roll(-1, 2));
+try {
+    var_dump($c->roll(-1, 2));
+} catch (\ValueError $e) {
+    echo $e->getMessage() . \PHP_EOL;
+}
 
-var_dump(intlcal_roll(1, 2, 3));
+try {
+    var_dump(intlcal_roll(1, 2, 3));
+} catch (\TypeError $e) {
+    echo $e->getMessage() . \PHP_EOL;
+}
 --EXPECTF--
-Warning: IntlCalendar::roll(): intlcal_roll: invalid field in %s on line %d
-bool(false)
-
-Fatal error: Uncaught TypeError: intlcal_roll(): Argument #1 ($calendar) must be of type IntlCalendar, int given in %s:%d
-Stack trace:
-#0 %s(%d): intlcal_roll(1, 2, 3)
-#1 {main}
-  thrown in %s on line %d
+IntlCalendar::roll(): Argument #1 ($field) must be a valid field
+intlcal_roll(): Argument #1 ($calendar) must be of type IntlCalendar, int given
index 163e41fe482863bd14b03bdc8216b5240f7c4836..e3e3797b7a1259c7086f157f901b89e679d92d89 100644 (file)
@@ -8,23 +8,27 @@ if (!extension_loaded('intl'))
        die('skip intl extension not enabled');
 --FILE--
 <?php
-ini_set("intl.error_level", E_WARNING);
 
 $c = new IntlGregorianCalendar(NULL, 'pt_PT');
 
-var_dump($c->setFirstDayOfWeek(0));
+try {
+    var_dump($c->setFirstDayOfWeek(0));
+} catch (\ValueError $e) {
+    echo $e->getMessage() . \PHP_EOL;
+}
 
-var_dump(intlcal_set_first_day_of_week($c, 0));
-var_dump(intlcal_set_first_day_of_week(1, 2));
---EXPECTF--
-Warning: IntlCalendar::setFirstDayOfWeek(): intlcal_set_first_day_of_week: invalid day of week in %s on line %d
-bool(false)
+try {
+    var_dump(intlcal_set_first_day_of_week($c, 0));
+} catch (\ValueError $e) {
+    echo $e->getMessage() . \PHP_EOL;
+}
+try {
+    var_dump(intlcal_set_first_day_of_week(1, 2));
+} catch (\TypeError $e) {
+    echo $e->getMessage() . \PHP_EOL;
+}
 
-Warning: intlcal_set_first_day_of_week(): intlcal_set_first_day_of_week: invalid day of week in %s on line %d
-bool(false)
-
-Fatal error: Uncaught TypeError: intlcal_set_first_day_of_week(): Argument #1 ($calendar) must be of type IntlCalendar, int given in %s:%d
-Stack trace:
-#0 %s(%d): intlcal_set_first_day_of_week(1, 2)
-#1 {main}
-  thrown in %s on line %d
+--EXPECT--
+IntlCalendar::setFirstDayOfWeek(): Argument #1 ($dayOfWeek) must be a valid day of the week
+intlcal_set_first_day_of_week(): Argument #2 ($dayOfWeek) must be a valid day of the week
+intlcal_set_first_day_of_week(): Argument #1 ($calendar) must be of type IntlCalendar, int given
index c1b1a944fb87f74a57c129e9eeedad2021b90047..04c4811eb0a30931a70e13d1a344efd2e9274136 100644 (file)
@@ -8,23 +8,27 @@ if (!extension_loaded('intl'))
        die('skip intl extension not enabled');
 --FILE--
 <?php
-ini_set("intl.error_level", E_WARNING);
 
 $c = new IntlGregorianCalendar(NULL, 'pt_PT');
 
-var_dump($c->setMinimalDaysInFirstWeek(0));
+try {
+    var_dump($c->setMinimalDaysInFirstWeek(0));
+} catch (\ValueError $e) {
+    echo $e->getMessage() . \PHP_EOL;
+}
 
-var_dump(intlcal_set_minimal_days_in_first_week($c, 0));
-var_dump(intlcal_set_minimal_days_in_first_week(1, 2));
---EXPECTF--
-Warning: IntlCalendar::setMinimalDaysInFirstWeek(): intlcal_set_minimal_days_in_first_week: invalid number of days; must be between 1 and 7 in %s on line %d
-bool(false)
+try {
+    var_dump(intlcal_set_minimal_days_in_first_week($c, 0));
+} catch (\ValueError $e) {
+    echo $e->getMessage() . \PHP_EOL;
+}
+try {
+    var_dump(intlcal_set_minimal_days_in_first_week(1, 2));
+} catch (\TypeError $e) {
+    echo $e->getMessage() . \PHP_EOL;
+}
 
-Warning: intlcal_set_minimal_days_in_first_week(): intlcal_set_minimal_days_in_first_week: invalid number of days; must be between 1 and 7 in %s on line %d
-bool(false)
-
-Fatal error: Uncaught TypeError: intlcal_set_minimal_days_in_first_week(): Argument #1 ($calendar) must be of type IntlCalendar, int given in %s:%d
-Stack trace:
-#0 %s(%d): intlcal_set_minimal_days_in_first_week(1, 2)
-#1 {main}
-  thrown in %s on line %d
+--EXPECT--
+IntlCalendar::setMinimalDaysInFirstWeek(): Argument #1 ($numberOfDays) must be between 1 and 7
+intlcal_set_minimal_days_in_first_week(): Argument #2 ($numberOfDays) must be between 1 and 7
+intlcal_set_minimal_days_in_first_week(): Argument #1 ($calendar) must be of type IntlCalendar, int given
index c89e502e7a7a338d501f48bff37b0652de296ff0..80ed808e47db17c017adbfd72ce1453f541cfc88 100644 (file)
@@ -12,19 +12,23 @@ ini_set("intl.error_level", E_WARNING);
 
 $c = new IntlGregorianCalendar(NULL, 'pt_PT');
 
-var_dump($c->setSkippedWallTimeOption(3));
-var_dump($c->setRepeatedWallTimeOption(2));
+try {
+    var_dump($c->setSkippedWallTimeOption(3));
+} catch (\ValueError $e) {
+    echo $e->getMessage() . \PHP_EOL;
+}
+try {
+    var_dump($c->setRepeatedWallTimeOption(2));
+} catch (\ValueError $e) {
+    echo $e->getMessage() . \PHP_EOL;
+}
 
-var_dump(intlcal_set_repeated_wall_time_option(1, 1));
---EXPECTF--
-Warning: IntlCalendar::setSkippedWallTimeOption(): intlcal_set_skipped_wall_time_option: invalid option in %s on line %d
-bool(false)
-
-Warning: IntlCalendar::setRepeatedWallTimeOption(): intlcal_set_repeated_wall_time_option: invalid option in %s on line %d
-bool(false)
-
-Fatal error: Uncaught TypeError: intlcal_set_repeated_wall_time_option(): Argument #1 ($calendar) must be of type IntlCalendar, int given in %s:%d
-Stack trace:
-#0 %s(%d): intlcal_set_repeated_wall_time_option(1, 1)
-#1 {main}
-  thrown in %s on line %d
+try {
+    var_dump(intlcal_set_repeated_wall_time_option(1, 1));
+} catch (\TypeError $e) {
+    echo $e->getMessage() . \PHP_EOL;
+}
+--EXPECT--
+IntlCalendar::setSkippedWallTimeOption(): Argument #1 ($wallTimeOption) must be one of IntlCalendar::WALLTIME_FIRST, IntlCalendar::WALLTIME_LAST, or IntlCalendar::WALLTIME_NEXT_VALID
+IntlCalendar::setRepeatedWallTimeOption(): Argument #1 ($wallTimeOption) must be either IntlCalendar::WALLTIME_FIRST or IntlCalendar::WALLTIME_LAST
+intlcal_set_repeated_wall_time_option(): Argument #1 ($calendar) must be of type IntlCalendar, int given
index 21133536049ceeb9456e0e4375cb87d78199c525..236d3b6451dbb978971a3a8846f7835b63ccd43e 100644 (file)
@@ -24,22 +24,26 @@ try {
     echo $exception->getMessage() . "\n";
 }
 
-var_dump($c->set(-1, 2));
-
-var_dump(intlcal_set($c, -1, 2));
-var_dump(intlcal_set(1, 2, 3));
---EXPECTF--
-IntlCalendar::set() expects at most 6 parameters, 7 given
-No variant with 4 arguments
-
-Warning: IntlCalendar::set(): intlcal_set: invalid field in %s on line %d
-bool(false)
+try {
+    var_dump($c->set(-1, 2));
+} catch (\ValueError $e) {
+    echo $e->getMessage() . \PHP_EOL;
+}
 
-Warning: intlcal_set(): intlcal_set: invalid field in %s on line %d
-bool(false)
+try {
+    var_dump(intlcal_set($c, -1, 2));
+} catch (\ValueError $e) {
+    echo $e->getMessage() . \PHP_EOL;
+}
 
-Fatal error: Uncaught TypeError: intlcal_set(): Argument #1 ($calendar) must be of type IntlCalendar, int given in %s:%d
-Stack trace:
-#0 %s(%d): intlcal_set(1, 2, 3)
-#1 {main}
-  thrown in %s on line %d
+try {
+    var_dump(intlcal_set(1, 2, 3));
+} catch (\TypeError $e) {
+    echo $e->getMessage() . \PHP_EOL;
+}
+--EXPECT--
+IntlCalendar::set() expects at most 6 parameters, 7 given
+IntlCalendar::set() has no variant with exactly 4 parameters
+IntlCalendar::set(): Argument #1 ($year) must be a valid field
+intlcal_set(): Argument #2 ($year) must be a valid field
+intlcal_set(): Argument #1 ($calendar) must be of type IntlCalendar, int given
index 20f45ef6d24de55ed61c5a991f5a3415edce6c5e..01cf75c4c2071afa01735a59b39c39a5f243a748 100644 (file)
@@ -16,13 +16,40 @@ var_dump($cal->toDateTime());
 var_dump("exception: {$e->getMessage()}");
 }
 
-var_dump(intlcal_to_date_time(3));
+try {
+    var_dump(intlcal_to_date_time($cal));
+} catch (\Exception $e) {
+    var_dump($e->getMessage());
+}
+
+$cal = IntlCalendar::createInstance("Etc/Unknown");
+try {
+    var_dump($cal->toDateTime());
+} catch (\Exception $e) {
+    var_dump($e->getMessage());
+}
+
+try {
+    var_dump(intlcal_to_date_time($cal));
+} catch (\Exception $e) {
+    var_dump($e->getMessage());
+}
+
+try {
+    var_dump(intlcal_to_date_time(3));
+} catch (\TypeError $e) {
+    echo $e->getMessage() . \PHP_EOL;
+}
 --EXPECTF--
 Warning: IntlCalendar::toDateTime(): intlcal_to_date_time: DateTimeZone constructor threw exception in %s on line %d
 string(77) "exception: DateTimeZone::__construct(): Unknown or bad timezone (Etc/Unknown)"
 
-Fatal error: Uncaught TypeError: intlcal_to_date_time(): Argument #1 ($calendar) must be of type IntlCalendar, int given in %s:%d
-Stack trace:
-#0 %s(%d): intlcal_to_date_time(3)
-#1 {main}
-  thrown in %s on line %d
+Warning: intlcal_to_date_time(): 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
+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
+string(66) "DateTimeZone::__construct(): Unknown or bad timezone (Etc/Unknown)"
+intlcal_to_date_time(): Argument #1 ($calendar) must be of type IntlCalendar, int given