Hi, 2011/9/19 Frédéric Hardy <frederic.ha...@mageekbox.net>
> Hi ! > > >> You misunderstand what LSP means. It does not mean "overriding methods >> should have same signatures", it means "overriding methods should accept any >> data that base method accepts". It never says it can not accept any other >> data. >> > Idem. > So you can have : > > class A { public function f($a) { ... } } > class A1 extends A { public function f($a = null) { ... } } > class A2 extends A { public function f($a, $b = null) { ... } } > > BUT You can't have : > > class A3 extends A { public function f() { ... } } > Sure you can. With function A3::f() you can both call $a3->f() and $a3->f(any $a that would work with A), any usage of A3 as a A will work just fine, and this is the criteria. > > I'm agree that it's valid from PHP point of view because the language does > not handle the argument in $a3->f(uniqid()), but it's totaly invalid from > OOP point of view. > > So if it's invalid for "normal" method, it's more invalid for abstract > method, even if abstract method is constructor. > Abstract method define a MANDATORY interface. > So you can have : > > abstract class A { public abstract function f($a); } > class A1 extends A { public function f($a = null) { ... } } > class A2 extends A { public function f($a, $b = null) { ... } } > > BUT You can't have : > > class A3 extends A { public function f() { ... } } > > And the use of func_get_args() is not incompatible with that : > > class A4 extends A { > public function ($a) { > $variadicArgs = array_slice(func_get_args(), 1); > } > } > > Best regard, > > Fred > > -- > ==============================**==============================** > ============ > Frédéric Hardy : Architecte d'application/Admin. système/Ergonome > CV : > http://blog.mageekbox.net/**public/cv.frederic.hardy.pdf<http://blog.mageekbox.net/public/cv.frederic.hardy.pdf> > Blog : http://blog.mageekbox.net > Twitter : http://twitter.com/mageekguy > ==============================**==============================** > ============ > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Etienne Kneuss http://www.colder.ch