Skip to content

Commit 93d7999

Browse files
authored
Apply fixes from StyleCI (pterodactyl#372)
1 parent 7bd14db commit 93d7999

File tree

22 files changed

+43
-32
lines changed

22 files changed

+43
-32
lines changed

app/Exceptions/Handler.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use Log;
66
use Exception;
7-
use DisplayException;
87
use Illuminate\Auth\AuthenticationException;
98
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
109

app/Http/Controllers/API/Admin/NodeController.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
use Fractal;
2828
use Illuminate\Http\Request;
2929
use Pterodactyl\Models\Node;
30-
use Pterodactyl\Http\Controllers\Controller;
3130
use Pterodactyl\Exceptions\DisplayException;
31+
use Pterodactyl\Http\Controllers\Controller;
3232
use Pterodactyl\Repositories\NodeRepository;
3333
use Pterodactyl\Transformers\Admin\NodeTransformer;
3434
use Pterodactyl\Exceptions\DisplayValidationException;
@@ -135,6 +135,7 @@ public function store(Request $request)
135135
], 400);
136136
} catch (\Exception $ex) {
137137
Log::error($ex);
138+
138139
return response()->json([
139140
'error' => 'An unhandled exception occured while attemping to create this node. Please try again.',
140141
], 500);
@@ -163,6 +164,7 @@ public function delete(Request $request, $id)
163164
], 400);
164165
} catch (\Exception $ex) {
165166
Log::error($ex);
167+
166168
return response()->json([
167169
'error' => 'An unhandled exception occured while attemping to delete this node. Please try again.',
168170
], 500);

app/Http/Controllers/API/Admin/ServerController.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,13 @@ public function store(Request $request)
113113
], 400);
114114
} catch (TransferException $ex) {
115115
Log::warning($ex);
116+
116117
return response()->json([
117118
'error' => 'A TransferException was encountered while trying to contact the daemon, please ensure it is online and accessible. This error has been logged.',
118119
], 504);
119120
} catch (\Exception $ex) {
120121
Log::error($ex);
122+
121123
return response()->json([
122124
'error' => 'An unhandled exception occured while attemping to add this server. Please try again.',
123125
], 500);
@@ -146,18 +148,20 @@ public function delete(Request $request, $id)
146148
], 400);
147149
} catch (TransferException $ex) {
148150
Log::warning($ex);
151+
149152
return response()->json([
150153
'error' => 'A TransferException was encountered while trying to contact the daemon, please ensure it is online and accessible. This error has been logged.',
151154
], 504);
152155
} catch (\Exception $ex) {
153156
Log::error($ex);
157+
154158
return response()->json([
155159
'error' => 'An unhandled exception occured while attemping to add this server. Please try again.',
156160
], 500);
157161
}
158162
}
159163

160-
/**
164+
/**
161165
* Update the details for a server.
162166
*
163167
* @param \Illuminate\Http\Request $request
@@ -190,6 +194,7 @@ public function details(Request $request, $id)
190194
], 400);
191195
} catch (\Exception $ex) {
192196
Log::error($ex);
197+
193198
return response()->json([
194199
'error' => 'An unhandled exception occured while attemping to modify this server. Please try again.',
195200
], 500);
@@ -223,11 +228,13 @@ public function container(Request $request, $id)
223228
], 400);
224229
} catch (TransferException $ex) {
225230
Log::warning($ex);
231+
226232
return response()->json([
227233
'error' => 'A TransferException was encountered while trying to contact the daemon, please ensure it is online and accessible. This error has been logged.',
228234
], 504);
229235
} catch (\Exception $ex) {
230236
Log::error($ex);
237+
231238
return response()->json([
232239
'error' => 'An unhandled exception occured while attemping to modify this server container. Please try again.',
233240
], 500);
@@ -256,6 +263,7 @@ public function install(Request $request, $id)
256263
], 400);
257264
} catch (\Exception $ex) {
258265
Log::error($ex);
266+
259267
return response()->json([
260268
'error' => 'An unhandled exception occured while attemping to toggle the install status for this server. Please try again.',
261269
], 500);
@@ -283,6 +291,7 @@ public function rebuild(Request $request, $id)
283291
return response('', 204);
284292
} catch (TransferException $ex) {
285293
Log::warning($ex);
294+
286295
return response()->json([
287296
'error' => 'A TransferException was encountered while trying to contact the daemon, please ensure it is online and accessible. This error has been logged.',
288297
], 504);
@@ -318,11 +327,13 @@ public function suspend(Request $request, $id)
318327
], 400);
319328
} catch (TransferException $ex) {
320329
Log::warning($ex);
330+
321331
return response()->json([
322332
'error' => 'A TransferException was encountered while trying to contact the daemon, please ensure it is online and accessible. This error has been logged.',
323333
], 504);
324334
} catch (\Exception $ex) {
325335
Log::error($ex);
336+
326337
return response()->json([
327338
'error' => 'An unhandled exception occured while attemping to ' . $action . ' this server. Please try again.',
328339
], 500);
@@ -363,11 +374,13 @@ public function build(Request $request, $id)
363374
], 400);
364375
} catch (TransferException $ex) {
365376
Log::warning($ex);
377+
366378
return response()->json([
367379
'error' => 'A TransferException was encountered while trying to contact the daemon, please ensure it is online and accessible. This error has been logged.',
368380
], 504);
369381
} catch (\Exception $ex) {
370382
Log::error($ex);
383+
371384
return response()->json([
372385
'error' => 'An unhandled exception occured while attemping to modify the build settings for this server. Please try again.',
373386
], 500);
@@ -400,11 +413,13 @@ public function startup(Request $request, $id)
400413
], 400);
401414
} catch (TransferException $ex) {
402415
Log::warning($ex);
416+
403417
return response()->json([
404418
'error' => 'A TransferException was encountered while trying to contact the daemon, please ensure it is online and accessible. This error has been logged.',
405419
], 504);
406420
} catch (\Exception $ex) {
407421
Log::error($ex);
422+
408423
return response()->json([
409424
'error' => 'An unhandled exception occured while attemping to modify the startup settings for this server. Please try again.',
410425
], 500);

app/Http/Controllers/API/Admin/UserController.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
use Fractal;
2828
use Illuminate\Http\Request;
2929
use Pterodactyl\Models\User;
30-
use Pterodactyl\Http\Controllers\Controller;
3130
use Pterodactyl\Exceptions\DisplayException;
31+
use Pterodactyl\Http\Controllers\Controller;
3232
use Pterodactyl\Repositories\UserRepository;
3333
use Pterodactyl\Transformers\Admin\UserTransformer;
3434
use Pterodactyl\Exceptions\DisplayValidationException;
@@ -109,6 +109,7 @@ public function store(Request $request)
109109
], 400);
110110
} catch (\Exception $ex) {
111111
Log::error($ex);
112+
112113
return response()->json([
113114
'error' => 'An unhandled exception occured while attemping to create this user. Please try again.',
114115
], 500);
@@ -145,6 +146,7 @@ public function update(Request $request, $user)
145146
], 400);
146147
} catch (\Exception $ex) {
147148
Log::error($ex);
149+
148150
return response()->json([
149151
'error' => 'An unhandled exception occured while attemping to update this user. Please try again.',
150152
], 500);
@@ -173,6 +175,7 @@ public function delete(Request $request, $id)
173175
], 400);
174176
} catch (\Exception $ex) {
175177
Log::error($ex);
178+
176179
return response()->json([
177180
'error' => 'An unhandled exception occured while attemping to delete this user. Please try again.',
178181
], 500);

app/Http/Controllers/API/User/ServerController.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,9 @@
2727
use Fractal;
2828
use Illuminate\Http\Request;
2929
use Pterodactyl\Models\Server;
30-
use GuzzleHttp\Exception\ConnectException;
3130
use Pterodactyl\Http\Controllers\Controller;
32-
use Pterodactyl\Transformers\User\ServerTransformer;
3331
use Pterodactyl\Repositories\Daemon\PowerRepository;
32+
use Pterodactyl\Transformers\User\ServerTransformer;
3433

3534
class ServerController extends Controller
3635
{

app/Http/Middleware/CheckServer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function handle(Request $request, Closure $next)
6464
$this->request = $request;
6565
$this->server = Server::byUuid($request->route()->server);
6666

67-
if(! $this->exists()) {
67+
if (! $this->exists()) {
6868
return response()->view('errors.404', [], 404);
6969
}
7070

@@ -124,6 +124,6 @@ protected function installed()
124124
}
125125
}
126126

127-
return ($this->server->installed === 1);
127+
return $this->server->installed === 1;
128128
}
129129
}

app/Http/Middleware/HMACAuthorization.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,11 @@
2828
use Crypt;
2929
use Config;
3030
use Closure;
31-
use Response;
3231
use Debugbar;
3332
use IPTools\IP;
3433
use IPTools\Range;
3534
use Illuminate\Http\Request;
3635
use Pterodactyl\Models\APIKey;
37-
use Pterodactyl\Models\APIPermission;
3836
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; // 400
3937
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; // 403
4038

@@ -150,7 +148,7 @@ protected function validateRequest()
150148
protected function validateIPAccess()
151149
{
152150
if (! is_null($this->key()->allowed_ips)) {
153-
foreach($this->key()->allowed_ips as $ip) {
151+
foreach ($this->key()->allowed_ips as $ip) {
154152
if (Range::parse($ip)->contains(new IP($this->request()->ip()))) {
155153
return true;
156154
}
@@ -194,7 +192,8 @@ protected function generateSignature()
194192
*
195193
* @return string
196194
*/
197-
protected function public() {
195+
protected function public()
196+
{
198197
return $this->token['public'];
199198
}
200199

@@ -203,7 +202,8 @@ protected function public() {
203202
*
204203
* @return string
205204
*/
206-
protected function hash() {
205+
protected function hash()
206+
{
207207
return $this->token['hash'];
208208
}
209209

@@ -212,7 +212,8 @@ protected function hash() {
212212
*
213213
* @return \Pterodactyl\Models\APIKey
214214
*/
215-
protected function key() {
215+
protected function key()
216+
{
216217
return $this->key;
217218
}
218219

app/Models/APIPermission.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class APIPermission extends Model
7171
'view',
7272
'power',
7373
'command',
74-
]
74+
],
7575
],
7676

7777
// All other pemissions below are administrative actions.
@@ -120,7 +120,7 @@ class APIPermission extends Model
120120
];
121121

122122
/**
123-
* Return permissions for API
123+
* Return permissions for API.
124124
*
125125
* @return array
126126
*/

app/Models/Server.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,8 @@ public function js($additional = null, $overwrite = null)
209209
*
210210
* @return array
211211
*/
212-
public function getTableColumns() {
212+
public function getTableColumns()
213+
{
213214
return Schema::getColumnListing($this->getTable());
214215
}
215216

app/Providers/MacroServiceProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,15 @@ public function boot()
6666
return Cache::tags([
6767
'ApiKeyMacro',
6868
'ApiKeyMacro:Key:' . $parts[0],
69-
])->remember('ApiKeyMacro.' . $parts[0], Carbon::now()->addMinutes(15), function() use ($parts) {
69+
])->remember('ApiKeyMacro.' . $parts[0], Carbon::now()->addMinutes(15), function () use ($parts) {
7070
return APIKey::where('public', $parts[0])->first();
7171
});
7272
}
7373

7474
return false;
7575
});
7676

77-
Request::macro('apiKeyHasPermission', function($permission) {
77+
Request::macro('apiKeyHasPermission', function ($permission) {
7878
$key = Request::apiKey();
7979
if (! $key) {
8080
return false;

0 commit comments

Comments
 (0)