public format ( $string, |
||
$style |
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(''); }
private static function drawBorder(IO $io, array $columnLengths, $indentation, $lineChar, $crossingLChar, $crossingCChar, $crossingRChar, Style $style = null) { $line = str_repeat(' ', $indentation); $line .= $crossingLChar; for ($i = 0, $l = count($columnLengths); $i < $l; ++$i) { $line .= str_repeat($lineChar, $columnLengths[$i]); $line .= $i < $l - 1 ? $crossingCChar : $crossingRChar; } // Remove trailing space $line = rtrim($line); // Render only non-empty separators if ($line) { $io->write($io->format($line, $style) . "\n"); } }