php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #24477 Problem returning new class by ref from function
Submitted: 2003-07-03 06:13 UTC Modified: 2003-07-29 05:58 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:1 (50.0%)
From: karl at karlaustin dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5CVS-2003-07-03 (dev) OS: RH7.3
Private report: No CVE-ID: None
 [2003-07-03 06:13 UTC] karl at karlaustin dot com
Description:
------------
Fatal error: Only variables or references can be returned by reference in /usr/local/php5/lib/php/DB/common.php on line 737

If seems that doing:

return new DB_result($this, $result);

in a function results in the above error, but:

$_tmp = new DB_result($this, $result);
return $_tmp;

Is fine.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-07-03 06:17 UTC] derick@php.net
Cause:
http://news.php.net/article.php?group=php.zend-engine.cvs&article=1432

I wonder if we really should break BC here...
 [2003-07-03 07:09 UTC] karl at karlaustin dot com
Well from the text of that item it would suggest that doing:

return new object(); 

is fine, but:

return (new object());

is not fine, that's how it would seem to me as an end user.

 PEAR is ridled with returns like the one I list (Although IMHO it should have only one return and assign return values to a variable then return at the end, but that's another story).
 [2003-07-09 04:12 UTC] jsemczyk at elv dot enic dot fr
I have the same error, it seems like it comes from a function that must return a reference, but objects are already references.

this doesn't work, but worked before beta1, I tried PEAR before beta1 and it uses lots of this :

function &myFunc()
{
    return new MyClass();
}

This works fine :

function myFunc()
{
    return new MyClass();
}

I don't understand why it comes from return (new Class()); cause it doesn't work.
 [2003-07-27 07:16 UTC] stas@php.net
What is the meaning of returning result of new by reference?
 [2003-07-29 04:45 UTC] jsemczyk at elv dot enic dot fr
I think it is the same problem as here : http://bugs.php.net/bug.php?id=24687

As zeev said, in the current zend2 you can't connect to a returned value.

But it is really needed to unreference returned value, and you can do it in most object oriented languages.

Here, we break a compatibilty with PEAR, Horde (and other projects I guess). For now, I am waiting for a new version of PEAR, and then Horde.
 [2003-07-29 05:58 UTC] sniper@php.net
Same as bug #24687 (add your comments there, if any)

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Sep 18 20:01:27 2024 UTC