1 | <?php |
||
11 | abstract class ApiException extends Exception implements JsonApiExceptionContract |
||
12 | { |
||
13 | /** |
||
14 | * Get unique identifier for this particular occurrence |
||
15 | * of the problem. |
||
16 | */ |
||
17 | public function id(): string |
||
18 | { |
||
19 | return ''; |
||
20 | } |
||
21 | |||
22 | /** |
||
23 | * Get application-specific error code. |
||
24 | */ |
||
25 | public function code(): string |
||
26 | { |
||
27 | return ''; |
||
28 | } |
||
29 | |||
30 | /** |
||
31 | * Get human-readable explanation specific to this |
||
32 | * occurrence of the problem. |
||
33 | */ |
||
34 | public function detail(): string |
||
35 | { |
||
36 | return ''; |
||
37 | } |
||
38 | |||
39 | /** |
||
40 | * Get the URI that yield further details about this |
||
41 | * particular occurrence of the problem. |
||
42 | */ |
||
43 | public function href(): string |
||
44 | { |
||
45 | return ''; |
||
46 | } |
||
47 | |||
48 | /** |
||
49 | * Get associated resources, which can be dereferenced |
||
50 | * from the request document. |
||
51 | */ |
||
52 | public function links(): array |
||
53 | { |
||
54 | return []; |
||
55 | } |
||
56 | |||
57 | /** |
||
58 | * Get relative path to the relevant attribute within |
||
59 | * the associated resource(s). |
||
60 | */ |
||
61 | public function path(): string |
||
62 | { |
||
63 | return ''; |
||
64 | } |
||
65 | |||
66 | /** |
||
67 | * Get non-standard meta-information about the error. |
||
68 | */ |
||
69 | public function meta(): array |
||
73 | |||
74 | protected function getResponseData(): array |
||
85 | |||
86 | protected function getApiResponse(): JsonResponse |
||
91 | |||
92 | public function render(Request $request) |
||
93 | { |
||
94 | return $this->getApiResponse(); |
||
95 | } |
||
96 | |||
97 | private function getAvailableData(): array |
||
98 | { |
||
109 | } |
||
110 |
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: