Bug #52158 [Opn]: invokeArgs with args should be pass ref cause ReflectionException
| From: | rquadling@php.net | Date: | Wed, 23 Jun 2010 12:12:05 +0000 |
| Subject: | Bug #52158 [Opn]: invokeArgs with args should be pass ref cause ReflectionException | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-4591@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=52158&edit=1
ID: 52158
Updated by: rquadling@php.net
Reported by: laruence at yahoo dot com dot cn
Summary: invokeArgs with args should be pass ref cause
ReflectionException
Status: Open
Type: Bug
Package: Documentation problem
PHP Version: 5.2.14RC1
New Comment:
As of V5.3.0, there is an E_WARNING generated ...
"Warning: Parameter 1 to who() expected to be a reference, value
given".
Using ...
$method->invokeArgs(array(&$name));
is the correct way to make the call.
"NOTE : Arguments passed by reference must be supplied as references
when using
invokeArgs()."
Previous Comments:
------------------------------------------------------------------------
[2010-06-23 13:56:58] laruence at yahoo dot com dot cn
Description:
------------
ReflectionMethod or ReflectionFunction reflects a funtion with arguments
shoule be passed by reference, when invokeArgs cause invocation failed
with a Exception.
I think this should been noted in php manual
more info(chinese) :http://www.laruence.com/2010/06/22/1618.html
Test script:
---------------
function who(&$name) {
echo $name;
}
$name = "laruence";
$method = new ReflectionFunction("who");
$method->invokeArgs(array($name));
Expected result:
----------------
"laruence"
Actual result:
--------------
Uncaught exception 'ReflectionException' with message
'Invocation of function who() failed'
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=52158&edit=1