Walk back traces

@param array|\Traversable $backtraces
@param callable $callback
430247
public static function walkBacktrace($backtraces, callable $callback)
    {
        foreach($backtraces as $index => $item){
            $func  = $item['function'] ?? '';
            $class = $item['class'] ?? '';
            $type  = $item['type'] ?? '';
            $file  = $item['file'] ?? '';
            $line  = $item['line'] ?? '';
            ($callback)($index, $file, $line, $class, $type, $func);
        }
    }
460511
public static function walkRecursive(&$array, $callback, $data = null)
    {
        foreach ($array as $key => &$value) {
            if (is_array($value)) {
                self::walkRecursive($value, $callback, $data);
            } else {
                $callback($value, $key, $array, $data);
            }
        }
    }
1224655
private function array_walk(&$original, $callback, $userdata = [])
    {
        $resolved = (array)$original;

        array_walk($resolved, $callback, $userdata);

        if(count((array)$original) == 1) $resolved = reset($resolved);

        $original = $resolved;
    }
209
public static void setTrace(boolean trace) {
        FallbackLoggerConfiguration.trace.set(trace);
        if (trace) {
            debug.set(true);
        }
    }
869482
public void setTraces(Trace... traces) {
        this.traces.clear();
        for (Trace trace : traces) {
            if (!trace.addReplacements(this.traces)) {
                this.traces.add(trace);
            }
        }
    }
865241
function backtrack() {

            // The idea is to pull matches off of our match list, rolling back
            // characters from the query. We pay special attention to the special
            // characters since they are searched first.
            while (result.length > 0) {
                var item = result.pop();

                // nothing in the list? there's no possible match then.
                if (!item) {
                    return false;
                }

                // we pulled off a match, which means that we need to put a character
                // back into our query. strCounter is going to be set once we've pulled
                // off the right special character and know where we're going to restart
                // searching from.
                queryCounter--;

                if (item instanceof SpecialMatch) {
                    // pulled off a special, which means we need to make that special available
                    // for matching again
                    specialsCounter--;

                    // check to see if we've gone back as far as we need to
                    if (item.index < deadBranches[queryCounter]) {
                        // we now know that this part of the query does not match beyond this
                        // point
                        deadBranches[queryCounter] = item.index - 1;

                        // since we failed with the specials along this track, we're
                        // going to reset to looking for matches consecutively.
                        state = ANY_MATCH;

                        // we figure out where to start looking based on the new
                        // last item in the list. If there isn't anything else
                        // in the match list, we'll start over at the starting special
                        // (which is generally the beginning of the string, or the
                        // beginning of the last segment of the string)
                        item = result[result.length - 1];
                        if (!item) {
                            strCounter = specials[startingSpecial] + 1;
                            return true;
                        }
                        strCounter = item.index + 1;
                        return true;
                    }
                }
            }
            return false;
        }
763008
private function getTrace()
    {
        $trace = array();

        if (PHP_VERSION_ID >= 50400) {
            $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 10);
        } else if (PHP_VERSION_ID >= 50306) {
            $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
        } else {
            $trace = debug_backtrace();
        }
        if (empty($trace)) {
            return '';
        }
        array_shift($trace); // ignore $this->getTrace();
        array_shift($trace); // ignore $this->process()
        $i = 0;
        $returnArray = array();
        while (isset($trace[$i]['class']) && false === strpos($trace[$i]['class'], 'Zend\\Log')
            && false === strpos($trace[$i]['class'], 'DhErrorLogging')) {
            $i++;
            $returnArray[] = array(
                'file'     => isset($trace[$i]['file'])   ? $trace[$i]['file']   : null,
                'line'     => isset($trace[$i]['line'])   ? $trace[$i]['line']   : null,
                'class'    => isset($trace[$i]['class'])    ? $trace[$i]['class']    : null,
                'function' => isset($trace[$i]['function']) ? $trace[$i]['function'] : null,
            );
        }

        return $returnArray;
    }
523548
protected function walkProgress($walkable, $callback, $count = null)
    {
        $isMultiPageCollection = ($walkable instanceof Collection && $walkable->getLastPageNumber() > 1);

        if ($isMultiPageCollection) {
            return $this->walkProgressMultiPage(
                $walkable,
                $callback
            );
        }

        $walkableCount = $count ?: count($walkable);
        $walkableIndex = 0;

        $counterLength = strlen((string)$walkableCount);

        $serializedIndex = serialize(
            $counterLength . '_' . $walkableCount . '_' . microtime()
        );
        $serializedIndexFull = $serializedIndex . '_walkProgress_full';
        $serializedIndexRow = $serializedIndex . '_walkProgress_row';

        $this->timeMessureHelper->start($serializedIndexFull);

        foreach ($walkable as $item) {
            $this->timeMessureHelper->start($serializedIndexRow);

            $walkableIndex++;

            $currentCounter = str_pad($walkableIndex, $counterLength, '0', STR_PAD_LEFT);

            $this->output->write('|- ' . $currentCounter . ' / ' . $walkableCount . ' -> ');

            try {
                $result = $callback($item);

                $this->output->writeln('<comment>' . $result . '</comment> -> <info>' . $this->timeMessureHelper->output($serializedIndexRow) . '</info>');
            } catch (\Exception $exception) {
                $this->output->logException($exception);
                $this->output->logError($this->timeMessureHelper->output($serializedIndexRow));
            }
        }

        $this->output->writeln('');
        $this->output->writeln('<comment>Progress Done!</comment> -> <info>' . $this->timeMessureHelper->output($serializedIndexFull) . '</info>');
    }
1103472
public function dispatchDebug($data, $tags = null, $ignoreTraceCalls = 0) {
		if($this->isActive()) {
			$message = new DebugMessage();
			$message->data = $this->dumper->dump($data);
			if($tags) {
				$message->tags = explode('.', $tags);
			}
			if($this->detectTraceAndSource && $ignoreTraceCalls !== null) {
				$message->trace = $this->fetchTrace(debug_backtrace(), $message->file, $message->line, $ignoreTraceCalls);
			}
			$this->sendMessage($message);
		}
	}
967268
public static function trace($str)
    {
        $dbg = debug_backtrace();
        phpCAS :: log($str . ' [' . basename($dbg[0]['file']) . ':' . $dbg[0]['line'] . ']');
    }
1152711
public function getBacktrace( $trace )
    {
        $traces = [ ];

        $i = 1;

        foreach ( $trace as $t )
        {
            $traceString = '';

            if ( !isset( $t[ 'file' ] ) )
            {
                $t[ 'file' ] = 'unknown';
            }
            if ( !isset( $t[ 'line' ] ) )
            {
                $t[ 'line' ] = 0;
            }
            if ( !isset( $t[ 'function' ] ) )
            {
                $t[ 'function' ] = 'unknown';
            }

            $traceString .= '#' .
                $i . ' ' .
                $t[ 'file' ] . '(' .
                $t[ 'line' ] . '): ';

            if ( isset( $t[ 'object' ] ) && is_object( $t[ 'object' ] ) )
            {
                $traceString .= get_class( $t[ 'object' ] ) . '->';
            }

            $traceString .= $t[ 'function' ] . '()';

            $traces[ ] = $traceString;

            $i++;
        }

        return $traces;
    }
949328
function extractBacktrace(lines) {
  var backtraceLines = [];
  while(lines.length && lines[lines.length - 1].trim().indexOf('at ') === 0) {
    backtraceLines.push(lines.pop());
  }
  return backtraceLines;
}
710821
function(trace, callback) {
      var item = {body: {trace: trace}};
      if (callback) {
        item.callback = callback;
      }

      this.items.push(item);
      this.handleEvents();
    }
492436
protected function format_backtrace($btrace)
    {
        if (empty($btrace) || count($btrace) == 0) {
            return "backtrace empty";
        }
        
        $trace = "";
        
        foreach ($btrace as $nr => &$btrace_entry) {
            if ($nr == 0) {
                $trace .= $btrace_entry["args"][2] . "\r\n" . "line: " . $btrace_entry["args"][3] . "\r\n" . $btrace_entry["args"][1];
                
                $cstack = $this->extract_call_stack($btrace);
                if (!empty($cstack)) {
                    $trace .= "\r\n\r\nCall stack:\r\n\r\n" . $cstack;
                }
                
                continue;
            }
        }
        
        return $trace;
    }
848093
public function addMethod($method, $callback)
        {
            $this->traceInternal("Added '" . $method . "' to " . __METHOD__ . "()");
            $this->callbacks[$method] = $callback;
        }
659758
public function backward($args, $total, array $callableArgs = [])
    {
        $total = $this->computeTotalCount($total, $callableArgs);

        $args = $this->protectArgs($args);
        $limit = $args['last'];
        $offset = \max(0, $this->connectionBuilder->getOffsetWithDefault($args['before'], $total) - $limit);

        $entities = \call_user_func($this->fetcher, $offset, $limit);

        return $this->handleEntities($entities, function ($entities) use ($args, $offset, $total) {
            return $this->connectionBuilder->connectionFromArraySlice($entities, $args, [
                'sliceStart' => $offset,
                'arrayLength' => $total,
            ]);
        });
    }
1354558
public static int[] setSteps(Last[][][] traceback, int[] xyMax, List<Step> sx, List<Step> sy) {
		return setSteps(traceback, true, xyMax, Last.SUBSTITUTION, sx, sy);
	}