Skip to content

Commit e025f2a

Browse files
authored
reflection: Test ReflectionFunction::__toString() with bound variables (php#20608)
1 parent b64cd42 commit e025f2a

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
--TEST--
2+
ReflectionFunction::__toString() with bound variables
3+
--FILE--
4+
<?php
5+
6+
$closure_without_bounds = fn () => 0;
7+
8+
$rf = new ReflectionFunction($closure_without_bounds);
9+
echo (string) $rf;
10+
11+
$global = "";
12+
$closure_with_bounds = function() use($global) {
13+
static $counter = 0;
14+
return $counter++;
15+
};
16+
17+
$rf = new ReflectionFunction($closure_with_bounds);
18+
echo (string) $rf;
19+
20+
?>
21+
--EXPECTF--
22+
Closure [ <user> function {closure:%s:%d} ] {
23+
@@ %sReflectionFunction__toString_bound_variables.php 3 - 3
24+
}
25+
Closure [ <user> function {closure:%s:%d} ] {
26+
@@ %sReflectionFunction__toString_bound_variables.php 9 - 12
27+
28+
- Bound Variables [2] {
29+
Variable #0 [ $global ]
30+
Variable #1 [ $counter ]
31+
}
32+
}

0 commit comments

Comments
 (0)