예제 #1
0
파일: ErrorHandler.php 프로젝트: pdyn/base
 /**
  * Format a backtrace for better display.
  *
  * @param array $backtrace A backtrace from debug_backtrace.
  * @return string Html that better displays the backtrace.
  */
 public static function format_backtrace($backtrace)
 {
     global $CFG;
     $html = '';
     $i = count($backtrace);
     foreach ($backtrace as $trace) {
         $file = isset($trace['file']) ? str_replace($CFG->base_absroot, '', $trace['file']) : 'unknown';
         $line = 'Line: ' . (isset($trace['line']) ? $trace['line'] : '-');
         $func = isset($trace['function']) ? $trace['function'] : '';
         ini_set('html_errors', 0);
         $argstr = [];
         if (!empty($trace['args']) && is_array($trace['args'])) {
             foreach ($trace['args'] as $arg) {
                 ob_start();
                 var_dump($arg);
                 $stringval = ob_get_contents();
                 ob_end_clean();
                 $argstr[] = $stringval;
             }
         }
         $args = implode(', ', $argstr);
         $func .= '(' . $args . ')';
         if (\pdyn\base\Utils::is_cli_env() === true) {
             $html .= $i . "\t" . $file . "\t" . $line . "\t" . $func . "\n";
         } else {
             $html .= '<tr>';
             $html .= '<td style="vertical-align:top">' . $i . '</td>';
             $html .= '<td style="vertical-align:top">' . $file . '</td>';
             $html .= '<td style="vertical-align:top">' . $line . '</td>';
             $html .= '<td><pre style="margin:0;">' . $func . '</pre></td>';
             $html .= '</tr>';
         }
         $i--;
     }
     return \pdyn\base\Utils::is_cli_env() === true ? "**********\n" . $html . "**********\n" : '<table cellspacing="5" style="color:inherit">' . $html . '</table>';
 }
예제 #2
0
파일: UtilsTest.php 프로젝트: pdyn/base
 /**
  * Test is_cli_env function.
  */
 public function test_isclienv()
 {
     $this->assertTrue(\pdyn\base\Utils::is_cli_env());
 }