diff options
author | George Peter Banyard <girgias@php.net> | 2019-11-20 23:35:03 +0100 |
---|---|---|
committer | George Peter Banyard <girgias@php.net> | 2019-11-22 00:36:54 +0100 |
commit | 501a72e354a0d93498411a982615e03a44c9327c (patch) | |
tree | 624ce53ec5e56109a0249ea7d7ece57f6b26b2b5 | |
parent | 8a977e07d08b9a035236002c07ee424b61281635 (diff) | |
download | php-git-501a72e354a0d93498411a982615e03a44c9327c.tar.gz |
Promote warning to value error in strpbrk()
Closes GH-4598
-rw-r--r-- | ext/standard/string.c | 4 | ||||
-rw-r--r-- | ext/standard/tests/strings/strpbrk_error.phpt | 18 |
2 files changed, 10 insertions, 12 deletions
diff --git a/ext/standard/string.c b/ext/standard/string.c index a23c85c6d3..75162a19ca 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -6068,8 +6068,8 @@ PHP_FUNCTION(strpbrk) ZEND_PARSE_PARAMETERS_END(); if (!ZSTR_LEN(char_list)) { - php_error_docref(NULL, E_WARNING, "The character list cannot be empty"); - RETURN_FALSE; + zend_value_error("The character list cannot be empty"); + return; } for (haystack_ptr = ZSTR_VAL(haystack); haystack_ptr < (ZSTR_VAL(haystack) + ZSTR_LEN(haystack)); ++haystack_ptr) { diff --git a/ext/standard/tests/strings/strpbrk_error.phpt b/ext/standard/tests/strings/strpbrk_error.phpt index 075e0b2462..93f1ac4295 100644 --- a/ext/standard/tests/strings/strpbrk_error.phpt +++ b/ext/standard/tests/strings/strpbrk_error.phpt @@ -8,18 +8,16 @@ Test strpbrk() function : error conditions * Alias to functions: */ -echo "*** Testing strpbrk() : error conditions ***\n"; - $haystack = 'This is a Simple text.'; -echo "\n-- Testing strpbrk() function with empty second argument --\n"; -var_dump( strpbrk($haystack, '') ); +echo "-- Testing strpbrk() function with empty second argument --\n"; +try { + strpbrk($haystack, ''); +} catch (\ValueError $e) { + echo $e->getMessage() . "\n"; +} ?> ---EXPECTF-- -*** Testing strpbrk() : error conditions *** - +--EXPECT-- -- Testing strpbrk() function with empty second argument -- - -Warning: strpbrk(): The character list cannot be empty in %s on line %d -bool(false) +The character list cannot be empty |