]> granicus.if.org Git - php/commitdiff
Promote warning to value error in strpbrk()
authorGeorge Peter Banyard <girgias@php.net>
Wed, 20 Nov 2019 22:35:03 +0000 (23:35 +0100)
committerGeorge Peter Banyard <girgias@php.net>
Thu, 21 Nov 2019 23:36:54 +0000 (00:36 +0100)
Closes GH-4598

ext/standard/string.c
ext/standard/tests/strings/strpbrk_error.phpt

index a23c85c6d3632a849af50ab97f2078110eb44afa..75162a19ca448c5bfb956b7afc12eb3da80ac794 100644 (file)
@@ -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) {
index 075e0b246261ec7dad7730c8b28d82b77880b8e7..93f1ac42959bd5ec0d628afbd85b243c0fd7c30b 100644 (file)
@@ -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