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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: mfaust at usinternet dot com
New email:
PHP Version: OS:

 

 [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-2019 The PHP Group
All rights reserved.
Last updated: Fri Aug 23 05:01:27 2019 UTC