Skip to content

Commit 2163ea6

Browse files
committed
ext/intl: GregorianCalendar using C++ upcasting operator.
when fetching the internal ICU object also removing one useless cast.
1 parent d292968 commit 2163ea6

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

ext/intl/calendar/calendar_class.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ U_CFUNC void calendar_object_construct(zval *object,
7171

7272
CALENDAR_METHOD_FETCH_OBJECT_NO_CHECK; //populate to from object
7373
assert(co->ucal == NULL);
74-
co->ucal = (Calendar*)calendar;
74+
co->ucal = calendar;
7575
}
7676

7777
/* {{{ clone handler for Calendar */

ext/intl/calendar/gregoriancalendar_methods.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ using icu::StringPiece;
4646
}
4747

4848
static inline GregorianCalendar *fetch_greg(Calendar_object *co) {
49-
return (GregorianCalendar*)co->ucal;
49+
GregorianCalendar *gcal = dynamic_cast<GregorianCalendar *>(co->ucal);
50+
ZEND_ASSERT(gcal != NULL);
51+
return gcal;
5052
}
5153

5254
static bool set_gregorian_calendar_time_zone(GregorianCalendar *gcal, UErrorCode status)

0 commit comments

Comments
 (0)