php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #62178 ReflectionMethod::__construct should carry the object reference if supplied
Submitted: 2012-05-29 09:50 UTC Modified: -
Votes:3
Avg. Score:4.3 ± 0.5
Reproduced:3 of 3 (100.0%)
Same Version:3 (100.0%)
Same OS:2 (66.7%)
From: denvil at gmail dot com Assigned:
Status: Open Package: Reflection related
PHP Version: 5.3.13 OS: Mac OS X Lion
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
31 - 24 = ?
Subscribe to this entry?

 
 [2012-05-29 09:50 UTC] denvil at gmail dot com
Description:
------------
Please let me know if I have misunderstood the whole idea behind the reflections.

I use callbacks in my code a lot, and they are good when I use 
call_user_func_array() along with array($object, $method) as the argument.

This makes abstraction and normalizing handler classes very easily.

But I found this code pattern difficult to port to the reflections, as long as 
there is nowhere I can pass the method along with the reference of that 
particular object in the reflection class.

Imagined scenario as follow,
```
$object = new MyHandler($initialize_options);

$callback = new ReflectionMethod($object, 'handleResult');

$net->request($parameters, $callback);
```

Expected result:
----------------
ReflectionMethod::invoke() and ReflectionMethod::invokeArgs() should have their 
first parameter remains optional, but calls a non-static method even when NULL is 
specified in case an object instance is provided in 
ReflectionMethod::__construct().

Actual result:
--------------
ReflectionMethod::invokeArgs() takes the first parameter as the object reference, 
static method is assumed if the first parameter is omitted (NULL).

Patches

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 04:01:29 2024 UTC