Skip to content

Commit 2e3852f

Browse files
committed
fix error when 'args' index isn't defined in php stack trace
1 parent 5ad3013 commit 2e3852f

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/Understand/UnderstandLaravel/ExceptionEncoder.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ protected function getStackTraceFile(array $trace)
9191
*/
9292
protected function stackTraceCallToString(array $trace)
9393
{
94-
if (!isset($trace['type']))
94+
if (! isset($trace['type']))
9595
{
9696
return 'function';
9797
}
@@ -117,6 +117,11 @@ protected function stackTraceArgsToArray(array $trace)
117117
{
118118
$params = [];
119119

120+
if (! isset($trace['args']))
121+
{
122+
return $params;
123+
}
124+
120125
foreach ($trace['args'] as $arg)
121126
{
122127
if (is_array($arg))

tests/ExceptionEncoderTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,14 @@ public function testEmptyExceptionMessageCase()
4242
$this->assertSame('DomainException', $exceptionArray['message']);
4343
}
4444

45+
public function testStactTraceSerializationWithoutArgs()
46+
{
47+
$stackTrace = debug_backtrace();
48+
unset($stackTrace[0]['args']);
49+
50+
$encoder = new Understand\UnderstandLaravel\ExceptionEncoder();
51+
$stackTraceArray = $encoder->stackTraceToArray($stackTrace);
52+
53+
$this->assertEmpty($stackTraceArray[0]['args']);
54+
}
4555
}

0 commit comments

Comments
 (0)