ID:               34128
 Updated by:       [EMAIL PROTECTED]
 Reported By:      tim dot rodger at gmail dot com
-Status:           Open
+Status:           Closed
 Bug Type:         Class/Object related
 Operating System: Debian Sarge (kernel 2.6.12)
 PHP Version:      5.0.4
 New Comment:

Fixed -> closed.


Previous Comments:
------------------------------------------------------------------------

[2005-08-14 18:05:31] tim dot rodger at gmail dot com

I've installed the latest snap-shot on a second debian machine (with a
2.6.9 kernel), since I didn't want to replace php on the machine i
found the bug on. I've just now tested the bug under the latest version
5.1.0-dev and it's fixed.

------------------------------------------------------------------------

[2005-08-14 15:12:38] [EMAIL PROTECTED]

Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip



------------------------------------------------------------------------

[2005-08-14 15:08:17] tim dot rodger at gmail dot com

Description:
------------
When a static (either public or protected) class member is initialised
to a default value in a class declaration and later the value is
over-written in the class where it is decalred, inheriting classes
cannot access the new member value. In the example class Bar can access
the value assigned to Foo's $name member, but Bar cannot access the
value assigned to Foo's $age member.

If the $age member is assigned a value inside class Bar (in the
constructor for example) then the code works as expected.

Reproduce code:
---------------
<?php
class Foo{
        protected static $name;
        protected static $age = NULL;
        public function __construct($name, $age){
                self::$name = $name;
                self::$age = $age;}
        protected static function getName(){return self::$name;}
        protected static function getAge(){return self::$age;}
}
class Bar extends Foo {
        public function __construct($name, $age){
                parent::__construct($name, $age);}
        public function display(){
                print "name = '" . self::$name . "'\ngetName() = '" .
self::getName() . "'\nage = '" . self::$age . "'\ngetAge() = '" .
self::getAge() . "'\n";}
}
$b = new Bar('test', 100);
$b->display();
?>

Expected result:
----------------
name = 'test'
getName() = 'test'
age = '100'
getAge() = '100'


Actual result:
--------------
name = 'test'
getName() = 'test'
age = ''
getAge() = '100'



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=34128&edit=1

Reply via email to