From:             Denfie at gmx dot net
Operating system: ubuntu4.1
PHP version:      5.2.10
PHP Bug Type:     Scripting Engine problem
Bug description:  Problem with extending classes

Description:
------------
I want to extend a class C from another class class B who was extend 
from my abstract class A. I want to get the different value of the same 
variable. So I initialize my variable "name"  and read the variable at 
my function "__toString()", so please look to my code couse my english 
is not the best ;) . its hard for me to explain.

Reproduce code:
---------------
abstract class A {
        public $name = "CLASS:A";
        public function __toString(){
                return " => ABSTRACT " . $this->name;
        }
}
class B extends A {
        public function __construct(){
                $this->name = "CLASS:B";
        }
        public function __toString(){
                return " => " . $this->name . parent::__toString();
        }
}
class C extends B {
        public function __construct(){
                parent::__construct();
                $this->name = "CLASS:C";
        }
}
$deb_b = new B();
$deb_c = new C();
printf("Result: Beginn B %s<br />", $deb_b);
printf("Result: Beginn C %s<br />", $deb_c);

Expected result:
----------------
Result: Beginn B = => CLASS:B => ABSTRACT CLASS:B
Result: Beginn C = => CLASS:C => ABSTRACT CLASS:C

Actual result:
--------------
Result: Beginn B => CLASS:B => ABSTRACT CLASS:A
Result: Beginn C => CLASS:C => CLASS:B => ABSTRACT CLASS:A

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

Reply via email to