Annotation of embedaddon/php/ext/pcre/tests/preg_replace_error2.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Test preg_replace() function : error conditions - wrong arg types
                      3: --FILE--
                      4: <?php
                      5: /*
                      6: * proto string preg_replace(mixed regex, mixed replace, mixed subject [, int limit [, count]])
                      7: * Function is implemented in ext/pcre/php_pcre.c
                      8: */
                      9: error_reporting(E_ALL&~E_NOTICE);
                     10: /*
                     11: * Testing how preg_replace reacts to being passed the wrong type of replacement argument
                     12: */
                     13: echo "*** Testing preg_replace() : error conditions ***\n";
                     14: $regex = '/[a-zA-Z]/';
                     15: $replace = array('this is a string', array('this is', 'a subarray'),);
                     16: $subject = 'test';
                     17: foreach($replace as $value) {
                     18:     print "\nArg value is: $value\n";
                     19:     var_dump(preg_replace($regex, $value, $subject));
                     20: }
                     21: $value = new stdclass(); //Object
                     22: var_dump(preg_replace($regex, $value, $subject));
                     23: echo "Done";
                     24: ?>
                     25: --EXPECTF--
                     26: *** Testing preg_replace() : error conditions ***
                     27: 
                     28: Arg value is: this is a string
                     29: string(64) "this is a stringthis is a stringthis is a stringthis is a string"
                     30: 
                     31: Arg value is: Array
                     32: 
                     33: Warning: preg_replace(): Parameter mismatch, pattern is a string while replacement is an array in %spreg_replace_error2.php on line %d
                     34: bool(false)
                     35: 
                     36: Catchable fatal error: Object of class stdClass could not be converted to string in %spreg_replace_error2.php on line %d
                     37: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>