|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51581 getDefaultProperties incorrect for static properties
Submitted: 2010-04-17 02:24 UTC Modified: 2010-05-26 18:45 UTC
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: ChadFulton at gmail dot com Assigned: dmitry (profile)
Status: Wont fix Package: Scripting Engine problem
PHP Version: 5.3.2 OS: Mac OSx 10.6
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2010-04-17 02:24 UTC] ChadFulton at gmail dot com
The array ReflectionClass's getDefaultProperties() method changes for static 
properties, depending upon what value the static property currently holds.

I suppose there is an argument to be made that this is expected/desired, since 
static properties are meant to hold across all instances of the class. However, it 
doesn't seem like it necessarily fits as part of a function to get the *default* 

Test script:

class foo {
    static public $bar = 'true default value';

$r = new ReflectionClass('foo');

foo::$bar = 'new static value, no longer default though';



Expected result:
    [bar] => true default value
    [bar] => true default value

Actual result:
    [bar] => true default value
    [bar] => new static value, no longer default though


fix-reflection-of-default-static-members (last revision 2010-05-12 13:45 UTC by
fix-refs-to-default-static-members (last revision 2010-05-12 13:42 UTC by

Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-05-12 15:42 UTC]
The following patch has been added/updated:

Patch Name: fix-refs-to-default-static-members
Revision:   1273671720
 [2010-05-12 15:45 UTC]
The following patch has been added/updated:

Patch Name: fix-reflection-of-default-static-members
Revision:   1273671935
 [2010-05-12 15:45 UTC]
-Status: Open +Status: Assigned -Assigned To: +Assigned To: dmitry
 [2010-05-12 15:45 UTC]
Dmitry, could you please review the fix-refs-to-default-static-members patch?

Thank you.
 [2010-05-13 07:20 UTC] ChadFulton at gmail dot com
Thanks for taking this issue up!
 [2010-05-21 11:29 UTC]
-Package: Reflection related +Package: Scripting Engine problem
 [2010-05-21 11:29 UTC]
IMO actually a scripting engine problem.
 [2010-05-26 18:45 UTC]
-Status: Assigned +Status: Wont fix
 [2010-05-26 18:45 UTC]
PHP don't have to keep the default values of static class variables of user-defined classes. Of course it might be used in ext/Reflection but it would require less-efficient and more-memory-consumption implementation which would affect any php script which use classes with static properties.

I would stay the behaviour as is and would disable access to default static properties values which is incorrect anyway.
 [2012-07-06 21:50 UTC] dev at pp3345 dot de

I was going to report a similar bug as I'm experiencing the same problem. I actually believe that this problem should be 
fixed as it could be quite useful in some cases to retrieve the default values of static class properties. It would be nice 
if you could think about fixing this again. I'm not sure if this is easily possible, but a solution without raising memory 
consumption for everyone could be an additional ini-setting that enables and disables tracking of the default values of 
static properties.
 [2013-01-19 14:45 UTC]
Automatic comment from SVN on behalf of googleguy
Log: Added note to documentat that this method is only intended to work with internal classes for getting the default value of static class properties.

Fixes bug #63370 also references bug #51581
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Mon Jan 20 06:01:23 2020 UTC