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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 10:01:33 2025 UTC