On Sat, Sep 17, 2011 at 20:08, Stas Malyshev <smalys...@sugarcrm.com> wrote:
> Hi! > > On Sat, Sep 17, 2011 at 17:08, Laruence<larue...@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