1 | <?php |
||
18 | class Errors extends Dispatcher { |
||
19 | |||
20 | /** @var array PHP errors constants values => names(will be initialized in first call) */ |
||
21 | protected static $errorsConstantsValues = array(); |
||
22 | /** @var array PHP errors constants names */ |
||
23 | protected static $errorsConstantsNames = array( |
||
24 | 'E_STRICT', |
||
25 | 'E_DEPRECATED', |
||
26 | 'E_RECOVERABLE_ERROR', |
||
27 | 'E_NOTICE', |
||
28 | 'E_WARNING', |
||
29 | 'E_ERROR', |
||
30 | 'E_PARSE', |
||
31 | 'E_USER_DEPRECATED', |
||
32 | 'E_USER_NOTICE', |
||
33 | 'E_USER_WARNING', |
||
34 | 'E_USER_ERROR', |
||
35 | 'E_CORE_WARNING', |
||
36 | 'E_CORE_ERROR', |
||
37 | 'E_COMPILE_ERROR', |
||
38 | 'E_COMPILE_WARNING', |
||
39 | ); |
||
40 | |||
41 | /** @var bool Don't send errors messages with same file, line & class */ |
||
42 | public $ignoreRepeatedSource = true; |
||
43 | /** @var bool Dispatch $exception->getPrevious() if not empty */ |
||
44 | public $dispatchPreviousExceptions = true; |
||
45 | |||
46 | /** @var ErrorMessage[] */ |
||
47 | protected $sentMessages = array(); |
||
48 | |||
49 | /** |
||
50 | * Send error message to client |
||
51 | * @param null|integer $code |
||
52 | * @param null|string $text |
||
53 | * @param null|string $file |
||
54 | * @param null|integer $line |
||
55 | * @param int|array $ignoreTraceCalls Ignore tracing classes by name prefix `array('PhpConsole')` or fixed number of calls to ignore |
||
56 | */ |
||
57 | 18 | public function dispatchError($code = null, $text = null, $file = null, $line = null, $ignoreTraceCalls = 0) { |
|
71 | |||
72 | /** |
||
73 | * Send exception message to client |
||
74 | * @param \Exception|\Throwable $exception |
||
75 | */ |
||
76 | 14 | public function dispatchException($exception) { |
|
91 | |||
92 | /** |
||
93 | * Send message to PHP Console connector |
||
94 | * @param Message $message |
||
95 | */ |
||
96 | 31 | protected function sendMessage(Message $message) { |
|
102 | |||
103 | /** |
||
104 | * Get PHP error constant name by value |
||
105 | * @param int $code |
||
106 | * @return string |
||
107 | */ |
||
108 | 17 | protected function getErrorTypeByCode($code) { |
|
121 | |||
122 | /** |
||
123 | * Return true if message with same file, line & class was already sent |
||
124 | * @param ErrorMessage $message |
||
125 | * @return bool |
||
126 | */ |
||
127 | 31 | protected function isIgnored(ErrorMessage $message) { |
|
137 | } |
||
138 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.