1--TEST--
2Test preg_split() function : error conditions - bad regular expressions
3--FILE--
4<?php
5/*
6 * Function is implemented in ext/pcre/php_pcre.c
7 */
8/*
9 * Testing how preg_split reacts to being passed the wrong type of regex argument
10 */
11$regex_array = [
12    'abcdef', //Regex without delimiter
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    '/[a-zA-Z]/', //Regex string
22];
23$subject = '1 2 a 3 4 b 5 6';
24foreach ($regex_array as $regex_value) {
25    try {
26        var_dump(preg_split($regex_value, $subject));
27    } catch (TypeError $e) {
28        echo $e->getMessage(), "\n";
29    }
30}
31$regex_value = new stdclass(); //Object
32try {
33    var_dump(preg_split($regex_value, $subject));
34} catch (TypeError $e) {
35    echo $e->getMessage(), "\n";
36}
37?>
38--EXPECTF--
39
40Warning: preg_split(): Delimiter must not be alphanumeric, backslash, or NUL byte in %spreg_split_error1.php on line %d
41bool(false)
42
43Warning: preg_split(): No ending delimiter '/' found in %spreg_split_error1.php on line %d
44bool(false)
45
46Warning: preg_split(): Unknown modifier '/' in %spreg_split_error1.php on line %d
47bool(false)
48
49Warning: preg_split(): Unknown modifier 'F' in %spreg_split_error1.php on line %d
50bool(false)
51preg_split(): Argument #1 ($pattern) must be of type string, array given
52array(3) {
53  [0]=>
54  string(4) "1 2 "
55  [1]=>
56  string(5) " 3 4 "
57  [2]=>
58  string(4) " 5 6"
59}
60preg_split(): Argument #1 ($pattern) must be of type string, stdClass given
61