xref: /PHP-8.2/ext/reflection/tests/bug52057.phpt (revision 4d3944f9)
1--TEST--
2Bug #52057 (ReflectionClass fails on Closure class)
3--FILE--
4<?php
5
6$closure = function($a) { echo $a; };
7
8$reflection = new ReflectionClass('closure');
9var_dump($reflection->hasMethod('__invoke')); // true
10
11$reflection = new ReflectionClass($closure);
12var_dump($reflection->hasMethod('__invoke')); // true
13
14$reflection = new ReflectionObject($closure);
15var_dump($reflection->hasMethod('__invoke')); // true
16
17$reflection = new ReflectionClass('closure');
18var_dump($h = $reflection->getMethod('__invoke')); // true
19var_dump($h->class.'::'.$h->getName());
20
21$reflection = new ReflectionClass($closure);
22var_dump($h = $reflection->getMethod('__invoke')); // true
23var_dump($h->class.'::'.$h->getName());
24
25$reflection = new ReflectionObject($closure);
26var_dump($h = $reflection->getMethod('__invoke')); // true
27var_dump($h->class.'::'.$h->getName());
28
29?>
30--EXPECTF--
31bool(true)
32bool(true)
33bool(true)
34object(ReflectionMethod)#%d (2) {
35  ["name"]=>
36  string(8) "__invoke"
37  ["class"]=>
38  string(7) "Closure"
39}
40string(17) "Closure::__invoke"
41object(ReflectionMethod)#%d (2) {
42  ["name"]=>
43  string(8) "__invoke"
44  ["class"]=>
45  string(7) "Closure"
46}
47string(17) "Closure::__invoke"
48object(ReflectionMethod)#%d (2) {
49  ["name"]=>
50  string(8) "__invoke"
51  ["class"]=>
52  string(7) "Closure"
53}
54string(17) "Closure::__invoke"
55