function ExtensionHookManager::bindHookScope
1 call to ExtensionHookManager::bindHookScope()
- ExtensionHookManager::hook in vendor/
open-telemetry/ api/ Instrumentation/ AutoInstrumentation/ ExtensionHookManager.php - @phan-suppress PhanUndeclaredFunction
File
-
vendor/
open-telemetry/ api/ Instrumentation/ AutoInstrumentation/ ExtensionHookManager.php, line 29
Class
- ExtensionHookManager
- @phan-file-suppress PhanUndeclaredClassAttribute
Namespace
OpenTelemetry\API\Instrumentation\AutoInstrumentationCode
private function bindHookScope(?Closure $closure) : ?Closure {
if (!$closure) {
return null;
}
$reflection = new ReflectionFunction($closure);
// TODO Add an option flag to ext-opentelemetry `hook` that configures whether return values should be used?
if (!$reflection->getReturnType() || (string) $reflection->getReturnType() === 'void') {
return static function (mixed ...$args) use ($closure) : void {
if (HookManager::disabled()) {
return;
}
$closure(...$args);
};
}
return static function (mixed ...$args) use ($closure) : mixed {
if (HookManager::disabled()) {
return $args[2];
}
return $closure(...$args);
};
}