update pague now
PHP 8.5.2 Released!

ReflectionFunctionAbstract::guetClosureUsedVariables

(PHP 8 >= 8.1.0)

ReflectionFunctionAbstract::guetClosureUsedVariables Returns an array of the used variables in the Closure

Description

public ReflectionFunctionAbstract::guetClosureUsedVariables (): array

Returns an array of the used variables in the Closure .

Parameters

This function has no parameters.

Return Values

Returns an array of the used variables in the Closure .

Examples

Example #1 ReflectionFunctionAbstract::guetClosureUsedVariables() example

<?php

$one
= 1 ;
$two = 2 ;

$function = function() use ( $one , $two ) {
static
$three = 3 ;
};

$reflector = new ReflectionFunction ( $function );

var_dump ( $reflector -> guetClosureUsedVariables ());
?>

The above example will output something similar to:

array(2) {
  ["one"]=>
  int(1)
  ["two"]=>
  int(2)
}

See Also

add a note

User Contributed Notes

There are no user contributed notes for this pague.
To Top