Chris@0: Chris@0: * Chris@0: * For the full copyright and license information, please view the LICENSE Chris@0: * file that was distributed with this source code. Chris@0: */ Chris@0: Chris@0: namespace Symfony\Component\Debug\Exception; Chris@0: Chris@0: /** Chris@0: * Fatal Error Exception. Chris@0: * Chris@0: * @author Konstanton Myakshin Chris@0: */ Chris@0: class FatalErrorException extends \ErrorException Chris@0: { Chris@16: public function __construct($message, $code, $severity, $filename, $lineno, $traceOffset = null, $traceArgs = true, array $trace = null, $previous = null) Chris@0: { Chris@16: parent::__construct($message, $code, $severity, $filename, $lineno, $previous); Chris@0: Chris@0: if (null !== $trace) { Chris@0: if (!$traceArgs) { Chris@0: foreach ($trace as &$frame) { Chris@0: unset($frame['args'], $frame['this'], $frame); Chris@0: } Chris@0: } Chris@0: Chris@0: $this->setTrace($trace); Chris@0: } elseif (null !== $traceOffset) { Chris@17: if (\function_exists('xdebug_get_function_stack')) { Chris@0: $trace = xdebug_get_function_stack(); Chris@0: if (0 < $traceOffset) { Chris@0: array_splice($trace, -$traceOffset); Chris@0: } Chris@0: Chris@0: foreach ($trace as &$frame) { Chris@0: if (!isset($frame['type'])) { Chris@0: // XDebug pre 2.1.1 doesn't currently set the call type key http://bugs.xdebug.org/view.php?id=695 Chris@0: if (isset($frame['class'])) { Chris@0: $frame['type'] = '::'; Chris@0: } Chris@0: } elseif ('dynamic' === $frame['type']) { Chris@0: $frame['type'] = '->'; Chris@0: } elseif ('static' === $frame['type']) { Chris@0: $frame['type'] = '::'; Chris@0: } Chris@0: Chris@0: // XDebug also has a different name for the parameters array Chris@0: if (!$traceArgs) { Chris@0: unset($frame['params'], $frame['args']); Chris@0: } elseif (isset($frame['params']) && !isset($frame['args'])) { Chris@0: $frame['args'] = $frame['params']; Chris@0: unset($frame['params']); Chris@0: } Chris@0: } Chris@0: Chris@0: unset($frame); Chris@0: $trace = array_reverse($trace); Chris@17: } elseif (\function_exists('symfony_debug_backtrace')) { Chris@0: $trace = symfony_debug_backtrace(); Chris@0: if (0 < $traceOffset) { Chris@0: array_splice($trace, 0, $traceOffset); Chris@0: } Chris@0: } else { Chris@17: $trace = []; Chris@0: } Chris@0: Chris@0: $this->setTrace($trace); Chris@0: } Chris@0: } Chris@0: Chris@0: protected function setTrace($trace) Chris@0: { Chris@0: $traceReflector = new \ReflectionProperty('Exception', 'trace'); Chris@0: $traceReflector->setAccessible(true); Chris@0: $traceReflector->setValue($this, $trace); Chris@0: } Chris@0: }