1 | <?php |
||
14 | class Handler extends ExceptionHandler |
||
15 | { |
||
16 | //<editor-fold desc="Fields"> |
||
17 | /** |
||
18 | * A list of the exception types that should not be reported. |
||
19 | * |
||
20 | * @var array |
||
21 | */ |
||
22 | protected $dontReport = [ |
||
23 | ValidationException::class, |
||
24 | ]; |
||
25 | //</editor-fold desc="Fields"> |
||
26 | |||
27 | //<editor-fold desc="Public Methods"> |
||
28 | /** @noinspection PhpMissingParentCallCommonInspection */ |
||
29 | /** |
||
30 | * Render an exception into an HTTP response. |
||
31 | * |
||
32 | * @param \Illuminate\Http\Request $request |
||
33 | * @param \Exception $exception |
||
34 | * @param bool $printTrace if true a trace will be appended to the exception message |
||
35 | * @return \Illuminate\Http\Response |
||
36 | * @SuppressWarnings(PHPMD.UnusedFormalParameter) |
||
37 | */ |
||
38 | public function render($request, Exception $exception, $printTrace = false) |
||
48 | //</editor-fold desc="Public Methods"> |
||
49 | |||
50 | //<editor-fold desc="Protected Methods"> |
||
51 | /** |
||
52 | * Extracts the status code of an exception |
||
53 | * @param Exception $exception the exception to extract from |
||
54 | * @return int|mixed the status code or 500 if no status code found |
||
55 | */ |
||
56 | protected function getExceptionHTTPStatusCode(Exception $exception) |
||
66 | |||
67 | /** |
||
68 | * Gets the exception name of an exception which is used by clients to identify the type of the error. |
||
69 | * @param Exception $exception the exception whose name we want |
||
70 | * @return string the exception name |
||
71 | */ |
||
72 | protected function getExceptionName(Exception $exception): string |
||
94 | |||
95 | /** |
||
96 | * Extracts the status and the message from the given exception and status code |
||
97 | * @param Exception $exception the raised exception |
||
98 | * @param string|null $statusCode the status code or null if unknown |
||
99 | * @param bool $printTrace if true a trace will be appended to the exception message |
||
100 | * @return array containing the infos status and message |
||
101 | */ |
||
102 | protected function getJsonMessage(Exception $exception, $statusCode = null, $printTrace = false) |
||
127 | //</editor-fold desc="Protected Methods"> |
||
128 | } |
||
129 |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: