private static function getCallbackSourceFilePathImpl()

in agent/php/ElasticApm/Impl/AutoInstrument/WordPressAutoInstrumentation.php [264:299]


    private static function getCallbackSourceFilePathImpl($callback, Logger $logger): ?string
    {
        // If callback is a Closure or string but not 'Class::method'
        if ($callback instanceof Closure) {
            return self::getCallbackSourceFilePathImplForFunc($callback, $logger);
        }

        // If callback is a string but not 'Class::method'
        if (is_string($callback)) {
            if (($afterClassNamePos = strpos($callback, '::')) === false) {
                return self::getCallbackSourceFilePathImplForFunc($callback, $logger);
            }
            $className = substr($callback, /* offset */ 0, /* length */ $afterClassNamePos);
            return self::getCallbackSourceFilePathImplForClass($className, $logger);
        }

        if (!is_array($callback)) {
            ($loggerProxy = $logger->ifDebugLevelEnabled(__LINE__, __FUNCTION__)) && $loggerProxy->log('callback of unexpected type');
            return null;
        }

        if (ArrayUtil::isEmpty($callback)) {
            ($loggerProxy = $logger->ifDebugLevelEnabled(__LINE__, __FUNCTION__)) && $loggerProxy->log('callback is an empty array');
            return null;
        }

        $firstElement = $callback[0];

        if (is_string($firstElement) || is_object($firstElement)) {
            return self::getCallbackSourceFilePathImplForClass($firstElement, $logger);
        }

        ($loggerProxy = $logger->ifDebugLevelEnabled(__LINE__, __FUNCTION__))
        && $loggerProxy->log('callback is an array but its first element is of unexpected type', ['firstElement type' => DbgUtil::getType($firstElement), 'firstElement' => $firstElement]);
        return null;
    }