Webmozart\Console\UI\Component\ExceptionTrace::printTrace PHP Méthode

printTrace() private méthode

private printTrace ( IO $io, Exception $exception )
$io Webmozart\Console\Api\IO\IO
$exception Exception
    private function printTrace(IO $io, Exception $exception)
    {
        $traces = $exception->getTrace();
        $cwd = getcwd() . DIRECTORY_SEPARATOR;
        $cwdLength = strlen($cwd);
        $lastTrace = array('function' => '', 'args' => array());
        if (null !== $exception->getFile()) {
            $lastTrace['file'] = $exception->getFile();
        }
        if (null !== $exception->getLine()) {
            $lastTrace['line'] = $exception->getLine();
        }
        array_unshift($traces, $lastTrace);
        $io->errorLine('<b>Exception trace:</b>');
        foreach ($traces as $trace) {
            $namespace = '';
            $class = '';
            $location = 'n/a';
            if (isset($trace['class'])) {
                if (false !== ($pos = strrpos($trace['class'], '\\'))) {
                    $namespace = substr($trace['class'], 0, $pos + 1);
                    $class = substr($trace['class'], $pos + 1);
                } else {
                    $class = $trace['class'];
                }
            }
            if (isset($trace['file'])) {
                if (0 === strpos($trace['file'], $cwd)) {
                    $location = substr($trace['file'], $cwdLength);
                } else {
                    $location = $trace['file'];
                }
            }
            // class, operator, function
            $signature = $class . (isset($trace['type']) ? $trace['type'] : '') . $trace['function'];
            $location .= ':' . (isset($trace['line']) ? $trace['line'] : 'n/a');
            $io->errorLineRaw(sprintf('  %s%s()', $namespace, $io->format('<u>' . $signature . '</u>')));
            $io->errorLineRaw(sprintf('    %s', $io->format('<c1>' . $location . '</c1>')));
        }
        $io->errorLine('');
        $io->errorLine('');
    }