Skip to content

Commit 5f67bac

Browse files
ext/intl: Fix compile issues with ICU versions lower than 67 (#18868)
1 parent ee1bbcf commit 5f67bac

File tree

4 files changed

+44
-6
lines changed

4 files changed

+44
-6
lines changed

ext/intl/listformatter/listformatter.stub.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,13 @@
88
*/
99
final class IntlListFormatter {
1010

11+
#if U_ICU_VERSION_MAJOR_NUM >= 67
1112
/** @cvalue ULISTFMT_TYPE_AND */
1213
public const int TYPE_AND = UNKNOWN;
14+
#else
15+
/** @cvalue INTL_LISTFORMATTER_FALLBACK_TYPE_AND */
16+
public const int TYPE_AND = UNKNOWN;
17+
#endif
1318

1419
#if U_ICU_VERSION_MAJOR_NUM >= 67
1520
/** @cvalue ULISTFMT_TYPE_OR */
@@ -19,8 +24,13 @@ final class IntlListFormatter {
1924
public const int TYPE_UNITS = UNKNOWN;
2025
#endif
2126

27+
#if U_ICU_VERSION_MAJOR_NUM >= 67
2228
/** @cvalue ULISTFMT_WIDTH_WIDE */
2329
public const int WIDTH_WIDE = UNKNOWN;
30+
#else
31+
/** @cvalue INTL_LISTFORMATTER_FALLBACK_WIDTH_WIDE */
32+
public const int WIDTH_WIDE = UNKNOWN;
33+
#endif
2434

2535
#if U_ICU_VERSION_MAJOR_NUM >= 67
2636
/** @cvalue ULISTFMT_WIDTH_SHORT */

ext/intl/listformatter/listformatter_arginfo.h

Lines changed: 21 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ext/intl/listformatter/listformatter_class.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
#include "php.h"
1616
#include "php_intl.h"
1717
#include <unicode/ulistformatter.h>
18-
#include "listformatter_arginfo.h"
1918
#include "listformatter_class.h"
19+
#include "listformatter_arginfo.h"
2020
#include "intl_convert.h"
2121

2222
static zend_object_handlers listformatter_handlers;
@@ -53,8 +53,13 @@ PHP_METHOD(IntlListFormatter, __construct)
5353
ListFormatter_object *obj = Z_INTL_LISTFORMATTER_P(ZEND_THIS);
5454
char* locale;
5555
size_t locale_len = 0;
56-
zend_long type = ULISTFMT_TYPE_AND;
57-
zend_long width = ULISTFMT_WIDTH_WIDE;
56+
#if U_ICU_VERSION_MAJOR_NUM >= 67
57+
zend_long type = ULISTFMT_TYPE_AND;
58+
zend_long width = ULISTFMT_WIDTH_WIDE;
59+
#else
60+
zend_long type = INTL_LISTFORMATTER_FALLBACK_TYPE_AND;
61+
zend_long width = INTL_LISTFORMATTER_FALLBACK_WIDTH_WIDE;
62+
#endif
5863
ZEND_PARSE_PARAMETERS_START(1, 3)
5964
Z_PARAM_STRING(locale, locale_len)
6065
Z_PARAM_OPTIONAL
@@ -90,12 +95,12 @@ PHP_METHOD(IntlListFormatter, __construct)
9095

9196
LISTFORMATTER_OBJECT(obj) = ulistfmt_openForType(locale, type, width, &status);
9297
#else
93-
if (type != ULISTFMT_TYPE_AND) {
98+
if (type != INTL_LISTFORMATTER_FALLBACK_TYPE_AND) {
9499
zend_argument_value_error(2, "contains an unsupported type. ICU 66 and below only support IntlListFormatter::TYPE_AND");
95100
RETURN_THROWS();
96101
}
97102

98-
if (width != ULISTFMT_WIDTH_WIDE) {
103+
if (width != INTL_LISTFORMATTER_FALLBACK_WIDTH_WIDE) {
99104
zend_argument_value_error(3, "contains an unsupported width. ICU 66 and below only support IntlListFormatter::WIDTH_WIDE");
100105
RETURN_THROWS();
101106
}

ext/intl/listformatter/listformatter_class.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,7 @@ static inline ListFormatter_object *php_intl_listformatter_fetch_object(zend_obj
4949
void listformatter_register_class( void );
5050
extern zend_class_entry *ListFormatter_ce_ptr;
5151

52+
#define INTL_LISTFORMATTER_FALLBACK_TYPE_AND 0
53+
#define INTL_LISTFORMATTER_FALLBACK_WIDTH_WIDE 0
54+
5255
#endif // LISTFORMATTER_CLASS_H

0 commit comments

Comments
 (0)