On Fri, Apr 9, 2021 at 9:24 AM Benjamin Morel <benjamin.mo...@gmail.com>
wrote:

> Hi internals,
>
> I'm wondering why PHP 8 started warning about required parameters declared
> after optional ones, when this version is the one that also introduced
> named parameters, which can take advantage of this:
>
> ```
> function test($a = 1, $b) {
>     echo $a, $b;
> }
>
> test(b: 2);
> ```
>
> > Deprecated: Required parameter $b follows optional parameter $a in
> /in/DmhYG on line 3
> > 12
>
> https://3v4l.org/DmhYG
>
> If I'm not mistaken, the introduction of this warning (January 2020
> <https://externals.io/message/108052>) predates the introduction of named
> parameters (May 2020 <https://wiki.php.net/rfc/named_params>), which could
> explain why it would have temporarily made sense to introduce this warning.
>
> Shouldn't it be removed now, that it makes IMO full sense with named
> parameters to have required and optional parameters at arbitrary positions?
>

I'd say it's the other way around, and named parameters are at fault here:
We should not be allowing that call. We should probably explicitly drop
such default values during compilation (which will change reflection output
though).

Nikita

Reply via email to