1 | <?php |
||
18 | trait ErrorHandlerTrait |
||
19 | { |
||
20 | /** |
||
21 | * @var string The url of the error api without trailing slash. Make sure you have installed the error api |
||
22 | * module on the requested api url (https://luya.io/guide/module/luyadev---luya-module-errorapi). |
||
23 | * |
||
24 | * An example when using the erroapi module, the url could look like this `https://luya.io/errorapi`. |
||
25 | */ |
||
26 | public $api; |
||
27 | |||
28 | /** |
||
29 | * @var boolean Enable the transfer of exceptions to the defined `$api` server. |
||
30 | */ |
||
31 | public $transferException = false; |
||
32 | |||
33 | /** |
||
34 | * @var \Curl\Curl|null The curl object from the last error api call. |
||
35 | * @since 1.0.5 |
||
36 | */ |
||
37 | public $lastTransferCall; |
||
38 | |||
39 | /** |
||
40 | * @var array An array of exceptions which are whitelisted and therefore NOT TRANSFERED. |
||
41 | * @since 1.0.5 |
||
42 | */ |
||
43 | public $whitelist = ['yii\web\NotFoundHttpException']; |
||
44 | |||
45 | /** |
||
46 | * @var array |
||
47 | * @since 1.0.6 |
||
48 | */ |
||
49 | public $sensitiveKeys = ['password', 'pwd', 'pass', 'passwort', 'pw', 'token', 'hash', 'authorization']; |
||
50 | |||
51 | /** |
||
52 | * Send a custom message to the api server event its not related to an exception. |
||
53 | * |
||
54 | * Sometimes you just want to pass informations from your application, this method allows you to transfer |
||
55 | * a message to the error api server. |
||
56 | * |
||
57 | * Example of sending a message |
||
58 | * |
||
59 | * ```php |
||
60 | * Yii::$app->errorHandler->transferMessage('Something went wrong here!', __FILE__, __LINE__); |
||
61 | * ``` |
||
62 | * |
||
63 | * @param string $message The message you want to send to the error api server. |
||
64 | * @param string $file The you are currently send the message (use __FILE__) |
||
65 | * @param string $line The line you want to submit (use __LINE__) |
||
66 | * @return bool|null |
||
67 | */ |
||
68 | public function transferMessage($message, $file = __FILE__, $line = __LINE__) |
||
76 | |||
77 | /** |
||
78 | * Send the array data to the api server. |
||
79 | * |
||
80 | * @param array $data The array to be sent to the server. |
||
81 | * @return boolean|null true/false if data has been sent to the api successfull or not, null if the transfer is disabled. |
||
82 | */ |
||
83 | private function apiServerSendData(array $data) |
||
100 | |||
101 | /** |
||
102 | * @inheritdoc |
||
103 | */ |
||
104 | public function renderException($exception) |
||
112 | |||
113 | /** |
||
114 | * Get an readable array to transfer from an exception |
||
115 | * |
||
116 | * @param mixed $exception Exception object |
||
117 | * @return array An array with transformed exception data |
||
118 | */ |
||
119 | public function getExceptionArray($exception) |
||
169 | |||
170 | /** |
||
171 | * Cover senstive values from a given list of keys. |
||
172 | * |
||
173 | * This applys only for the first key inside the array and does not work recursive. |
||
174 | * |
||
175 | * The main purpose is to remove passwords transferd to api when existing in post, get or session. |
||
176 | * |
||
177 | * @param array $data |
||
178 | * @param array $key |
||
|
|||
179 | * @since 1.0.6 |
||
180 | */ |
||
181 | public function coverSensitiveValues(array $data, array $keys) |
||
197 | |||
198 | /** |
||
199 | * Build trace array from exception. |
||
200 | * |
||
201 | * @param object $exception |
||
202 | * @return array |
||
203 | */ |
||
204 | private function buildTrace($exception) |
||
218 | } |
||
219 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.