File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,12 @@ class A {
19
19
public function c () {
20
20
echo static ::class.'->c ' , "\n" ;
21
21
}
22
+
23
+ public function makeClosure () {
24
+ return function () {
25
+ echo static ::class.'::{closure} ' ."\n" ;
26
+ };
27
+ }
22
28
}
23
29
24
30
class B extends A {}
@@ -46,6 +52,26 @@ $d = \Closure::fromCallable($c);
46
52
$ r = new \ReflectionFunction ($ d );
47
53
var_dump ($ r ->getClosureCalledClass ());
48
54
$ d ();
55
+
56
+ $ c = ['A ' , 'b ' ];
57
+ $ d = \Closure::fromCallable ($ c );
58
+ $ r = new \ReflectionFunction ($ d );
59
+ var_dump ($ r ->getClosureCalledClass ());
60
+ $ d ();
61
+
62
+ $ b = new B ();
63
+ $ d = $ b ->makeClosure ();
64
+ $ r = new \ReflectionFunction ($ d );
65
+ var_dump ($ r ->getClosureCalledClass ());
66
+ $ d ();
67
+
68
+ $ d = function () {
69
+ echo "{closure} \n" ;
70
+ };
71
+ $ r = new \ReflectionFunction ($ d );
72
+ var_dump ($ r ->getClosureCalledClass ());
73
+ $ d ();
74
+
49
75
?>
50
76
--EXPECTF--
51
77
object(ReflectionClass)#%d (1) {
@@ -68,3 +94,15 @@ object(ReflectionClass)#%d (1) {
68
94
string(1) "B"
69
95
}
70
96
B->e
97
+ object(ReflectionClass)#%d (1) {
98
+ ["name"]=>
99
+ string(1) "A"
100
+ }
101
+ A::b
102
+ object(ReflectionClass)#%d (1) {
103
+ ["name"]=>
104
+ string(1) "B"
105
+ }
106
+ B::{closure}
107
+ NULL
108
+ {closure}
You can’t perform that action at this time.
0 commit comments