Bug #51581 [NEW]: getDefaultProperties incorrect for static properties

From: Date: Sat, 17 Apr 2010 00:24:07 +0000
Subject: Bug #51581 [NEW]: getDefaultProperties incorrect for static properties
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-149624@lists.php.net to get a copy of this message
From:             
Operating system: Mac OSx 10.6
PHP version:      5.3.2
Package:          Reflection related
Bug Type:         Bug
Bug description:getDefaultProperties incorrect for static properties

Description:
------------
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* 
property.

Test script:
---------------
<?php

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

$r = new ReflectionClass('foo');
print_r($r->getDefaultProperties());

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

print_r($r->getDefaultProperties());

?>

Expected result:
----------------
Array
(
    [bar] => true default value
)
Array
(
    [bar] => true default value
)

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

-- 
Edit bug report at http://bugs.php.net/bug.php?id=51581&edit=1
-- 
Try a snapshot (PHP 5.2):            http://bugs.php.net/fix.php?id=51581&r=trysnapshot52
Try a snapshot (PHP 5.3):            http://bugs.php.net/fix.php?id=51581&r=trysnapshot53
Try a snapshot (PHP 6.0):            http://bugs.php.net/fix.php?id=51581&r=trysnapshot60
Fixed in SVN:                        http://bugs.php.net/fix.php?id=51581&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=51581&r=needdocs
Fixed in release:                    http://bugs.php.net/fix.php?id=51581&r=alreadyfixed
Need backtrace:                      http://bugs.php.net/fix.php?id=51581&r=needtrace
Need Reproduce Script:               http://bugs.php.net/fix.php?id=51581&r=needscript
Try newer version:                   http://bugs.php.net/fix.php?id=51581&r=oldversion
Not developer issue:                 http://bugs.php.net/fix.php?id=51581&r=support
Expected behavior:                   http://bugs.php.net/fix.php?id=51581&r=notwrong
Not enough info:                     http://bugs.php.net/fix.php?id=51581&r=notenoughinfo
Submitted twice:                     http://bugs.php.net/fix.php?id=51581&r=submittedtwice
register_globals:                    http://bugs.php.net/fix.php?id=51581&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=51581&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=51581&r=dst
IIS Stability:                       http://bugs.php.net/fix.php?id=51581&r=isapi
Install GNU Sed:                     http://bugs.php.net/fix.php?id=51581&r=gnused
Floating point limitations:          http://bugs.php.net/fix.php?id=51581&r=float
No Zend Extensions:                  http://bugs.php.net/fix.php?id=51581&r=nozend
MySQL Configuration Error:           http://bugs.php.net/fix.php?id=51581&r=mysqlcfg



Thread (8 messages)

« previous php.bugs (#149624) next »