Esempio n. 1
0
 public function test_parse_drops_null_lines()
 {
     $callback = function ($line) {
         if ($line['file'] == 'dropme.php') {
             return NULL;
         }
         return $line;
     };
     $lines = array(array('file' => 'dropme.php', 'line' => 1, 'function' => ''), array('file' => '[PROJECT_ROOT]/app.php', 'line' => 789, 'function' => 'get'));
     $backtrace = Backtrace::parse($lines, array('filters' => array($callback)));
     $this->assertEquals(array(Line::parse($lines[1])), $backtrace->lines);
 }
Esempio n. 2
0
 /**
  * Parses a PHP backtrace and returns a new `Backtrace` object. Provided
  * options are passed to [Line::parse] which may include filters
  * (see [Config::$backtrace_filters]) which are called for with each line
  * in the trace.
  *
  * @param   array  $backtrace  The raw PHP backtrace.
  * @param   array  $options    Options and filters to apply to lines.
  * @return  Backtrace          The parsed backtrace.
  */
 public static function parse(array $backtrace, array $options = array())
 {
     $lines = array();
     // Parse each line in the backtrace.
     foreach ($backtrace as $line) {
         $parsed = Line::parse($line, $options);
         if ($parsed !== NULL) {
             $lines[] = $parsed;
         }
     }
     // Instantiate a new backtrace from the lines
     return new self($lines);
 }
Esempio n. 3
0
 public function test_extract_source_from_backtrace_should_prefer_application_lines()
 {
     $raw_backtrace = array(array('file' => FIXTURES_PATH . '/vendor/some_lib.php', 'line' => 58, 'function' => 'die'), array('file' => FIXTURES_PATH . '/MyClass.php', 'line' => 12, 'function' => 'does_amazing_things'));
     $notice = $this->build_notice(array('backtrace' => $raw_backtrace, 'project_root' => FIXTURES_PATH));
     $line = Backtrace\Line::parse($raw_backtrace[1]);
     $this->assertEquals($line->source, $notice->source_extract);
 }