On Wednesday, 23 July 2025 at 14:03, Tim Düsterhus <t...@bastelstu.be> wrote:

> Hi
> 
> Am 2025-07-23 13:30, schrieb Nicolas Grekas:
> 
> > > About destructuring non-array values, null is a very common case that
> > > allows writing nice readable code.
> > > Here is a dummy example:
> > > if ([$a, $b] = $array[$key] ?? null) { /.../ }
> > > 
> > > Turning this into a warning will have a significant impact for sure.
> > > Even
> > > a deprecation would just make the language a bit less pleasant to use
> > > without any real benefit, unless I missed any other rationale.
> > > 
> > > If you want to provide default values, then surely:
> > > 
> > > if ([$a, $b] = $array[$key] ?? [null, null])
> > > 
> > > makes more sense, especially as this allows you to choice different
> > > defaults for $a and $b.
> > 
> > That's broken, the "if" will always be truthy using this style.
> > There's nothing wrong with the current code. It doesn't need to be
> > deprecated.
> 
> 
> It seems appropriate to mention the previous (declined) “Destructuring
> Coalesce” RFC at this point:
> https://wiki.php.net/rfc/destructuring_coalesce. Perhaps it might make
> sense to revisit that one?
> 
> Best regards
> Tim Düsterhus

I've dropped warning null from the proposal, and mentioned the declined RFC.

Best regards,

Gina P. Banyard

Reply via email to