ReflectionFunction::getClosure

(PHP >= 5.4.0)

ReflectionFunction::getClosureReturns a dynamically created closure for the function

Description

public Closure ReflectionFunction::getClosure ( void )

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values

Returns Closure. Returns NULL in case of an error.

Коментарии

If you have a callback that is going to be invoked often, you can use this method (and the related method for ReflectProperty) to get a closure that will execute at near native speed.

Some benchmark comparisons with php 5.4.22 on ubuntu:

[function call]      [time]     [%slower]
function():          0.09527      0%
Reflection::Closure: 0.09729      2%
$string():           0.102641     8%
Reflection:          0.197122   107%
call_user_func:      0.214045   125%

[method call]        [time]  [% slower] [%vs func]
->method():          0.103611    0%       9%
Reflection::Closure: 0.1043      1%       9%
$string():           0.109885    6%      15%
Reflection:          0.20451    97%     115%
call_user_func:      0.219205  112%     130%
2013-11-23 07:34:27
http://php5.kiev.ua/manual/ru/reflectionfunction.getclosure.html

    Поддержать сайт на родительском проекте КГБ