Skip to content

Commit ed93fb8

Browse files
committed
Drop bubble up todo with warning, albeit can't seem to hit this
1 parent cacb143 commit ed93fb8

File tree

2 files changed

+33
-10
lines changed

2 files changed

+33
-10
lines changed

ext/intl/calendar/calendar_methods.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,11 +1079,7 @@ U_CFUNC PHP_FUNCTION(intlcal_to_date_time)
10791079
object_init_ex(return_value, php_date_get_date_ce());
10801080
zend_call_known_instance_method_with_2_params(
10811081
Z_OBJCE_P(return_value)->constructor, Z_OBJ_P(return_value), NULL, &ts_zval, timezone_zval);
1082-
// TODO Bubble up exception?
10831082
if (EG(exception)) {
1084-
intl_errors_set(CALENDAR_ERROR_P(co), U_ILLEGAL_ARGUMENT_ERROR,
1085-
"intlcal_to_date_time: DateTime constructor has thrown exception",
1086-
1);
10871083
zend_object_store_ctor_failed(Z_OBJ_P(return_value));
10881084
zval_ptr_dtor(return_value);
10891085
zval_ptr_dtor(&ts_zval);

ext/intl/tests/calendar_toDateTime_error.phpt

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,40 @@ var_dump($cal->toDateTime());
1616
var_dump("exception: {$e->getMessage()}");
1717
}
1818

19-
var_dump(intlcal_to_date_time(3));
19+
try {
20+
var_dump(intlcal_to_date_time($cal));
21+
} catch (\Exception $e) {
22+
var_dump($e->getMessage());
23+
}
24+
25+
$cal = IntlCalendar::createInstance("Etc/Unknown");
26+
try {
27+
var_dump($cal->toDateTime());
28+
} catch (\Exception $e) {
29+
var_dump($e->getMessage());
30+
}
31+
32+
try {
33+
var_dump(intlcal_to_date_time($cal));
34+
} catch (\Exception $e) {
35+
var_dump($e->getMessage());
36+
}
37+
38+
try {
39+
var_dump(intlcal_to_date_time(3));
40+
} catch (\TypeError $e) {
41+
echo $e->getMessage() . \PHP_EOL;
42+
}
2043
--EXPECTF--
2144
Warning: IntlCalendar::toDateTime(): intlcal_to_date_time: DateTimeZone constructor threw exception in %s on line %d
2245
string(77) "exception: DateTimeZone::__construct(): Unknown or bad timezone (Etc/Unknown)"
2346

24-
Fatal error: Uncaught TypeError: intlcal_to_date_time(): Argument #1 ($calendar) must be of type IntlCalendar, int given in %s:%d
25-
Stack trace:
26-
#0 %s(%d): intlcal_to_date_time(3)
27-
#1 {main}
28-
thrown in %s on line %d
47+
Warning: intlcal_to_date_time(): intlcal_to_date_time: DateTimeZone constructor threw exception in %s on line %d
48+
string(66) "DateTimeZone::__construct(): Unknown or bad timezone (Etc/Unknown)"
49+
50+
Warning: IntlCalendar::toDateTime(): intlcal_to_date_time: DateTimeZone constructor threw exception in %s on line %d
51+
string(66) "DateTimeZone::__construct(): Unknown or bad timezone (Etc/Unknown)"
52+
53+
Warning: intlcal_to_date_time(): intlcal_to_date_time: DateTimeZone constructor threw exception in %s on line %d
54+
string(66) "DateTimeZone::__construct(): Unknown or bad timezone (Etc/Unknown)"
55+
intlcal_to_date_time(): Argument #1 ($calendar) must be of type IntlCalendar, int given

0 commit comments

Comments
 (0)