Skip to content

Commit 501a72e

Browse files
committed
Promote warning to value error in strpbrk()
Closes GH-4598
1 parent 8a977e0 commit 501a72e

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

ext/standard/string.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6068,8 +6068,8 @@ PHP_FUNCTION(strpbrk)
60686068
ZEND_PARSE_PARAMETERS_END();
60696069

60706070
if (!ZSTR_LEN(char_list)) {
6071-
php_error_docref(NULL, E_WARNING, "The character list cannot be empty");
6072-
RETURN_FALSE;
6071+
zend_value_error("The character list cannot be empty");
6072+
return;
60736073
}
60746074

60756075
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 & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,16 @@ 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+
try {
15+
strpbrk($haystack, '');
16+
} catch (\ValueError $e) {
17+
echo $e->getMessage() . "\n";
18+
}
1719

1820
?>
19-
--EXPECTF--
20-
*** Testing strpbrk() : error conditions ***
21-
21+
--EXPECT--
2222
-- Testing strpbrk() function with empty second argument --
23-
24-
Warning: strpbrk(): The character list cannot be empty in %s on line %d
25-
bool(false)
23+
The character list cannot be empty

0 commit comments

Comments
 (0)