/** * @param string $error * @param string $file * @param int $line * @param array|null $trace */ private function showError($error, $file, $line, array $trace = null) { $baseLen = strlen(realpath(__DIR__ . '/../../..')) + 1; $message = [$error]; $message[] = ''; $message[] = sprintf('#0 %s(%d)', substr($file, $baseLen), $line); if ($trace != null) { foreach ($trace as $pos => $step) { $file = 'unknown file'; if (isset($step['file'])) { $file = substr($step['file'], $baseLen); } $message[] = sprintf('#%d %s(%d): %s%s%s()', $pos + 1, $file, isset($step['line']) ? $step['line'] : 0, isset($step['class']) ? $step['class'] : '', isset($step['type']) ? $step['type'] : '', $step['function']); } $message[] = sprintf('#%d {main}', count($trace) + 1); } $this->ouput->writeError(sprintf(file_get_contents(__DIR__ . '/error.txt'), join("\n ", $message), $this->environment->getRuntimeString(), $this->version->getVersion())); }