1 | <?php |
||
8 | trait HandleShutdownError |
||
9 | { |
||
10 | /** |
||
11 | * @var boolean |
||
12 | */ |
||
13 | protected $registeredShutdown = false; |
||
14 | |||
15 | /** |
||
16 | * A string which reserves memory that can be used to log the error in case of an out of memory fatal error |
||
17 | * @var string |
||
18 | */ |
||
19 | protected $reservedMemory; |
||
20 | |||
21 | |||
22 | /** |
||
23 | * Run the fatal error callback |
||
24 | * |
||
25 | * @param \Exception|\Error $error |
||
26 | * @return void |
||
27 | */ |
||
28 | abstract protected function callOnFatalError($error); |
||
29 | |||
30 | /** |
||
31 | * Wrapper method for `error_get_last` |
||
32 | * |
||
33 | * @return array|null |
||
34 | */ |
||
35 | abstract protected function errorGetLast(); |
||
36 | |||
37 | /** |
||
38 | * Wrapper method for `register_shutdown_function` |
||
39 | * |
||
40 | * @param callable $callback |
||
41 | * @return void |
||
42 | */ |
||
43 | abstract protected function registerShutdownFunction($callback); |
||
44 | |||
45 | /** |
||
46 | * Log an error or exception |
||
47 | * |
||
48 | * @param \Exception|\Error $error |
||
49 | * @return void |
||
50 | */ |
||
51 | abstract public function log($error); |
||
52 | |||
53 | /** |
||
54 | * Get the types of errors that will be logged |
||
55 | * |
||
56 | * @return int Binary set of E_* constants |
||
57 | */ |
||
58 | abstract public function getLoggedErrorTypes(); |
||
59 | |||
60 | |||
61 | /** |
||
62 | * Reserve memory for shutdown function in case of out of memory |
||
63 | */ |
||
64 | 32 | protected function reserveMemory() |
|
68 | |||
69 | /** |
||
70 | * Register the shutdown function |
||
71 | */ |
||
72 | 32 | protected function initShutdownFunction() |
|
81 | |||
82 | /** |
||
83 | * Called when the script has ends |
||
84 | * @ignore |
||
85 | */ |
||
86 | 16 | public function shutdownFunction() |
|
105 | } |
||
106 |