1--TEST--
2Test preg_match() function : error conditions - wrong arg types
3--FILE--
4<?php
5/* Function is implemented in ext/pcre/php_pcre.c */
6/*
7* Testing how preg_match reacts to being passed the wrong type of subject argument
8*/
9echo "*** Testing preg_match() : error conditions ***\n";
10$regex = '/[a-zA-Z]/';
11$input = array('this is a string', array('this is', 'a subarray'),);
12foreach($input as $value) {
13    @print "\nArg value is: $value\n";
14    try {
15        var_dump(preg_match($regex, $value));
16    } catch (TypeError $e) {
17        echo $e->getMessage(), "\n";
18    }
19}
20$value = new stdclass(); //Object
21try {
22    var_dump(preg_match($regex, $value));
23} catch (TypeError $e) {
24    echo $e->getMessage(), "\n";
25}
26echo "Done";
27?>
28--EXPECT--
29*** Testing preg_match() : error conditions ***
30
31Arg value is: this is a string
32int(1)
33
34Arg value is: Array
35preg_match(): Argument #2 ($subject) must be of type string, array given
36preg_match(): Argument #2 ($subject) must be of type string, stdClass given
37Done
38