Re: Re: Proposal for RFC to remove undefined array index warning when used ina ternary

From: Date: Sat, 26 Feb 2022 23:04:58 +0000
Subject: Re: Re: Proposal for RFC to remove undefined array index warning when used ina ternary
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-117146@lists.php.net to get a copy of this message
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 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 that such operator isn't really needed. See https://externals.io/message/89292#89292 and https://externals.io/message/101606#101610 Maybe, it would be worthwhile to refresh a discussion about adding such operator to the PHP language?

« previous php.internals (#117146) next »