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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
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

Add a Patch

Pull Requests

Add a Pull Request

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: Fri Apr 26 05:01:30 2024 UTC