ID:               44139
 Updated by:       [EMAIL PROTECTED]
 Reported By:      andrea at 3site dot it
 Status:           Open
 Bug Type:         Scripting Engine problem
 Operating System: Windows XP
 PHP Version:      5.2.5
 New Comment:

Ops... 5_3 also issued 'Fatal error'.

Warning: Parameter 1 to array_unshift() expected to be a reference,
value given in %s on line %d

Fatal error: Uncaught exception 'ReflectionException' with message
'Invocation of function array_unshift() failed' in %s:%d
Stack trace:
#0 %s(19): ReflectionFunction->invoke(Array, 1)
#1 {main}
  thrown in %s on line %d



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

[2008-02-17 19:40:54] [EMAIL PROTECTED]

PHP 5.2.6:

$ref->invoke($arr, 1);
Fatal error: Uncaught exception 'ReflectionException' with message
'Invocation of function array_unshift() failed' 

$ref->invokeArgs(array($arr, 0));
Fatal error: Uncaught exception 'ReflectionException' with message
'Invocation of function array_unshift() failed'

PHP 5.3.0:

$ref->invoke($arr, 1); and $ref->invokeArgs(array($arr, 0));
Warning: Parameter 1 to array_unshift() expected to be a reference,
value given



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

[2008-02-17 00:06:41] andrea at 3site dot it

Description:
------------
For some reason, ReflectionFunction doesn't allow me to to invoke a
basic function like, for example, array_unshift.

Reproduce code:
---------------
$arr = array(2, 3, 4);

/** EXPECTED RESULT
 * array_unshift($arr, 1);
 * array_unshift($arr, 0);
 * var_dump($arr);      // 0, 1, 2, 3, 4
 */

$ref = new ReflectionFunction('array_unshift');

// WARNING: Call-time pass-by-reference has been deprecated
$ref->invoke(&$arr, 1);
$ref->invokeArgs(array(&$arr, 0));
var_dump($arr); // correct and expected result

// FATAL ERROR - Uncaught exception 'ReflectionException' with message
'Invocation of function array_unshift() failed'
$ref->invoke($arr, 1);
$ref->invokeArgs(array($arr, 0));
var_dump($arr); // nothing, because of fatal error ... 

exit;

Expected result:
----------------
I would like to do what I'm trying to do without errors.
I mean both fatal and warning.

Actual result:
--------------
An illogical problem for a simple operation.

You have a "passed by reference" in your core but you choosed to
disable send by reference in PHP ... and ReflectionFunction doesn't seem
to be able to manage this kind of "situation".

Please do not reply with something like: change your PHP configuration
... I would like to write not deprecated code. Thank You.


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


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

Reply via email to