Re: [RFC] Nullsafe operator
| From: | Markus Fischer | Date: | Tue, 14 Jul 2020 08:44:40 +0000 |
| Subject: | Re: [RFC] Nullsafe operator | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-110993@lists.php.net to get a copy of this message | ||
Hi Ilija,
I'd like to introduce another RFC I've been working on: https://wiki.php.net/rfc/nullsafe_operator It introduces the nullsafe operator ?-> that skips null values when calling functions and fetching properties. In contrast to the last few attempts this RFC includes full short circuiting.Would this still work together with short-circuiting and the null coalesce operator? I just didn't see a clear example about this but also figured that could be a practical way to use this:
$country = $session?->user?->getAddress()?->country ?? 'defaultCountry';(hope the example is readable, my MUA insists on wrapping the lines) thanks, - Markus