Re: [RFC] Unary null coalescing operator
| From: | Sara Golemon | Date: | Wed, 21 Jun 2017 19:44:33 +0000 |
| Subject: | Re: [RFC] Unary null coalescing operator | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-99596@lists.php.net to get a copy of this message | ||
On Wed, Jun 21, 2017 at 1:05 PM, Andrea Faulds <ajf@ajf.me> wrote:
> Here's a small RFC for a small feature, which I've wondered about for a
> while: https://wiki.php.net/rfc/unary_null_coalescing_operator
>
> What do you think of it?
>
I think that
if ($_GET['x']?? === 1) looks and feels a lot like `if
(@$_GET['x'] === 1)`...
Yes, the latter has runtime performance issues and will still send
notices to error handlers and logs. But perhaps if we're going to
extend syntax, the syntax could be something along the lines of:
if (@@$_GET['x'] === 1)
The double @@ could indicate "No, really, don't send any kind of
warning (or lower) anywhere. Just deal with it. And as a bonus, the
@@ syntax is valid in older PHPs (acting like a single @).
-Sara