|
|
@ -149,6 +149,13 @@ class ErrorHandler extends Component |
|
|
|
$html .= '<a href="http://yiiframework.com/doc/api/2.0/' . $this->htmlEncode($part) . '" target="_blank">' . $this->htmlEncode($part) . '</a>\\'; |
|
|
|
$html .= '<a href="http://yiiframework.com/doc/api/2.0/' . $this->htmlEncode($part) . '" target="_blank">' . $this->htmlEncode($part) . '</a>\\'; |
|
|
|
} |
|
|
|
} |
|
|
|
$html = rtrim($html, '\\'); |
|
|
|
$html = rtrim($html, '\\'); |
|
|
|
|
|
|
|
} elseif (strpos($code, '()') !== false) { |
|
|
|
|
|
|
|
// method/function call |
|
|
|
|
|
|
|
$self = $this; |
|
|
|
|
|
|
|
$html = preg_replace_callback('/^(.*)\(\)$/', function ($matches) use ($self) { |
|
|
|
|
|
|
|
return '<a href="http://yiiframework.com/doc/api/2.0/' . $this->htmlEncode($matches[1]) . '" target="_blank">' . |
|
|
|
|
|
|
|
$self->htmlEncode($matches[1]) . '</a>()'; |
|
|
|
|
|
|
|
}, $code); |
|
|
|
} |
|
|
|
} |
|
|
|
return $html; |
|
|
|
return $html; |
|
|
|
} |
|
|
|
} |
|
|
@ -184,13 +191,18 @@ class ErrorHandler extends Component |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Renders a single call stack element. |
|
|
|
* Renders a single call stack element. |
|
|
|
* @param string $file name where call has happened. |
|
|
|
* @param string|null $file name where call has happened. |
|
|
|
* @param integer $line number on which call has happened. |
|
|
|
* @param integer|null $line number on which call has happened. |
|
|
|
|
|
|
|
* @param string|null $class called class name. |
|
|
|
|
|
|
|
* @param string|null $method called function/method name. |
|
|
|
* @param integer $index number of the call stack element. |
|
|
|
* @param integer $index number of the call stack element. |
|
|
|
* @return string HTML content of the rendered call stack element. |
|
|
|
* @return string HTML content of the rendered call stack element. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function renderCallStackItem($file, $line, $index) |
|
|
|
public function renderCallStackItem($file, $line, $class, $method, $index) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
$lines = array(); |
|
|
|
|
|
|
|
$begin = $end = 0; |
|
|
|
|
|
|
|
if ($file !== null && $line !== null) { |
|
|
|
$line--; // adjust line number from one-based to zero-based |
|
|
|
$line--; // adjust line number from one-based to zero-based |
|
|
|
$lines = @file($file); |
|
|
|
$lines = @file($file); |
|
|
|
if ($line < 0 || $lines === false || ($lineCount = count($lines)) < $line + 1) { |
|
|
|
if ($line < 0 || $lines === false || ($lineCount = count($lines)) < $line + 1) { |
|
|
@ -200,11 +212,14 @@ class ErrorHandler extends Component |
|
|
|
$half = (int)(($index == 0 ? $this->maxSourceLines : $this->maxTraceSourceLines) / 2); |
|
|
|
$half = (int)(($index == 0 ? $this->maxSourceLines : $this->maxTraceSourceLines) / 2); |
|
|
|
$begin = $line - $half > 0 ? $line - $half : 0; |
|
|
|
$begin = $line - $half > 0 ? $line - $half : 0; |
|
|
|
$end = $line + $half < $lineCount ? $line + $half : $lineCount - 1; |
|
|
|
$end = $line + $half < $lineCount ? $line + $half : $lineCount - 1; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$view = new View(); |
|
|
|
$view = new View(); |
|
|
|
return $view->renderFile($this->callStackItemView, array( |
|
|
|
return $view->renderFile($this->callStackItemView, array( |
|
|
|
'file' => $file, |
|
|
|
'file' => $file, |
|
|
|
'line' => $line, |
|
|
|
'line' => $line, |
|
|
|
|
|
|
|
'class' => $class, |
|
|
|
|
|
|
|
'method' => $method, |
|
|
|
'index' => $index, |
|
|
|
'index' => $index, |
|
|
|
'lines' => $lines, |
|
|
|
'lines' => $lines, |
|
|
|
'begin' => $begin, |
|
|
|
'begin' => $begin, |
|
|
@ -219,7 +234,7 @@ class ErrorHandler extends Component |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function isCoreFile($file) |
|
|
|
public function isCoreFile($file) |
|
|
|
{ |
|
|
|
{ |
|
|
|
return $file === 'unknown' || strpos(realpath($file), YII_PATH . DIRECTORY_SEPARATOR) === 0; |
|
|
|
return $file === null || strpos(realpath($file), YII_PATH . DIRECTORY_SEPARATOR) === 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|