ID: 46594 Updated by: [EMAIL PROTECTED] Reported By: dckorah at gmail dot com -Status: Open +Status: Closed Bug Type: Class/Object related Operating System: Linux (Ububtu 7.10) PHP Version: 5.2.6 New Comment:
This is actually fixed in PHP_5_3 branch already: [EMAIL PROTECTED] ~]$ src/build/php_5_3/sapi/cli/php -n t.php Fatal error: Non-static method A::__construct() cannot be called statically, assuming $this from incompatible context in /home/jani/t.php on line 11 [EMAIL PROTECTED] ~]$ src/build/php_5_2/sapi/cli/php -n t.php object(B)#1 (2) { ["a_property"]=> string(19) "property set from A" ["b_property"]=> string(19) "property set from B" } Previous Comments: ------------------------------------------------------------------------ [2008-11-18 23:29:57] [EMAIL PROTECTED] Actually this has nothing to do with __construct(), same happens with "regular" methods too. ------------------------------------------------------------------------ [2008-11-17 14:04:31] dckorah at gmail dot com 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 this bug report at http://bugs.php.net/?id=46594&edit=1