chore: add phpstan static analysis minimum (#4511)
This commit is contained in:
parent
3f7e2a565f
commit
a1a52754ad
67 changed files with 561 additions and 279 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue