1--TEST--
2Test preg_match_all() function : error conditions - wrong arg types
3--FILE--
4<?php
5/*
6* proto int preg_match_all(string pattern, string subject, array subpatterns [, int flags [, int offset]])
7* Function is implemented in ext/pcre/php_pcre.c
8*/
9error_reporting(E_ALL&~E_NOTICE);
10/*
11* Testing how preg_match_all reacts to being passed the wrong type of input argument
12*/
13echo "*** Testing preg_match_all() : error conditions ***\n";
14$regex = '/[a-zA-Z]/';
15$value = new stdclass(); //Object
16var_dump(preg_match_all($regex, $value, $matches));
17var_dump($matches);
18$input = array(array('this is', 'a subarray'), 'test',);
19foreach($input as $value) {
20    print "\nArg value is: $value\n";
21    var_dump(preg_match_all($regex, $value, $matches));
22    var_dump($matches);
23}
24echo "Done";
25?>
26--EXPECTF--
27*** Testing preg_match_all() : error conditions ***
28
29Warning: preg_match_all() expects parameter 2 to be string, object given in %spreg_match_all_error2.php on line %d
30bool(false)
31NULL
32
33Arg value is: Array
34
35Warning: preg_match_all() expects parameter 2 to be string, array given in %spreg_match_all_error2.php on line %d
36bool(false)
37NULL
38
39Arg value is: test
40int(4)
41array(1) {
42  [0]=>
43  array(4) {
44    [0]=>
45    string(1) "t"
46    [1]=>
47    string(1) "e"
48    [2]=>
49    string(1) "s"
50    [3]=>
51    string(1) "t"
52  }
53}
54Done
55