Upgrade to Laravel 9 (#4413)

Co-authored-by: DaneEveritt <dane@daneeveritt.com>
This commit is contained in:
Matthew Penner 2022-10-14 10:59:20 -06:00 committed by GitHub
parent 95e15d2c8a
commit cbcf62086f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
573 changed files with 4387 additions and 9411 deletions

View file

@ -15,11 +15,9 @@ class AccountTransformer extends BaseClientTransformer
}
/**
* Return basic information about the currently logged in user.
*
* @return array
* Return basic information about the currently logged-in user.
*/
public function transform(User $model)
public function transform(User $model): array
{
return [
'id' => $model->id,

View file

@ -30,7 +30,7 @@ class ActivityLogTransformer extends BaseClientTransformer
'description' => $model->description,
'properties' => $this->properties($model),
'has_additional_metadata' => $this->hasAdditionalMetadata($model),
'timestamp' => $model->timestamp->toIso8601String(),
'timestamp' => $model->timestamp->toAtomString(),
];
}

View file

@ -14,12 +14,7 @@ class AllocationTransformer extends BaseClientTransformer
return 'allocation';
}
/**
* Return basic information about the currently logged in user.
*
* @return array
*/
public function transform(Allocation $model)
public function transform(Allocation $model): array
{
return [
'id' => $model->id,

View file

@ -16,17 +16,15 @@ class ApiKeyTransformer extends BaseClientTransformer
/**
* Transform this model into a representation that can be consumed by a client.
*
* @return array
*/
public function transform(ApiKey $model)
public function transform(ApiKey $model): array
{
return [
'identifier' => $model->identifier,
'description' => $model->memo,
'allowed_ips' => $model->allowed_ips,
'last_used_at' => $model->last_used_at ? $model->last_used_at->toIso8601String() : null,
'created_at' => $model->created_at->toIso8601String(),
'last_used_at' => $model->last_used_at ? $model->last_used_at->toAtomString() : null,
'created_at' => $model->created_at->toAtomString(),
];
}
}

View file

@ -11,10 +11,7 @@ class BackupTransformer extends BaseClientTransformer
return Backup::RESOURCE_NAME;
}
/**
* @return array
*/
public function transform(Backup $backup)
public function transform(Backup $backup): array
{
return [
'uuid' => $backup->uuid,
@ -24,8 +21,8 @@ class BackupTransformer extends BaseClientTransformer
'ignored_files' => $backup->ignored_files,
'checksum' => $backup->checksum,
'bytes' => $backup->bytes,
'created_at' => $backup->created_at->toIso8601String(),
'completed_at' => $backup->completed_at ? $backup->completed_at->toIso8601String() : null,
'created_at' => $backup->created_at->toAtomString(),
'completed_at' => $backup->completed_at ? $backup->completed_at->toAtomString() : null,
];
}
}

View file

@ -3,7 +3,9 @@
namespace Pterodactyl\Transformers\Api\Client;
use Pterodactyl\Models\Database;
use League\Fractal\Resource\Item;
use Pterodactyl\Models\Permission;
use League\Fractal\Resource\NullResource;
use Illuminate\Contracts\Encryption\Encrypter;
use Pterodactyl\Contracts\Extensions\HashidsInterface;
@ -11,15 +13,9 @@ class DatabaseTransformer extends BaseClientTransformer
{
protected array $availableIncludes = ['password'];
/**
* @var \Illuminate\Contracts\Encryption\Encrypter
*/
private $encrypter;
private Encrypter $encrypter;
/**
* @var \Pterodactyl\Contracts\Extensions\HashidsInterface
*/
private $hashids;
private HashidsInterface $hashids;
/**
* Handle dependency injection.
@ -54,10 +50,8 @@ class DatabaseTransformer extends BaseClientTransformer
/**
* Include the database password in the request.
*
* @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource
*/
public function includePassword(Database $database)
public function includePassword(Database $database): Item|NullResource
{
if (!$this->request->user()->can(Permission::ACTION_DATABASE_VIEW_PASSWORD, $database->server)) {
return $this->null();

View file

@ -14,10 +14,7 @@ class EggTransformer extends BaseClientTransformer
return Egg::RESOURCE_NAME;
}
/**
* @return array
*/
public function transform(Egg $egg)
public function transform(Egg $egg): array
{
return [
'uuid' => $egg->uuid,

View file

@ -12,10 +12,7 @@ class EggVariableTransformer extends BaseClientTransformer
return EggVariable::RESOURCE_NAME;
}
/**
* @return array
*/
public function transform(EggVariable $variable)
public function transform(EggVariable $variable): array
{
// This guards against someone incorrectly retrieving variables (haha, me) and then passing
// them into the transformer and along to the user. Just throw an exception and break the entire

View file

@ -9,10 +9,8 @@ class FileObjectTransformer extends BaseClientTransformer
{
/**
* Transform a file object response from the daemon into a standardized response.
*
* @return array
*/
public function transform(array $item)
public function transform(array $item): array
{
return [
'name' => Arr::get($item, 'name'),
@ -22,8 +20,8 @@ class FileObjectTransformer extends BaseClientTransformer
'is_file' => Arr::get($item, 'file', true),
'is_symlink' => Arr::get($item, 'symlink', false),
'mimetype' => Arr::get($item, 'mime', 'application/octet-stream'),
'created_at' => Carbon::parse(Arr::get($item, 'created', ''))->toIso8601String(),
'modified_at' => Carbon::parse(Arr::get($item, 'modified', ''))->toIso8601String(),
'created_at' => Carbon::parse(Arr::get($item, 'created', ''))->toAtomString(),
'modified_at' => Carbon::parse(Arr::get($item, 'modified', ''))->toAtomString(),
];
}

View file

@ -4,7 +4,7 @@ namespace Pterodactyl\Transformers\Api\Client;
use Pterodactyl\Models\Task;
use Pterodactyl\Models\Schedule;
use Illuminate\Database\Eloquent\Model;
use League\Fractal\Resource\Collection;
class ScheduleTransformer extends BaseClientTransformer
{
@ -22,10 +22,8 @@ class ScheduleTransformer extends BaseClientTransformer
/**
* Returns a transformed schedule model such that a client can view the information.
*
* @return array
*/
public function transform(Schedule $model)
public function transform(Schedule $model): array
{
return [
'id' => $model->id,
@ -40,21 +38,19 @@ class ScheduleTransformer extends BaseClientTransformer
'is_active' => $model->is_active,
'is_processing' => $model->is_processing,
'only_when_online' => $model->only_when_online,
'last_run_at' => $model->last_run_at ? $model->last_run_at->toIso8601String() : null,
'next_run_at' => $model->next_run_at ? $model->next_run_at->toIso8601String() : null,
'created_at' => $model->created_at->toIso8601String(),
'updated_at' => $model->updated_at->toIso8601String(),
'last_run_at' => $model->last_run_at?->toAtomString(),
'next_run_at' => $model->next_run_at?->toAtomString(),
'created_at' => $model->created_at->toAtomString(),
'updated_at' => $model->updated_at->toAtomString(),
];
}
/**
* Allows attaching the tasks specific to the schedule in the response.
*
* @return \League\Fractal\Resource\Collection
*
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
*/
public function includeTasks(Schedule $model)
public function includeTasks(Schedule $model): Collection
{
return $this->collection(
$model->tasks,

View file

@ -5,17 +5,17 @@ namespace Pterodactyl\Transformers\Api\Client;
use Pterodactyl\Models\Egg;
use Pterodactyl\Models\Server;
use Pterodactyl\Models\Subuser;
use League\Fractal\Resource\Item;
use Pterodactyl\Models\Allocation;
use Pterodactyl\Models\Permission;
use Illuminate\Container\Container;
use Pterodactyl\Models\EggVariable;
use League\Fractal\Resource\Collection;
use League\Fractal\Resource\NullResource;
use Pterodactyl\Services\Servers\StartupCommandService;
class ServerTransformer extends BaseClientTransformer
{
/**
* @var string[]
*/
protected array $defaultIncludes = ['allocations', 'variables'];
protected array $availableIncludes = ['egg', 'subusers'];
@ -77,11 +77,9 @@ class ServerTransformer extends BaseClientTransformer
/**
* Returns the allocations associated with this server.
*
* @return \League\Fractal\Resource\Collection
*
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
*/
public function includeAllocations(Server $server)
public function includeAllocations(Server $server): Collection
{
$transformer = $this->makeTransformer(AllocationTransformer::class);
@ -104,11 +102,9 @@ class ServerTransformer extends BaseClientTransformer
}
/**
* @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource
*
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
*/
public function includeVariables(Server $server)
public function includeVariables(Server $server): Collection|NullResource
{
if (!$this->request->user()->can(Permission::ACTION_STARTUP_READ, $server)) {
return $this->null();
@ -124,11 +120,9 @@ class ServerTransformer extends BaseClientTransformer
/**
* Returns the egg associated with this server.
*
* @return \League\Fractal\Resource\Item
*
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
*/
public function includeEgg(Server $server)
public function includeEgg(Server $server): Item
{
return $this->item($server->egg, $this->makeTransformer(EggTransformer::class), Egg::RESOURCE_NAME);
}
@ -136,11 +130,9 @@ class ServerTransformer extends BaseClientTransformer
/**
* Returns the subusers associated with this server.
*
* @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource
*
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
*/
public function includeSubusers(Server $server)
public function includeSubusers(Server $server): Collection|NullResource
{
if (!$this->request->user()->can(Permission::ACTION_USER_READ, $server)) {
return $this->null();

View file

@ -14,10 +14,8 @@ class StatsTransformer extends BaseClientTransformer
/**
* Transform stats from the daemon into a result set that can be used in
* the client API.
*
* @return array
*/
public function transform(array $data)
public function transform(array $data): array
{
return [
'current_state' => Arr::get($data, 'state', 'stopped'),

View file

@ -17,11 +17,9 @@ class SubuserTransformer extends BaseClientTransformer
/**
* Transforms a subuser into a model that can be shown to a front-end user.
*
* @return array|void
*
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
*/
public function transform(Subuser $model)
public function transform(Subuser $model): array
{
return array_merge(
$this->makeTransformer(UserTransformer::class)->transform($model->user),

View file

@ -16,10 +16,8 @@ class TaskTransformer extends BaseClientTransformer
/**
* Transforms a schedule's task into a client viewable format.
*
* @return array
*/
public function transform(Task $model)
public function transform(Task $model): array
{
return [
'id' => $model->id,
@ -29,8 +27,8 @@ class TaskTransformer extends BaseClientTransformer
'time_offset' => $model->time_offset,
'is_queued' => $model->is_queued,
'continue_on_failure' => $model->continue_on_failure,
'created_at' => $model->created_at->toIso8601String(),
'updated_at' => $model->updated_at->toIso8601String(),
'created_at' => $model->created_at->toAtomString(),
'updated_at' => $model->updated_at->toAtomString(),
];
}
}

View file

@ -20,7 +20,7 @@ class UserSSHKeyTransformer extends BaseClientTransformer
'name' => $model->name,
'fingerprint' => $model->fingerprint,
'public_key' => $model->public_key,
'created_at' => $model->created_at->toIso8601String(),
'created_at' => $model->created_at->toAtomString(),
];
}
}

View file

@ -18,10 +18,8 @@ class UserTransformer extends BaseClientTransformer
/**
* Transforms a User model into a representation that can be shown to regular
* users of the API.
*
* @return array
*/
public function transform(User $model)
public function transform(User $model): array
{
return [
'uuid' => $model->uuid,
@ -29,7 +27,7 @@ class UserTransformer extends BaseClientTransformer
'email' => $model->email,
'image' => 'https://gravatar.com/avatar/' . md5(Str::lower($model->email)),
'2fa_enabled' => $model->use_totp,
'created_at' => $model->created_at->toIso8601String(),
'created_at' => $model->created_at->toAtomString(),
];
}
}