Skip to content

Commit 5536dc2

Browse files
[ErrorHandler] fix setting $trace to null in FatalError
1 parent 5fe0f94 commit 5536dc2

File tree

1 file changed

+25
-27
lines changed

1 file changed

+25
-27
lines changed

src/Symfony/Component/ErrorHandler/Error/FatalError.php

+25-27
Original file line numberDiff line numberDiff line change
@@ -32,39 +32,37 @@ public function __construct(string $message, int $code, array $error, int $trace
3232
unset($frame['args'], $frame['this'], $frame);
3333
}
3434
}
35-
} elseif (null !== $traceOffset) {
36-
if (\function_exists('xdebug_get_function_stack')) {
37-
$trace = xdebug_get_function_stack();
38-
if (0 < $traceOffset) {
39-
array_splice($trace, -$traceOffset);
40-
}
35+
} elseif (null !== $traceOffset && \function_exists('xdebug_get_function_stack')) {
36+
$trace = xdebug_get_function_stack();
37+
if (0 < $traceOffset) {
38+
array_splice($trace, -$traceOffset);
39+
}
4140

42-
foreach ($trace as &$frame) {
43-
if (!isset($frame['type'])) {
44-
// XDebug pre 2.1.1 doesn't currently set the call type key http://bugs.xdebug.org/view.php?id=695
45-
if (isset($frame['class'])) {
46-
$frame['type'] = '::';
47-
}
48-
} elseif ('dynamic' === $frame['type']) {
49-
$frame['type'] = '->';
50-
} elseif ('static' === $frame['type']) {
41+
foreach ($trace as &$frame) {
42+
if (!isset($frame['type'])) {
43+
// XDebug pre 2.1.1 doesn't currently set the call type key http://bugs.xdebug.org/view.php?id=695
44+
if (isset($frame['class'])) {
5145
$frame['type'] = '::';
5246
}
53-
54-
// XDebug also has a different name for the parameters array
55-
if (!$traceArgs) {
56-
unset($frame['params'], $frame['args']);
57-
} elseif (isset($frame['params']) && !isset($frame['args'])) {
58-
$frame['args'] = $frame['params'];
59-
unset($frame['params']);
60-
}
47+
} elseif ('dynamic' === $frame['type']) {
48+
$frame['type'] = '->';
49+
} elseif ('static' === $frame['type']) {
50+
$frame['type'] = '::';
6151
}
6252

63-
unset($frame);
64-
$trace = array_reverse($trace);
65-
} else {
66-
$trace = [];
53+
// XDebug also has a different name for the parameters array
54+
if (!$traceArgs) {
55+
unset($frame['params'], $frame['args']);
56+
} elseif (isset($frame['params']) && !isset($frame['args'])) {
57+
$frame['args'] = $frame['params'];
58+
unset($frame['params']);
59+
}
6760
}
61+
62+
unset($frame);
63+
$trace = array_reverse($trace);
64+
} else {
65+
$trace = [];
6866
}
6967

7068
foreach ([

0 commit comments

Comments
 (0)