in agent/php/ElasticApm/Impl/AutoInstrument/MySQLiAutoInstrumentation.php [512:568]
private function interceptCallsTo(
RegistrationContextInterface $ctx,
string $className,
string $methodName,
callable $preHook
): void {
$funcName = self::buildFuncName($className, $methodName);
$ctx->interceptCallsToInternalFunction(
$className . '_' . $methodName,
/**
* @param array $interceptedCallArgs
*
* @return null|callable(int, bool, mixed): void
*/
function (array $interceptedCallArgs) use ($preHook, $funcName): ?callable {
if (!$this->util->verifyMinArgsCount(1, $interceptedCallArgs)) {
return null;
}
$interceptedCallThis = $interceptedCallArgs[0];
if (
$interceptedCallThis !== null
&& !$this->util->verifyIsObject($interceptedCallThis)
) {
return null;
}
/** @var ?object $interceptedCallThis */
return $preHook(
null /* <- className */,
$funcName /* <- funcName / methodName */,
$interceptedCallThis,
array_slice($interceptedCallArgs, 1) /* <- interceptedCallArgs */
);
}
);
$ctx->interceptCallsToInternalMethod(
$className,
$methodName,
/**
* @param ?object $interceptedCallThis
* @param array $interceptedCallArgs
*
* @return null|callable(int, bool, mixed): void
*/
function (
?object $interceptedCallThis,
array $interceptedCallArgs
) use (
$className,
$methodName /* <- funcName / methodName */,
$preHook
): ?callable {
return $preHook($className, $methodName, $interceptedCallThis, $interceptedCallArgs);
}
);
}