php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #50792 call_user_func_array, __call and references
Submitted: 2010-01-18 14:49 UTC Modified: 2010-01-18 17:23 UTC
From: david at grudl dot com Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 5.3.1 OS:
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: david at grudl dot com
New email:
PHP Version: OS:

 

 [2010-01-18 14:49 UTC] 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.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-01-18 17:23 UTC] jani@php.net
See bug #50394 and next time, search first.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 22:01:28 2024 UTC