#50049 [NEW]: ReflectionMethod::invokeArgs() alters arguments passed to reflected method
| From: | jrs2k5 at gmail dot com | Date: | Sun, 01 Nov 2009 14:27:39 +0000 |
| Subject: | #50049 [NEW]: ReflectionMethod::invokeArgs() alters arguments passed to reflected method | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-144132@lists.php.net to get a copy of this message | ||
From: jrs2k5 at gmail dot com
Operating system: Windows XP
PHP version: 5.3.0
PHP Bug Type: Reflection related
Bug description: ReflectionMethod::invokeArgs() alters arguments passed to reflected method
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 bug report at http://bugs.php.net/?id=50049&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=50049&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=50049&r=trysnapshot53
Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=50049&r=trysnapshot60
Fixed in SVN: http://bugs.php.net/fix.php?id=50049&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=50049&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=50049&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=50049&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=50049&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=50049&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=50049&r=support
Expected behavior: http://bugs.php.net/fix.php?id=50049&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=50049&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=50049&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=50049&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=50049&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=50049&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=50049&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=50049&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=50049&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=50049&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=50049&r=mysqlcfg