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

From: Date: Tue, 23 Feb 2010 15:25:20 +0000
Subject: #50870 [Opn->Bgs]: 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-3960@lists.php.net to get a copy of this message
ID: 50870 Updated by: johannes@php.net Reported By: sjoerd-php at linuxonly dot nl -Status: Open +Status: Bogus Bug Type: Documentation problem PHP Version: Irrelevant 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 This is a design decision. Previous Comments: ------------------------------------------------------------------------ [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 (#3960) next »