Bug #64337 [Opn->Nab]: Static properties overwritten by children
| From: | laruence@php.net | Date: | Sat, 02 Mar 2013 14:42:08 +0000 |
| Subject: | Bug #64337 [Opn->Nab]: Static properties overwritten by children | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-177520@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=64337&edit=1
ID: 64337
Updated by: laruence@php.net
Reported by: nat at nath dot is
Summary: Static properties overwritten by children
-Status: Open
+Status: Not a bug
Type: Bug
Package: *General Issues
Operating System: OSX
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
if you want a new copy of static variable in sub-class => redeclare it.
not bug here.
Previous Comments:
------------------------------------------------------------------------
[2013-03-02 13:02:11] nat at nath dot is
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 this bug report at https://bugs.php.net/bug.php?id=64337&edit=1