Closed
Description
Description
It seems that when using a ReflectionFunction
method getClosureUsedVariables()
to retrieve its use
variables, when the closure has a variadic argument, getClosureUsedVariables()
returns an empty array
it can be reproduced (both in PHP8.1 and PHP8.2) by running this simple snipped
$data = 1;
$closure = function($var) use($data){};
var_dump((new ReflectionFunction($closure))->getClosureUsedVariables());
$closure = function($var, ...$variadic) use($data){};
var_dump((new ReflectionFunction($closure))->getClosureUsedVariables());
Resulted in this output:
array(1) {
["data"] => int(1)
}
array(0) {
}
But I expected this output instead:
array(1) {
["data"] => int(1)
}
array(0) {
["data"] => int(1)
}
PHP Version
PHP 8.2.2 (also in PHP 8.1.15 as well)
Operating System
tested in Ubuntu 20.04, 21.04 and alpine