Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108198 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 9060 invoked from network); 19 Jan 2020 23:06:39 -0000 Received: from unknown (HELO localhost.localdomain) (76.75.200.58) by pb1.pair.com with SMTP; 19 Jan 2020 23:06:39 -0000 To: internals@lists.php.net References: Date: Sun, 19 Jan 2020 22:14:53 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:52.0) Gecko/20100101 Firefox/52.0 SeaMonkey/2.49.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Posted-By: 46.59.72.204 Subject: Re: Warn when declaring required parameter after optional one From: ajf@ajf.me (Andrea Faulds) Message-ID: 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