#50792 [Opn->Fbk]: call_user_func_array, __call and references

From: Date: Mon, 18 Jan 2010 17:22:32 +0000
Subject: #50792 [Opn->Fbk]: call_user_func_array, __call and references
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-146770@lists.php.net to get a copy of this message
ID: 50792 Updated by: jani@php.net Reported By: david at grudl dot com -Status: Open +Status: Feedback Bug Type: Class/Object related PHP Version: 5.3.1 New Comment: Please try using this snapshot: http://snaps.php.net/php5.3-latest.tar.gz For Windows: http://windows.php.net/snapshots/ Both 5.3.2-dev and 5.2.12-dev return 2 for me. I don't have older versions around to test. :) Previous Comments: ------------------------------------------------------------------------ [2010-01-18 14:49:46] david at grudl dot com Description: ------------ The way how call_user_func_array() passes arguments to the function by reference has been broken in PHP versions 5.3.1, 5.2.11, 5.2.12 in conjunction with __call(). See http://php.net/manual/en/function.call-user-func-array.php - Note: Referenced variables in param_arr are passed to the function by a reference, others are passed by a value. In other words, it does not depend on the function signature whether the parameter is passed by a value or by a reference. Reproduce code: --------------- class Test { public function __call($name, $args) { $args[0]++; } } $viaRef = 1; call_user_func_array( array(new Test, 'method'), array(& $viaRef) ); echo $viaRef; Expected result: ---------------- 2 Actual result: -------------- PHP 5.3.1, 5.2.11, 5.2.12 returns „1“, other versions „2“ as documented. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=50792&edit=1

« previous php.bugs (#146770) next »