Skip to content

Commit 7959359

Browse files
committed
Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4: ext/intl: Expose Spoofchecker restriction-level APIs on all supported ICU versions
2 parents c8c48f5 + 4f94715 commit 7959359

7 files changed

Lines changed: 40 additions & 26 deletions

ext/intl/spoofchecker/spoofchecker.stub.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ class Spoofchecker
1919
public const int INVISIBLE = UNKNOWN;
2020
/** @cvalue USPOOF_CHAR_LIMIT */
2121
public const int CHAR_LIMIT = UNKNOWN;
22-
#if U_ICU_VERSION_MAJOR_NUM >= 58
2322
/** @cvalue USPOOF_ASCII */
2423
public const int ASCII = UNKNOWN;
2524
/** @cvalue USPOOF_HIGHLY_RESTRICTIVE */
@@ -34,7 +33,6 @@ class Spoofchecker
3433
public const int SINGLE_SCRIPT_RESTRICTIVE = UNKNOWN;
3534
/** @cvalue USPOOF_MIXED_NUMBERS */
3635
public const int MIXED_NUMBERS = UNKNOWN;
37-
#endif
3836
#if U_ICU_VERSION_MAJOR_NUM >= 62
3937
/** @cvalue USPOOF_HIDDEN_OVERLAY */
4038
public const int HIDDEN_OVERLAY = UNKNOWN;
@@ -71,9 +69,7 @@ public function setAllowedLocales(string $locales): void {}
7169
/** @tentative-return-type */
7270
public function setChecks(int $checks): void {}
7371

74-
#if U_ICU_VERSION_MAJOR_NUM >= 58
7572
/** @tentative-return-type */
7673
public function setRestrictionLevel(int $level): void {}
77-
#endif
7874
public function setAllowedChars(string $pattern, int $patternOptions = 0): void {}
7975
}

ext/intl/spoofchecker/spoofchecker_arginfo.h

Lines changed: 1 addition & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ext/intl/spoofchecker/spoofchecker_main.c

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

138-
#if U_ICU_VERSION_MAJOR_NUM >= 58
139138
/* TODO Document this method on PHP.net */
140139
/* {{{ Set the loosest restriction level allowed for strings. */
141140
PHP_METHOD(Spoofchecker, setRestrictionLevel)
@@ -164,7 +163,6 @@ PHP_METHOD(Spoofchecker, setRestrictionLevel)
164163
uspoof_setRestrictionLevel(co->uspoof, (URestrictionLevel)level);
165164
}
166165
/* }}} */
167-
#endif
168166

169167
PHP_METHOD(Spoofchecker, setAllowedChars)
170168
{
@@ -208,9 +206,9 @@ PHP_METHOD(Spoofchecker, setAllowedChars)
208206
#endif
209207
pattern_option != (USET_IGNORE_SPACE|USET_CASE_INSENSITIVE) &&
210208
pattern_option != (USET_IGNORE_SPACE|USET_ADD_CASE_MAPPINGS)) {
211-
zend_argument_value_error(2, "must be a valid pattern option, 0 or (SpoofChecker::IGNORE_SPACE|(<none> or SpoofChecker::USET_CASE_INSENSITIVE or SpoofChecker::USET_ADD_CASE_MAPPINGS"
209+
zend_argument_value_error(2, "must be a valid pattern option, 0 or (SpoofChecker::IGNORE_SPACE|(<none> or SpoofChecker::CASE_INSENSITIVE or SpoofChecker::ADD_CASE_MAPPINGS"
212210
#if U_ICU_VERSION_MAJOR_NUM >= 73
213-
" or SpoofChecker::USET_SIMPLE_CASE_INSENSITIVE"
211+
" or SpoofChecker::SIMPLE_CASE_INSENSITIVE"
214212
#endif
215213
"))"
216214
);

ext/intl/tests/spoofchecker_007.phpt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,6 @@ spoofchecker with restriction level
44
intl
55
--SKIPIF--
66
<?php if(!class_exists("Spoofchecker")) print 'skip'; ?>
7-
<?php
8-
$r = new ReflectionClass("SpoofChecker");
9-
if (false === $r->getConstant("SINGLE_SCRIPT_RESTRICTIVE")) {
10-
die("skip Incompatible ICU version");
11-
}
12-
?>
137
--FILE--
148
<?php
159

ext/intl/tests/spoofchecker_008.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,6 @@ try {
3939
bool(true)
4040
bool(false)
4141
bool(false)
42-
Spoofchecker::setAllowedChars(): Argument #2 ($patternOptions) must be a valid pattern option, 0 or (SpoofChecker::IGNORE_SPACE|(<none> or SpoofChecker::USET_CASE_INSENSITIVE%s))
42+
Spoofchecker::setAllowedChars(): Argument #2 ($patternOptions) must be a valid pattern option, 0 or (SpoofChecker::IGNORE_SPACE|(<none> or SpoofChecker::CASE_INSENSITIVE%s))
4343
Spoofchecker::setAllowedChars(): Argument #1 ($pattern) must be a valid regular expression character set pattern
4444
Spoofchecker::setAllowedChars(): Argument #1 ($pattern) must be a valid regular expression character set pattern
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
--TEST--
2+
Spoofchecker exposes restriction-level APIs on all supported ICU versions
3+
--EXTENSIONS--
4+
intl
5+
--SKIPIF--
6+
<?php if (!class_exists("Spoofchecker")) print 'skip'; ?>
7+
--FILE--
8+
<?php
9+
$r = new ReflectionClass("Spoofchecker");
10+
11+
$ascii = $r->getConstant("ASCII");
12+
$singleScriptRestrictive = $r->getConstant("SINGLE_SCRIPT_RESTRICTIVE");
13+
$mixedNumbers = $r->getConstant("MIXED_NUMBERS");
14+
15+
var_dump($ascii !== false);
16+
var_dump($singleScriptRestrictive !== false);
17+
var_dump($mixedNumbers !== false);
18+
var_dump(is_int($ascii));
19+
var_dump(is_int($singleScriptRestrictive));
20+
var_dump(is_int($mixedNumbers));
21+
var_dump($ascii !== $singleScriptRestrictive);
22+
var_dump($ascii !== $mixedNumbers);
23+
var_dump($singleScriptRestrictive !== $mixedNumbers);
24+
var_dump($r->hasMethod("setRestrictionLevel"));
25+
?>
26+
--EXPECT--
27+
bool(true)
28+
bool(true)
29+
bool(true)
30+
bool(true)
31+
bool(true)
32+
bool(true)
33+
bool(true)
34+
bool(true)
35+
bool(true)
36+
bool(true)

ext/intl/tests/spoofchecker_unknown_restriction_level.phpt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ intl
55
--SKIPIF--
66
<?php
77
if (!class_exists("Spoofchecker")) print 'skip';
8-
9-
if (!method_exists(new Spoofchecker(), 'setRestrictionLevel')) print 'skip ICU version < 58';
108
?>
119
--FILE--
1210
<?php

0 commit comments

Comments
 (0)