Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 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\ErrorHandler\Error;
13
 
14
class FatalError extends \Error
15
{
16
    private array $error;
17
 
18
    /**
19
     * @param array $error An array as returned by error_get_last()
20
     */
21
    public function __construct(string $message, int $code, array $error, int $traceOffset = null, bool $traceArgs = true, array $trace = null)
22
    {
23
        parent::__construct($message, $code);
24
 
25
        $this->error = $error;
26
 
27
        if (null !== $trace) {
28
            if (!$traceArgs) {
29
                foreach ($trace as &$frame) {
30
                    unset($frame['args'], $frame['this'], $frame);
31
                }
32
            }
33
        } elseif (null !== $traceOffset) {
34
            if (\function_exists('xdebug_get_function_stack') && $trace = @xdebug_get_function_stack()) {
35
                if (0 < $traceOffset) {
36
                    array_splice($trace, -$traceOffset);
37
                }
38
 
39
                foreach ($trace as &$frame) {
40
                    if (!isset($frame['type'])) {
41
                        // XDebug pre 2.1.1 doesn't currently set the call type key http://bugs.xdebug.org/view.php?id=695
42
                        if (isset($frame['class'])) {
43
                            $frame['type'] = '::';
44
                        }
45
                    } elseif ('dynamic' === $frame['type']) {
46
                        $frame['type'] = '->';
47
                    } elseif ('static' === $frame['type']) {
48
                        $frame['type'] = '::';
49
                    }
50
 
51
                    // XDebug also has a different name for the parameters array
52
                    if (!$traceArgs) {
53
                        unset($frame['params'], $frame['args']);
54
                    } elseif (isset($frame['params']) && !isset($frame['args'])) {
55
                        $frame['args'] = $frame['params'];
56
                        unset($frame['params']);
57
                    }
58
                }
59
 
60
                unset($frame);
61
                $trace = array_reverse($trace);
62
            } else {
63
                $trace = [];
64
            }
65
        }
66
 
67
        foreach ([
68
            'file' => $error['file'],
69
            'line' => $error['line'],
70
            'trace' => $trace,
71
        ] as $property => $value) {
72
            if (null !== $value) {
73
                $refl = new \ReflectionProperty(\Error::class, $property);
74
                $refl->setValue($this, $value);
75
            }
76
        }
77
    }
78
 
79
    public function getError(): array
80
    {
81
        return $this->error;
82
    }
83
}