Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

default value for array should be array #527

Merged
merged 2 commits into from
Jan 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions lib/Raven/Stacktrace.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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'])) {
Expand Down
14 changes: 14 additions & 0 deletions test/Raven/Tests/StacktraceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down