From:             dckorah at gmail dot com
Operating system: Linux (Ububtu 7.10)
PHP version:      5.2.6
PHP Bug Type:     Class/Object related
Bug description:  call to OtherClass::__construct within MyClass::__construct

Description:
------------
<?php
class A {
    function __construct() {
        $this->a_property = 'property set from A';
    }
}

class B {
    function __construct() {
        A::__construct();
        $this->b_property = 'property set from B';
    }
}
?>
In the above code, if you initialise class B and inspect the properties of
it, you will see that both a_property and b_property are set.

This is quite unexpected from an OO language.


version info:
PHP 5.2.3-1ubuntu6.4 (cli) (built: Jul 23 2008 06:20:35)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies


Reproduce code:
---------------
<?php

class A {
    function __construct() {
        $this->a_property = 'property set from A';
    }
}

class B {
    function __construct() {
        A::__construct();
        $this->b_property = 'property set from B';
    }
}

?>


Expected result:
----------------
Class A has got nothing to do with class B and this should not happen. If
at all an user trys this, it should throw an error.

Actual result:
--------------
Please see description.

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

Reply via email to