Re: [PHP-DEV] [VOTE] Nullable intersection types

2021-08-14 Thread Alexandru Pătrănescu
On Sun, Aug 15, 2021, 04:33 Marco Pivetta wrote: > Heyo, just a follow-up. > > On Fri, 13 Aug 2021, 13:30 Marco Pivetta, wrote: > > > Hey Nicolas, > > > > I voted NO on this one. I'm not opposed to nullable intersection types, > > but not in PHP 8.1. > > > > Specifically, I'm waiting for the fir

Re: [PHP-DEV] [VOTE] Nullable intersection types

2021-08-14 Thread Marco Pivetta
Heyo, just a follow-up. On Fri, 13 Aug 2021, 13:30 Marco Pivetta, wrote: > Hey Nicolas, > > > On Fri, Aug 13, 2021 at 11:35 AM Nicolas Grekas > wrote: > >> Hi everyone, >> >> I'm happy to announce that the vote for nullable intersection types is now >> open: >> https://wiki.php.net/rfc/nullable

Re: [PHP-DEV] [RFC] Never For Argument Types

2021-08-14 Thread Mike Schinkel
> On Aug 14, 2021, at 10:40 AM, Jordan LeDoux wrote: > > Never is treated as the bottom type for the purpose of Liskov substitution > already with its use as a return type. The exception to this in its use as > a return type is that it isn't treated as the union identity in the return > type. How

Re: [PHP-DEV] [RFC] Never For Argument Types

2021-08-14 Thread Jordan LeDoux
On Sat, Aug 14, 2021 at 10:12 AM Claude Pache wrote: > > If users of that interface would suddenly be *required* to specify a > parameter type, whereas previously they were *forbidden* to specify one, > except a meaningless `mixed`... it would be not nice and useless. > > Moreover, note that `mix

Re: [PHP-DEV] [RFC] Never For Argument Types

2021-08-14 Thread Claude Pache
> > On Fri, 13 Aug 2021 at 19:27, Jordan LeDoux wrote: > >> Hey internals, >> >> I've been working on the draft for my operator overloading RFC, and in >> doing so I encountered a separate change that I would like to see. >> >> That is, the use of `never` as an argument type for interfaces.

Re: [PHP-DEV] [RFC] Never For Argument Types

2021-08-14 Thread Matthew Brown
Hey! Using the "never" type to require that downstream libs specify a type does not make intuitive sense to me, because the same is not true the other way (covariantly) for return types. The existence of a "never" type on an overriding method does not require that upstream libs specify a return t

Re: [PHP-DEV] Unwrap reference after foreach

2021-08-14 Thread Claude Pache
> Le 13 août 2021 à 15:28, Nikita Popov a écrit : > > Hi internals, > > I'd like to address a common footgun when using foreach by reference: > https://wiki.php.net/rfc/foreach_unwrap_ref > > This addresses the issue described in the big red box at > https://www.php.net/manual/en/control-struc

Re: [PHP-DEV] [RFC] Never For Argument Types

2021-08-14 Thread Jordan LeDoux
The RFC has been moved to the wiki: https://wiki.php.net/rfc/never_for_parameter_types The most critical points of discussion in my mind are: 1. Should never require **explicit** widening as discussed? This could be very useful but would make it the only case in PHP where omitting a type is not s

Re: [PHP-DEV] Unwrap reference after foreach

2021-08-14 Thread Hans Henrik Bergan
well today you can do foreach($it as &$value){...} unset($value); - which is pretty close, but it will break with $value="initial";foreach($it as &$value){...}unset($value); echo $value; here $value will not be "initial", it will be undefined, however you *CAN* do $value="initial";(function()use(&

Re: [PHP-DEV] [RFC] Never For Argument Types

2021-08-14 Thread Jordan LeDoux
On Sat, Aug 14, 2021 at 7:01 AM AllenJB wrote: > > Whilst I understand there's a historical aspect to the keyword naming > used in this RFC, as a PHP developer, I think the use of "never" here is > going to be confusing to people when considered along-side the never > return type. > > I think it

Re: [PHP-DEV] [RFC] Never For Argument Types

2021-08-14 Thread G. P. B.
On Sat, 14 Aug 2021 at 16:01, AllenJB wrote: > This RFC only considers this feature for arguments. Why is it also not a > valid feature for return types? I think it might be useful for abstract > classes and interfaces (for example, the Iterator interface) to force > implementers to specify a ret

Re: [PHP-DEV] Unwrap reference after foreach

2021-08-14 Thread Hans Henrik Bergan
Speaking of, i hope that one day we can support javascript-style let in php :) like foreach($it as let &$v){} but that's a discussion for another thread (and i'm sure it has been discussed before, i haven't actually checked though) On Sat, 14 Aug 2021 at 15:23, Hossein Baghayi wrote: > On Fri, 1

Re: [PHP-DEV] [RFC] Never For Argument Types

2021-08-14 Thread AllenJB
On 14/08/2021 00:27, Jordan LeDoux wrote: Hey internals, I've been working on the draft for my operator overloading RFC, and in doing so I encountered a separate change that I would like to see. That is, the use of `never` as an argument type for interfaces. Since arguments in PHP are contrav

Re: [PHP-DEV] [RFC] Never For Argument Types

2021-08-14 Thread Jordan LeDoux
On Sat, Aug 14, 2021 at 6:25 AM Nikita Popov wrote: > > function addMultiple(CollectionInterface $collection, mixed ...$inputs): > void { > foreach ($inputs as $input) $collection->add($input); > } > > A static analyzer should flag this CollectionInterface::add() call as > invalid, because mi

Re: [PHP-DEV] [RFC] Never For Argument Types

2021-08-14 Thread Nikita Popov
On Sat, Aug 14, 2021 at 1:27 AM Jordan LeDoux wrote: > Hey internals, > > I've been working on the draft for my operator overloading RFC, and in > doing so I encountered a separate change that I would like to see. > > That is, the use of `never` as an argument type for interfaces. Since > argumen

Re: [PHP-DEV] Unwrap reference after foreach

2021-08-14 Thread Hossein Baghayi
On Fri, 13 Aug 2021 at 17:59, Nikita Popov wrote: > I'd like to address a common footgun when using foreach by reference: > https://wiki.php.net/rfc/foreach_unwrap_ref > Hello, I had a question regarding this. Wouldn't it be possible to limit ```$value```'s scope to only foreach's block then dis

Re: [PHP-DEV] [RFC] Never For Argument Types

2021-08-14 Thread Deleu
On Sat, Aug 14, 2021, 14:48 G. P. B. wrote: > On Sat, 14 Aug 2021 at 10:55, Deleu wrote: > >> Hi Jordan, >> >> Does it make sense to explain in the RFC the difference between never and >> mixed in this context? The RFC vaguely mentions that never can never be >> used directly, but if it's limite

Re: [PHP-DEV] [RFC] Never For Argument Types

2021-08-14 Thread Larry Garfield
On Sat, Aug 14, 2021, at 7:48 AM, G. P. B. wrote: > On Sat, 14 Aug 2021 at 10:55, Deleu wrote: > > > Hi Jordan, > > > > Does it make sense to explain in the RFC the difference between never and > > mixed in this context? The RFC vaguely mentions that never can never be > > used directly, but if i

Re: [PHP-DEV] [RFC] Never For Argument Types

2021-08-14 Thread G. P. B.
On Sat, 14 Aug 2021 at 10:55, Deleu wrote: > Hi Jordan, > > Does it make sense to explain in the RFC the difference between never and > mixed in this context? The RFC vaguely mentions that never can never be > used directly, but if it's limited to abstract class and interfaces, isn't > that alrea

[PHP-DEV] Re: Broken reference at https://wiki.php.net/rfc/howto

2021-08-14 Thread Christoph M. Becker
On 14.08.2021 at 00:43, Willian de Souza wrote: > Hope I'm in the right place, I was reading > and I found a broken reference, > the link to the explanation of the "bottom post"  in first step > redirects to this page: >

Re: [PHP-DEV] [RFC] Never For Argument Types

2021-08-14 Thread Deleu
Hi Jordan, Does it make sense to explain in the RFC the difference between never and mixed in this context? The RFC vaguely mentions that never can never be used directly, but if it's limited to abstract class and interfaces, isn't that already impossible to use directly? Or does it mean that the