Skip to content

Commit 99f15bd

Browse files
committed
Promote warnings to errors in strpbrk()
1 parent c53064f commit 99f15bd

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

ext/standard/string.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6114,8 +6114,8 @@ PHP_FUNCTION(strpbrk)
61146114
ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
61156115

61166116
if (!ZSTR_LEN(char_list)) {
6117-
php_error_docref(NULL, E_WARNING, "The character list cannot be empty");
6118-
RETURN_FALSE;
6117+
zend_throw_error(NULL, "The character list cannot be empty");
6118+
return;
61196119
}
61206120

61216121
for (haystack_ptr = ZSTR_VAL(haystack); haystack_ptr < (ZSTR_VAL(haystack) + ZSTR_LEN(haystack)); ++haystack_ptr) {

ext/standard/tests/strings/strpbrk_error.phpt

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,19 @@ Test strpbrk() function : error conditions
88
* Alias to functions:
99
*/
1010

11-
echo "*** Testing strpbrk() : error conditions ***\n";
12-
1311
$haystack = 'This is a Simple text.';
1412

15-
echo "\n-- Testing strpbrk() function with empty second argument --\n";
16-
var_dump( strpbrk($haystack, '') );
13+
echo "-- Testing strpbrk() function with empty second argument --\n";
14+
15+
try {
16+
strpbrk($haystack, '');
17+
} catch (\Error $e) {
18+
echo $e->getMessage() . "\n";
19+
}
1720

1821
?>
1922
===DONE===
2023
--EXPECTF--
21-
*** Testing strpbrk() : error conditions ***
22-
2324
-- Testing strpbrk() function with empty second argument --
24-
25-
Warning: strpbrk(): The character list cannot be empty in %s on line %d
26-
bool(false)
25+
The character list cannot be empty
2726
===DONE===

0 commit comments

Comments
 (0)