Code formatting

This commit is contained in:
Anton Terekhov
2011-10-13 14:55:06 +04:00
parent 642c5909aa
commit 3ebfac9db4
12 changed files with 92 additions and 86 deletions

View File

@ -11,39 +11,39 @@
class ErrorHandler
{
static public function init()
{
set_error_handler(array('ErrorHandler', 'error_handler'));
}
static public function error_handler($errno, $errstr, $errfile, $errline )
static public function error_handler($errno, $errstr, $errfile, $errline)
{
ob_clean();
throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
return false;
}
static protected function getSource($file, $hiline)
{
$code = array();
$i = 0;
foreach(file($file) as $line) {
foreach (file($file) as $line) {
$i++;
if($i >= $hiline - 10 && $i <= $hiline + 10) {
if ($i >= $hiline - 10 && $i <= $hiline + 10) {
if ($i == $hiline) {
$code[] = '<tr class="error"><th>' . $i . '</th><td><span class="specific">' . htmlentities($line, ENT_QUOTES, 'UTF-8') . '</span></td></tr>';
}else{
} else {
$code[] = '<tr><th>' . $i . '</th><td>' . htmlentities($line, ENT_QUOTES, 'UTF-8') . '</td></tr>';
}
}
if($i > $hiline + 10) {
if ($i > $hiline + 10) {
break;
}
}
return implode('', $code);
}
static protected function wrapArray($array, $name)
{
if (!$array) {
@ -60,12 +60,12 @@ class ErrorHandler
$text .= '</tbody></table>';
return $text;
}
static protected function wrapTrace($trace)
{
return '<code>' . nl2br($trace) . '</code>';
}
/**
* @param Exception $exception
*/
@ -73,22 +73,22 @@ class ErrorHandler
{
ob_clean();
$class = get_class($exception);
$method = Env::Server('REQUEST_METHOD', '');
$uri = Env::getRequestUri();
$source = self::getSource($exception->getFile(), $exception->getLine());
$time = date('r', Env::Server('REQUEST_TIME', time()));
$trace = nl2br($exception->getTraceAsString());
$get = self::wrapArray(Env::Get(), 'GET');
$post = self::wrapArray(Env::Post(), 'POST');
$session = self::wrapArray(Session::get(), 'SESSION');
$files = self::wrapArray(Env::Files(), 'FILES');
$cookies = self::wrapArray(Env::Cookie(), 'COOKIE');
$server = self::wrapArray(Env::Server(), 'SERVER');
$message =<<<EOD
$message = <<<EOD
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>