(PHP 8 >= 8.1.0)
ReflectionFunctionAbstract::getClosureUsedVariables — Returns an array of the used variables in the Closure
Returns an array of the used variables in the Closure.
Esta función no tiene parámetros.
Returns an array of the used variables in the Closure.
Ejemplo #1 ReflectionFunctionAbstract::getClosureUsedVariables() example
<?php
$one = 1;
$two = 2;
$function = function() use ($one, $two) {
static $three = 3;
};
$reflector = new ReflectionFunction($function);
var_dump($reflector->getClosureUsedVariables());
?>
El resultado del ejemplo sería algo similar a:
array(2) { ["one"]=> int(1) ["two"]=> int(2) }