1--TEST--
2Test preg_replace_callback() function : error
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*/
9echo "***Testing preg_replace_callback() : error conditions***\n";
10//Zero arguments
11echo "\n-- Testing preg_replace_callback() function with Zero arguments --\n";
12var_dump(preg_replace_callback());
13//Test preg_replace_callback() with one more than the expected number of arguments
14echo "\n-- Testing preg_replace_callback() function with more than expected no. of arguments --\n";
15$replacement = array('zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine');
16function integer_word($matches) {
17    global $replacement;
18    return $replacement[$matches[0]];
19}
20$regex = '/\d/';
21$subject = 'there are 7 words in this sentence.';
22$limit = 10;
23$extra_arg = 10;
24var_dump(preg_replace_callback($regex, 'integer_word', $subject, $limit, $count, $extra_arg));
25//Testing preg_replace_callback() with one less than the expected number of arguments
26echo "\n-- Testing preg_replace_callback() function with less than expected no. of arguments --\n";
27$regex = '/\d/';
28var_dump(preg_replace_callback($regex, 'integer word'));
29echo "Done";
30?>
31--EXPECTF--
32***Testing preg_replace_callback() : error conditions***
33
34-- Testing preg_replace_callback() function with Zero arguments --
35
36Warning: preg_replace_callback() expects at least 3 parameters, 0 given in %s on line %d
37NULL
38
39-- Testing preg_replace_callback() function with more than expected no. of arguments --
40
41Warning: preg_replace_callback() expects at most 5 parameters, 6 given in %s on line %d
42NULL
43
44-- Testing preg_replace_callback() function with less than expected no. of arguments --
45
46Warning: preg_replace_callback() expects at least 3 parameters, 2 given in %s on line %d
47NULL
48Done
49