#50049 [Opn->Bgs]: ReflectionMethod::invokeArgs() alters arguments passed to reflected method

From: Date: Sun, 01 Nov 2009 15:22:03 +0000
Subject: #50049 [Opn->Bgs]: ReflectionMethod::invokeArgs() alters arguments passed to reflected method
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-144134@lists.php.net to get a copy of this message
ID: 50049 Updated by: felipe@php.net Reported By: jrs2k5 at gmail dot com -Status: Open +Status: Bogus Bug Type: Reflection related Operating System: Windows XP PHP Version: 5.3.0 New Comment: You must to use: $rm->invokeArgs($obj, array($args)); Previous Comments: ------------------------------------------------------------------------ [2009-11-01 14:27:39] jrs2k5 at gmail dot com Description: ------------ The definition for ReflectionMethod::invokeArgs() indicates that it takes an array as its 2nd argument. I assume this array is then passed to the method being reflected, however it is not. -- Additionally, if I use type hinting in the reflected method, (e.g. public function callMe(array $args)) the script terminates with a fatal error. Reproduce code: --------------- <?php class MyClass { public static function test() { $obj = new MyClass(); $ro = new ReflectionObject($obj); $rm = $ro->getMethod("callMe"); $args = array("key1" => "value1", "key2" => "value2", "key3" => "value3"); print_r($args); $rm->invokeArgs($obj, $args); } public function callMe($args) { print_r($args); } } MyClass::test(); ?> Expected result: ---------------- Array ( [key1] => value1 [key2] => value2 [key3] => value3 ) Array ( [key1] => value1 [key2] => value2 [key3] => value3 ) Actual result: -------------- Array ( [key1] => value1 [key2] => value2 [key3] => value3 ) value1 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=50049&edit=1

« previous php.bugs (#144134) next »