From: roland at inkoeln dot com
Operating system: Linux
PHP version: 4.3.3
PHP Bug Type: Variables related
Bug description: Call-time pass-by-reference has been deprecated but without it it's impossible to pass a object-reference via call_user_function

Description:
------------
You *must* use Call-time pass-by-reference to pass a
object-reference when using call_user_function.

In the example changeA() is declared to use passing
by reference but it still doesn't work. I think
call_user_function should either try to discover if it's
passing by reference at runtime or just pass always by
reference.




Reproduce code:
---------------
<?php

class A {
var $_id = 'A';

function printID() {
print "A::id=[".$this->_id."]\n";
}

function remote(&$obj_ref, $obj_method) {
call_user_func(array(&$obj_ref, $obj_method), $this);
// this on works:
// call_user_func(array(&$obj_ref, $obj_method),&$this);
}
}

class B {
function changeA(&$obj) {
$obj->_id = 'B';
$obj->printID();
}
}

$a = new A();
$b = new B();
$a->printID();
$a->remote($b, 'changeA');
$a->printID();

?>

Expected result:
----------------
A::id=[A]
A::id=[B]
A::id=[B]




Actual result:
--------------
A::id=[A]
A::id=[B]
A::id=[A]


--
Edit bug report at [url]http://bugs.php.net/?id=25419&edit=1[/url]
--
Try a CVS snapshot (php4): [url]http://bugs.php.net/fix.php?id=25419&r=trysnapshot4[/url]
Try a CVS snapshot (php5): [url]http://bugs.php.net/fix.php?id=25419&r=trysnapshot5[/url]
Fixed in CVS: [url]http://bugs.php.net/fix.php?id=25419&r=fixedcvs[/url]
Fixed in release: [url]http://bugs.php.net/fix.php?id=25419&r=alreadyfixed[/url]
Need backtrace: [url]http://bugs.php.net/fix.php?id=25419&r=needtrace[/url]
Try newer version: [url]http://bugs.php.net/fix.php?id=25419&r=oldversion[/url]
Not developer issue: [url]http://bugs.php.net/fix.php?id=25419&r=support[/url]
Expected behavior: [url]http://bugs.php.net/fix.php?id=25419&r=notwrong[/url]
Not enough info: [url]http://bugs.php.net/fix.php?id=25419&r=notenoughinfo[/url]
Submitted twice: [url]http://bugs.php.net/fix.php?id=25419&r=submittedtwice[/url]
register_globals: [url]http://bugs.php.net/fix.php?id=25419&r=globals[/url]
PHP 3 support discontinued: [url]http://bugs.php.net/fix.php?id=25419&r=php3[/url]
Daylight Savings: [url]http://bugs.php.net/fix.php?id=25419&r=dst[/url]
IIS Stability: [url]http://bugs.php.net/fix.php?id=25419&r=isapi[/url]
Install GNU Sed: [url]http://bugs.php.net/fix.php?id=25419&r=gnused[/url]