php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #61658 Inherited static properties are not overwritten
Submitted: 2012-04-07 06:10 UTC Modified: 2012-04-07 06:44 UTC
From: thomash dot usa at gmail dot com Assigned:
Status: Closed Package: Class/Object related
PHP Version: 5.3.8 OS: Arch Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: thomash dot usa at gmail dot com
New email:
PHP Version: OS:

 

 [2012-04-07 06:10 UTC] 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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-04-07 06:16 UTC] thomash dot usa at gmail dot com
-PHP Version: 5.4.0 +PHP Version: 5.3.8
 [2012-04-07 06:16 UTC] thomash dot usa at gmail dot com
PHP Version set to 5.3.8
 [2012-04-07 06:44 UTC] thomash dot usa at gmail dot com
Ignore me, It's late
 [2012-04-07 06:44 UTC] thomash dot usa at gmail dot com
-Status: Open +Status: Closed
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jan 05 03:01:28 2025 UTC