#41428 [Opn->Bgs]: Calling parent::__construct() causes a fatal error
| From: | sniper@php.net | Date: | Fri, 18 May 2007 10:58:17 +0000 |
| Subject: | #41428 [Opn->Bgs]: Calling parent::__construct() causes a fatal error | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-112811@lists.php.net to get a copy of this message | ||
ID: 41428
Updated by: sniper@php.net
Reported By: dasher at inspiredthinking dot co dot uk
-Status: Open
+Status: Bogus
Bug Type: Class/Object related
Operating System: Windows Vista Ultimate x64
PHP Version: 5.2.2
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
Previous Comments:
------------------------------------------------------------------------
[2007-05-18 09:24:38] judas dot iscariote at gmail dot com
huh ? it raises the expected error message..
PHP Fatal error: Call to undefined method parentClass::parentclass()
this is the expected behaviuor as parent::parentClass(); does not
exists at all.
------------------------------------------------------------------------
[2007-05-18 09:14:31] dasher at inspiredthinking dot co dot uk
Description:
------------
Calling parent::_construct() from an extended class causes a fatal
error when the parent doesn't have a constructor.
When you've full control over the code - it's not an issue - but when
the parent comes from a code library it's becomes difficult to know if
you should call the constructor. With code libraries such as PEAR - the
parent class might not have a constructor today but might have one
tomorrow.
Reproduce code:
---------------
class parentClass {
function someMethod() {
}
}
class childClass extends parentClass {
function childClass() {
parent::parentClass();
}
}
$obj = new childClass();
Expected result:
----------------
The code above should run without generating a Fatal error - at most
the error should be an E_NOTICE or E_WARNING.
Actual result:
--------------
Fatal error: Can not call constructor in filename.php on Line 007
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=41428&edit=1