1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
--TEST--
ReflectionFunctionAbstract::getClosureUsedVariables
--FILE--
<?php
$reflector = new ReflectionFunction("strlen");
var_dump($reflector->getClosureUsedVariables());
$function = function() {
static $one = 1;
};
$reflector = new ReflectionFunction($function);
var_dump($reflector->getClosureUsedVariables());
$one = 1;
$two = 2;
$function = function() use ($one, $two) {
static $three = 3;
};
$reflector = new ReflectionFunction($function);
var_dump($reflector->getClosureUsedVariables());
$function = fn() => $three = [$one];
$reflector = new ReflectionFunction($function);
var_dump($reflector->getClosureUsedVariables());
$function = function() use (&$one) {
static $three = 3;
};
$reflector = new ReflectionFunction($function);
var_dump($reflector->getClosureUsedVariables());
?>
--EXPECT--
array(0) {
}
array(0) {
}
array(2) {
["one"]=>
int(1)
["two"]=>
int(2)
}
array(1) {
["one"]=>
int(1)
}
array(1) {
["one"]=>
&int(1)
}
|