From:             techlivezheng at gmail dot com
Operating system: Linux
PHP version:      5.4.3
Package:          Scripting Engine problem
Bug Type:         Feature/Change Request
Bug description:Abstract static property?

Description:
------------
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 () {
        parent::DumpTest();
        echo 'B-self:' . self::$mTest . "\n";
        echo 'B-parent:' . parent::$mTest . "\n";
    }
}

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

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

B::setTest('test1');//This will change the $mStorages of class A
B::DumpTest();
//static:test1
//A-self:test1
//B-self:test1
//B-parent:test1
C::setTest('test2');
C::DumpTest();
//static:test2
//A-self:test1
//C-self:test2
//C-parent:test1
D::setTest('test3');
D::DumpTest();
static:test3
//A-self:test1
//C-self:test2
//C-parent:test1
//D-self:test3
//D-parent:test2


-- 
Edit bug report at https://bugs.php.net/bug.php?id=62320&edit=1
-- 
Try a snapshot (PHP 5.4):            
https://bugs.php.net/fix.php?id=62320&r=trysnapshot54
Try a snapshot (PHP 5.3):            
https://bugs.php.net/fix.php?id=62320&r=trysnapshot53
Try a snapshot (trunk):              
https://bugs.php.net/fix.php?id=62320&r=trysnapshottrunk
Fixed in SVN:                        
https://bugs.php.net/fix.php?id=62320&r=fixed
Fixed in SVN and need be documented: 
https://bugs.php.net/fix.php?id=62320&r=needdocs
Fixed in release:                    
https://bugs.php.net/fix.php?id=62320&r=alreadyfixed
Need backtrace:                      
https://bugs.php.net/fix.php?id=62320&r=needtrace
Need Reproduce Script:               
https://bugs.php.net/fix.php?id=62320&r=needscript
Try newer version:                   
https://bugs.php.net/fix.php?id=62320&r=oldversion
Not developer issue:                 
https://bugs.php.net/fix.php?id=62320&r=support
Expected behavior:                   
https://bugs.php.net/fix.php?id=62320&r=notwrong
Not enough info:                     
https://bugs.php.net/fix.php?id=62320&r=notenoughinfo
Submitted twice:                     
https://bugs.php.net/fix.php?id=62320&r=submittedtwice
register_globals:                    
https://bugs.php.net/fix.php?id=62320&r=globals
PHP 4 support discontinued:          
https://bugs.php.net/fix.php?id=62320&r=php4
Daylight Savings:                    https://bugs.php.net/fix.php?id=62320&r=dst
IIS Stability:                       
https://bugs.php.net/fix.php?id=62320&r=isapi
Install GNU Sed:                     
https://bugs.php.net/fix.php?id=62320&r=gnused
Floating point limitations:          
https://bugs.php.net/fix.php?id=62320&r=float
No Zend Extensions:                  
https://bugs.php.net/fix.php?id=62320&r=nozend
MySQL Configuration Error:           
https://bugs.php.net/fix.php?id=62320&r=mysqlcfg

Reply via email to