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*/
11echo "*** Testing preg_split() : error conditions ***\n";
12$regex_array = array('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', array('[a-z]', //Array of Regexes
16'[A-Z]', '[0-9]'), '/[a-zA-Z]/', //Regex string
17);
18$subject = '1 2 a 3 4 b 5 6';
19foreach($regex_array as $regex_value) {
20    @print "\nArg value is $regex_value\n";
21    try {
22        var_dump(preg_split($regex_value, $subject));
23    } catch (TypeError $e) {
24        echo $e->getMessage(), "\n";
25    }
26}
27$regex_value = new stdclass(); //Object
28try {
29    var_dump(preg_split($regex_value, $subject));
30} catch (TypeError $e) {
31    echo $e->getMessage(), "\n";
32}
33?>
34--EXPECTF--
35*** Testing preg_split() : error conditions ***
36
37Arg value is abcdef
38
39Warning: preg_split(): Delimiter must not be alphanumeric, backslash, or NUL in %spreg_split_error1.php on line %d
40bool(false)
41
42Arg value is /[a-zA-Z]
43
44Warning: preg_split(): No ending delimiter '/' found in %spreg_split_error1.php on line %d
45bool(false)
46
47Arg value is [a-zA-Z]/
48
49Warning: preg_split(): Unknown modifier '/' in %spreg_split_error1.php on line %d
50bool(false)
51
52Arg value is /[a-zA-Z]/F
53
54Warning: preg_split(): Unknown modifier 'F' in %spreg_split_error1.php on line %d
55bool(false)
56
57Arg value is Array
58preg_split(): Argument #1 ($pattern) must be of type string, array given
59
60Arg value is /[a-zA-Z]/
61array(3) {
62  [0]=>
63  string(4) "1 2 "
64  [1]=>
65  string(5) " 3 4 "
66  [2]=>
67  string(4) " 5 6"
68}
69preg_split(): Argument #1 ($pattern) must be of type string, stdClass given
70