Skip to content

Commit

Permalink
[ErrorHandler] fix setting $trace to null in FatalError
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-grekas committed May 28, 2020
1 parent 5fe0f94 commit 5536dc2
Showing 1 changed file with 25 additions and 27 deletions.
52 changes: 25 additions & 27 deletions src/Symfony/Component/ErrorHandler/Error/FatalError.php
Expand Up @@ -32,39 +32,37 @@ public function __construct(string $message, int $code, array $error, int $trace
unset($frame['args'], $frame['this'], $frame);
}
}
} elseif (null !== $traceOffset) {
if (\function_exists('xdebug_get_function_stack')) {
$trace = xdebug_get_function_stack();
if (0 < $traceOffset) {
array_splice($trace, -$traceOffset);
}
} elseif (null !== $traceOffset && \function_exists('xdebug_get_function_stack')) {
$trace = xdebug_get_function_stack();
if (0 < $traceOffset) {
array_splice($trace, -$traceOffset);
}

foreach ($trace as &$frame) {
if (!isset($frame['type'])) {
// XDebug pre 2.1.1 doesn't currently set the call type key http://bugs.xdebug.org/view.php?id=695
if (isset($frame['class'])) {
$frame['type'] = '::';
}
} elseif ('dynamic' === $frame['type']) {
$frame['type'] = '->';
} elseif ('static' === $frame['type']) {
foreach ($trace as &$frame) {
if (!isset($frame['type'])) {
// XDebug pre 2.1.1 doesn't currently set the call type key http://bugs.xdebug.org/view.php?id=695
if (isset($frame['class'])) {
$frame['type'] = '::';
}

// XDebug also has a different name for the parameters array
if (!$traceArgs) {
unset($frame['params'], $frame['args']);
} elseif (isset($frame['params']) && !isset($frame['args'])) {
$frame['args'] = $frame['params'];
unset($frame['params']);
}
} elseif ('dynamic' === $frame['type']) {
$frame['type'] = '->';
} elseif ('static' === $frame['type']) {
$frame['type'] = '::';
}

unset($frame);
$trace = array_reverse($trace);
} else {
$trace = [];
// XDebug also has a different name for the parameters array
if (!$traceArgs) {
unset($frame['params'], $frame['args']);
} elseif (isset($frame['params']) && !isset($frame['args'])) {
$frame['args'] = $frame['params'];
unset($frame['params']);
}
}

unset($frame);
$trace = array_reverse($trace);
} else {
$trace = [];
}

foreach ([
Expand Down

0 comments on commit 5536dc2

Please sign in to comment.