ID: 39868 Updated by: [EMAIL PROTECTED] Reported By: jb at ez dot no -Status: Open +Status: Bogus Bug Type: Unknown/Other Function Operating System: Kubuntu 6.10 PHP Version: 5.2.0 New Comment:
Your arguments are based on wrong assumption that object is created in __construct(). This is wrong, because __construct() is supposed to initialize it, the object itself is created by "new" and already exists in __construct(). No bug here. Previous Comments: ------------------------------------------------------------------------ [2006-12-19 10:38:45] jb at ez dot no I'm sorry but this is definitely not Bogus, changing back to Open. ------------------------------------------------------------------------ [2006-12-19 09:59:37] jb at ez dot no > You didn't read my reply, did you? > "Master::__construct() is called, you don't see the > output because the > exception is thrown just before you print it." I did read it, and I just think you misunderstood my explanation. If you see in Master::__construct() there is no exception throwing, hence this constructor cannot throw any exceptions. The throwing is done in the Child::__construct() (which does not inherit the Master class) and so it will not interfere with the constructor of the Master class. I don't see why PHP would call the constructor then immediately stop it before it gets to the first line of the constructor code. Did you try to run this through a debugger (GDB) to verify that the constructor is actually run? ------------------------------------------------------------------------ [2006-12-19 09:32:21] [EMAIL PROTECTED] >You don't think it is a problem that the destructor (for >Master) is called while the constructor (for Master) is >never called? You didn't read my reply, did you? "Master::__construct() is called, you don't see the output because the exception is thrown just before you print it." ------------------------------------------------------------------------ [2006-12-19 08:28:46] jb at ez dot no You don't think it is a problem that the destructor (for Master) is called while the constructor (for Master) is never called? In this example neither the constructor or the destructor should be called since an exception is thrown in the Child class, ie. the new Master() expression should never be processed. The problem seems to be that PHP actually allocates the object for Master and then delays the call to construct until the parameters are prepared (which makes sense, except the allocation). Then when the exception is thrown PHP will cleanup all variables/objects, it then sees the allocated object and tries the destructor, In a good object oriented language you would never call the destructor unless the constructor was called and was completed 100%. ------------------------------------------------------------------------ [2006-12-18 14:46:29] [EMAIL PROTECTED] I don't see anything wrong here. With "$b = new Child(); $a = new Master( $b );" the second line does not get executed, of course you won't see any of Master methods called. But "$a = new Master( new Child() );" is totally different case - Master::__construct() is called, you don't see the output because the exception is thrown just before you print it. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/39868 -- Edit this bug report at http://bugs.php.net/?id=39868&edit=1