xref: /php-src/ext/standard/tests/array/bug74345.phpt (revision 96f2f317)
1--TEST--
2Bug #74345: Call trampoline leaked if callback not invoked
3--FILE--
4<?php
5
6class Test {
7    public function __call($name, $args) {
8        echo "__call()\n";
9    }
10}
11
12$name = "foo" . ($x = "bar");
13$cb = [new Test, $name];
14array_map($cb, []);
15array_map($cb, [], []);
16try {
17    array_map($cb, null);
18} catch (Error $e) {
19    echo $e->getMessage(), "\n";
20}
21try {
22    array_map($cb, null, null);
23} catch (Error $e) {
24    echo $e->getMessage(), "\n";
25}
26array_filter([], $cb);
27array_reduce([], $cb);
28
29$array = [];
30array_walk($array, $cb);
31array_walk_recursive($array, $cb);
32usort($array, $cb);
33
34try {
35    preg_replace_callback('/./', $cb, new stdClass);
36} catch (Error $e) {
37    echo $e->getMessage(), "\n";
38}
39
40?>
41===DONE===
42--EXPECT--
43array_map(): Argument #2 ($array) must be of type array, null given
44array_map(): Argument #2 ($array) must be of type array, null given
45preg_replace_callback(): Argument #3 ($subject) must be of type array|string, stdClass given
46===DONE===
47