1 | <?php |
||
8 | trait HandleUncaughtException |
||
9 | { |
||
10 | /** |
||
11 | * @var callable|false |
||
12 | */ |
||
13 | protected $chainedExceptionHandler; |
||
14 | |||
15 | |||
16 | /** |
||
17 | * Log the following exception classes (and subclasses) |
||
18 | * @var array |
||
19 | */ |
||
20 | protected $logExceptionClasses = []; |
||
21 | |||
22 | |||
23 | /** |
||
24 | * Wrapper method for `set_error_handler` |
||
25 | * |
||
26 | * @param callable $callback |
||
27 | * @param int $error_types |
||
28 | * @return callable|null |
||
29 | */ |
||
30 | abstract protected function setErrorHandler($callback, $error_types = E_ALL); |
||
31 | |||
32 | /** |
||
33 | * Wrapper method for `set_exception_handler` |
||
34 | * |
||
35 | * @param callable $callback |
||
36 | * @return callable|null |
||
37 | */ |
||
38 | abstract protected function setExceptionHandler($callback); |
||
39 | |||
40 | /** |
||
41 | * Log an error or exception |
||
42 | * |
||
43 | * @param \Exception|\Error $error |
||
44 | * @return void |
||
45 | */ |
||
46 | abstract public function log($error); |
||
47 | |||
48 | /** |
||
49 | * Get the types of errors that will be logged |
||
50 | * |
||
51 | * @return int Binary set of E_* constants |
||
52 | */ |
||
53 | abstract public function getLoggedErrorTypes(); |
||
54 | |||
55 | |||
56 | /** |
||
57 | * Get the error handler that has been replaced. |
||
58 | * |
||
59 | * @return callable|false|null |
||
60 | */ |
||
61 | 2 | public function getChainedExceptionHandler() |
|
65 | |||
66 | /** |
||
67 | * Get a list of Exception and other Throwable classes that will be logged |
||
68 | * @return array |
||
69 | */ |
||
70 | 4 | public function getLoggedExceptionClasses() |
|
74 | |||
75 | |||
76 | /** |
||
77 | * Log these types of errors or exceptions |
||
78 | * |
||
79 | * @param string $class Exception class name |
||
80 | */ |
||
81 | 18 | protected function logUncaughtException($class) |
|
89 | |||
90 | |||
91 | /** |
||
92 | * Use the global error handler |
||
93 | */ |
||
94 | 18 | protected function initExceptionHandler() |
|
100 | |||
101 | /** |
||
102 | * Uncaught exception handler |
||
103 | * @ignore |
||
104 | * |
||
105 | * @param \Exception|\Error $exception |
||
106 | */ |
||
107 | 18 | public function handleException($exception) |
|
135 | } |
||
136 | |||
137 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: