Re: [RFC] Nullsafe operator

From: Date: Wed, 03 Jun 2020 06:24:47 +0000
Subject: Re: [RFC] Nullsafe operator
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-110338@lists.php.net to get a copy of this message
On 02/06/2020 22:52, Ilija Tovilo wrote:
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. I like it a lot! Concise and clear RFC.
From having used a similar feature in TypeScript I can say it is quite convenient, easy to get used to and makes for much leaner code. IMO not having it on array accesses isn't so bad as with arrays you can easily isset($deep['into']['the']['array']) in one go, while with objects and getters etc it tends to lead to much uglier and repetitive code like:
    if ($foo && $foo->getBar() && $foo->getBar()->getBaz()) { ... }
So yeah, +1 Best, Jordi -- Jordi Boggiano @seldaek - https://seld.be

« previous php.internals (#110338) next »