php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #66832 Feature: Reverse assignment string operators
Submitted: 2014-03-06 09:50 UTC Modified: 2014-03-06 11:55 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: nicolas dot giraud dot dev at gmail dot com Assigned:
Status: Wont fix Package: Strings related
PHP Version: Irrelevant OS: All
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: nicolas dot giraud dot dev at gmail dot com
New email:
PHP Version: OS:

 

 [2014-03-06 09:50 UTC] nicolas dot giraud dot dev at gmail dot com
Description:
------------
This is not a bug but a feature request. I thought someone already asked it but I wasn't able to find anything like that. 
I would like to know if it's possible to have reversed assignment string operator.
Thank you


Test script:
---------------
$a =. $b; // same as $a = $b . $a;

Expected result:
----------------
$a = 'World';
$b = 'Hello ';
$a =. $b; //$a worth now "Hello World";

//Multiple string operations in assignements
$a = 'a'; $b = 'b'; $c = 'c';
$c .= $b .= $a; //$c worth now 'cba'

$a = 'a'; $b = 'b'; $c = 'c';
$c =. $b =. $a; //$c worth now 'abc'

Actual result:
--------------
Not implemented (yet?)
Only the following snippet works:

$a = 'a'; $b = 'b'; $c = 'c';
$c .= $b .= $a; //$c worth now 'cba'

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-03-06 11:55 UTC] nikic@php.net
-Status: Open +Status: Wont fix
 [2014-03-06 11:55 UTC] nikic@php.net
This is too exotic. No language that I am aware of supports postfix compound assignment operators. The use cases are rather limited and it has a lot of potential of confusing and typos, as it's so close to the normal compound assignment syntax.

Furthermore we'd have to add this for all other operators as well, to stay consistent. In which case we'd run into issues like =& already being the by-ref assignment operator.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 00:01:30 2024 UTC