Re: Warn when declaring required parameter after optional one
| From: | Andrea Faulds | Date: | Sun, 19 Jan 2020 21:14:53 +0000 |
| Subject: | Re: Warn when declaring required parameter after optional one | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-108198@lists.php.net to get a copy of this message | ||
Hi Nikita,
Nikita Popov wrote:
Since nullable types have been available since PHP 7.1, having a required
parameter after an optional one is increasingly likely a bug rather than an
intentional workaround, so I think it would be good to throw a warning for
this case.
Wouldn't it be trivial to special-case = NULL here to not cause a warning, or to cause an E_NOTICE instead of an E_WARNING? That would make this less annoying for old code. I don't know whether I think this worth doing or not, I just want to point out the possibility.
Thanks,
Andrea