Exemplo n.º 1
0
 /**
  * assert handler
  *
  * @param string $file filename 
  * @param int    $line line number
  * @param string $code code that failed
  *
  * @returns void
  * @throws Exception each time called new Exception is thrown
  */
 public static function myAssertHandler($file, $line, $code)
 {
     $fileDump = CodeSnippet::getCodeSnippet($file, $line, self::NEAR_CODE);
     $message = "Assertion failed on line {$file}: {$line},code:\n\n{$fileDump}";
     $message .= "\nFailed expression: ";
     $message .= var_export($code, true);
     $message .= "\n";
     throw new Exception($message);
 }
Exemplo n.º 2
0
 private function getStatusString()
 {
     $caller = $this->getCallerData(2);
     $class = isset($caller['class']) ? $caller['class'] : "";
     $class = preg_replace("@.*\\\\@", "", $class);
     $function = $caller['function'];
     $caller = $this->getCallerData(1);
     $file = $caller['file'];
     $line = $caller['line'];
     $snippet = CodeSnippet::getCodeSnippet($file, $line, 5);
     $tooltipHtml = sprintf("<span class='trace_tooltip'>Function&nbsp;%s::%s()<br/>\n" . "Line:&nbsp;%s<br/>\n" . "File:&nbsp'%s'<br/>\n" . "<br/>Code snippet:<pre>%s</pre></span>", hescape($class), hescape($function), hescape($line), hescape($file), hescape($snippet));
     return sprintf("<span class='trace_s'>%+0.2fs %s</span>", $this->timer->getElapsedTime(), $tooltipHtml);
 }
Exemplo n.º 3
0
 /**
  * Returns information about this particular trace event.
  *
  * @returns array with with time, caller data and code snippet
  */
 private function getInfoArray()
 {
     $info = array();
     $caller = $this->getCallerData(2);
     $class = isset($caller['class']) ? $caller['class'] : "";
     $class = preg_replace("@.*\\\\@", "", $class);
     $function = $caller['function'];
     $caller = $this->getCallerData(1);
     $file = $caller['file'];
     $line = $caller['line'];
     $snippet = CodeSnippet::getCodeSnippet($file, $line, 5);
     $info['class'] = $class;
     $info['function'] = $function;
     $info['line'] = $line;
     $info['file'] = $file;
     $info['snippet'] = $snippet;
     $info['elapsedTime'] = $this->timer->getElapsedTime();
     return $info;
 }