Re: Signature compatibility: Number of arguments

From: Date: Wed, 18 Sep 2013 10:30:01 +0000
Subject: Re: Signature compatibility: Number of arguments
References: 1  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
On Thu, Aug 29, 2013 at 11:33 AM, Nikita Popov <[email protected]> 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()
>
> This doesn't really make sense. Removing parameters doesn't violate LSP,
> because in PHP it is legal to pass more arguments than declared. (Only
> adding additional required parameters would violate LSP.)
>
> Is it okay to change this?
>
> Thanks,
> Nikita
>

Considering that we might support named parameters in the future I'm
withdrawing this suggestion. This allows removing a parameter name, which
would cause problems in that context.

Nikita


Thread (7 messages)

« previous php.internals (#69182) next »