ID:               47693
 User updated by:  joffrey at coolhaven dot info
 Reported By:      joffrey at coolhaven dot info
 Status:           Open
 Bug Type:         Scripting Engine problem
 Operating System: Linux
 PHP Version:      5.3CVS-2009-03-17 (CVS)
 New Comment:

All of a sudden I realized a catch 22: you know which parameters are
call-by-reference because you must define them in your function.

This makes the use of referenced values in func_get_args() not
essential but practical. Not only for the sake of completeness but also
useful in combination with call_user_func_array().


Previous Comments:
------------------------------------------------------------------------

[2009-03-17 16:43:05] joffrey at coolhaven dot info

Description:
------------
Calling func_get_args() returns copies of the arguments of the
function. It would be more useful to return referenced values if those
are defined in the function parameters.

This is useful when using func_get_args() for function parameter
overloading and calling other functions from a function using
call_user_func_array().

A bit off topic: I see var_dump is aware if the variable is a
referenced one. Would it be possible to implement a 'is_reference()'
function now?

Reproduce code:
---------------
$a = 1;
$b = 2;
$c = "3";

function f($a, &$b, &$c)
  {
  var_dump(func_get_args());
  }

var_dump(array($a, &$b, &$c));

f($a, $b, $c);


Expected result:
----------------
array(3) {
  [0]=>
  int(1)
  [1]=>
  ∫(2)
  [2]=>
  &string(1) "3"
}
array(3) {
  [0]=>
  int(1)
  [1]=>
  ∫(2)
  [2]=>
  &string(1) "3"
}

Actual result:
--------------
array(3) {
  [0]=>
  int(1)
  [1]=>
  ∫(2)
  [2]=>
  &string(1) "3"
}
array(3) {
  [0]=>
  int(1)
  [1]=>
  int(2)
  [2]=>
  string(1) "3"
}



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=47693&edit=1

Reply via email to