Am 17.09.2011 20:08, schrieb Stas Malyshev: > Hi! > >> On Sat, Sep 17, 2011 at 17:08, Laruence<[email protected]> 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
in this case i agree
practical sample:
class a
{
public function whatever($param, $no_cache=0)
{
}
}
class b extends a
{
public function whatever($param)
{
}
}
think about $no_cache is a new param of a library class with a default value
currently you have to "fix" all classes which are extend this class everywhere
as long you are using E_STRICT which we are using on all production machines
in combination with display_errors off and a global error-log for all hosts
to make sure we are dealing with really clean code
the same if b has an additonal parameter
as long a has lesser params this is technical OK and compatible
signature.asc
Description: OpenPGP digital signature
