Re: [RFC] anti-coalescing-operator

From: Date: Thu, 24 Oct 2019 17:56:58 +0000
Subject: Re: [RFC] anti-coalescing-operator
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-107664@lists.php.net to get a copy of this message
On Thu, Oct 24, 2019 at 1:46 PM Stephen Reay <php-lists@koalephant.com> wrote: > Hi Ken, > > This sounds like an alternative approach (for solving the same basic > problem) to the nullsafe operator discussed a while back, no? > https://wiki.php.net/rfc/nullsafe_calls > > > Cheers > Stephen > Hi Stephen! Yes, it would be similar if the object you're testing against is the same object you want to call (e.g., $foo !?? $foo->getBar()). But, if the variable is not an object, or it's just a test for another object, then the nullsafe operator does not seem to address this situation (e.g., $userId !?? $bar->getUser($userId())). In fact, I could see this RFC complimenting the nullsafe operator: $userId !?? $bar->getUser($userId)?->getName(). Thank you, Ken Stanley PS. Dan, I am going to respond to your request for a code example; I am taking my time so that I can give you and everyone else a good example. :)

« previous php.internals (#107664) next »