php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #63370 ReflectionCLass::getDefaultProperties() return is incorrect for static properti
Submitted: 2012-10-26 14:01 UTC Modified: 2013-01-19 14:46 UTC
From: dimzav at gmail dot com Assigned: googleguy (profile)
Status: Closed Package: Reflection related
PHP Version: 5.3.18 OS: Win 7 x64
Private report: No CVE-ID: None
 [2012-10-26 14:01 UTC] dimzav at gmail dot com
Description:
------------
ReflectionCLass::getDefaultProperties() returns current value of static property, not the default one. I can't add comment to https://bugs.php.net/bug.php?id=51581 but it is evidently a bug and must be fixed.

Test script:
---------------
class A
{
    public static $a = 1;
}

A::$a = 2;

$reflectionCLass = new ReflectionClass('A');
$defaultProperties = $reflectionCLass->getDefaultProperties();
var_dump($defaultProperties);

Expected result:
----------------
Default value of $a static property is 1, it should be returned by ReflectionCLass::getDefaultProperties() instead of current value.

Actual result:
--------------
C:\OpenServer\modules\php\PHP-5.3.18\php.exe temp.php
array(1) {
  ["a"]=>
  int(2)
}


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-10-26 17:32 UTC] hanskrentel at yahoo dot de
Please do not create a duplicate of the existing issue #51581. There was a 
decision to not fix it for some reasons.

Also IMHO default values for global static class variables are as useful as 
getting default values for other global variables.

You might have more luck in requesting a general reflection features for 
variables - global ones, local ones, static ones and class static ones.
 [2012-10-26 17:49 UTC] dimzav at gmail dot com
Reasons given are:
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 don't understand why performance issue should be excuse for bug. And I can't add comments to that bug, so what else can I do? Only create new ticket for bug which is evident and can't be excused by any performance reasons.
 [2012-10-28 11:50 UTC] cataphract@php.net
Should be documented only to work with internal classes. Otherwise, Won't Fix (see the justification in bug #51581).
 [2012-10-28 11:50 UTC] cataphract@php.net
-Type: Bug +Type: Documentation Problem
 [2013-01-19 14:45 UTC] googleguy@php.net
Automatic comment from SVN on behalf of googleguy
Revision: http://svn.php.net/viewvc/?view=revision&revision=329237
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
 [2013-01-19 14:46 UTC] googleguy@php.net
The fix for this bug has been committed.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.


 [2013-01-19 14:46 UTC] googleguy@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: googleguy
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 07:01:28 2024 UTC