Re: [PHP-DEV] Allowing NULL for some internal functions

2022-02-27 Thread Craig Francis
On Wed, 23 Feb 2022 at 14:00, Guilliam Xavier wrote: > On Tue, Feb 22, 2022 at 3:59 AM Alexandru Pătrănescu > wrote: > > But when types are not considered important I think it's worth pursuing > > extending the coercion from null to the 4 other types where it's > happening > > right now: > > -

Re: [PHP-DEV] Proposal for RFC to remove undefined array index warning when used ina ternary

2022-02-27 Thread Mel Dafert
>Hi, > >In PHP, you can write `$array['a']['b']['c'] ?? 'default';`. It works when >either null or inexistant index is encountered at any depth of the expression. > >—Claude You're right, I did not know that. Thank you. That basically replaces the need for my proposal, then. Regards, Mel --

Re: [PHP-DEV] Proposal for RFC to remove undefined array index warning when used ina ternary

2022-02-27 Thread Claude Pache
> Le 27 févr. 2022 à 18:06, Robert Landers a écrit : > >> $val = $array[?'a'][?'b'][?'c'] ?? 'default'; >> >> Currently, the last example would need to be a rather unwieldy ternary: >> >> $val = (isset($array['a']) && isset($array['a']['b']) && >> isset($array['a']['b']['c']) ?

Re: [PHP-DEV] Allowing NULL for some internal functions

2022-02-27 Thread Craig Francis
On Sat, 1 Jan 2022 at 23:17, Craig Francis wrote: > Draft RFC: > https://wiki.php.net/rfc/allow_null > To get a better idea on how I should progress this RFC, I've created a simple quiz (well, modified an old script). This is to decide if my RFC should either - continue to allow NULL to be

Re: [PHP-DEV] Re: Proposal for RFC to remove undefined array index warning when used ina ternary

2022-02-27 Thread Robert Landers
On Sun, Feb 27, 2022 at 10:59 AM Mel Dafert wrote: > On 27 February 2022 00:04:58 CET, Kamil Tekiela > wrote: > >I just wanted to add that the following > > > >$name = $_POST['name'] ?: 'Default Name'; > > > >with existence check would be > > > >$name = $_POST['name'] ?? null ?: 'Default Name';

Re: [PHP-DEV] Re: Proposal for RFC to remove undefined arrayindexwarning when used ina ternary

2022-02-27 Thread Larry Garfield
On Sun, Feb 27, 2022, at 9:11 AM, Robert Landers wrote: > On Sun, Feb 27, 2022 at 12:35 PM Mark Randall wrote: > >> On 27/02/2022 09:12, Robert Landers wrote: >> > I'd also venture that this warning has caused more harm than good, in >> that >> > writing "$var['something'] ?? null" is second

Re: [PHP-DEV] Interface for reflection entities who implements getAttributes method

2022-02-27 Thread Larry Garfield
On Fri, Feb 25, 2022, at 4:57 PM, DANIEL VARGAS MUCCILLO wrote: > Hi Internals, hope you are all well. > > I've been playing around with Attributes and found that the only > way for safely type hint for reflection entities who implement the > getAttributes method is the following union: > >

Re: [PHP-DEV] Re: Proposal for RFC to remove undefined arrayindexwarning when used ina ternary

2022-02-27 Thread Robert Landers
On Sun, Feb 27, 2022 at 12:35 PM Mark Randall wrote: > On 27/02/2022 09:12, Robert Landers wrote: > > I'd also venture that this warning has caused more harm than good, in > that > > writing "$var['something'] ?? null" is second nature when writing new > > code, even if there is practically no

Re: [PHP-DEV] Re: Proposal for RFC to remove undefined arrayindexwarning when used ina ternary

2022-02-27 Thread Mark Randall
On 27/02/2022 09:12, Robert Landers wrote: I'd also venture that this warning has caused more harm than good, in that writing "$var['something'] ?? null" is second nature when writing new code, even if there is practically no chance for a non-existent key. Using null coalesce should only be

Re: [PHP-DEV] Re: Proposal for RFC to remove undefined array index warning when used ina ternary

2022-02-27 Thread Mel Dafert
On 27 February 2022 00:04:58 CET, Kamil Tekiela wrote: >I just wanted to add that the following > >$name = $_POST['name'] ?: 'Default Name'; > >with existence check would be > >$name = $_POST['name'] ?? null ?: 'Default Name'; > >You don't need empty(). > >I would be against changing the

Re: [PHP-DEV] Re: Proposal for RFC to remove undefined array indexwarning when used ina ternary

2022-02-27 Thread Robert Landers
On Sun, Feb 27, 2022 at 12:10 AM Mark Randall wrote: > On 26/02/2022 22:34, Robert Landers wrote: > > This is not semantically the same though. A $_POST of a form, for > example, > > will usually contain an empty value if the form input was empty, but > > missing if the form control wasn't in

Re: [PHP-DEV] Re: Proposal for RFC to remove undefined array index warning when used ina ternary

2022-02-27 Thread Robert Landers
> > I would be against changing the behaviour of elvis/ternary operator. > However, I remember seeing past suggestions to implement another operator. > One that would fill the gap between null-coalesce and elvis operators. If I > recall correctly, most of the time, these proposals end in consensus