Skip to content

Commit d4f3ae9

Browse files
ext/intl: Do not register IntlNumberRangeFormatter on ICU 62 or lower (php#20197)
1 parent 26c96d3 commit d4f3ae9

File tree

4 files changed

+4
-21
lines changed

4 files changed

+4
-21
lines changed

ext/intl/php_intl.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,10 @@ PHP_MINIT_FUNCTION( intl )
190190
/* Register 'ListFormatter' PHP class */
191191
listformatter_register_class( );
192192

193+
#if U_ICU_VERSION_MAJOR_NUM >= 63
193194
/* Register 'NumberRangeFormatter' PHP class */
194195
rangeformatter_register_class( );
195-
196+
#endif
196197
/* Register 'Normalizer' PHP class */
197198
normalizer_register_Normalizer_class( );
198199

ext/intl/rangeformatter/rangeformatter_class.cpp

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ extern "C" {
2323
#include <unicode/numberformatter.h>
2424
#include <unicode/unistr.h>
2525
#include "../intl_convertcpp.h"
26-
#endif
2726

2827
extern "C" {
2928
#include "../intl_error.h"
@@ -34,14 +33,12 @@ extern "C" {
3433
#include "intl_convert.h"
3534
}
3635

37-
#if U_ICU_VERSION_MAJOR_NUM >= 63
3836
using icu::number::NumberRangeFormatter;
3937
using icu::number::NumberFormatter;
4038
using icu::number::UnlocalizedNumberFormatter;
4139
using icu::number::LocalizedNumberRangeFormatter;
4240
using icu::UnicodeString;
4341
using icu::MeasureUnit;
44-
#endif
4542

4643
static zend_object_handlers rangeformatter_handlers;
4744
zend_class_entry *class_entry_IntlNumberRangeFormatter;
@@ -71,10 +68,6 @@ U_CFUNC PHP_METHOD(IntlNumberRangeFormatter, __construct)
7168

7269
U_CFUNC PHP_METHOD(IntlNumberRangeFormatter, createFromSkeleton)
7370
{
74-
#if U_ICU_VERSION_MAJOR_NUM < 63
75-
zend_throw_error(NULL, "IntlNumberRangeFormatter is not available in ICU 62 and earlier");
76-
RETURN_THROWS();
77-
#else
7871
char* skeleton;
7972
char* locale;
8073
size_t locale_len;
@@ -145,15 +138,10 @@ U_CFUNC PHP_METHOD(IntlNumberRangeFormatter, createFromSkeleton)
145138
RANGEFORMATTER_OBJECT(php_intl_numberrangeformatter_fetch_object(obj)) = nrf;
146139

147140
RETURN_OBJ(obj);
148-
#endif
149141
}
150142

151143
U_CFUNC PHP_METHOD(IntlNumberRangeFormatter, format)
152144
{
153-
#if U_ICU_VERSION_MAJOR_NUM < 63
154-
zend_throw_error(NULL, "IntlNumberRangeFormatter is not available in ICU 62 and earlier");
155-
RETURN_THROWS();
156-
#else
157145
zval *start;
158146
zval *end;
159147

@@ -191,7 +179,6 @@ U_CFUNC PHP_METHOD(IntlNumberRangeFormatter, format)
191179
INTL_G(error_level) = old_error_level;
192180

193181
RETVAL_NEW_STR(ret);
194-
#endif
195182
}
196183

197184
U_CFUNC PHP_METHOD(IntlNumberRangeFormatter, getErrorCode)
@@ -236,3 +223,4 @@ void rangeformatter_register_class(void)
236223
rangeformatter_handlers.free_obj = IntlNumberRangeFormatter_object_free;
237224
rangeformatter_handlers.clone_obj = NULL;
238225
}
226+
#endif

ext/intl/rangeformatter/rangeformatter_class.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,20 @@
1515
#ifndef RANGEFORMATTER_CLASS_H
1616
#define RANGEFORMATTER_CLASS_H
1717

18-
#if U_ICU_VERSION_MAJOR_NUM >= 63
1918
#include <unicode/numberrangeformatter.h>
2019

2120
#ifdef __cplusplus
2221
using icu::number::LocalizedNumberRangeFormatter;
2322
#else
2423
typedef void LocalizedNumberRangeFormatter;
2524
#endif
26-
#endif // U_ICU_VERSION_MAJOR_NUM >= 63
2725

2826
typedef struct {
2927
// error handling
3028
intl_error error;
3129

3230
// formatter handling
33-
#if U_ICU_VERSION_MAJOR_NUM >= 63
3431
LocalizedNumberRangeFormatter* unumrf;
35-
#else
36-
void* unumrf;
37-
#endif
3832
} rangeformatter_data;
3933

4034
typedef struct {

ext/intl/tests/rangeformatter/rangeformatter_icu63_compatibility.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ try {
2323
}
2424
?>
2525
--EXPECT--
26-
IntlNumberRangeFormatter is not available in ICU 62 and earlier
26+
Class "IntlNumberRangeFormatter" not found

0 commit comments

Comments
 (0)