Completed
Push — master ( d1be6d...8440b6 )
by Andrey
07:58
created

FatalErrorException::__construct()   C

Complexity

Conditions 17
Paths 8

Size

Total Lines 54

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 17
nc 8
nop 8
dl 0
loc 54
rs 5.2166
c 0
b 0
f 0

How to fix   Long Method    Complexity    Many Parameters   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php
2
3
/*
4
 * This file is part of the Symfony package.
5
 *
6
 * (c) Fabien Potencier <[email protected]>
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 <[email protected]>
18
 * @author Konstanton Myakshin <[email protected]>
19
 * @author Nicolas Grekas <[email protected]>
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 <[email protected]>
35
 */
36
class FatalErrorException extends LegacyFatalErrorException
0 ignored issues
show
Deprecated Code introduced by
The class Symfony\Component\HttpKe...ion\FatalErrorException has been deprecated with message: Deprecated in 2.3, to be removed in 3.0. Use the same class from the Debug component instead.

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
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
}
100