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