|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #50049 ReflectionMethod::invokeArgs() alters arguments passed to reflected method
Submitted: 2009-11-01 14:27 UTC Modified: 2009-11-01 15:22 UTC
From: jrs2k5 at gmail dot com Assigned:
Status: Not a bug Package: Reflection related
PHP Version: 5.3.0 OS: Windows XP
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: jrs2k5 at gmail dot com
New email:
PHP Version: OS:


 [2009-11-01 14:27 UTC] jrs2k5 at gmail dot com
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:

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");
        $rm->invokeArgs($obj, $args);

    public function callMe($args) {



Expected result:
    [key1] => value1
    [key2] => value2
    [key3] => value3
    [key1] => value1
    [key2] => value2
    [key3] => value3

Actual result:
    [key1] => value1
    [key2] => value2
    [key3] => value3


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2009-11-01 15:22 UTC]
You must to use: $rm->invokeArgs($obj, array($args));
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 13 04:01:28 2024 UTC