コード例 #1
0
 public function test()
 {
     $exception = new ErrorException(E_NOTICE, 'message', 'file', 0, 1);
     $this->assertSame(E_NOTICE, $exception->getSeverity());
     $this->assertSame('message', $exception->getMessage());
     $this->assertSame('Notice', $exception->getSeverityAsString());
     $this->assertSame('E_NOTICE', $exception->getSeverityAsConstantName());
     $this->assertSame('file', $exception->getFile());
     $this->assertSame(0, $exception->getLine());
     $sourceTrace = array_slice($exception->getTrace(), 1);
     $this->assertSame($sourceTrace, $exception->getSourceTrace());
     $this->assertSame(StackTraceFormatter::format($exception->getSourceTrace()), $exception->getSourceTraceAsString());
     $this->assertSame('exception \'Hyperframework\\Common\\ErrorException\' ' . "with message 'message' in file:0" . PHP_EOL . 'Stack trace:' . PHP_EOL . $exception->getSourceTraceAsString(), (string) $exception);
 }
コード例 #2
0
 /**
  * @return string
  */
 public function getSourceTraceAsString()
 {
     $trace = $this->getSourceTrace();
     return StackTraceFormatter::format($trace);
 }
コード例 #3
0
 public function testFormatInvocation()
 {
     $this->assertSame("Class->test('01234567890123\\n...'," . " Array, NULL, Object(stdClass))", StackTraceFormatter::formatInvocation(['class' => 'Class', 'type' => '->', 'function' => 'test', 'args' => ["01234567890123\n\n", [], null, new stdClass()]]));
 }
コード例 #4
0
 /**
  * @return void
  */
 private function renderStackTrace()
 {
     echo '<table class="stack-trace"><tr><td class="content">', '<h2>Stack Trace</h2><table><tbody>';
     $index = 0;
     $last = count($this->trace) - 1;
     foreach ($this->trace as $frame) {
         if ($frame !== '{main}') {
             $invocation = StackTraceFormatter::formatInvocation($frame);
             echo '<tr><td class="index">', $index, '</td><td class="value';
             if ($index === $last) {
                 echo ' last';
             }
             echo '"><div class="frame"><div class="position">';
             if (isset($frame['file'])) {
                 $this->renderPath($frame['file'], ' <span class="line">' . $frame['line'] . '</span>');
             } else {
                 echo '<span class="internal">internal function</span>';
             }
             echo '</div><div class="invocation"><code>', $invocation, '</code></div></div></td></tr>';
         }
         ++$index;
     }
     echo '</tbody></table></td></tr></table>';
 }