php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #69259 One reference passing fail with call_user_func_array() causes other fails
Submitted: 2015-03-19 05:36 UTC Modified: 2015-03-19 08:33 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: ryosuke_i_628 at yahoo dot co dot jp Assigned:
Status: Closed Package: *General Issues
PHP Version: Irrelevant 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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: ryosuke_i_628 at yahoo dot co dot jp
New email:
PHP Version: OS:

 

 [2015-03-19 05:36 UTC] ryosuke_i_628 at yahoo dot co dot jp
Description:
------------
One reference passing fail with call_user_func_array() causes other fails.
HHVM is already fixed on this issue, however, PHP 7 still has this problem.
http://3v4l.org/jd9Nd

Test script:
---------------
<?php
function inc(&$a, &$b) {
    ++$a; ++$b;
}
$a = 1;
$b = 1;
$params = array($a, &$b);
call_user_func_array('inc', $params);
var_dump($params);

Expected result:
----------------
Warning: Parameter 1 to inc() expected to be a reference, value given in ... on line ...
array(2) {
  [0]=>
  int(1)
  [1]=>
  &int(2)
}

Actual result:
--------------
Warning: Parameter 1 to inc() expected to be a reference, value given in ... on line ...
array(2) {
  [0]=>
  int(1)
  [1]=>
  &int(1)
}

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-03-19 08:02 UTC] demon@php.net
-Status: Open +Status: Verified -Assigned To: +Assigned To: demon
 [2015-03-19 08:19 UTC] laruence@php.net
-Assigned To: demon +Assigned To:
 [2015-03-19 08:19 UTC] laruence@php.net
from what I can tell, it is by design, if the parameters checking is fail, the destination function won't be called.

thus this behavior is expected.


thanks
 [2015-03-19 08:19 UTC] laruence@php.net
-Status: Verified +Status: Feedback
 [2015-03-19 08:33 UTC] ryosuke_i_628 at yahoo dot co dot jp
-Status: Feedback +Status: Closed
 [2015-03-19 08:33 UTC] ryosuke_i_628 at yahoo dot co dot jp
To be sure.

<?php
function inc(&$a, &$b) {
    ++$a; ++$b;
    echo 'Function called' . PHP_EOL;
}
$a = 1;
$b = 1;
$params = array($a, &$b);
call_user_func_array('inc', $params);
var_dump($params);
?>

I verified this script doesn't print "Function called", thanks.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 02 16:01:37 2025 UTC