mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00

Make a distinction at compile time between bind types for static variables getStaticVariables remains unchanged Fixes #80071
60 lines
975 B
PHP
60 lines
975 B
PHP
--TEST--
|
|
ReflectionFunctionAbstract::getClosureUsedVariables
|
|
--FILE--
|
|
<?php
|
|
$reflector = new ReflectionFunction("strlen");
|
|
|
|
var_dump($reflector->getClosureUsedVariables());
|
|
|
|
$function = function() {
|
|
static $one = 1;
|
|
};
|
|
|
|
$reflector = new ReflectionFunction($function);
|
|
|
|
var_dump($reflector->getClosureUsedVariables());
|
|
|
|
$one = 1;
|
|
$two = 2;
|
|
|
|
$function = function() use ($one, $two) {
|
|
static $three = 3;
|
|
};
|
|
|
|
$reflector = new ReflectionFunction($function);
|
|
|
|
var_dump($reflector->getClosureUsedVariables());
|
|
|
|
$function = fn() => $three = [$one];
|
|
|
|
$reflector = new ReflectionFunction($function);
|
|
|
|
var_dump($reflector->getClosureUsedVariables());
|
|
|
|
$function = function() use (&$one) {
|
|
static $three = 3;
|
|
};
|
|
|
|
$reflector = new ReflectionFunction($function);
|
|
|
|
var_dump($reflector->getClosureUsedVariables());
|
|
?>
|
|
--EXPECT--
|
|
array(0) {
|
|
}
|
|
array(0) {
|
|
}
|
|
array(2) {
|
|
["one"]=>
|
|
int(1)
|
|
["two"]=>
|
|
int(2)
|
|
}
|
|
array(1) {
|
|
["one"]=>
|
|
int(1)
|
|
}
|
|
array(1) {
|
|
["one"]=>
|
|
&int(1)
|
|
}
|