ID: 50049
Updated by: [email protected]
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