/** @return int */
public function first() {}
- /** @return int|false */
+ /** @return int */
public function following(int $offset) {}
/** @return int */
/** @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 */
/** @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 */
/* 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")
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);
}
static void _breakiter_no_args_ret_int32(
- const char *func_name,
int32_t (BreakIterator::*func)(),
INTERNAL_FUNCTION_PARAMETERS)
{
}
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;
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);
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);
}
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);
}
}
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);
}
}
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;
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);
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;
public function equals(IntlCalendar $calendar) {}
/**
- * @return int|false
+ * @return int
* @alias intlcal_field_difference
*/
public function fieldDifference(float $when, int $field) {}
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) {}
public static function getAvailableLocales() {}
/**
- * @return int|false
+ * @return int
* @alias intlcal_get_day_of_week_type
*/
public function getDayOfWeekType(int $dayOfWeek) {}
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) {}
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() {}
public function setMinimalDaysInFirstWeek(int $numberOfDays) {}
/**
- * @return int|false
+ * @return int
* @alias intlcal_get_minimum
*/
public function getMinimum(int $field) {}
public function getSkippedWallTimeOption() {}
/**
- * @return float|false
+ * @return float
* @alias intlcal_get_time
*/
public function getTime() {}
public function getType() {}
/**
- * @return int|false
+ * @return int
* @alias intlcal_get_weekend_transition
*/
public function getWeekendTransition(int $dayOfWeek) {}
public function setGregorianChange(float $change) {}
/**
- * @return float|false
+ * @return float
* @alias intlgregcal_get_gregorian_change
*/
public function getGregorianChange() {}
/* 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()
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,
RETURN_THROWS();
}
- //does not work; see ICU bug 9194
-#if 0
StringEnumeration *se = Calendar::getKeywordValuesForLocale(key,
Locale::createFromName(locale), (UBool)commonly_used,
status);
"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);
}
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(),
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;
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)
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;
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));
}
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]);
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;
}
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));
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);
}
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;
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)
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;
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(),
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;
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)
}
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;
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)
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)
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;
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;
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;
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;
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;
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));
}
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;
}
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;
}
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);
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);
// 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();
}
}
}
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;
&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()" );
&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()" );
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 {}
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 {}
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 {}
/* 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")
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()
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)
#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()
#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()
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)
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)
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()
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
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
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
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
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
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
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
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
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
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
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
$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
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
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