public function internalFuncCallPreHook()

in agent/php/ElasticApm/Impl/AutoInstrument/InterceptionManager.php [86:134]


    public function internalFuncCallPreHook(
        int $interceptRegistrationId,
        ?object $thisObj,
        array $interceptedCallArgs
    ): bool {
        $localLogger = $this->logger->inherit()->addAllContext(
            [
                'interceptRegistrationId' => $interceptRegistrationId,
                'thisObj type' => DbgUtil::getType($thisObj),
                'interceptedCallArgs count' => count($interceptedCallArgs),
                'thisObj' => $this->logger->possiblySecuritySensitive($thisObj),
                'interceptedCallArgs' => $this->logger->possiblySecuritySensitive($interceptedCallArgs),
            ]
        );
        $loggerProxyTrace = $localLogger->ifTraceLevelEnabledNoLine(__FUNCTION__);

        $loggerProxyTrace && $loggerProxyTrace->log(__LINE__, 'Entered');

        $interceptRegistration
            = ArrayUtil::getValueIfKeyExistsElse($interceptRegistrationId, $this->interceptedCallRegistrations, null);
        if ($interceptRegistration === null) {
            ($loggerProxy = $localLogger->ifErrorLevelEnabled(__LINE__, __FUNCTION__))
            && $loggerProxy->log('There is no registration with the given interceptRegistrationId');
            return false;
        }
        $localLogger->addContext('interceptRegistration', $interceptRegistration);

        $loggerProxyTrace && $loggerProxyTrace->log(__LINE__, 'Calling preHook...');
        try {
            $preHookRetVal = ($interceptRegistration->preHook)($thisObj, $interceptedCallArgs);
        } catch (Throwable $throwable) {
            ($loggerProxy = $localLogger->ifErrorLevelEnabled(__LINE__, __FUNCTION__))
            && $loggerProxy->logThrowable(
                $throwable,
                'preHook has let a Throwable to escape'
            );
            return false;
        }

        $shouldCallPostHook = ($preHookRetVal !== null);
        if ($shouldCallPostHook) {
            $this->interceptedCallInProgressRegistrationId = $interceptRegistrationId;
            $this->interceptedCallInProgressRegistration = $interceptRegistration;
            $this->interceptedCallInProgressPreHookRetVal = $preHookRetVal;
        }

        $loggerProxyTrace && $loggerProxyTrace->log(__LINE__, 'preHook completed successfully', ['shouldCallPostHook' => $shouldCallPostHook]);
        return $shouldCallPostHook;
    }