debug_backtrace

Supported Versions: PHP 4 >= 4.3.0, PHP 5, PHP 7, PHP 8
Generates a backtrace
<?php debug_backtrace(int $options = DEBUG_BACKTRACE_PROVIDE_OBJECT, int $limit = 0): array
<?php     static function findTestClassAndMethodThatCalledThis()

    {

        $traces = debug_backtrace(options: DEBUG_BACKTRACE_IGNORE_ARGS, limit: 10);



        foreach ($traces as $trace) {

            if (is_subclass_of($trace['class'], TestCase::class)) {
<?php     protected function guessBelongsToRelation()

    {

        [$one, $two, $caller] = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3);



        return $caller['function'];

    }
<?php     protected function guessBelongsToManyRelation()

    {

        $caller = Arr::first(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS), function ($trace) {

            return ! in_array(

                $trace['function'],

                array_merge(static::$manyMethods, ['guessBelongsToManyRelation'])
<?php     protected function guessRelationship()

    {

        return debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3)[2]['function'];

    }
<?php             return [$ability, $arguments];

        }



        $method = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3)[2]['function'];



        return [$this->normalizeGuessedAbilityName($method), $ability];

    }
<?php             return call_user_func(static::$dumpSourceResolver);

        }



        $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 20);



        $sourceKey = null;
<?php     function once(callable $callback)

    {

        $onceable = Onceable::tryFromTrace(

            debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT, 2),

            $callback,

        );
<?php     protected static function ensureIntlExtensionIsInstalled()

    {

        if (! extension_loaded('intl')) {

            $method = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2)[1]['function'];



            throw new RuntimeException('The "intl" PHP extension is required to use the ['.$method.'] method.');

        }
<?php     public static function create(int $argument, string $type): static

    {

        $stack = debug_backtrace();



        $function = $stack[1]['function'];
<?php     {

        $current = null;



        foreach (debug_backtrace(self::BACKTRACE_OPTIONS) as $trace) {

            assert(array_key_exists(self::FILE, $trace));



            $traceFile = str_replace(DIRECTORY_SEPARATOR, '/', $trace[self::FILE]);
<?php     {

        $current = null;



        foreach (debug_backtrace(self::BACKTRACE_OPTIONS) as $trace) {

            assert(array_key_exists(self::FILE, $trace));



            $traceFile = str_replace(DIRECTORY_SEPARATOR, '/', $trace[self::FILE]);
<?php     private static function backtrace(): array

    {

        $backtrace = debug_backtrace(self::BACKTRACE_OPTIONS);



        foreach ($backtrace as $trace) {

            if (! isset($trace['file'])) {
<?php     public function record(Data $data)

    {

        $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 8);

        $file = (string)Arr::get($backtrace, '6.file');

        $lineNumber = (int)Arr::get($backtrace, '6.line');
<?php function once(callable $callback): mixed

{

    $trace = debug_backtrace(

        DEBUG_BACKTRACE_PROVIDE_OBJECT, 2

    );



    $backtrace = new Backtrace($trace);
<?php             return false;

        }



        return collect(debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT, 5))

            ->pluck('class')

            ->contains(PaginatedResourceResponse::class);

    }