php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #33558 warning with nested calls to functions returning by reference
Submitted: 2005-07-03 23:04 UTC Modified: 2005-08-15 12:47 UTC
Votes:12
Avg. Score:4.9 ± 0.3
Reproduced:10 of 10 (100.0%)
Same Version:8 (80.0%)
Same OS:6 (60.0%)
From: l dot alberton at quipo dot it Assigned: derick (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 4.4.0RC1 OS: *
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: l dot alberton at quipo dot it
New email:
PHP Version: OS:

 

 [2005-07-03 23:04 UTC] l dot alberton at quipo dot it
Description:
------------
When a function which returns a reference calls another function which returns a reference, the engine complains because the outer function does not return a variable reference.


It happens with PHP4.4.0RC2 too.

Reproduce code:
---------------
<?php
function & foo() {
    $var = 'a';
    return $var;
}

function & bar() {
    return foo();
}

$a =& bar();
?>

Expected result:
----------------
no NOTICEs

Actual result:
--------------
Notice: Only variable references should be returned by reference in test_ref.php on line 8

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-07-03 23:08 UTC] derick@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

You can only return variable by reference, not function\'s results. (This never worked correctly before anyway, now you just get a nice notice about it so that you can fix your code).
 [2005-07-03 23:56 UTC] l dot alberton at quipo dot it
>You can only return variable by reference, not function's results.

even if the function result *is* a reference?


> (This never worked correctly before anyway, now you just get a nice
> notice about it so that you can fix your code).

the fact that it never worked doesn't mean it is not a bug... quite frankly I don't see any reason why it's my code that need fixing and not the engine itself.
I may be stubborn, but I'm not convinced at all. I still think that I'm not doing anything wrong here, and if it doesn't work it's because of an engine limitation, not because of a fault of my code.
 [2005-07-18 09:42 UTC] dmitry@php.net
Fixed in CVS HEAD and PHP_5_0.
 [2005-08-15 12:47 UTC] derick@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 10:01:29 2024 UTC