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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
44 - 28 = ?
Subscribe to this entry?

 
 [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: Fri May 17 08:01:35 2024 UTC