xref: /PHP-8.2/Zend/tests/gh8962.phpt (revision 1f6baa77)
1--TEST--
2GH-8962: Display function name when var_dumping fake closure
3--FILE--
4<?php
5
6namespace Foo {
7    class Bar {
8        public function baz() {}
9        public static function qux() {}
10    }
11
12    function quux() {}
13
14    var_dump(\Closure::fromCallable([new Bar(), 'baz']));
15    var_dump(\Closure::fromCallable([Bar::class, 'qux']));
16    var_dump(\Closure::fromCallable('Foo\Bar::qux'));
17    var_dump(quux(...));
18}
19
20?>
21--EXPECT--
22object(Closure)#2 (2) {
23  ["function"]=>
24  string(12) "Foo\Bar::baz"
25  ["this"]=>
26  object(Foo\Bar)#1 (0) {
27  }
28}
29object(Closure)#2 (1) {
30  ["function"]=>
31  string(12) "Foo\Bar::qux"
32}
33object(Closure)#2 (1) {
34  ["function"]=>
35  string(12) "Foo\Bar::qux"
36}
37object(Closure)#2 (1) {
38  ["function"]=>
39  string(8) "Foo\quux"
40}
41