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 {
1919 public function c () {
2020 echo static ::class.'->c ' , "\n" ;
2121 }
22+
23+ public function makeClosure () {
24+ return function () {
25+ echo static ::class.'::{closure} ' ."\n" ;
26+ };
27+ }
2228}
2329
2430class B extends A {}
@@ -46,6 +52,26 @@ $d = \Closure::fromCallable($c);
4652$ r = new \ReflectionFunction ($ d );
4753var_dump ($ r ->getClosureCalledClass ());
4854$ 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+
4975?>
5076--EXPECTF--
5177object(ReflectionClass)#%d (1) {
@@ -68,3 +94,15 @@ object(ReflectionClass)#%d (1) {
6894 string(1) "B"
6995}
7096B->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