CakeFest 2024: The Official CakePHP Conference

ReflectionFunctionAbstract::getClosureUsedVariables

(PHP 8 >= 8.1.0)

ReflectionFunctionAbstract::getClosureUsedVariablesReturns an array of the used variables in the Closure

Description

public ReflectionFunctionAbstract::getClosureUsedVariables(): array

Returns an tableau of the used variables in the Closure.

Liste de paramètres

Cette fonction ne contient aucun paramètre.

Valeurs de retour

Returns an tableau of the used variables in the Closure.

Exemples

Exemple #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());
?>

Résultat de l'exemple ci-dessus est similaire à :

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

Voir aussi

add a note

User Contributed Notes

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