Edit report at https://bugs.php.net/bug.php?id=71250&edit=1
ID: 71250
Updated by: cmb@php.net
Reported by: mfaust at usinternet dot com
Summary: ReflectionFunction getStaticVariables returns the
variables defined in "use"
-Status: Assigned
+Status: Verified
-Type: Bug
+Type: Documentation Problem
Package: Reflection related
Operating System: Linux
PHP Version: 5.6.16
-Assigned To: laruence
+Assigned To:
Block user comment: N
Private report: N
New Comment:
See <https://3v4l.org/lUemN>.
While this *might* have been overlooked when anonymous functions
have been implemented, at this point there is likely code relying
on this behavior, so changing it would constitute a BC break.
Thus, I'm changing to documentation problem.
If anyone is interested in changing the current behavior, please
pursue the RFC process[1].
[1] <https://wiki.php.net/rfc/howto>
Previous Comments:
------------------------------------------------------------------------
[2016-01-02 07:36:18] laruence@php.net
There is no such info in run-time. thus I don't see a easy way to fix it, but maybe we could
fix this in 7.1.
------------------------------------------------------------------------
[2015-12-30 21:10:02] mfaust at usinternet dot com
Description:
------------
ReflectionFunction::getStaticVariables returns the variables defined in a "use" clause of
an anonymous function even though they are not specifically declared as "static" within
the function. This might be an internal implementation detail of how "use" works but they
should not be reported as "static" variables in terms of reflection.
Test script:
---------------
$var = 6;
$a = function() use ($var){
echo $var;
};
$reflected = new \ReflectionFunction($a);
var_export($reflected->getStaticVariables());
Expected result:
----------------
Should not have 'var' listed as a static variable.
array( )
Actual result:
--------------
Has 'var' listed as a static variable
array('var' => 6)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=71250&edit=1