ReflectionFunction::getClosure

(PHP 5 >= 5.4.0, PHP 7, PHP 8)

ReflectionFunction::getClosure β€” Π’ΠΎΠ·Π²Ρ€Π°Ρ‰Π°Π΅Ρ‚ динамичСски созданноС Π·Π°ΠΌΡ‹ΠΊΠ°Π½ΠΈΠ΅ для Ρ„ΡƒΠ½ΠΊΡ†ΠΈΠΈ

ОписаниС

public function ReflectionFunction::getClosure(): Closure

ΠŸΠΎΠ»ΡƒΡ‡Π°Π΅Ρ‚ динамичСски созданноС Π·Π°ΠΌΡ‹ΠΊΠ°Π½ΠΈΠ΅ для Ρ„ΡƒΠ½ΠΊΡ†ΠΈΠΈ.

Бписок ΠΏΠ°Ρ€Π°ΠΌΠ΅Ρ‚Ρ€ΠΎΠ²

Π‘ΠΈΠ³Π½Π°Ρ‚ΡƒΡ€Π° Ρ„ΡƒΠ½ΠΊΡ†ΠΈΠΈ Π½Π΅ содСрТит ΠΏΠ°Ρ€Π°ΠΌΠ΅Ρ‚Ρ€ΠΎΠ².

Π’ΠΎΠ·Π²Ρ€Π°Ρ‰Π°Π΅ΠΌΡ‹Π΅ значСния

Π’ΠΎΠ·Π²Ρ€Π°Ρ‰Π°Π΅Ρ‚ Ρ‚ΠΎΠ»ΡŒΠΊΠΎ Ρ‡Ρ‚ΠΎ созданноС Π·Π°ΠΌΡ‹ΠΊΠ°Π½ΠΈΠ΅ (Closure).

οΌ‹Π”ΠΎΠ±Π°Π²ΠΈΡ‚ΡŒ

ΠŸΡ€ΠΈΠΌΠ΅Ρ‡Π°Π½ΠΈΡ ΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚Π΅Π»Π΅ΠΉ 1 note

up
9
php dot net-bug at spamhereplease dot com ΒΆ
12 years ago
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%