Reflection API r1.136

php.internals

Timm Friebe

21 years ago
revision 1.136 date: 2004/10/31 15:30:53; author: helly; state: Exp; lines: +163 -1 - Add ReflectionFunction::invokeArgs(array) - Add ReflectionMethod::invokeArgs(obj, array) Why was this added? These: 1) call_user_func_array( array(new ReflectionMethod('class', 'method'), 'invoke', array(1, 2, 3) ) 2) call_user_func( array(new ReflectionMethod('class', 'method'), 'invoke', 1, 2, 3 ) work just fine. Do we really need to duplicate code where a solution already exists? - Timm

Sebastian Bergmann

21 years ago
Timm Friebe wrote:
> Why was this added?
I asked Marcus to add these.
> These: > > 1) call_user_func_array( > array(new ReflectionMethod('class', 'method'), 'invoke', > array(1, 2, 3) > ) > > 2) call_user_func( > array(new ReflectionMethod('class', 'method'), 'invoke', > 1, 2, 3 > ) > > work just fine.
They work, but not seamless.
-- Sebastian Bergmann http://www.sebastian-bergmann.de/ GnuPG Key: 0xB85B5D69 / 27A7 2B14 09E4 98CD 6277 0E5B 6867 C514 B85B 5D69

Timm Friebe

21 years ago
On Tue, 2004-11-02 at 13:52, Sebastian Bergmann wrote:
> Timm Friebe wrote: > > Why was this added? > > I asked Marcus to add these.
He forgot to support invokeArgs(NULL, array(...)) for static invocation ("Warning: invokeArgs() expects parameter 1 to be object, null given"). [...call_user_func* equivalents...]
> They work, but not seamless.
Care to elaborate? Except for the call_user_func-syntax being longer I don't see any difference. - Timm

Sebastian Bergmann

21 years ago
Timm Friebe wrote:
> Care to elaborate? Except for the call_user_func-syntax being longer I > don't see any difference.
The difference is that with using a method of ReflectionFunction or ReflectionMethod I do not have to switch paradigms (Reflection API and OOP vs. call_user_func*() and non-OOP).
-- Sebastian Bergmann http://www.sebastian-bergmann.de/ GnuPG Key: 0xB85B5D69 / 27A7 2B14 09E4 98CD 6277 0E5B 6867 C514 B85B 5D69

Marcus Börger

21 years ago
Hello Sebastian, hello Timm, after all the differnece is whether we know of the typical PHP user can find out. marcus p.s.: Timm you're going to FFM? Tuesday, November 2, 2004, 11:45:18 PM, you wrote:
> Timm Friebe wrote: >> Care to elaborate? Except for the call_user_func-syntax being longer I >> don't see any difference.
> The difference is that with using a method of ReflectionFunction or > ReflectionMethod I do not have to switch paradigms (Reflection API and > OOP vs. call_user_func*() and non-OOP).
> -- > Sebastian Bergmann http://www.sebastian-bergmann.de/ > GnuPG Key: 0xB85B5D69 / 27A7 2B14 09E4 98CD 6277 0E5B 6867 C514 B85B 5D69
-- Best regards, Marcus mailto:helly@php.net