JFIFxxC      C  " }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3RbrFILE ON : __2605b8/index.php gilour

File "ResolvesEventOrigin.php"

Full Path: /var/www/drive/sentry/sentry-laravel/src/Sentry/Laravel/Features/Concerns/ResolvesEventOrigin.php
File size: 1.41 KB
MIME-type: text/x-php
Charset: utf-8

<?php

namespace Sentry\Laravel\Features\Concerns;

use Illuminate\Contracts\Container\Container;
use Sentry\Laravel\Tracing\BacktraceHelper;

trait ResolvesEventOrigin
{
    protected function container(): Container
    {
        return app();
    }

    protected function resolveEventOrigin(): ?array
    {
        $backtraceHelper = $this->makeBacktraceHelper();

        // We limit the backtrace to 20 frames to prevent too much overhead and we'd reasonable expect the origin to be within the first 20 frames
        $firstAppFrame = $backtraceHelper->findFirstInAppFrameForBacktrace(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 20));

        if ($firstAppFrame === null) {
            return null;
        }

        $filePath = $backtraceHelper->getOriginalViewPathForFrameOfCompiledViewPath($firstAppFrame) ?? $firstAppFrame->getFile();

        return [
            'code.filepath' => $filePath,
            'code.function' => $firstAppFrame->getFunctionName(),
            'code.lineno' => $firstAppFrame->getLine(),
        ];
    }

    protected function resolveEventOriginAsString(): ?string
    {
        $origin = $this->resolveEventOrigin();

        if ($origin === null) {
            return null;
        }

        return "{$origin['code.filepath']}:{$origin['code.lineno']}";
    }

    private function makeBacktraceHelper(): BacktraceHelper
    {
        return $this->container()->make(BacktraceHelper::class);
    }
}