Re: __constructor parameter limitations.

From: Date: Sat, 17 Sep 2011 20:28:06 +0000
Subject: Re: __constructor parameter limitations.
References: 1 2 3 4 5 6  Groups: php.internals 
Request: Send a blank email to internals+get-55490@lists.php.net to get a copy of this message
On Sat, Sep 17, 2011 at 20:08, Stas Malyshev <smalyshev@sugarcrm.com> wrote: > Hi! > > On Sat, Sep 17, 2011 at 17:08, Laruence<laruence@php.net> wrote: >> >>> class A { public function init($a, $b) { } } >>>> >>>> class B extends A { public function init($a) { } } >>>> >>>> => PHP Strict Standards: Declaration of B::init() should be compatible >>>> >>> with >>> >>>> that of A::init() >>>> >>> do you know any reason for this? >>> >>> >> The reason for this is simply that B must act like A since every B object >> is >> also an object of A. >> > > This is not a real reason, it's just repeating it. All B is saying in fact > "I'm going to ignore everything but the first parameter", and there's no > real reason not to allow it to do that. There's no "act" that makes B > incompatible with A here, this warning is completely useless. > Right, In this very specific case the error should not be outputted, the check could be refined to let that pass. Just it it may be refined to handle contravariant typehints correctly > > -- > Stanislav Malyshev, Software Architect > SugarCRM: http://www.sugarcrm.com/ > (408)454-6900 ext. 227 > -- Etienne Kneuss http://www.colder.ch

« previous php.internals (#55490) next »