Ask a Question related to PHP Bugs, Design and Development.
-
andrei@php.net #1
#40694 [NEW]: __call() does not allow passing args by reference
From: [email]andrei@php.net[/email]
Operating system:
PHP version: 5CVS-2007-03-02 (CVS)
PHP Bug Type: Scripting Engine problem
Bug description: __call() does not allow passing args by reference
Description:
------------
__call() method does not allow specifying the arguments array by
reference. Essentially this means that there is no way to return modified
arguments when using overloading.
Reproduce code:
---------------
class Foo {
function __call($method, &$args)
{
print $args[0]."\n";
$args[0] = 5;
print $args[0]."\n";
return true;
}
}
$v = 'str';
$o = new Foo();
$o->test($v);
var_dump($v);
Expected result:
----------------
str
5
int(5)
Actual result:
--------------
str
5
string(3) "str"
--
Edit bug report at [url]http://bugs.php.net/?id=40694&edit=1[/url]
--
Try a CVS snapshot (PHP 4.4): [url]http://bugs.php.net/fix.php?id=40694&r=trysnapshot44[/url]
Try a CVS snapshot (PHP 5.2): [url]http://bugs.php.net/fix.php?id=40694&r=trysnapshot52[/url]
Try a CVS snapshot (PHP 6.0): [url]http://bugs.php.net/fix.php?id=40694&r=trysnapshot60[/url]
Fixed in CVS: [url]http://bugs.php.net/fix.php?id=40694&r=fixedcvs[/url]
Fixed in release: [url]http://bugs.php.net/fix.php?id=40694&r=alreadyfixed[/url]
Need backtrace: [url]http://bugs.php.net/fix.php?id=40694&r=needtrace[/url]
Need Reproduce Script: [url]http://bugs.php.net/fix.php?id=40694&r=needscript[/url]
Try newer version: [url]http://bugs.php.net/fix.php?id=40694&r=oldversion[/url]
Not developer issue: [url]http://bugs.php.net/fix.php?id=40694&r=support[/url]
Expected behavior: [url]http://bugs.php.net/fix.php?id=40694&r=notwrong[/url]
Not enough info: [url]http://bugs.php.net/fix.php?id=40694&r=notenoughinfo[/url]
Submitted twice: [url]http://bugs.php.net/fix.php?id=40694&r=submittedtwice[/url]
register_globals: [url]http://bugs.php.net/fix.php?id=40694&r=globals[/url]
PHP 3 support discontinued: [url]http://bugs.php.net/fix.php?id=40694&r=php3[/url]
Daylight Savings: [url]http://bugs.php.net/fix.php?id=40694&r=dst[/url]
IIS Stability: [url]http://bugs.php.net/fix.php?id=40694&r=isapi[/url]
Install GNU Sed: [url]http://bugs.php.net/fix.php?id=40694&r=gnused[/url]
Floating point limitations: [url]http://bugs.php.net/fix.php?id=40694&r=float[/url]
No Zend Extensions: [url]http://bugs.php.net/fix.php?id=40694&r=nozend[/url]
MySQL Configuration Error: [url]http://bugs.php.net/fix.php?id=40694&r=mysqlcfg[/url]
andrei@php.net Guest
-
Passing Variables by Reference
I have a webservice that accepts some variables by reference and after the service is called, all the passed variables are 'undefined' Thanks for... -
#25831 [Ver->WFx]: overload/__call breaks method Pass by reference
ID: 25831 Updated by: moriyoshi@php.net Reported By: viking at dslnorthwest dot net -Status: Verified +Status:... -
#25831 [Ver]: overload/__call breaks method Pass by reference
ID: 25831 Updated by: alan_k@php.net Reported By: viking at dslnorthwest dot net Status: Verified Bug Type: ... -
#25831 [Opn->Ver]: overload/__call breaks method Pass by reference
ID: 25831 Updated by: alan_k@php.net -Summary: Pass by reference doesn't work with subclasses of DB_DataObject... -
passing row types by reference
Hallo, I´m working with the new informix funcionality that allow use structure data like rows an list rows. I would like to know how I can... -
pollita@php.net #2
#40694 [Opn->Ver]: __call() does not allow passing args by reference
ID: 40694
Updated by: [email]pollita@php.net[/email]
Reported By: [email]andrei@php.net[/email]
-Status: Open
+Status: Verified
Bug Type: Scripting Engine problem
PHP Version: 5CVS-2007-03-02 (CVS)
New Comment:
Summary from IRC:
This should be fixable by selectively populating arg_info in
zend_std_get_method() with a structure that turns on the pass rest by
ref flag. That'll tell the macros in zend_vm_def.h to send the
arguments by reference. From there, you might need to modify
zend_std_call_user_call() a little bit where it's building the args
array... (Havn't looked close enough to be sure)
While addressing this, you should look at the return value as well,
again this should be a minor matter of checking the __call
implementation and flipping the return type in zend_std_get_method()...
Previous Comments:
------------------------------------------------------------------------
[2007-03-02 17:27:59] [email]andrei@php.net[/email]
Description:
------------
__call() method does not allow specifying the arguments array by
reference. Essentially this means that there is no way to return
modified arguments when using overloading.
Reproduce code:
---------------
class Foo {
function __call($method, &$args)
{
print $args[0]."\n";
$args[0] = 5;
print $args[0]."\n";
return true;
}
}
$v = 'str';
$o = new Foo();
$o->test($v);
var_dump($v);
Expected result:
----------------
str
5
int(5)
Actual result:
--------------
str
5
string(3) "str"
------------------------------------------------------------------------
--
Edit this bug report at [url]http://bugs.php.net/?id=40694&edit=1[/url]
pollita@php.net Guest



Reply With Quote

