ext/mbstring: Use standard wording for ValueError

This commit is contained in:
Gina Peter Bnayard 2024-08-18 23:32:07 +02:00 committed by Gina Peter Banyard
parent 997199e938
commit 9a2fdbec48
8 changed files with 31 additions and 31 deletions

View File

@ -2238,7 +2238,7 @@ PHP_FUNCTION(mb_substr_count)
ZEND_PARSE_PARAMETERS_END();
if (ZSTR_LEN(needle) == 0) {
zend_argument_value_error(2, "must not be empty");
zend_argument_cannot_be_empty_error(2);
RETURN_THROWS();
}
@ -2278,7 +2278,7 @@ PHP_FUNCTION(mb_substr_count)
if (ZSTR_LEN(needle_u8) == 0) {
zend_string_free(haystack_u8);
zend_string_free(needle_u8);
zend_argument_value_error(2, "must not be empty");
zend_argument_cannot_be_empty_error(2);
RETURN_THROWS();
}
}
@ -5673,7 +5673,7 @@ PHP_FUNCTION(mb_ord)
ZEND_PARSE_PARAMETERS_END();
if (str_len == 0) {
zend_argument_value_error(1, "must not be empty");
zend_argument_cannot_be_empty_error(1);
RETURN_THROWS();
}
@ -5810,7 +5810,7 @@ PHP_FUNCTION(mb_str_pad)
}
if (ZSTR_LEN(pad) == 0) {
zend_argument_value_error(3, "must be a non-empty string");
zend_argument_cannot_be_empty_error(3);
RETURN_THROWS();
}

View File

@ -900,7 +900,7 @@ static void _php_mb_regex_ereg_exec(INTERNAL_FUNCTION_PARAMETERS, int icase)
}
if (arg_pattern_len == 0) {
zend_argument_value_error(1, "must not be empty");
zend_argument_cannot_be_empty_error(1);
RETURN_THROWS();
}
@ -1468,7 +1468,7 @@ PHP_FUNCTION(mb_ereg_search_init)
}
if (arg_pattern && arg_pattern_len == 0) {
zend_argument_value_error(2, "must not be empty");
zend_argument_cannot_be_empty_error(2);
RETURN_THROWS();
}

View File

@ -43,28 +43,28 @@ foreach($inputs as $input) {
--EXPECT--
-- Iteration 1 --
Without $regs arg:
mb_ereg(): Argument #1 ($pattern) must not be empty
mb_ereg(): Argument #1 ($pattern) cannot be empty
With $regs arg:
mb_ereg(): Argument #1 ($pattern) must not be empty
mb_ereg(): Argument #1 ($pattern) cannot be empty
NULL
-- Iteration 2 --
Without $regs arg:
mb_ereg(): Argument #1 ($pattern) must not be empty
mb_ereg(): Argument #1 ($pattern) cannot be empty
With $regs arg:
mb_ereg(): Argument #1 ($pattern) must not be empty
mb_ereg(): Argument #1 ($pattern) cannot be empty
NULL
-- Iteration 3 --
Without $regs arg:
mb_ereg(): Argument #1 ($pattern) must not be empty
mb_ereg(): Argument #1 ($pattern) cannot be empty
With $regs arg:
mb_ereg(): Argument #1 ($pattern) must not be empty
mb_ereg(): Argument #1 ($pattern) cannot be empty
NULL
-- Iteration 4 --
Without $regs arg:
mb_ereg(): Argument #1 ($pattern) must not be empty
mb_ereg(): Argument #1 ($pattern) cannot be empty
With $regs arg:
mb_ereg(): Argument #1 ($pattern) must not be empty
mb_ereg(): Argument #1 ($pattern) cannot be empty
NULL

View File

@ -25,5 +25,5 @@ try {
?>
--EXPECT--
mb_ereg_search_init(): Argument #2 ($pattern) must not be empty
mb_ereg_search_init(): Argument #2 ($pattern) cannot be empty
No pattern was provided

View File

@ -35,7 +35,7 @@ array(3) {
array(0) {
}
}
ValueError: mb_ereg(): Argument #1 ($pattern) must not be empty
ValueError: mb_ereg(): Argument #1 ($pattern) cannot be empty
array(3) {
[0]=>
string(0) ""

View File

@ -56,7 +56,7 @@ try {
bool(true)
bool(true)
bool(true)
mb_ord(): Argument #1 ($string) must not be empty
mb_ord(): Argument #1 ($string) cannot be empty
mb_ord(): Argument #2 ($encoding) must be a valid encoding, "typo" given
mb_ord(): Argument #2 ($encoding) must be a valid encoding, "pass" given
mb_ord() does not support the "JIS" encoding

View File

@ -9,27 +9,27 @@ echo "--- Error conditions ---\n";
try {
var_dump(mb_str_pad('▶▶', 6, '', STR_PAD_RIGHT));
} catch (ValueError $e) {
var_dump($e->getMessage());
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump(mb_str_pad('▶▶', 6, '', STR_PAD_LEFT));
} catch (ValueError $e) {
var_dump($e->getMessage());
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump(mb_str_pad('▶▶', 6, '', STR_PAD_BOTH));
} catch (ValueError $e) {
var_dump($e->getMessage());
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump(mb_str_pad('▶▶', 6, ' ', 123456));
} catch (ValueError $e) {
var_dump($e->getMessage());
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump(mb_str_pad('▶▶', 6, ' ', STR_PAD_BOTH, 'unexisting'));
var_dump(mb_str_pad('▶▶', 6, ' ', STR_PAD_BOTH, 'non-existing'));
} catch (ValueError $e) {
var_dump($e->getMessage());
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
echo "--- Simple ASCII strings ---\n";
@ -87,11 +87,11 @@ foreach ($tests as $encoding => $test) {
?>
--EXPECT--
--- Error conditions ---
string(66) "mb_str_pad(): Argument #3 ($pad_string) must be a non-empty string"
string(66) "mb_str_pad(): Argument #3 ($pad_string) must be a non-empty string"
string(66) "mb_str_pad(): Argument #3 ($pad_string) must be a non-empty string"
string(90) "mb_str_pad(): Argument #4 ($pad_type) must be STR_PAD_LEFT, STR_PAD_RIGHT, or STR_PAD_BOTH"
string(82) "mb_str_pad(): Argument #5 ($encoding) must be a valid encoding, "unexisting" given"
ValueError: mb_str_pad(): Argument #3 ($pad_string) cannot be empty
ValueError: mb_str_pad(): Argument #3 ($pad_string) cannot be empty
ValueError: mb_str_pad(): Argument #3 ($pad_string) cannot be empty
ValueError: mb_str_pad(): Argument #4 ($pad_type) must be STR_PAD_LEFT, STR_PAD_RIGHT, or STR_PAD_BOTH
ValueError: mb_str_pad(): Argument #5 ($encoding) must be a valid encoding, "non-existing" given
--- Simple ASCII strings ---
string(7) "+Hello+"
string(10) "+-World+-+"

View File

@ -69,9 +69,9 @@ output_handler=
?>
--EXPECT--
== Empty needle should raise an error ==
mb_substr_count(): Argument #2 ($needle) must not be empty
mb_substr_count(): Argument #2 ($needle) must not be empty
mb_substr_count(): Argument #2 ($needle) must not be empty
mb_substr_count(): Argument #2 ($needle) cannot be empty
mb_substr_count(): Argument #2 ($needle) cannot be empty
mb_substr_count(): Argument #2 ($needle) cannot be empty
== Return value for empty haystack should always be zero ==
int(0)
int(0)