php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #73400 requesting syntactic sugar for T_COALESCE (??)
Submitted: 2016-10-27 11:38 UTC Modified: 2016-10-27 12:41 UTC
From: raffaellobertini at gmail dot com Assigned: cmb (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 7.1.0RC4 OS: CentOS
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: raffaellobertini at gmail dot com
New email:
PHP Version: OS:

 

 [2016-10-27 11:38 UTC] raffaellobertini at gmail dot com
Description:
------------
it often happen doing something similar to this assignment pattern:

$something = $something ?? ....whatever... ;

as a syntactic sugar it will be nice to have:

$something ??= ....whatever;

that will be interpreted as the original first line. Just simply syntactic sugar.

like the case of the operator:

$a = $a + 1;
$a++;





Expected result:
----------------
if $something is set $something will be no operation or assigned itself, otherwise the RH operand will be assigned to $something.

Actual result:
--------------
PHP Parse error:  syntax error, unexpected ?? (T_COALESCE) in php shell code on line 1

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-10-27 11:41 UTC] raffaellobertini at gmail dot com
i forgot to add:

$a = $a + $b;

$a += $b;

you got what i mean..
 [2016-10-27 12:41 UTC] cmb@php.net
-Status: Open +Status: Closed -Package: Compile Failure +Package: Scripting Engine problem -Assigned To: +Assigned To: cmb
 [2016-10-27 12:41 UTC] cmb@php.net
It has already been decided to add this feature[1], but for time reasons
we did not yet manage to implement it. It is supposed that the null
coalesce equal operator will be available as of PHP 7.2.

I'm therefore closing this ticket.

[1] <https://wiki.php.net/rfc/null_coalesce_equal_operator>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Jun 16 05:01:29 2024 UTC