Skip to content

Commit 9bca1f8

Browse files
committed
Reviews
1 parent 0e43563 commit 9bca1f8

File tree

5 files changed

+17
-19
lines changed

5 files changed

+17
-19
lines changed

ext/mbstring/php_mbregex.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -652,10 +652,10 @@ static bool _php_mb_regex_init_options(const char *parg, size_t narg, OnigOption
652652
*syntax = ONIG_SYNTAX_POSIX_EXTENDED;
653653
break;
654654
case 'e':
655-
zend_argument_value_error(option_arg_num, "option 'e' is not supported");
655+
zend_value_error("Option \"e\" is not supported");
656656
return false;
657657
default:
658-
// TODO Unsupported ValueError
658+
zend_value_error("Option \"%c\" is not supported", c);
659659
break;
660660
}
661661
}
@@ -920,7 +920,7 @@ static void _php_mb_regex_ereg_exec(INTERNAL_FUNCTION_PARAMETERS, int icase)
920920
string_len,
921921
php_mb_regex_get_mbctype_encoding()
922922
)) {
923-
zend_argument_value_error(2, "must be a valid string in '%s'", php_mb_regex_get_mbctype());
923+
zend_argument_value_error(2, "must be a valid string in \"%s\" encoding", php_mb_regex_get_mbctype());
924924
RETURN_THROWS();
925925
}
926926

@@ -1041,8 +1041,7 @@ static void _php_mb_regex_ereg_replace_exec(INTERNAL_FUNCTION_PARAMETERS, OnigOp
10411041
}
10421042

10431043
if (!php_mb_check_encoding(string, string_len, enc)) {
1044-
zend_argument_value_error(3, "must be a valid string in '%s'", php_mb_regex_get_mbctype());
1045-
RETURN_THROWS();
1044+
RETURN_NULL();
10461045
}
10471046

10481047
if (option_str != NULL) {
@@ -1059,7 +1058,6 @@ static void _php_mb_regex_ereg_replace_exec(INTERNAL_FUNCTION_PARAMETERS, OnigOp
10591058
/* create regex pattern buffer */
10601059
re = php_mbregex_compile_pattern(arg_pattern, arg_pattern_len, options, syntax);
10611060
if (re == NULL) {
1062-
// Should this be considered an error instead?
10631061
RETURN_FALSE;
10641062
}
10651063

@@ -1357,7 +1355,7 @@ static void _php_mb_regex_ereg_search_exec(INTERNAL_FUNCTION_PARAMETERS, int mod
13571355
}
13581356

13591357
if (arg_options) {
1360-
_php_mb_regex_init_options(arg_options, arg_options_len, &option, &syntax, NULL);
1358+
_php_mb_regex_init_options(arg_options, arg_options_len, &option, &syntax, 2);
13611359
} else {
13621360
option |= MBREX(regex_default_options);
13631361
syntax = MBREX(regex_default_syntax);
@@ -1496,7 +1494,7 @@ PHP_FUNCTION(mb_ereg_search_init)
14961494

14971495
if (arg_options) {
14981496
option = 0;
1499-
_php_mb_regex_init_options(arg_options, arg_options_len, &option, &syntax, NULL);
1497+
_php_mb_regex_init_options(arg_options, arg_options_len, &option, &syntax, 3);
15001498
} else {
15011499
option = MBREX(regex_default_options);
15021500
syntax = MBREX(regex_default_syntax);

ext/mbstring/tests/bug69151.phpt

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,7 @@ try {
1616
}
1717
var_dump([] === $matches);
1818

19-
try {
20-
var_dump(NULL === mb_ereg_replace('.', "\\0", $str));
21-
} catch (\ValueError $e) {
22-
echo $e->getMessage() . \PHP_EOL;
23-
}
19+
var_dump(NULL === mb_ereg_replace('.', "\\0", $str));
2420

2521
try {
2622
var_dump(false === mb_ereg_search_init("\x80", '.'));
@@ -30,8 +26,8 @@ try {
3026
var_dump(false === mb_ereg_search());
3127
?>
3228
--EXPECT--
33-
mb_eregi(): Argument #2 ($string) must be a valid string in 'UTF-8'
29+
mb_eregi(): Argument #2 ($string) must be a valid string in "UTF-8" encoding
30+
bool(true)
3431
bool(true)
35-
mb_ereg_replace(): Argument #3 ($string) must be a valid string in 'UTF-8'
3632
mb_ereg_search_init(): Argument #1 ($string) must be a valid string in 'UTF-8'
3733
bool(true)

ext/mbstring/tests/bug72164.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ try {
1919

2020
?>
2121
--EXPECT--
22-
mb_ereg_replace(): Argument #4 ($option) option 'e' is not supported
22+
Option "e" is not supported

ext/mbstring/tests/bug73532.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ try {
1414
}
1515
?>
1616
--EXPECT--
17-
mb_eregi(): Argument #2 ($string) must be a valid string in 'UTF-8'
17+
mb_eregi(): Argument #2 ($string) must be a valid string in "UTF-8" encoding

ext/mbstring/tests/bug76999.phpt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,16 @@ mb_regex_set_options("pr");
1111
var_dump(mb_regex_set_options("m"));
1212
var_dump(mb_regex_set_options("mdi"));
1313
var_dump(mb_regex_set_options("m"));
14-
var_dump(mb_regex_set_options("a"));
14+
try {
15+
var_dump(mb_regex_set_options("a"));
16+
} catch (\ValueError $e) {
17+
echo $e->getMessage() . \PHP_EOL;
18+
}
1519
var_dump(mb_regex_set_options());
1620
?>
1721
--EXPECT--
1822
string(2) "pr"
1923
string(2) "mr"
2024
string(3) "imd"
21-
string(2) "mr"
25+
Option "a" is not supported
2226
string(1) "r"

0 commit comments

Comments
 (0)