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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Thu May 02 13:01:30 2024 UTC