php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71250 ReflectionFunction getStaticVariables returns the variables defined in "use"
Submitted: 2015-12-30 21:10 UTC Modified: 2016-01-02 07:36 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: mfaust at usinternet dot com Assigned: laruence (profile)
Status: Assigned Package: Reflection related
PHP Version: 5.6.16 OS: Linux
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2015-12-30 21:10 UTC] 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)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-01-02 07:36 UTC] laruence@php.net
-Assigned To: +Assigned To: laruence
 [2016-01-02 07:36 UTC] 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.
 
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC