Bug #64337 [NEW]: Static properties overwritten by children
| From: | nat at nath dot is | Date: | Sat, 02 Mar 2013 13:02:11 +0000 |
| Subject: | Bug #64337 [NEW]: Static properties overwritten by children | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-177518@lists.php.net to get a copy of this message | ||
From: nat at nath dot is
Operating system: OSX
PHP version: Irrelevant
Package: *General Issues
Bug Type: Bug
Bug description:Static properties overwritten by children
Description:
------------
If you extend a class, which has a static property, and set that static
property,
it will overwrite the variable in the parent, not in the child.
Test script:
---------------
<?php
class One {
public static $var = 'hi';
}
class Two extends One {
public static function set($var) {
static::$var = $var;
}
}
Two::set('bye');
var_dump(One::$var);
Expected result:
----------------
"hi"
Actual result:
--------------
"bye"
--
Edit bug report at https://bugs.php.net/bug.php?id=64337&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=64337&r=trysnapshot54
Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=64337&r=trysnapshot53
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=64337&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=64337&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=64337&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=64337&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=64337&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=64337&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=64337&r=support
Expected behavior: https://bugs.php.net/fix.php?id=64337&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=64337&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=64337&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=64337&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=64337&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=64337&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=64337&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=64337&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=64337&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=64337&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=64337&r=mysqlcfg