Re: Nullsafe array access can still emit a warning

From: Date: Wed, 24 Aug 2022 13:11:06 +0000
Subject: Re: Nullsafe array access can still emit a warning
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-118461@lists.php.net to get a copy of this message
Hey Gert, On Wed, 24 Aug 2022 at 14:59, Gert de Pagter <gertp93@gmail.com> wrote: > Hi Internals, > > I recently learned that using null safe on an array access can still > emit a warning when the array access is not defined. I kinda expected > it to work like a null coalesce and just short circuit there,without > the warning. > > Is there any chance this behaviour could be changed in a n upcoming > PHP version? I didn't see anything mentioned specifically about this > in the RFC. > > https://3v4l.org/1raa8 > > Greetings, > Gert de Pagter/ BackEndTea > This seems expected behavior to me: it's "nullsafe", not "undefinedsafe". If it operated like ??, then $undefined?->bar() would be valid too, which seems wrong, IMO. Marco Pivetta https://twitter.com/Ocramius https://ocramius.github.io/

« previous php.internals (#118461) next »