1 | <?php |
||
9 | class SystemFacade |
||
10 | { |
||
11 | /** |
||
12 | * Turns on output buffering. |
||
13 | * |
||
14 | * @return bool |
||
15 | */ |
||
16 | 2 | public function startOutputBuffering() |
|
20 | |||
21 | /** |
||
22 | * @param callable $handler |
||
23 | * @param int $types By default E_ALL | E_STRICT |
||
24 | * |
||
25 | * @return string|null |
||
26 | */ |
||
27 | 6 | public function setErrorHandler(callable $handler, $types = null) |
|
28 | { |
||
29 | 6 | return set_error_handler($handler, $types === null ? E_ALL | E_STRICT : $types); |
|
30 | } |
||
31 | |||
32 | /** |
||
33 | * @param callable $handler |
||
34 | * |
||
35 | * @return string|null |
||
36 | */ |
||
37 | 5 | public function setExceptionHandler(callable $handler) |
|
41 | |||
42 | /** |
||
43 | * @return void |
||
44 | */ |
||
45 | 1 | public function restoreExceptionHandler() |
|
46 | { |
||
47 | 1 | restore_exception_handler(); |
|
48 | 1 | } |
|
49 | |||
50 | /** |
||
51 | * @return void |
||
52 | */ |
||
53 | 1 | public function restoreErrorHandler() |
|
54 | { |
||
55 | 1 | restore_error_handler(); |
|
56 | 1 | } |
|
57 | |||
58 | /** |
||
59 | * @param callable $function |
||
60 | * |
||
61 | * @return void |
||
62 | */ |
||
63 | 5 | public function registerShutdownFunction(callable $function) |
|
64 | { |
||
65 | 5 | register_shutdown_function($function); |
|
66 | 5 | } |
|
67 | |||
68 | /** |
||
69 | * @return string|false |
||
70 | */ |
||
71 | 2 | public function cleanOutputBuffer() |
|
75 | |||
76 | /** |
||
77 | * @return int |
||
78 | */ |
||
79 | 1 | public function getOutputBufferLevel() |
|
83 | |||
84 | /** |
||
85 | * @return bool |
||
86 | */ |
||
87 | 1 | public function endOutputBuffering() |
|
91 | |||
92 | /** |
||
93 | * @return void |
||
94 | */ |
||
95 | 1 | public function flushOutputBuffer() |
|
99 | |||
100 | /** |
||
101 | * @return int |
||
102 | */ |
||
103 | 4 | public function getErrorReportingLevel() |
|
107 | |||
108 | /** |
||
109 | * @return array|null |
||
110 | */ |
||
111 | 1 | public function getLastError() |
|
115 | |||
116 | /** |
||
117 | * @param int $httpCode |
||
118 | * |
||
119 | * @return int |
||
120 | */ |
||
121 | 1 | public function setHttpResponseCode($httpCode) |
|
125 | |||
126 | /** |
||
127 | * @param int $exitStatus |
||
128 | */ |
||
129 | public function stopExecution($exitStatus) |
||
133 | } |
||
134 |
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.