1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

ext/intl: Do not register IntlNumberRangeFormatter on ICU 62 or lower (#20197)

This commit is contained in:
Bogdan Ungureanu
2025-10-17 22:09:14 +03:00
committed by GitHub
parent 26c96d38f4
commit d4f3ae90d2
4 changed files with 4 additions and 21 deletions

View File

@@ -190,9 +190,10 @@ PHP_MINIT_FUNCTION( intl )
/* Register 'ListFormatter' PHP class */
listformatter_register_class( );
#if U_ICU_VERSION_MAJOR_NUM >= 63
/* Register 'NumberRangeFormatter' PHP class */
rangeformatter_register_class( );
#endif
/* Register 'Normalizer' PHP class */
normalizer_register_Normalizer_class( );

View File

@@ -23,7 +23,6 @@ extern "C" {
#include <unicode/numberformatter.h>
#include <unicode/unistr.h>
#include "../intl_convertcpp.h"
#endif
extern "C" {
#include "../intl_error.h"
@@ -34,14 +33,12 @@ extern "C" {
#include "intl_convert.h"
}
#if U_ICU_VERSION_MAJOR_NUM >= 63
using icu::number::NumberRangeFormatter;
using icu::number::NumberFormatter;
using icu::number::UnlocalizedNumberFormatter;
using icu::number::LocalizedNumberRangeFormatter;
using icu::UnicodeString;
using icu::MeasureUnit;
#endif
static zend_object_handlers rangeformatter_handlers;
zend_class_entry *class_entry_IntlNumberRangeFormatter;
@@ -71,10 +68,6 @@ U_CFUNC PHP_METHOD(IntlNumberRangeFormatter, __construct)
U_CFUNC PHP_METHOD(IntlNumberRangeFormatter, createFromSkeleton)
{
#if U_ICU_VERSION_MAJOR_NUM < 63
zend_throw_error(NULL, "IntlNumberRangeFormatter is not available in ICU 62 and earlier");
RETURN_THROWS();
#else
char* skeleton;
char* locale;
size_t locale_len;
@@ -145,15 +138,10 @@ U_CFUNC PHP_METHOD(IntlNumberRangeFormatter, createFromSkeleton)
RANGEFORMATTER_OBJECT(php_intl_numberrangeformatter_fetch_object(obj)) = nrf;
RETURN_OBJ(obj);
#endif
}
U_CFUNC PHP_METHOD(IntlNumberRangeFormatter, format)
{
#if U_ICU_VERSION_MAJOR_NUM < 63
zend_throw_error(NULL, "IntlNumberRangeFormatter is not available in ICU 62 and earlier");
RETURN_THROWS();
#else
zval *start;
zval *end;
@@ -191,7 +179,6 @@ U_CFUNC PHP_METHOD(IntlNumberRangeFormatter, format)
INTL_G(error_level) = old_error_level;
RETVAL_NEW_STR(ret);
#endif
}
U_CFUNC PHP_METHOD(IntlNumberRangeFormatter, getErrorCode)
@@ -236,3 +223,4 @@ void rangeformatter_register_class(void)
rangeformatter_handlers.free_obj = IntlNumberRangeFormatter_object_free;
rangeformatter_handlers.clone_obj = NULL;
}
#endif

View File

@@ -15,7 +15,6 @@
#ifndef RANGEFORMATTER_CLASS_H
#define RANGEFORMATTER_CLASS_H
#if U_ICU_VERSION_MAJOR_NUM >= 63
#include <unicode/numberrangeformatter.h>
#ifdef __cplusplus
@@ -23,18 +22,13 @@ using icu::number::LocalizedNumberRangeFormatter;
#else
typedef void LocalizedNumberRangeFormatter;
#endif
#endif // U_ICU_VERSION_MAJOR_NUM >= 63
typedef struct {
// error handling
intl_error error;
// formatter handling
#if U_ICU_VERSION_MAJOR_NUM >= 63
LocalizedNumberRangeFormatter* unumrf;
#else
void* unumrf;
#endif
} rangeformatter_data;
typedef struct {

View File

@@ -23,4 +23,4 @@ try {
}
?>
--EXPECT--
IntlNumberRangeFormatter is not available in ICU 62 and earlier
Class "IntlNumberRangeFormatter" not found