Edit report at https://bugs.php.net/bug.php?id=61658&edit=1
ID: 61658
User updated by: thomash dot usa at gmail dot com
Reported by: thomash dot usa at gmail dot com
Summary: Inherited static properties are not overwritten
-Status: Open
+Status: Closed
Type: Bug
Package: Class/Object related
Operating System: Arch Linux
PHP Version: 5.3.8
Block user comment: N
Private report: N
New Comment:
Ignore me, It's late
Previous Comments:
------------------------------------------------------------------------
[2012-04-07 06:16:39] thomash dot usa at gmail dot com
PHP Version set to 5.3.8
------------------------------------------------------------------------
[2012-04-07 06:10:30] thomash dot usa at gmail dot com
Description:
------------
I'm not sure if this is a bug or if this is intended, but I didn't find
anything in the documentation:
If a class inherits a static property, but overrides it with its own static
property, the property of the parent is used.
(If the properties are not marked as static, I get the expected result)
Test script:
---------------
class A{
protected static $hi="Hello";
public function __construct(){
$class=get_class();
echo $class::$hi;
}
}
class B extends A{
protected static $hi="What's up";
}
$a=new A();
$b=new B();
Expected result:
----------------
HelloWhat's up
Actual result:
--------------
HelloHello
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=61658&edit=1