chore: add phpstan static analysis minimum (#4511)

This commit is contained in:
Lance Pioch 2022-11-28 11:56:03 -05:00 committed by GitHub
parent 3f7e2a565f
commit a1a52754ad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
67 changed files with 561 additions and 279 deletions

View file

@ -29,11 +29,11 @@ class ResourceBelongsToServer
public function handle(Request $request, Closure $next): mixed
{
$params = $request->route()->parameters();
if (is_null($params) || !$params['server'] instanceof Server) {
if (!$params['server'] instanceof Server) {
throw new InvalidArgumentException('This middleware cannot be used in a context that is missing a server in the parameters.');
}
/** @var \Pterodactyl\Models\Server $server */
/** @var Server $server */
$server = $request->route()->parameter('server');
$exception = new NotFoundHttpException('The requested resource was not found for this server.');
foreach ($params as $key => $model) {
@ -45,6 +45,7 @@ class ResourceBelongsToServer
continue;
}
/** @var Allocation|Backup|Database|Schedule|Subuser $model */
switch (get_class($model)) {
// All of these models use "server_id" as the field key for the server
// they are assigned to, so the logic is identical for them all.
@ -71,6 +72,7 @@ class ResourceBelongsToServer
// Tasks are special since they're (currently) the only item in the API
// that requires something in addition to the server in order to be accessed.
case Task::class:
/** @var Schedule $schedule */
$schedule = $request->route()->parameter('schedule');
if ($model->schedule_id !== $schedule->id || $schedule->server_id !== $server->id) {
throw $exception;