php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #61881 Dereferencing in returning References
Submitted: 2012-04-30 16:20 UTC Modified: 2012-04-30 16:26 UTC
From: semias at web dot de Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 5.4.1 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: semias at web dot de
New email:
PHP Version: OS:

 

 [2012-04-30 16:20 UTC] semias at web dot de
Description:
------------
As in Example #8 Array dereferencing (http://docs.php.net/manual/en/language.types.array.php)
// As of PHP 5.4 it is possible to array dereference the result of a function or method call directly. Before it was only possible using a temporary variable. 

$secondElement = getArray()[1];

I would expect same in Returning References:

class foo {
    public $value = 42;
    public function &getValue() {
        return $this->value;
    }
}

&$foo->getValue() = 'new value';

instead of ...

$v = &$foo->getValue();
$v = 'bla';

Or does any syntax to do it directly already exists?

:) Thank You

Test script:
---------------
none


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-04-30 16:26 UTC] felipe@php.net
-Status: Open +Status: Not a bug
 [2012-04-30 16:26 UTC] felipe@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Does not exists shortcut for such.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 02 05:01:31 2024 UTC