|
9 | 9 | * file that was distributed with this source code.
|
10 | 10 | */
|
11 | 11 |
|
12 |
| -namespace Symfony\Component\ErrorHandler\Exception; |
| 12 | +namespace Symfony\Component\ErrorHandler\Error; |
13 | 13 |
|
14 |
| -/** |
15 |
| - * Fatal Error Exception. |
16 |
| - * |
17 |
| - * @author Konstanton Myakshin <koc-dp@yandex.ru> |
18 |
| - */ |
19 |
| -class FatalErrorException extends \ErrorException |
| 14 | +class FatalError extends \Error |
20 | 15 | {
|
21 |
| - public function __construct(string $message, int $code, int $severity, string $filename, int $lineno, int $traceOffset = null, bool $traceArgs = true, array $trace = null, \Throwable $previous = null) |
| 16 | + private $error; |
| 17 | + |
| 18 | + /** |
| 19 | + * {@inheritdoc} |
| 20 | + * |
| 21 | + * @param array $error An array as returned by error_get_last() |
| 22 | + */ |
| 23 | + public function __construct(string $message, int $code, array $error, int $traceOffset = null, bool $traceArgs = true, array $trace = null) |
22 | 24 | {
|
23 |
| - parent::__construct($message, $code, $severity, $filename, $lineno, $previous); |
| 25 | + parent::__construct($message, $code); |
| 26 | + |
| 27 | + $this->error = $error; |
24 | 28 |
|
25 | 29 | if (null !== $trace) {
|
26 | 30 | if (!$traceArgs) {
|
27 | 31 | foreach ($trace as &$frame) {
|
28 | 32 | unset($frame['args'], $frame['this'], $frame);
|
29 | 33 | }
|
30 | 34 | }
|
31 |
| - |
32 |
| - $this->setTrace($trace); |
33 | 35 | } elseif (null !== $traceOffset) {
|
34 | 36 | if (\function_exists('xdebug_get_function_stack')) {
|
35 | 37 | $trace = xdebug_get_function_stack();
|
@@ -63,15 +65,24 @@ public function __construct(string $message, int $code, int $severity, string $f
|
63 | 65 | } else {
|
64 | 66 | $trace = [];
|
65 | 67 | }
|
| 68 | + } |
66 | 69 |
|
67 |
| - $this->setTrace($trace); |
| 70 | + foreach ([ |
| 71 | + 'file' => $error['file'], |
| 72 | + 'line' => $error['line'], |
| 73 | + 'trace' => $trace, |
| 74 | + ] as $property => $value) { |
| 75 | + $refl = new \ReflectionProperty(\Error::class, $property); |
| 76 | + $refl->setAccessible(true); |
| 77 | + $refl->setValue($this, $value); |
68 | 78 | }
|
69 | 79 | }
|
70 | 80 |
|
71 |
| - protected function setTrace(array $trace): void |
| 81 | + /** |
| 82 | + * {@inheritdoc} |
| 83 | + */ |
| 84 | + public function getError(): array |
72 | 85 | {
|
73 |
| - $traceReflector = new \ReflectionProperty('Exception', 'trace'); |
74 |
| - $traceReflector->setAccessible(true); |
75 |
| - $traceReflector->setValue($this, $trace); |
| 86 | + return $this->error; |
76 | 87 | }
|
77 | 88 | }
|
0 commit comments