Parse a trace element from the backtrace stack.

@param  int   $index
@param  array $trace

@return object|bool
355041
protected function parseTrace($index, array $trace)
    {
        $frame = (object) [
            'index'     => $index,
            'namespace' => null,
            'name'      => null,
            'line'      => isset($trace['line']) ? $trace['line'] : '?',
        ];

        if (isset($trace['function']) && $trace['function'] == 'substituteBindings') {
            $frame->name = 'Route binding';

            return $frame;
        }

        if (isset($trace['class']) && isset($trace['file']) && strpos(
                                                                   $trace['file'],
                                                                   DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'laravel' . DIRECTORY_SEPARATOR . 'framework'
                                                               ) === false && strpos(
                                                                                  $trace['file'],
                                                                                  DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'barryvdh' . DIRECTORY_SEPARATOR . 'laravel-debugbar'
                                                                              ) === false
        ) {
            $file = $trace['file'];

            if (isset($trace['object']) && is_a($trace['object'], 'Twig_Template')) {
                list($file, $frame->line) = $this->getTwigInfo($trace);
            } elseif (strpos($file, storage_path()) !== false) {
                $hash = pathinfo($file, PATHINFO_FILENAME);

                if (!$frame->name = $this->findViewFromHash($hash)) {
                    $frame->name = $hash;
                }

                $frame->namespace = 'view';

                return $frame;
            } elseif (strpos($file, 'Middleware') !== false) {
                $frame->name = $this->findMiddlewareFromFile($file);

                if ($frame->name) {
                    $frame->namespace = 'middleware';
                } else {
                    $frame->name = $this->normalizeFilename($file);
                }

                return $frame;
            }

            $frame->name = $this->normalizeFilename($file);

            return $frame;
        }


        return false;
    }
294855
private function traceHTML(array $trace) {
            ?>
            <table class="table" border="1">
                <thead>
                <tr>
                    <th>#</th>
                    <th>Method</th>
                    <th>Args</th>
                    <th>File</th>
                    <th>Line</th>
                </tr>
                </thead>
                <tbody><?php
                    foreach ($trace as $k => $v) {
                        $func = $loc = $line = '';
                        self::formatTraceLine($v, $func, $loc, $line);

                        if (isset($v['args']) && !empty($v['args'])) {
                            $args = Dump::html($v['args']);
                        } else {
                            $args = '<span class="label label-default">[none]</span>';
                        }

                        ?>
                        <tr>
                            <td><?= $k ?></td>
                            <td><?= $func ?></td>
                            <td class="text-center"><?= $args ?></td>
                            <td><?= $loc ? $loc : '<span class="label label-default">???</label>' ?></td>
                            <td><?= ($line == 0 || trim($line)) ? $line :
                                    '<span class="label label-default">???</span>' ?></td>
                        </tr>

                        <?php
                    }
                ?>
                </tbody>
            </table>
            <?php
        }
656671
protected function getTrace()
    {
        $backtrace = debug_backtrace();
        $index = null;
        $hasNull = false;
        $realClassName = static::__getRealClassName();
        foreach($backtrace as $i => $item)
        {
            if($realClassName === $item['class'])
            {
                $index = $i + 2;
                break;
            }
        }
        if(null === $index)
        {
            return [];
        }
        return array_splice($backtrace, $index);
    }
1332384
public static function dWithTrace(array $trace) {
		#clear all active buffers
		while(ob_get_level())
			ob_end_clean();

		if(!headers_sent())
			http_response_code(520);

		if(static::$format === 'html')
			echo '<pre>';
		foreach(array_slice(func_get_args(), 1) as $arg)
			var_dump($arg);
		if(static::$format === 'html')
			echo '</pre>';

		die(static::getReport($trace));
	}
423001
protected function getFixtureCaller($traceIndex = 6)
    {
        $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, $traceIndex + 1);
        $caller = $trace[$traceIndex];

        if (isset($caller['class'])) {
            $result = @$caller['class'] . '->' . @$caller['function'] . '()';
        } else {
            $result = @$caller['function'] . '()';
        }

        return $result;
    }
1316855
public function parse(array $trace)
    {
        $this->trace = &$trace;
        $traceCount = count($trace);
        
        for($this->eachIndex = $traceCount - 1; $this->eachIndex >= 0; --$this->eachIndex)
        {
            $traceLine = $trace[$this->eachIndex];
            if($this->isFindingBeanRealCall)
            {
                if($this->isKeep($traceLine))
                {
                    $this->isFindingBeanRealCall = false;
                }
                else
                {
                    unset($trace[$this->eachIndex]);
                }
            }
            else
            {
                if(isset($traceLine['class']))
                {
                    $ref = new \ReflectionClass($traceLine['class']);
                    if($ref->implementsInterface(IBean::class))
                    {
                        $this->beanRealCallRealClassName = $this->getBeanRealCallRealClassName();
                        if(null === $this->beanRealCallRealClassName)
                        {
                            continue;
                        }
                        $this->isFindingBeanRealCall = true;
                        unset($trace[$this->eachIndex]);
                        --$this->eachIndex;
                        unset($trace[$this->eachIndex]);
                    }
                }
            }
        }
        return array_values($trace);
    }
1314725
private function parseIndex( SimpleXMLElement $index )
    {
        $indexFields = array();

        foreach ( $index->field as $indexField )
        {
            $indexFieldName = (string) $indexField->name;

            $indexFields[$indexFieldName] = ezcDbSchema::createNewIndexField(
                isset( $indexField->sorting ) ? (string) $indexField->sorting : null
            );
        }

        return ezcDbSchema::createNewIndex(
            $indexFields,
            isset( $index->primary ) ? (string) $index->primary : false,
            isset( $index->unique ) ? (string) $index->unique : false
        );
    }
901240
public function get_request_comp(int $index=null) {
		$comp = $this->request_comp;
		if ($index === null)
			return $comp;
		if (isset($comp[$index]))
			return $comp[$index];
		return null;
	}
361429
protected static function get_calling_module_from_trace($backtrace)
    {
        if (!isset($backtrace[1]['file'])) {
            return null;
        }

        $callingfile = realpath($backtrace[1]['file']);

        return ModuleLoader::inst()->getManifest()->getModuleByPath($callingfile);
    }
547620
public function at($index){
        $return = NULL;
        $index = intval($index);
        $data = $this->asArray();
        reset($data);
        if ($index < 0){
            $index += $this->length();
        }
        $c = 1;
        while ($c <= $index){
            next($data);
            $c++;
        }
        $return = current($data);
        $Model = $this->buildModel($return);
        if ($Model !== NULL){
            $return = $Model;
        }
        return $return;
    }
1196383
protected function getTrace($e)
    {
        $traces = $e->getTrace();

        // Get trace from xdebug if enabled, failure exceptions only trace to the shutdown handler by default
        if (!$e instanceof \ErrorException) {
            return $traces;
        }

        if (!Misc::isLevelFatal($e->getSeverity())) {
            return $traces;
        }

        if (!extension_loaded('xdebug') || !xdebug_is_enabled()) {
            return [];
        }

        // Use xdebug to get the full stack trace and remove the shutdown handler stack trace
        $stack = array_reverse(xdebug_get_function_stack());
        $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
        $traces = array_diff_key($stack, $trace);

        return $traces;
    }
566493
public function val($index = 0) {

		if(false === ('-' . intval($index) == '-' . $index)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type integer, "%s" given', __METHOD__, gettype($index)), E_USER_ERROR);
		}

		$val = $this -> strip();

		if(true === isset($val[$index])) {
			return $val[$index];
		}

		return null;
	}
303173
public function get_row_attribs($index = null)
    {
        if ($index === null) {
            $index = $this->rowindex;
        }

        return $this->rows[$index] ? $this->rows[$index]->attrib : null;
    }
1063801
public function segment($index, $default = null)
	{
		$segments = explode('/', trim($this->getPathInfo(), '/'));

		$segments = array_filter($segments, function($v) { return $v != ''; });

		return array_get($segments, $index - 1, $default);
	}
390603
protected static function _cleanTrace( array &$trace, $skipLines = null, $basePath = null )
    {
        $_trace = array();
        $_basePath = $basePath ?: \Kisma::get( 'app.base_path' );

        //	Skip some lines
        if ( !empty( $skipLines ) && count( $trace ) > $skipLines )
        {
            $trace = array_slice( $trace, $skipLines );
        }

        foreach ( $trace as $_index => $_code )
        {
            $_traceItem = array();

            Scalar::sins( $trace[$_index], 'file', 'Unspecified' );
            Scalar::sins( $trace[$_index], 'line', 0 );
            Scalar::sins( $trace[$_index], 'function', 'Unspecified' );

            $_traceItem['file_name'] = trim(
                str_replace(
                    array(
                        $_basePath,
                        "\t",
                        "\r",
                        "\n",
                        PHP_EOL,
                        'phar://',
                    ),
                    array(
                        null,
                        '    ',
                        null,
                        null,
                        null,
                        null,
                    ),
                    $trace[$_index]['file']
                )
            );

            $_args = null;

            if ( isset( $_code['args'] ) && !empty( $_code['args'] ) )
            {
                foreach ( $_code['args'] as $_arg )
                {
                    if ( is_object( $_arg ) )
                    {
                        $_args .= get_class( $_arg ) . ', ';
                    }
                    else if ( is_array( $_arg ) )
                    {
                        $_args .= '[array], ';
                    }
                    else if ( is_bool( $_arg ) )
                    {
                        if ( $_arg )
                        {
                            $_args .= 'true, ';
                        }
                        else
                        {
                            $_args .= 'false, ';
                        }
                    }
                    else if ( is_numeric( $_arg ) )
                    {
                        $_args .= $_arg . ', ';
                    }
                    else if ( is_scalar( $_arg ) )
                    {
                        $_args .= '"' . $_arg . '", ';
                    }
                    else
                    {
                        $_args .= '"' . gettype( $_arg ) . '", ';
                    }
                }
            }

            $_traceItem['line'] = $trace[$_index]['line'];

            if ( isset( $_code['type'] ) )
            {
                $_traceItem['function'] = ( isset( $_code['class'] ) ? $_code['class'] : null ) . $_code['type'] . $_code['function'];
            }
            else
            {
                $_traceItem['function'] = $_code['function'];
            }

            $_traceItem['function'] .= '(' . ( $_args ? ' ' . trim( $_args, ', ' ) . ' ' : null ) . ')';
            $_traceItem['index'] = $_index;
            $_trace[] = $_traceItem;
        }

        return $_trace;
    }
262759
public function offsetGet($index)
    {
        foreach ((array)$this as $i => $element) {
            $i = (string)$i;
            if (is_string($element)) {
                continue;
            }
            if ($element->getElement()->getValue() == $index) {
                return $element;
            }
        }
        return parent::offsetGet($index);
    }
954543
public function read(string $index)
    {
        $this->withIndexFilter($index);

        $builder = $this->createIndexModelBuilder();
        $data    = $this->fetchResource($builder, $builder->getModelClass());

        return $data;
    }