diff --git a/lib/Raven/Stacktrace.php b/lib/Raven/Stacktrace.php index c3353d799..945e68d57 100644 --- a/lib/Raven/Stacktrace.php +++ b/lib/Raven/Stacktrace.php @@ -35,8 +35,8 @@ public static function get_stack_info($frames, */ $result = array(); for ($i = 0; $i < count($frames); $i++) { - $frame = isset($frames[$i]) ? $frames[$i] : null; - $nextframe = isset($frames[$i + 1]) ? $frames[$i + 1] : null; + $frame = isset($frames[$i]) ? $frames[$i] : array(); + $nextframe = isset($frames[$i + 1]) ? $frames[$i + 1] : array(); if (!array_key_exists('file', $frame)) { $context = array(); @@ -50,8 +50,10 @@ public static function get_stack_info($frames, } catch (ReflectionException $e) { // Forget it if we run into errors, it's not worth it. } - } else { + } elseif (!empty($frame['function'])) { $context['line'] = sprintf('%s(anonymous)', $frame['function']); + } else { + $context['line'] = sprintf('(anonymous)'); } if (empty($context['filename'])) { diff --git a/test/Raven/Tests/StacktraceTest.php b/test/Raven/Tests/StacktraceTest.php index c0f3c4cdc..641cc1128 100644 --- a/test/Raven/Tests/StacktraceTest.php +++ b/test/Raven/Tests/StacktraceTest.php @@ -192,6 +192,20 @@ public function testInAppWithAnonymous() $this->assertEquals($frames[0]['in_app'], false); } + public function testInAppWithEmptyFrame() + { + $stack = array( + array( + "function" => "{closure}", + ), + null + ); + + $frames = Raven_Stacktrace::get_stack_info($stack, true, null, 0, null, dirname(__FILE__)); + + $this->assertEquals($frames[0]['in_app'], false); + } + public function testInAppWithExclusion() { $stack = array(