Skip to content

Commit db1ef97

Browse files
committed
Add tests
1 parent 93f11d8 commit db1ef97

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

ext/reflection/tests/ReflectionFunction_getClosureCalledClass.phpt

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff 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

2430
class B extends A {}
@@ -46,6 +52,26 @@ $d = \Closure::fromCallable($c);
4652
$r = new \ReflectionFunction($d);
4753
var_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--
5177
object(ReflectionClass)#%d (1) {
@@ -68,3 +94,15 @@ object(ReflectionClass)#%d (1) {
6894
string(1) "B"
6995
}
7096
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}

0 commit comments

Comments
 (0)