1 | <?php |
||
10 | class Server extends ApiResource |
||
11 | { |
||
12 | /** |
||
13 | * Resource type. |
||
14 | * |
||
15 | * @return string |
||
16 | */ |
||
17 | public static function resourceType() |
||
21 | |||
22 | /** |
||
23 | * Resource path (relative to owner or API root). |
||
24 | * |
||
25 | * @return string |
||
26 | */ |
||
27 | public function resourcePath() |
||
31 | |||
32 | /** |
||
33 | * Throw HTTP Not Found exception. |
||
34 | * |
||
35 | * @throws \Exception |
||
36 | */ |
||
37 | protected static function throwNotFoundException() |
||
41 | |||
42 | /** |
||
43 | * Credential ID. |
||
44 | * |
||
45 | * @return int |
||
46 | */ |
||
47 | public function credentialId(): int |
||
51 | |||
52 | /** |
||
53 | * Human readable server size. |
||
54 | * |
||
55 | * @return string|null |
||
56 | */ |
||
57 | public function size() |
||
61 | |||
62 | /** |
||
63 | * Server region. |
||
64 | * |
||
65 | * @return string|null |
||
66 | */ |
||
67 | public function region() |
||
71 | |||
72 | /** |
||
73 | * Server's PHP version. |
||
74 | * |
||
75 | * @return string|null |
||
76 | */ |
||
77 | public function phpVersion() |
||
81 | |||
82 | /** |
||
83 | * Server public IP address. |
||
84 | * |
||
85 | * @return string|null |
||
86 | */ |
||
87 | public function ip() |
||
91 | |||
92 | /** |
||
93 | * Server private IP address. |
||
94 | */ |
||
95 | public function privateIp() |
||
99 | |||
100 | /** |
||
101 | * Server sudo password - only set on server save. |
||
102 | */ |
||
103 | public function sudoPassword() |
||
107 | |||
108 | /** |
||
109 | * Server sudo password - only set on server save. |
||
110 | */ |
||
111 | public function databasePassword() |
||
115 | |||
116 | /** |
||
117 | * Blackfire service status. |
||
118 | * |
||
119 | * @return string|null |
||
120 | */ |
||
121 | public function blackfireStatus() |
||
125 | |||
126 | /** |
||
127 | * Papertrail service status. |
||
128 | * |
||
129 | * @return string |
||
130 | */ |
||
131 | public function papertrailStatus() |
||
135 | |||
136 | /** |
||
137 | * Determines if server access was revoked from Forge. |
||
138 | * |
||
139 | * @return bool |
||
140 | */ |
||
141 | public function isRevoked(): bool |
||
145 | |||
146 | /** |
||
147 | * Determines if server was provisioned and ready to use. |
||
148 | * |
||
149 | * @return bool |
||
150 | */ |
||
151 | public function isReady(): bool |
||
155 | |||
156 | /** |
||
157 | * Network status. |
||
158 | * |
||
159 | * @return array|null |
||
160 | */ |
||
161 | public function network() |
||
165 | |||
166 | /** |
||
167 | * Reboot the server. |
||
168 | * |
||
169 | * @return bool |
||
170 | */ |
||
171 | public function reboot(): bool |
||
177 | |||
178 | /** |
||
179 | * Revoke Forge access to server. |
||
180 | * |
||
181 | * @return bool |
||
182 | **/ |
||
183 | public function revokeAccess(): bool |
||
189 | |||
190 | /** |
||
191 | * Reconnect revoked server. |
||
192 | * |
||
193 | * @return string Public SSH key. |
||
194 | */ |
||
195 | public function reconnect(): string |
||
209 | |||
210 | /** |
||
211 | * Reactivate revoked server. Make sure you've installed public SSH key |
||
212 | * before calling this method. |
||
213 | * |
||
214 | * @return bool |
||
215 | */ |
||
216 | public function reactivate(): bool |
||
222 | |||
223 | /** |
||
224 | * Create new Resource instance from HTTP response. |
||
225 | * |
||
226 | * @param \Psr\Http\Message\ResponseInterface $response |
||
227 | * @param \Laravel\Forge\ApiProvider $api |
||
228 | * @param \Laravel\Forge\Contracts\ResourceContract $owner = null |
||
229 | */ |
||
230 | public static function createFromResponse(ResponseInterface $response, ApiProvider $api, ResourceContract $owner = null) |
||
250 | } |
||
251 |
If you define a variable conditionally, it can happen that it is not defined for all execution paths.
Let’s take a look at an example:
In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.
Available Fixes
Check for existence of the variable explicitly:
Define a default value for the variable:
Add a value for the missing path: