Skip to content

Commit 386a467

Browse files
authored
ext/intl: fix build with older ICU (#23539)
Covariant return types for clone() were only introduced in ICU 65; before that NumberFormat::clone() returns Format*, so cast the result explicitly in NumberFormatter_object_clone(). <unicode/numberrangeformatter.h> is a C++-only header, and older ICU does not wrap it in U_SHOW_CPLUSPLUS_API, so including it from php_intl.c breaks the C compile. Move it into the __cplusplus branch, next to the using declaration that needs it.
1 parent 78c33e0 commit 386a467

2 files changed

Lines changed: 2 additions & 3 deletions

File tree

ext/intl/formatter/formatter_class.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ U_CFUNC zend_object *NumberFormatter_object_clone(zend_object *object)
7171

7272
/* clone formatter object. It may fail, the destruction code must handle this case */
7373
if (FORMATTER_OBJECT(nfo) != nullptr) {
74-
FORMATTER_OBJECT(new_nfo) = FORMATTER_OBJECT(nfo)->clone();
74+
FORMATTER_OBJECT(new_nfo) = static_cast<NumberFormat *>(FORMATTER_OBJECT(nfo)->clone());
7575
if (FORMATTER_OBJECT(new_nfo) == nullptr) {
7676
zend_throw_error(NULL, "Failed to clone NumberFormatter");
7777
}

ext/intl/rangeformatter/rangeformatter_class.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@
1515
#ifndef RANGEFORMATTER_CLASS_H
1616
#define RANGEFORMATTER_CLASS_H
1717

18-
#include <unicode/numberrangeformatter.h>
19-
2018
#ifdef __cplusplus
19+
#include <unicode/numberrangeformatter.h>
2120
using icu::number::LocalizedNumberRangeFormatter;
2221
#else
2322
typedef void LocalizedNumberRangeFormatter;

0 commit comments

Comments
 (0)