Skip to content

Commit 0fe6724

Browse files
committed
Rethink the version checks
As the actual behavior change happens with ICU >= 58, the new functionality should stay same in the lower versions. This comply also with lower PHP versions so far.
1 parent 2b43c62 commit 0fe6724

File tree

6 files changed

+7
-11
lines changed

6 files changed

+7
-11
lines changed

ext/intl/spoofchecker/spoofchecker.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,12 @@ void spoofchecker_register_constants(INIT_FUNC_ARGS)
4545
SPOOFCHECKER_EXPOSE_CLASS_CONST(INVISIBLE)
4646
SPOOFCHECKER_EXPOSE_CLASS_CONST(CHAR_LIMIT)
4747

48-
#if U_ICU_VERSION_MAJOR_NUM >= 51
48+
#if U_ICU_VERSION_MAJOR_NUM >= 58
4949
SPOOFCHECKER_EXPOSE_CLASS_CONST(ASCII)
5050
SPOOFCHECKER_EXPOSE_CLASS_CONST(HIGHLY_RESTRICTIVE)
5151
SPOOFCHECKER_EXPOSE_CLASS_CONST(MODERATELY_RESTRICTIVE)
5252
SPOOFCHECKER_EXPOSE_CLASS_CONST(MINIMALLY_RESTRICTIVE)
5353
SPOOFCHECKER_EXPOSE_CLASS_CONST(UNRESTRICTIVE)
54-
#endif
55-
#if U_ICU_VERSION_MAJOR_NUM >= 53
5654
SPOOFCHECKER_EXPOSE_CLASS_CONST(SINGLE_SCRIPT_RESTRICTIVE)
5755
#endif
5856

ext/intl/spoofchecker/spoofchecker_class.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ 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
87+
#if U_ICU_VERSION_MAJOR_NUM >= 58
8888
ZEND_BEGIN_ARG_INFO_EX(spoofchecker_set_restriction_level, 0, 0, 1)
8989
ZEND_ARG_INFO(0, level)
9090
ZEND_END_ARG_INFO()
@@ -102,7 +102,7 @@ zend_function_entry Spoofchecker_class_functions[] = {
102102
PHP_ME(Spoofchecker, areConfusable, spoofchecker_are_confusable, ZEND_ACC_PUBLIC)
103103
PHP_ME(Spoofchecker, setAllowedLocales, spoofchecker_set_allowed_locales, ZEND_ACC_PUBLIC)
104104
PHP_ME(Spoofchecker, setChecks, spoofchecker_set_checks, ZEND_ACC_PUBLIC)
105-
#if U_ICU_VERSION_MAJOR_NUM >= 51
105+
#if U_ICU_VERSION_MAJOR_NUM >= 58
106106
PHP_ME(Spoofchecker, setRestrictionLevel, spoofchecker_set_restriction_level, ZEND_ACC_PUBLIC)
107107
#endif
108108
PHP_FE_END

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 >= 51
81+
#if U_ICU_VERSION_MAJOR_NUM >= 58
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 >= 51
46+
#if U_ICU_VERSION_MAJOR_NUM >= 58
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: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ PHP_METHOD(Spoofchecker, setChecks)
134134
}
135135
/* }}} */
136136

137-
#if U_ICU_VERSION_MAJOR_NUM >= 51
137+
#if U_ICU_VERSION_MAJOR_NUM >= 58
138138
/* {{{ proto void Spoofchecker::setRestrictionLevel( int $restriction_level )
139139
* Set the loosest restriction level allowed for strings.
140140
*/
@@ -150,9 +150,7 @@ PHP_METHOD(Spoofchecker, setRestrictionLevel)
150150
SPOOFCHECKER_METHOD_FETCH_OBJECT;
151151

152152
if (USPOOF_ASCII != level &&
153-
#if U_ICU_VERSION_MAJOR_NUM >= 53
154153
USPOOF_SINGLE_SCRIPT_RESTRICTIVE != level &&
155-
#endif
156154
USPOOF_HIGHLY_RESTRICTIVE != level &&
157155
USPOOF_MODERATELY_RESTRICTIVE != level &&
158156
USPOOF_MINIMALLY_RESTRICTIVE != level &&

ext/intl/spoofchecker/spoofchecker_main.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ 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
26+
#if U_ICU_VERSION_MAJOR_NUM >= 58
2727
PHP_METHOD(Spoofchecker, setRestrictionLevel);
2828
#endif
2929

0 commit comments

Comments
 (0)