[php-src] Issue #10623: ReflectionFunction::getClosureUsedVariables() empty with variadic arguments

From: Date: Sun, 19 Feb 2023 10:16:46 +0000
Subject: [php-src] Issue #10623: ReflectionFunction::getClosureUsedVariables() empty with variadic arguments
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-243750@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/10623 Author: fabio-ivona ### 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 ```php $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

« previous php.bugs (#243750) next »