php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #62510 Some suggestions for static variables inside functions and methods
Submitted: 2012-07-08 18:06 UTC Modified: 2021-04-06 14:14 UTC
From: dev at pp3345 dot de Assigned:
Status: Suspended Package: Reflection related
PHP Version: 5.4.4 OS:
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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: dev at pp3345 dot de
New email:
PHP Version: OS:

 

 [2012-07-08 18:06 UTC] dev at pp3345 dot de
Description:
------------
With Reflection, it is possible to get and set static properties in classes, 
even 
when they are private or protected. This should also be possible for static 
variables inside functions and methods. There is a method 
ReflectionFunctionAbstract::getStaticVariables() that returns the names and 
values 
of static variables inside the function. In my opinion, there should also be a 
function ReflectionFunctionAbstract::setStaticVariable(). 

I'd also like to mention this bug: https://bugs.php.net/bug.php?id=51581 - It 
was 
declined about two years ago but I think it should be fixed. I suggested in a 
comment that a solution for the increased memory usage could be a ini-setting 
(like "reflection.track_static_properties") that enables (should probably be 
disabled by default) the tracking of the default values of static properties. If 
this could be done, I also suggest adding a similar function to retrieve the 
default values of static variables in functions, for example 
ReflectionFunctionAbstract::getDefaultStaticVariables().


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-04-06 14:14 UTC] cmb@php.net
-Status: Open +Status: Suspended
 [2021-04-06 14:14 UTC] cmb@php.net
While I think adding these methods makes sense, this is clearly
something that requires an RFC.  So if you, or anybody else for
that matter, is still interested in having these methods, please
pursue the RFC process[1].  For the time being, I suspend this
ticket.

Please note that uopz_set_static()[2] already allows to change the
value of function statics.

[1] <https://wiki.php.net/rfc/howto>
[2] <https://www.php.net/manual/en/function.uopz-set-static.php>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 16:01:28 2024 UTC