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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
50 + 13 = ?
Subscribe to this entry?

 
 [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: Thu Nov 21 15:01:22 2019 UTC