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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: denvil at gmail dot com
New email:
PHP Version: OS:

 

 [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

Pull Requests

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 17:01:32 2024 UTC