Skip to content

Commit 3ce3e96

Browse files
committed
Proper ICU version check for restriction levels availability
1 parent c35f693 commit 3ce3e96

File tree

5 files changed

+10
-2
lines changed

5 files changed

+10
-2
lines changed

ext/intl/spoofchecker/spoofchecker_class.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,11 @@ ZEND_BEGIN_ARG_INFO_EX(spoofchecker_are_confusable, 0, 0, 2)
8484
ZEND_ARG_INFO(1, error)
8585
ZEND_END_ARG_INFO()
8686

87+
#if U_ICU_VERSION_MAJOR_NUM >= 51
8788
ZEND_BEGIN_ARG_INFO_EX(spoofchecker_set_restriction_level, 0, 0, 1)
8889
ZEND_ARG_INFO(0, level)
8990
ZEND_END_ARG_INFO()
91+
#endif
9092

9193
/* }}} */
9294

@@ -100,7 +102,9 @@ zend_function_entry Spoofchecker_class_functions[] = {
100102
PHP_ME(Spoofchecker, areConfusable, spoofchecker_are_confusable, ZEND_ACC_PUBLIC)
101103
PHP_ME(Spoofchecker, setAllowedLocales, spoofchecker_set_allowed_locales, ZEND_ACC_PUBLIC)
102104
PHP_ME(Spoofchecker, setChecks, spoofchecker_set_checks, ZEND_ACC_PUBLIC)
105+
#if U_ICU_VERSION_MAJOR_NUM >= 51
103106
PHP_ME(Spoofchecker, setRestrictionLevel, spoofchecker_set_restriction_level, ZEND_ACC_PUBLIC)
107+
#endif
104108
PHP_FE_END
105109
};
106110
/* }}} */

ext/intl/spoofchecker/spoofchecker_class.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ extern zend_class_entry *Spoofchecker_ce_ptr;
7878
RETURN_FALSE; \
7979
} \
8080

81-
#if U_ICU_VERSION_MAJOR_NUM >= 58
81+
#if U_ICU_VERSION_MAJOR_NUM >= 51
8282
#define SPOOFCHECKER_DEFAULT_RESTRICTION_LEVEL USPOOF_HIGHLY_RESTRICTIVE
8383
#endif
8484

ext/intl/spoofchecker/spoofchecker_create.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ PHP_METHOD(Spoofchecker, __construct)
4343
co->uspoof = uspoof_open(SPOOFCHECKER_ERROR_CODE_P(co));
4444
INTL_METHOD_CHECK_STATUS(co, "spoofchecker: unable to open ICU Spoof Checker");
4545

46-
#if U_ICU_VERSION_MAJOR_NUM >= 58
46+
#if U_ICU_VERSION_MAJOR_NUM >= 51
4747
/* TODO save it into the object for further suspiction check comparison. */
4848
/* ICU 58 removes WSC and MSC handling. However there are restriction
4949
levels as defined in

ext/intl/spoofchecker/spoofchecker_main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ PHP_METHOD(Spoofchecker, setChecks)
134134
}
135135
/* }}} */
136136

137+
#if U_ICU_VERSION_MAJOR_NUM >= 53
137138
/* {{{ proto void Spoofchecker::setRestrictionLevel( int $restriction_level )
138139
* Set the loosest restriction level allowed for strings.
139140
*/
@@ -163,6 +164,7 @@ PHP_METHOD(Spoofchecker, setRestrictionLevel)
163164
uspoof_setRestrictionLevel(co->uspoof, (URestrictionLevel)level);
164165
}
165166
/* }}} */
167+
#endif
166168

167169
/*
168170
* Local variables:

ext/intl/spoofchecker/spoofchecker_main.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ PHP_METHOD(Spoofchecker, isSuspicious);
2323
PHP_METHOD(Spoofchecker, areConfusable);
2424
PHP_METHOD(Spoofchecker, setAllowedLocales);
2525
PHP_METHOD(Spoofchecker, setChecks);
26+
#if U_ICU_VERSION_MAJOR_NUM >= 51
2627
PHP_METHOD(Spoofchecker, setRestrictionLevel);
28+
#endif
2729

2830
#endif // SPOOFCHECKER_MAIN_H

0 commit comments

Comments
 (0)