Chris@0
|
1 <?php
|
Chris@0
|
2
|
Chris@0
|
3 /*
|
Chris@0
|
4 * This file is part of the Symfony package.
|
Chris@0
|
5 *
|
Chris@0
|
6 * (c) Fabien Potencier <fabien@symfony.com>
|
Chris@0
|
7 *
|
Chris@0
|
8 * For the full copyright and license information, please view the LICENSE
|
Chris@0
|
9 * file that was distributed with this source code.
|
Chris@0
|
10 */
|
Chris@0
|
11
|
Chris@0
|
12 namespace Symfony\Component\Debug\Exception;
|
Chris@0
|
13
|
Chris@0
|
14 /**
|
Chris@0
|
15 * Fatal Error Exception.
|
Chris@0
|
16 *
|
Chris@0
|
17 * @author Konstanton Myakshin <koc-dp@yandex.ru>
|
Chris@0
|
18 */
|
Chris@0
|
19 class FatalErrorException extends \ErrorException
|
Chris@0
|
20 {
|
Chris@16
|
21 public function __construct($message, $code, $severity, $filename, $lineno, $traceOffset = null, $traceArgs = true, array $trace = null, $previous = null)
|
Chris@0
|
22 {
|
Chris@16
|
23 parent::__construct($message, $code, $severity, $filename, $lineno, $previous);
|
Chris@0
|
24
|
Chris@0
|
25 if (null !== $trace) {
|
Chris@0
|
26 if (!$traceArgs) {
|
Chris@0
|
27 foreach ($trace as &$frame) {
|
Chris@0
|
28 unset($frame['args'], $frame['this'], $frame);
|
Chris@0
|
29 }
|
Chris@0
|
30 }
|
Chris@0
|
31
|
Chris@0
|
32 $this->setTrace($trace);
|
Chris@0
|
33 } elseif (null !== $traceOffset) {
|
Chris@17
|
34 if (\function_exists('xdebug_get_function_stack')) {
|
Chris@0
|
35 $trace = xdebug_get_function_stack();
|
Chris@0
|
36 if (0 < $traceOffset) {
|
Chris@0
|
37 array_splice($trace, -$traceOffset);
|
Chris@0
|
38 }
|
Chris@0
|
39
|
Chris@0
|
40 foreach ($trace as &$frame) {
|
Chris@0
|
41 if (!isset($frame['type'])) {
|
Chris@0
|
42 // XDebug pre 2.1.1 doesn't currently set the call type key http://bugs.xdebug.org/view.php?id=695
|
Chris@0
|
43 if (isset($frame['class'])) {
|
Chris@0
|
44 $frame['type'] = '::';
|
Chris@0
|
45 }
|
Chris@0
|
46 } elseif ('dynamic' === $frame['type']) {
|
Chris@0
|
47 $frame['type'] = '->';
|
Chris@0
|
48 } elseif ('static' === $frame['type']) {
|
Chris@0
|
49 $frame['type'] = '::';
|
Chris@0
|
50 }
|
Chris@0
|
51
|
Chris@0
|
52 // XDebug also has a different name for the parameters array
|
Chris@0
|
53 if (!$traceArgs) {
|
Chris@0
|
54 unset($frame['params'], $frame['args']);
|
Chris@0
|
55 } elseif (isset($frame['params']) && !isset($frame['args'])) {
|
Chris@0
|
56 $frame['args'] = $frame['params'];
|
Chris@0
|
57 unset($frame['params']);
|
Chris@0
|
58 }
|
Chris@0
|
59 }
|
Chris@0
|
60
|
Chris@0
|
61 unset($frame);
|
Chris@0
|
62 $trace = array_reverse($trace);
|
Chris@17
|
63 } elseif (\function_exists('symfony_debug_backtrace')) {
|
Chris@0
|
64 $trace = symfony_debug_backtrace();
|
Chris@0
|
65 if (0 < $traceOffset) {
|
Chris@0
|
66 array_splice($trace, 0, $traceOffset);
|
Chris@0
|
67 }
|
Chris@0
|
68 } else {
|
Chris@17
|
69 $trace = [];
|
Chris@0
|
70 }
|
Chris@0
|
71
|
Chris@0
|
72 $this->setTrace($trace);
|
Chris@0
|
73 }
|
Chris@0
|
74 }
|
Chris@0
|
75
|
Chris@0
|
76 protected function setTrace($trace)
|
Chris@0
|
77 {
|
Chris@0
|
78 $traceReflector = new \ReflectionProperty('Exception', 'trace');
|
Chris@0
|
79 $traceReflector->setAccessible(true);
|
Chris@0
|
80 $traceReflector->setValue($this, $trace);
|
Chris@0
|
81 }
|
Chris@0
|
82 }
|