These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * |
||
4 | */ |
||
5 | |||
6 | namespace Mvc5\Exception; |
||
7 | |||
8 | use Mvc5\Exception as _Exception; |
||
9 | |||
10 | class ErrorException |
||
11 | extends \ErrorException |
||
12 | implements Throwable |
||
13 | { |
||
14 | /** |
||
15 | * |
||
16 | */ |
||
17 | use Base; |
||
18 | |||
19 | /** |
||
20 | * |
||
21 | */ |
||
22 | const EXIT_CODE = 70; |
||
23 | |||
24 | /** |
||
25 | * @param $severity |
||
26 | * @param $message |
||
27 | * @param $file |
||
28 | 1 | * @param $line |
|
29 | * @codeCoverageIgnore |
||
30 | 1 | */ |
|
31 | 1 | static function handler($severity, $message, $file, $line) |
|
32 | { |
||
33 | $success = true; |
||
34 | while(ob_get_level() && $success) { |
||
35 | $success = ob_end_clean(); |
||
36 | } |
||
37 | |||
38 | $exception = new self($message, 0, $severity, $file, $line); |
||
39 | |||
40 | include __DIR__ . '/../../view/exception.phtml'; |
||
41 | |||
42 | exit(static::EXIT_CODE); |
||
0 ignored issues
–
show
|
|||
43 | } |
||
44 | } |
||
45 |
An exit expression should only be used in rare cases. For example, if you write a short command line script.
In most cases however, using an
exit
expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.