Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ PHP NEWS
. Fix incorrect argument positions in out-of-bounds errors for
IntlCalendar::set(), IntlCalendar::setDate(), IntlCalendar::setDateTime(),
and IntlGregorianCalendar date/time construction. (Weilin Du)
. Expose Spoofchecker restriction-level APIs on all supported ICU
versions. (Weilin Du)
. Fix SpoofChecker::setAllowedChars() to report PHP constant names
instead of ICU USET_* names in invalid pattern option errors.
(Weilin Du)

- MySQLnd:
. Fix persistent free of non-persistent connect_attr key (David Carlier).
Expand Down
2 changes: 2 additions & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ PHP 8.4 UPGRADE NOTES
- ValueError if the integer index does not fit in a signed 32 bit integer
. IntlDateFormatter::__construct() throws a ValueError if the locale is invalid.
. NumberFormatter::__construct() throws a ValueError if the locale is invalid.
. SpoofChecker::setAllowedChars() now reports PHP constant names instead
of ICU USET_* names in invalid pattern option errors.
. MBString:
. mb_encode_numericentity() and mb_decode_numericentity() now check that
the $map is only composed of integers, if not a ValueError is thrown.
Expand Down
4 changes: 0 additions & 4 deletions ext/intl/spoofchecker/spoofchecker.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class Spoofchecker
public const int INVISIBLE = UNKNOWN;
/** @cvalue USPOOF_CHAR_LIMIT */
public const int CHAR_LIMIT = UNKNOWN;
#if U_ICU_VERSION_MAJOR_NUM >= 58
/** @cvalue USPOOF_ASCII */
public const int ASCII = UNKNOWN;
/** @cvalue USPOOF_HIGHLY_RESTRICTIVE */
Expand All @@ -34,7 +33,6 @@ class Spoofchecker
public const int SINGLE_SCRIPT_RESTRICTIVE = UNKNOWN;
/** @cvalue USPOOF_MIXED_NUMBERS */
public const int MIXED_NUMBERS = UNKNOWN;
#endif
#if U_ICU_VERSION_MAJOR_NUM >= 62
/** @cvalue USPOOF_HIDDEN_OVERLAY */
public const int HIDDEN_OVERLAY = UNKNOWN;
Expand Down Expand Up @@ -71,9 +69,7 @@ public function setAllowedLocales(string $locales): void {}
/** @tentative-return-type */
public function setChecks(int $checks): void {}

#if U_ICU_VERSION_MAJOR_NUM >= 58
/** @tentative-return-type */
public function setRestrictionLevel(int $level): void {}
#endif
public function setAllowedChars(string $pattern, int $patternOptions = 0): void {}
}
22 changes: 1 addition & 21 deletions ext/intl/spoofchecker/spoofchecker_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions ext/intl/spoofchecker/spoofchecker_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ PHP_METHOD(Spoofchecker, setChecks)
}
/* }}} */

#if U_ICU_VERSION_MAJOR_NUM >= 58
/* TODO Document this method on PHP.net */
/* {{{ Set the loosest restriction level allowed for strings. */
PHP_METHOD(Spoofchecker, setRestrictionLevel)
Expand Down Expand Up @@ -164,7 +163,6 @@ PHP_METHOD(Spoofchecker, setRestrictionLevel)
uspoof_setRestrictionLevel(co->uspoof, (URestrictionLevel)level);
}
/* }}} */
#endif

PHP_METHOD(Spoofchecker, setAllowedChars)
{
Expand Down Expand Up @@ -208,9 +206,9 @@ PHP_METHOD(Spoofchecker, setAllowedChars)
#endif
pattern_option != (USET_IGNORE_SPACE|USET_CASE_INSENSITIVE) &&
pattern_option != (USET_IGNORE_SPACE|USET_ADD_CASE_MAPPINGS)) {
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"
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"
#if U_ICU_VERSION_MAJOR_NUM >= 73
" or SpoofChecker::USET_SIMPLE_CASE_INSENSITIVE"
" or SpoofChecker::SIMPLE_CASE_INSENSITIVE"
#endif
"))"
);
Expand Down
6 changes: 0 additions & 6 deletions ext/intl/tests/spoofchecker_007.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@ spoofchecker with restriction level
intl
--SKIPIF--
<?php if(!class_exists("Spoofchecker")) print 'skip'; ?>
<?php
$r = new ReflectionClass("SpoofChecker");
if (false === $r->getConstant("SINGLE_SCRIPT_RESTRICTIVE")) {
die("skip Incompatible ICU version");
}
?>
--FILE--
<?php

Expand Down
2 changes: 1 addition & 1 deletion ext/intl/tests/spoofchecker_008.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ try {
bool(true)
bool(false)
bool(false)
Spoofchecker::setAllowedChars(): Argument #2 ($patternOptions) must be a valid pattern option, 0 or (SpoofChecker::IGNORE_SPACE|(<none> or SpoofChecker::USET_CASE_INSENSITIVE%s))
Spoofchecker::setAllowedChars(): Argument #2 ($patternOptions) must be a valid pattern option, 0 or (SpoofChecker::IGNORE_SPACE|(<none> or SpoofChecker::CASE_INSENSITIVE%s))
Spoofchecker::setAllowedChars(): Argument #1 ($pattern) must be a valid regular expression character set pattern
Spoofchecker::setAllowedChars(): Argument #1 ($pattern) must be a valid regular expression character set pattern
36 changes: 36 additions & 0 deletions ext/intl/tests/spoofchecker_supported_icu57_apis.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
--TEST--
Spoofchecker exposes restriction-level APIs on all supported ICU versions
--EXTENSIONS--
intl
--SKIPIF--
<?php if (!class_exists("Spoofchecker")) print 'skip'; ?>
--FILE--
<?php
$r = new ReflectionClass("Spoofchecker");

$ascii = $r->getConstant("ASCII");
$singleScriptRestrictive = $r->getConstant("SINGLE_SCRIPT_RESTRICTIVE");
$mixedNumbers = $r->getConstant("MIXED_NUMBERS");

var_dump($ascii !== false);
var_dump($singleScriptRestrictive !== false);
var_dump($mixedNumbers !== false);
var_dump(is_int($ascii));
var_dump(is_int($singleScriptRestrictive));
var_dump(is_int($mixedNumbers));
var_dump($ascii !== $singleScriptRestrictive);
var_dump($ascii !== $mixedNumbers);
var_dump($singleScriptRestrictive !== $mixedNumbers);
var_dump($r->hasMethod("setRestrictionLevel"));
?>
--EXPECT--
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
2 changes: 0 additions & 2 deletions ext/intl/tests/spoofchecker_unknown_restriction_level.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ intl
--SKIPIF--
<?php
if (!class_exists("Spoofchecker")) print 'skip';

if (!method_exists(new Spoofchecker(), 'setRestrictionLevel')) print 'skip ICU version < 58';
?>
--FILE--
<?php
Expand Down
Loading