|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #62320 Abstract static property?
Submitted: 2012-06-14 07:04 UTC Modified: 2021-07-27 11:13 UTC
Avg. Score:4.0 ± 1.5
Reproduced:4 of 5 (80.0%)
Same Version:3 (75.0%)
Same OS:3 (75.0%)
From: techlivezheng at gmail dot com Assigned:
Status: Suspended Package: Scripting Engine problem
PHP Version: 5.4.3 OS: 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 — but make sure to vote on the bug!
Your email address:
Solve the problem:
21 + 8 = ?
Subscribe to this entry?

 [2012-06-14 07:04 UTC] techlivezheng at gmail dot com
As we have "late static bindings" now, would it be reasonable to have a "abstract static property"?

See the bellow example.

abstract class A {
    //If this could be declared as abstract to make 
    //the subclass have to redeclare it in order to
    //have it own $mTest to use.
    //If $mTest is not declared in one subclass, it would
    //change the $mTest of A which is shared by many 
    //subclasses, some unexpected things would happen.
    //The design is to make each subclass have its own
    //$mTest to use and it has to be existed.
    //$mTest in A is just for a skeleton purpose, even should
    //not be assigned a value.
    static $mTest;

    static function setTest($value) {
        static::$mTest = $value;

    static function DumpTest () {
        echo 'static:' . static::$mTest . "\n";
        echo 'A-self:' . self::$mTest . "\n";

class B extends A {
    static function DumpTest () {
        echo 'B-self:' . self::$mTest . "\n";
        echo 'B-parent:' . parent::$mTest . "\n";

class C extends A {
    static $mTest;
    static function DumpTest () {
        echo 'C-self:' . self::$mTest . "\n";
        echo 'C-parent:' . parent::$mTest . "\n";

class D extends C {
    static $mTest;
    static function DumpTest () {
        echo 'D-self:' . self::$mTest . "\n";
        echo 'D-parent:' . parent::$mTest . "\n";

B::setTest('test1');//This will change the $mStorages of class A


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2012-10-26 16:06 UTC] dagguh at gmail dot com
Late Static Binding is a failed concept and should be avoided in all cases.
There is no such thing as static inheritance. Static members of a class belong to 
this class and this class only.

Just use the regular instance methods and regular inheritance.
Your code will be more testable, extensible and modular.

Please close this issue as "won't fix".
 [2013-01-08 23:42 UTC] jon at langevin dot me
Very valid issue, please correct. Just because users such as "dagguh" can't 
figure out how to make LSB work, that doesn't mean it's a failed concept.

Great feature, it's just missing the needed abstract static functionality.
 [2021-07-27 11:13 UTC]
-Status: Open +Status: Suspended
 [2021-07-27 11:13 UTC]
Please pursue the RFC process[1].  For the time being, I suspend
this ticket.

[1] <>
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Tue Sep 28 00:03:37 2021 UTC