Re: Signature compatibility: Number of arguments
| From: | Patrick ALLAERT | Date: | Thu, 29 Aug 2013 11:14:11 +0000 |
| Subject: | Re: Signature compatibility: Number of arguments | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-68679@lists.php.net to get a copy of this message | ||
2013/8/29 Nikita Popov <nikita.ppv@gmail.com>:
> 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.
I respectfully disagree.
The first method requires at least one parameter (or two, depending on
the pending clarification in the other thread) , and the latest: zero
or more (or 1 or more).
> 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?
I see no reason to do so and I would say -0.5.