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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
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: Sun Nov 17 12:01:34 2019 UTC