mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
reflection: Test ReflectionFunction::__toString() with bound variables (#20608)
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
--TEST--
|
||||
ReflectionFunction::__toString() with bound variables
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$closure_without_bounds = fn () => 0;
|
||||
|
||||
$rf = new ReflectionFunction($closure_without_bounds);
|
||||
echo (string) $rf;
|
||||
|
||||
$global = "";
|
||||
$closure_with_bounds = function() use($global) {
|
||||
static $counter = 0;
|
||||
return $counter++;
|
||||
};
|
||||
|
||||
$rf = new ReflectionFunction($closure_with_bounds);
|
||||
echo (string) $rf;
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Closure [ <user> function {closure:%s:%d} ] {
|
||||
@@ %sReflectionFunction__toString_bound_variables.php 3 - 3
|
||||
}
|
||||
Closure [ <user> function {closure:%s:%d} ] {
|
||||
@@ %sReflectionFunction__toString_bound_variables.php 9 - 12
|
||||
|
||||
- Bound Variables [2] {
|
||||
Variable #0 [ $global ]
|
||||
Variable #1 [ $counter ]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user