|
2 | 2 | IntlDateFormatter::formatObject(): error conditions |
3 | 3 | --EXTENSIONS-- |
4 | 4 | intl |
| 5 | +--INI-- |
| 6 | +intl.default_locale=pt_PT |
| 7 | +date.timezone=Europe/Lisbon |
5 | 8 | --FILE-- |
6 | 9 | <?php |
7 | | -ini_set("intl.error_level", E_WARNING); |
8 | | -ini_set("intl.default_locale", "pt_PT"); |
9 | | -ini_set("date.timezone", "Europe/Lisbon"); |
10 | | - |
11 | | -var_dump(IntlDateFormatter::formatObject(new stdclass)); |
12 | 10 |
|
13 | 11 | class A extends IntlCalendar {function __construct(){}} |
14 | | -var_dump(IntlDateFormatter::formatObject(new A)); |
| 12 | + |
15 | 13 | class B extends DateTime {function __construct(){}} |
| 14 | + |
| 15 | +$cal = IntlCalendar::createInstance(); |
| 16 | + |
16 | 17 | try { |
17 | 18 | var_dump(IntlDateFormatter::formatObject(new B)); |
18 | | -} catch (Error $e) { |
19 | | - echo $e->getMessage(), "\n"; |
| 19 | + var_dump(intl_get_error_message()); |
| 20 | +} catch (Throwable $e) { |
| 21 | + echo $e::class, ': ', $e->getMessage(), "\n"; |
20 | 22 | } |
21 | 23 |
|
22 | | -$cal = IntlCalendar::createInstance(); |
| 24 | +var_dump(IntlDateFormatter::formatObject(new stdclass)); |
| 25 | +var_dump(intl_get_error_message()); |
| 26 | +var_dump(IntlDateFormatter::formatObject(new A)); |
| 27 | +var_dump(intl_get_error_message()); |
| 28 | + |
23 | 29 | var_dump(IntlDateFormatter::formatObject($cal, -2)); |
| 30 | +var_dump(intl_get_error_message()); |
24 | 31 | var_dump(IntlDateFormatter::formatObject($cal, array())); |
| 32 | +var_dump(intl_get_error_message()); |
25 | 33 | var_dump(IntlDateFormatter::formatObject($cal, array(1,2,3))); |
| 34 | +var_dump(intl_get_error_message()); |
26 | 35 | var_dump(IntlDateFormatter::formatObject($cal, array(array(), 1))); |
| 36 | +var_dump(intl_get_error_message()); |
27 | 37 | var_dump(IntlDateFormatter::formatObject($cal, array(1, -2))); |
| 38 | +var_dump(intl_get_error_message()); |
28 | 39 | var_dump(IntlDateFormatter::formatObject($cal, "")); |
| 40 | +var_dump(intl_get_error_message()); |
29 | 41 |
|
30 | 42 | ?> |
31 | | ---EXPECTF-- |
32 | | -Warning: IntlDateFormatter::formatObject(): datefmt_format_object: the passed object must be an instance of either IntlCalendar or DateTimeInterface in %s on line %d |
| 43 | +--EXPECT-- |
| 44 | +DateObjectError: Object of type B (inheriting DateTime) has not been correctly initialized by calling parent::__construct() in its constructor |
33 | 45 | bool(false) |
34 | | - |
35 | | -Warning: IntlDateFormatter::formatObject(): datefmt_format_object: bad IntlCalendar instance: not initialized properly in %s on line %d |
| 46 | +string(118) "datefmt_format_object: the passed object must be an instance of either IntlCalendar or DateTimeInterface: U_ZERO_ERROR" |
36 | 47 | bool(false) |
37 | | -Object of type B (inheriting DateTime) has not been correctly initialized by calling parent::__construct() in its constructor |
38 | | - |
39 | | -Warning: IntlDateFormatter::formatObject(): datefmt_format_object: the date/time format type is invalid in %s on line %d |
| 48 | +string(100) "datefmt_format_object: bad IntlCalendar instance: not initialized properly: U_ILLEGAL_ARGUMENT_ERROR" |
40 | 49 | bool(false) |
41 | | - |
42 | | -Warning: IntlDateFormatter::formatObject(): datefmt_format_object: bad format; if array, it must have two elements in %s on line %d |
| 50 | +string(85) "datefmt_format_object: the date/time format type is invalid: U_ILLEGAL_ARGUMENT_ERROR" |
43 | 51 | bool(false) |
44 | | - |
45 | | -Warning: IntlDateFormatter::formatObject(): datefmt_format_object: bad format; if array, it must have two elements in %s on line %d |
| 52 | +string(96) "datefmt_format_object: bad format; if array, it must have two elements: U_ILLEGAL_ARGUMENT_ERROR" |
46 | 53 | bool(false) |
47 | | - |
48 | | -Warning: IntlDateFormatter::formatObject(): datefmt_format_object: bad format; the date format (first element of the array) is not valid in %s on line %d |
| 54 | +string(96) "datefmt_format_object: bad format; if array, it must have two elements: U_ILLEGAL_ARGUMENT_ERROR" |
49 | 55 | bool(false) |
50 | | - |
51 | | -Warning: IntlDateFormatter::formatObject(): datefmt_format_object: bad format; the time format (second element of the array) is not valid in %s on line %d |
| 56 | +string(118) "datefmt_format_object: bad format; the date format (first element of the array) is not valid: U_ILLEGAL_ARGUMENT_ERROR" |
52 | 57 | bool(false) |
53 | | - |
54 | | -Warning: IntlDateFormatter::formatObject(): datefmt_format_object: the format is empty in %s on line %d |
| 58 | +string(119) "datefmt_format_object: bad format; the time format (second element of the array) is not valid: U_ILLEGAL_ARGUMENT_ERROR" |
55 | 59 | bool(false) |
| 60 | +string(68) "datefmt_format_object: the format is empty: U_ILLEGAL_ARGUMENT_ERROR" |
0 commit comments