Re: Warn when declaring required parameter after optional one

From: Date: Sun, 19 Jan 2020 22:18:02 +0000
Subject: Re: Warn when declaring required parameter after optional one
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to internals+get-108199@lists.php.net to get a copy of this message
On Fri, Jan 17, 2020 at 11:59 AM Nikita Popov <nikita.ppv@gmail.com> wrote: >> I've created https://github.com/php/php-src/pull/5067 >> to make code like >> function test($foo = null, $bar) {} >> throw a warning > > I was interested in seeing how prevalent this pattern, is, so I ran > some analysis on the top 2k composer packages. I found 527 signatures > that would throw a deprecation warning with this change. Of these 187 > are potentially used as "poor man's nullable types" (the optional > argument has both a type and a null default), while the other 340 are > definite bugs. Given that most of these usages are definite bugs, I'm in favor of deprecating this in PHP 8 and making it a compile error in PHP 9. This should provide plenty of time for codebases to migrate to the simpler nullable types syntax for the minority of usages that aren't bugs. Theodore

« previous php.internals (#108199) next »