How do I access parameters in ReflectionFunction that have been passed using use() in closure

Viewed 129

Recently I've been facing the issue to access the parameters via a ReflectionFunction that have been passed via the use() construct to a closure.

Example:

$var = 'test';
$var2 = 'test2';
$func = function()use($var,$var2) {
    echo $var;
};

$ref = new ReflectionFunction($func);
// Access the parameters here

How would I go on to solve this problem?

1 Answers
Related