On Thu, Aug 29, 2013 at 11:33 AM, Nikita Popov <nikita....@gmail.com> wrote:
> Hi internals! > > This is a spinoff from the variadics thread. Quoting Stas: > > > I also think this: > > public function query($query, ...$params) > > public function query(...$params) > > should be legal too. > > This is a general issue in PHP that we might want to fix: Currently a > method A is not compatible with a method B if A has less arguments than B. > > E.g. both of the following are incompatible signatures: > > public function foo($bar) > public function foo() > > public function foo($bar = NULL) > public function foo() > I dont really agree. One could use reflection on the parameter, thus expecting it to be here on a child instance : class Foo { public function bar($arg = null) { } } class Foo2 extends Foo { public function bar() { } } $o = new Foo; /* Switching to Foo2 will lead to an Exception */ $r = new ReflectionParameter(array($o, 'bar'), 'arg'); echo $r->getName(); PS : I remember having a long discussion with Gustavo, some time ago, about LSP in PHP ; and we could not agree on some points, particularly concerning optional parameters. Julien.Pauli