On Thu, Oct 24, 2019 at 1:46 PM Stephen Reay <php-li...@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. :)

Reply via email to