1--TEST--
2Test preg_replace_callback() function : error
3--FILE--
4<?php
5/*
6 * Function is implemented in ext/pcre/php_pcre.c
7 */
8/*
9 * Testing how preg_replace_callback reacts to being passed the wrong type of regex argument
10 */
11$regex_array = [
12    'abcdef', //Regex without delimiters
13    '/[a-zA-Z]', //Regex without closing delimiter
14    '[a-zA-Z]/', //Regex without opening delimiter
15    '/[a-zA-Z]/F',
16    [
17        '[a-z]', //Array of Regexes
18        '[A-Z]',
19        '[0-9]',
20    ],
21    '/[0-9]/', //Regex string
22];
23$replacement = [
24    'zero',
25    'one',
26    'two',
27    'three',
28    'four',
29    'five',
30    'six',
31    'seven',
32    'eight',
33    'nine',
34];
35function integer_word($matches) {
36    global $replacement;
37    return $replacement[$matches[0]];
38}
39$subject = 'number 1.';
40foreach ($regex_array as $regex_value) {
41    var_dump(preg_replace_callback($regex_value, 'integer_word', $subject));
42}
43?>
44--EXPECTF--
45
46Warning: preg_replace_callback(): Delimiter must not be alphanumeric, backslash, or NUL byte in %s on line %d
47NULL
48
49Warning: preg_replace_callback(): No ending delimiter '/' found in %s on line %d
50NULL
51
52Warning: preg_replace_callback(): Unknown modifier '/' in %s on line %d
53NULL
54
55Warning: preg_replace_callback(): Unknown modifier 'F' in %s on line %d
56NULL
57string(9) "number 1."
58string(11) "number one."
59