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