Re: [PHP-DEV] Warn when declaring required parameter after optional one

2020-02-06 Thread Nikita Popov
On Wed, Feb 5, 2020 at 1:15 PM Guilliam Xavier wrote: > Hi, > > On Wednesday, February 5, 2020, Nikita Popov wrote: >> >> >> I like this idea and have updated the pull request to ignore the "Type >> $param = null" case, so the deprecation should now just catch the >> "definitely" incorrect signa

Re: [PHP-DEV] Warn when declaring required parameter after optional one

2020-02-05 Thread Guilliam Xavier
Hi, On Wednesday, February 5, 2020, Nikita Popov wrote: > > > I like this idea and have updated the pull request to ignore the "Type > $param = null" case, so the deprecation should now just catch the > "definitely" incorrect signatures. > > So to summarize the current state: > > function test($f

Re: [PHP-DEV] Warn when declaring required parameter after optional one

2020-01-19 Thread Theodore Brown
On Fri, Jan 17, 2020 at 11:59 AM Nikita Popov 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 compos

Re: [PHP-DEV] Warn when declaring required parameter after optional one

2020-01-17 Thread Aran Reeks
Hi all, Whilst I totally see the benefits of this, I'm not sure if this is a job for PHP itself, rather a coding standard enforced optionally by something like PHPCS. It's certainly a bad practice, but I'm not sure the benefit will be worth the refactors required. I feel we might be an interestin

Re: [PHP-DEV] Warn when declaring required parameter after optional one

2020-01-17 Thread Nikita Popov
On Sat, Jan 11, 2020 at 2:35 PM Niklas Keller wrote: > Hi Nikita, > > while this is a rather small change, it has quite some BC impact, as > not all old code has been adjusted to run on PHP 7.1+ only using > nullable types. > > I'd like to see an RFC with a vote for this. > > Regards, > Niklas >

Re: [PHP-DEV] Warn when declaring required parameter after optional one

2020-01-11 Thread Niklas Keller
Hi Nikita, while this is a rather small change, it has quite some BC impact, as not all old code has been adjusted to run on PHP 7.1+ only using nullable types. I'd like to see an RFC with a vote for this. Regards, Niklas -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe,

Re: [PHP-DEV] Warn when declaring required parameter after optional one

2020-01-09 Thread Nikita Popov
On Thu, Jan 9, 2020 at 2:41 PM Bob Weinand wrote: > Hey, > > While I generally agree that it likely is a bug in new code, I would > rather deprecate it than warn or even error: the change would make it > impossible to retain a type without warning while preserving compatibility > with an old PHP

Re: [PHP-DEV] Warn when declaring required parameter after optional one

2020-01-09 Thread Sebastian Bergmann
Am 09.01.2020 um 13:31 schrieb Sebastian Bergmann: I would prefer erroring out over just emitting a warning. What I meant, of course, was deprecation (or warning) first before erroring out. Sorry. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.n

Re: [PHP-DEV] Warn when declaring required parameter after optional one

2020-01-09 Thread Bob Weinand
Hey, While I generally agree that it likely is a bug in new code, I would rather deprecate it than warn or even error: the change would make it impossible to retain a type without warning while preserving compatibility with an old PHP version and making incremental migrations harder (would then

Re: [PHP-DEV] Warn when declaring required parameter after optional one

2020-01-09 Thread Sebastian Bergmann
Am 09.01.2020 um 13:26 schrieb Nikita Popov: What do you think? I would prefer erroring out over just emitting a warning. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-DEV] Warn when declaring required parameter after optional one

2020-01-09 Thread Nikita Popov
Hi internals, I've created https://github.com/php/php-src/pull/5067 to make code like function test($foo = null, $bar) {} throw a warning: Warning: Required parameter $bar follows optional parameter Historically, having an "optional" parameter before a required one was useful for poor