#50870 [Opn->Csd]: Constructor parameters do not have to match those of superclass constructor

From: Date: Wed, 24 Feb 2010 12:44:54 +0000
Subject: #50870 [Opn->Csd]: Constructor parameters do not have to match those of superclass constructor
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-3967@lists.php.net to get a copy of this message
ID: 50870 Updated by: degeberg@php.net Reported By: sjoerd-php at linuxonly dot nl -Status: Open +Status: Closed Bug Type: Documentation problem PHP Version: Irrelevant -Assigned To: +Assigned To: degeberg New Comment: This bug has been fixed in the documentation's XML sources. Since the online and downloadable versions of the documentation need some time to get updated, we would like to ask you to be a bit patient. Thank you for the report, and for helping us make our documentation better. Previous Comments: ------------------------------------------------------------------------ [2010-02-24 12:44:37] svn@php.net Automatic comment from SVN on behalf of degeberg Revision: http://svn.php.net/viewvc/?view=revision&revision=295468 Log: Fixed PHP bug #50870 (Constructor parameters do not have to match those of superclass constructor) ------------------------------------------------------------------------ [2010-02-23 15:34:48] johannes@php.net Can't find it in the documentation, I thought I saw it there before :-/ So it was decided that we won't enforce the signature for constructors while we allow interfaces like interface FixedCtor { function __construct(A $foo); } which enforces a compatible constructor, but default behavior is to be less strict with constructors. The interface thing was added lateron. ------------------------------------------------------------------------ [2010-02-23 15:25:19] johannes@php.net 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 This is a design decision. ------------------------------------------------------------------------ [2010-01-28 07:59:57] sjoerd-php at linuxonly dot nl Description: ------------ It is unclear when a overloading method should have the same parameters as its superclass, this could use some documentation. If you override a method in a subclass, the method needs to have the same parameters as the superclass. The following will trigger an E_STRICT: class A { public function foo(stdClass $a) { } } class B extends A { public function foo($a) { } } Strict standards: Declaration of B::foo() should be compatible with that of A::foo() This does not apply to the constructor. The __construct special method may have different parameters. The following will not give a notice: class A { public function A(stdClass $a) { } } class B extends A { public function B($a) { } } ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=50870&edit=1

« previous php.doc.bugs (#3967) next »