These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace PragmaRX\Health\Http\Controllers; |
||
4 | |||
5 | use PragmaRX\Health\Service; |
||
6 | use Illuminate\Routing\Controller; |
||
7 | use Illuminate\Support\Facades\File; |
||
8 | |||
9 | class Health extends Controller |
||
10 | { |
||
11 | /** |
||
12 | * @var Service |
||
13 | */ |
||
14 | private $healthService; |
||
15 | |||
16 | /** |
||
17 | * Health constructor. |
||
18 | * |
||
19 | * @param Service $healthService |
||
20 | */ |
||
21 | 1 | public function __construct(Service $healthService) |
|
22 | { |
||
23 | 1 | $this->healthService = $healthService; |
|
24 | 1 | } |
|
25 | |||
26 | /** |
||
27 | * Check all resources. |
||
28 | * |
||
29 | * @return array |
||
30 | * @throws \Exception |
||
31 | */ |
||
32 | 1 | public function check() |
|
33 | { |
||
34 | 1 | $this->healthService->setAction('check'); |
|
35 | |||
36 | 1 | return response($this->healthService->health()); |
|
37 | } |
||
38 | |||
39 | /** |
||
40 | * Check and get one resource. |
||
41 | * |
||
42 | * @param $slug |
||
43 | * @return mixed |
||
44 | * @throws \Exception |
||
45 | */ |
||
46 | public function getResource($slug) |
||
47 | { |
||
48 | $this->healthService->setAction('resource'); |
||
49 | |||
50 | return $this->healthService->resource($slug); |
||
51 | } |
||
52 | |||
53 | /** |
||
54 | * Get all resources. |
||
55 | * |
||
56 | * @return mixed |
||
57 | * @throws \Exception |
||
58 | */ |
||
59 | public function allResources() |
||
60 | { |
||
61 | return $this->healthService->getResources(); |
||
62 | } |
||
63 | |||
64 | /** |
||
65 | * @return mixed |
||
66 | * @throws \Exception |
||
67 | */ |
||
68 | 1 | public function string() |
|
69 | { |
||
70 | 1 | $this->healthService->setAction('string'); |
|
71 | |||
72 | 1 | return response( |
|
73 | 1 | $this->healthService->string() |
|
74 | ); |
||
75 | } |
||
76 | |||
77 | /** |
||
78 | * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View |
||
79 | * @throws \Exception |
||
80 | */ |
||
81 | 1 | public function panel() |
|
82 | { |
||
83 | 1 | $this->healthService->setAction('panel'); |
|
84 | |||
85 | 1 | return response((string) view(config('health.views.panel'))); |
|
86 | } |
||
87 | |||
88 | View Code Duplication | public function assetAppJs() |
|
89 | { |
||
90 | $file = File::get(config('health.assets.js')); |
||
91 | |||
92 | $response = response()->make($file); |
||
0 ignored issues
–
show
|
|||
93 | |||
94 | $response->header('Content-Type', 'text/css'); |
||
95 | |||
96 | return $response; |
||
97 | } |
||
98 | |||
99 | View Code Duplication | public function assetAppCss() |
|
100 | { |
||
101 | $file = File::get(config('health.assets.css')); |
||
102 | |||
103 | $response = response()->make($file); |
||
0 ignored issues
–
show
The method
make does only exist in Illuminate\Contracts\Routing\ResponseFactory , but not in Illuminate\Http\Response .
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: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
Loading history...
|
|||
104 | |||
105 | $response->header('Content-Type', 'text/css'); |
||
106 | |||
107 | return $response; |
||
108 | } |
||
109 | |||
110 | public function config() |
||
111 | { |
||
112 | return config('health'); |
||
113 | } |
||
114 | } |
||
115 |
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: