ID: 40694
Updated by: [EMAIL PROTECTED]
Reported By: [EMAIL PROTECTED]
Status: Feedback
-Bug Type: Scripting Engine problem
+Bug Type: Feature/Change Request
PHP Version: 5CVS-2007-03-02 (CVS)
New Comment:
I don't see how it is possible without forcing the reference OR having
a method like __callByRef(), which makes little sense to me.
Previous Comments:
------------------------------------------------------------------------
[2007-09-04 19:59:54] [EMAIL PROTECTED]
You're forcing a call-time reference. How is this going to help when
call-time reference stuff is deprecated?
------------------------------------------------------------------------
[2007-08-31 12:13:24] [EMAIL PROTECTED]
<?php
class Foo {
function __call($method, $args) //NB 1
{
print $args[0]."\n";
$args[0] = 5;
print $args[0]."\n";
return true;
}
}
$v = 'str';
$o = new Foo();
$o->test(&$v); //NB 2
var_dump($v);
?>
This code results in:
str
5
int(5)
So I believe this report can be closed.
------------------------------------------------------------------------
[2007-03-02 17:51:47] [EMAIL PROTECTED]
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()...
------------------------------------------------------------------------
[2007-03-02 17:27:59] [EMAIL PROTECTED]
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 http://bugs.php.net/?id=40694&edit=1