From 7cee3e61b25d5db23ed242830a74b01fad2bea9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Wed, 2 Sep 2026 07:51:13 +0200 Subject: [PATCH] ext/intl: fix build with older ICU 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(). 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. --- ext/intl/formatter/formatter_class.cpp | 2 +- ext/intl/rangeformatter/rangeformatter_class.h | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/ext/intl/formatter/formatter_class.cpp b/ext/intl/formatter/formatter_class.cpp index 5b82b53c6d62..29817132acac 100644 --- a/ext/intl/formatter/formatter_class.cpp +++ b/ext/intl/formatter/formatter_class.cpp @@ -71,7 +71,7 @@ U_CFUNC zend_object *NumberFormatter_object_clone(zend_object *object) /* clone formatter object. It may fail, the destruction code must handle this case */ if (FORMATTER_OBJECT(nfo) != nullptr) { - FORMATTER_OBJECT(new_nfo) = FORMATTER_OBJECT(nfo)->clone(); + FORMATTER_OBJECT(new_nfo) = static_cast(FORMATTER_OBJECT(nfo)->clone()); if (FORMATTER_OBJECT(new_nfo) == nullptr) { zend_throw_error(NULL, "Failed to clone NumberFormatter"); } diff --git a/ext/intl/rangeformatter/rangeformatter_class.h b/ext/intl/rangeformatter/rangeformatter_class.h index 494a6d09a05f..4b6f02dc93c9 100644 --- a/ext/intl/rangeformatter/rangeformatter_class.h +++ b/ext/intl/rangeformatter/rangeformatter_class.h @@ -15,9 +15,8 @@ #ifndef RANGEFORMATTER_CLASS_H #define RANGEFORMATTER_CLASS_H -#include - #ifdef __cplusplus +#include using icu::number::LocalizedNumberRangeFormatter; #else typedef void LocalizedNumberRangeFormatter;