1--TEST-- 2ReflectionFunctionAbstract::getClosureUsedVariables 3--FILE-- 4<?php 5$reflector = new ReflectionFunction("strlen"); 6 7var_dump($reflector->getClosureUsedVariables()); 8 9$function = function() { 10 static $one = 1; 11}; 12 13$reflector = new ReflectionFunction($function); 14 15var_dump($reflector->getClosureUsedVariables()); 16 17$one = 1; 18$two = 2; 19 20$function = function() use ($one, $two) { 21 static $three = 3; 22}; 23 24$reflector = new ReflectionFunction($function); 25 26var_dump($reflector->getClosureUsedVariables()); 27 28$function = fn() => $three = [$one]; 29 30$reflector = new ReflectionFunction($function); 31 32var_dump($reflector->getClosureUsedVariables()); 33 34$function = function() use (&$one) { 35 static $three = 3; 36}; 37 38$reflector = new ReflectionFunction($function); 39 40var_dump($reflector->getClosureUsedVariables()); 41?> 42--EXPECT-- 43array(0) { 44} 45array(0) { 46} 47array(2) { 48 ["one"]=> 49 int(1) 50 ["two"]=> 51 int(2) 52} 53array(1) { 54 ["one"]=> 55 int(1) 56} 57array(1) { 58 ["one"]=> 59 &int(1) 60} 61