diff --git a/app/Exceptions/DisplayException.php b/app/Exceptions/DisplayException.php index 1c4e69bcc..a004e3669 100644 --- a/app/Exceptions/DisplayException.php +++ b/app/Exceptions/DisplayException.php @@ -16,8 +16,11 @@ use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface; class DisplayException extends PanelException implements HttpExceptionInterface { public const LEVEL_DEBUG = 'debug'; + public const LEVEL_INFO = 'info'; + public const LEVEL_WARNING = 'warning'; + public const LEVEL_ERROR = 'error'; /** diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index d30d2ab2c..2ca296e6d 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -114,7 +114,7 @@ class Handler extends ExceptionHandler /** * Render an exception into an HTTP response. * - * @param \Illuminate\Http\Request $request + * @param \Illuminate\Http\Request $request * * @throws \Throwable */ @@ -140,7 +140,7 @@ class Handler extends ExceptionHandler * Transform a validation exception into a consistent format to be returned for * calls to the API. * - * @param \Illuminate\Http\Request $request + * @param \Illuminate\Http\Request $request */ public function invalidJson($request, ValidationException $exception): JsonResponse { @@ -236,7 +236,7 @@ class Handler extends ExceptionHandler /** * Convert an authentication exception into an unauthenticated response. * - * @param \Illuminate\Http\Request $request + * @param \Illuminate\Http\Request $request */ protected function unauthenticated($request, AuthenticationException $exception): JsonResponse|RedirectResponse { diff --git a/app/Exceptions/Http/HttpForbiddenException.php b/app/Exceptions/Http/HttpForbiddenException.php index b0536257e..318ab3b6c 100644 --- a/app/Exceptions/Http/HttpForbiddenException.php +++ b/app/Exceptions/Http/HttpForbiddenException.php @@ -10,7 +10,7 @@ class HttpForbiddenException extends HttpException /** * HttpForbiddenException constructor. */ - public function __construct(string $message = null, \Throwable $previous = null) + public function __construct(?string $message = null, ?\Throwable $previous = null) { parent::__construct(Response::HTTP_FORBIDDEN, $message, $previous); } diff --git a/app/Exceptions/Http/Server/ServerStateConflictException.php b/app/Exceptions/Http/Server/ServerStateConflictException.php index 1e20082a3..c5b53b4da 100644 --- a/app/Exceptions/Http/Server/ServerStateConflictException.php +++ b/app/Exceptions/Http/Server/ServerStateConflictException.php @@ -12,7 +12,7 @@ class ServerStateConflictException extends ConflictHttpException * Exception thrown when the server is in an unsupported state for API access or * certain operations within the codebase. */ - public function __construct(Server $server, \Throwable $previous = null) + public function __construct(Server $server, ?\Throwable $previous = null) { $message = 'This server is currently in an unsupported state, please try again later.'; if ($server->isSuspended()) { diff --git a/app/Exceptions/Http/TwoFactorAuthRequiredException.php b/app/Exceptions/Http/TwoFactorAuthRequiredException.php index 6b9804812..fb9c09ebc 100644 --- a/app/Exceptions/Http/TwoFactorAuthRequiredException.php +++ b/app/Exceptions/Http/TwoFactorAuthRequiredException.php @@ -11,7 +11,7 @@ class TwoFactorAuthRequiredException extends HttpException implements HttpExcept /** * TwoFactorAuthRequiredException constructor. */ - public function __construct(\Throwable $previous = null) + public function __construct(?\Throwable $previous = null) { parent::__construct(Response::HTTP_BAD_REQUEST, 'Two-factor authentication is required on this account in order to access this endpoint.', $previous); } diff --git a/app/Exceptions/Service/ServiceLimitExceededException.php b/app/Exceptions/Service/ServiceLimitExceededException.php index 3609be97d..2570197d6 100644 --- a/app/Exceptions/Service/ServiceLimitExceededException.php +++ b/app/Exceptions/Service/ServiceLimitExceededException.php @@ -10,7 +10,7 @@ class ServiceLimitExceededException extends DisplayException * Exception thrown when something goes over a defined limit, such as allocated * ports, tasks, databases, etc. */ - public function __construct(string $message, \Throwable $previous = null) + public function __construct(string $message, ?\Throwable $previous = null) { parent::__construct($message, $previous, self::LEVEL_WARNING); } diff --git a/app/Exceptions/Service/User/TwoFactorAuthenticationTokenInvalid.php b/app/Exceptions/Service/User/TwoFactorAuthenticationTokenInvalid.php index d5f09884c..0c058d0d8 100644 --- a/app/Exceptions/Service/User/TwoFactorAuthenticationTokenInvalid.php +++ b/app/Exceptions/Service/User/TwoFactorAuthenticationTokenInvalid.php @@ -7,6 +7,7 @@ use App\Exceptions\DisplayException; class TwoFactorAuthenticationTokenInvalid extends DisplayException { public string $title = 'Invalid 2FA Code'; + public string $icon = 'tabler-2fa'; public function __construct() diff --git a/app/Extensions/Backups/BackupManager.php b/app/Extensions/Backups/BackupManager.php index ad1cfdbbc..9922a55c6 100644 --- a/app/Extensions/Backups/BackupManager.php +++ b/app/Extensions/Backups/BackupManager.php @@ -34,7 +34,7 @@ class BackupManager /** * Returns a backup adapter instance. */ - public function adapter(string $name = null): FilesystemAdapter + public function adapter(?string $name = null): FilesystemAdapter { return $this->get($name ?: $this->getDefaultAdapter()); } @@ -145,7 +145,7 @@ class BackupManager /** * Unset the given adapter instances. * - * @param string|string[] $adapter + * @param string|string[] $adapter */ public function forget(array|string $adapter): self { diff --git a/app/Extensions/DynamicDatabaseConnection.php b/app/Extensions/DynamicDatabaseConnection.php index d14407427..147f78064 100644 --- a/app/Extensions/DynamicDatabaseConnection.php +++ b/app/Extensions/DynamicDatabaseConnection.php @@ -7,7 +7,9 @@ use App\Models\DatabaseHost; class DynamicDatabaseConnection { public const DB_CHARSET = 'utf8'; + public const DB_COLLATION = 'utf8_unicode_ci'; + public const DB_DRIVER = 'mysql'; /** diff --git a/app/Filament/Pages/Settings.php b/app/Filament/Pages/Settings.php index f3ef2c2b9..f8d18a01c 100644 --- a/app/Filament/Pages/Settings.php +++ b/app/Filament/Pages/Settings.php @@ -38,6 +38,7 @@ class Settings extends Page implements HasForms use InteractsWithHeaderActions; protected static ?string $navigationIcon = 'tabler-settings'; + protected static ?string $navigationGroup = 'Advanced'; protected static string $view = 'filament.pages.settings'; diff --git a/app/Filament/Resources/ApiKeyResource.php b/app/Filament/Resources/ApiKeyResource.php index daefee22b..282ef6ecb 100644 --- a/app/Filament/Resources/ApiKeyResource.php +++ b/app/Filament/Resources/ApiKeyResource.php @@ -10,8 +10,11 @@ use Illuminate\Database\Eloquent\Model; class ApiKeyResource extends Resource { protected static ?string $model = ApiKey::class; + protected static ?string $label = 'API Key'; + protected static ?string $navigationIcon = 'tabler-key'; + protected static ?string $navigationGroup = 'Advanced'; public static function getNavigationBadge(): ?string diff --git a/app/Filament/Resources/DatabaseHostResource.php b/app/Filament/Resources/DatabaseHostResource.php index 7576fbc3a..790895983 100644 --- a/app/Filament/Resources/DatabaseHostResource.php +++ b/app/Filament/Resources/DatabaseHostResource.php @@ -13,6 +13,7 @@ class DatabaseHostResource extends Resource protected static ?string $label = 'Database Host'; protected static ?string $navigationIcon = 'tabler-database'; + protected static ?string $navigationGroup = 'Advanced'; public static function getNavigationBadge(): ?string diff --git a/app/Filament/Resources/DatabaseHostResource/RelationManagers/DatabasesRelationManager.php b/app/Filament/Resources/DatabaseHostResource/RelationManagers/DatabasesRelationManager.php index bdd93d60d..17cdb6248 100644 --- a/app/Filament/Resources/DatabaseHostResource/RelationManagers/DatabasesRelationManager.php +++ b/app/Filament/Resources/DatabaseHostResource/RelationManagers/DatabasesRelationManager.php @@ -41,6 +41,7 @@ class DatabasesRelationManager extends RelationManager ->formatStateUsing(fn (Get $get, Database $database) => 'jdbc:mysql://' . $get('username') . ':' . urlencode($database->password) . '@' . $database->host->host . ':' . $database->host->port . '/' . $get('database')), ]); } + public function table(Table $table): Table { return $table diff --git a/app/Filament/Resources/DatabaseResource.php b/app/Filament/Resources/DatabaseResource.php index 92580dfdf..912f6fe93 100644 --- a/app/Filament/Resources/DatabaseResource.php +++ b/app/Filament/Resources/DatabaseResource.php @@ -13,6 +13,7 @@ class DatabaseResource extends Resource protected static ?string $navigationIcon = 'tabler-database'; protected static bool $shouldRegisterNavigation = false; + protected static ?string $navigationGroup = 'Advanced'; public static function getNavigationBadge(): ?string diff --git a/app/Filament/Resources/EggResource/Pages/CreateEgg.php b/app/Filament/Resources/EggResource/Pages/CreateEgg.php index a663540cb..4ec91ea24 100644 --- a/app/Filament/Resources/EggResource/Pages/CreateEgg.php +++ b/app/Filament/Resources/EggResource/Pages/CreateEgg.php @@ -27,6 +27,7 @@ class CreateEgg extends CreateRecord protected static string $resource = EggResource::class; protected static bool $canCreateAnother = false; + public function form(Form $form): Form { return $form diff --git a/app/Filament/Resources/EggResource/Pages/ListEggs.php b/app/Filament/Resources/EggResource/Pages/ListEggs.php index 98132fedc..0069abed9 100644 --- a/app/Filament/Resources/EggResource/Pages/ListEggs.php +++ b/app/Filament/Resources/EggResource/Pages/ListEggs.php @@ -98,6 +98,7 @@ class ListEggs extends ListRecords ]), ]); } + protected function getHeaderActions(): array { return [ diff --git a/app/Filament/Resources/MountResource.php b/app/Filament/Resources/MountResource.php index a2d7a187e..a30f586e1 100644 --- a/app/Filament/Resources/MountResource.php +++ b/app/Filament/Resources/MountResource.php @@ -11,6 +11,7 @@ class MountResource extends Resource protected static ?string $model = Mount::class; protected static ?string $navigationIcon = 'tabler-layers-linked'; + protected static ?string $navigationGroup = 'Advanced'; public static function getNavigationBadge(): ?string diff --git a/app/Filament/Resources/MountResource/Pages/EditMount.php b/app/Filament/Resources/MountResource/Pages/EditMount.php index 71c6febb5..e44fb581b 100644 --- a/app/Filament/Resources/MountResource/Pages/EditMount.php +++ b/app/Filament/Resources/MountResource/Pages/EditMount.php @@ -96,6 +96,7 @@ class EditMount extends EditRecord 'lg' => 2, ]); } + protected function getHeaderActions(): array { return [ diff --git a/app/Filament/Resources/MountResource/Pages/ListMounts.php b/app/Filament/Resources/MountResource/Pages/ListMounts.php index d39c5d972..10bfbc6dd 100644 --- a/app/Filament/Resources/MountResource/Pages/ListMounts.php +++ b/app/Filament/Resources/MountResource/Pages/ListMounts.php @@ -17,6 +17,7 @@ use Filament\Tables\Table; class ListMounts extends ListRecords { protected static string $resource = MountResource::class; + public function table(Table $table): Table { return $table @@ -56,6 +57,7 @@ class ListMounts extends ListRecords ->button(), ]); } + protected function getHeaderActions(): array { return [ diff --git a/app/Filament/Resources/NodeResource/Widgets/NodeCpuChart.php b/app/Filament/Resources/NodeResource/Widgets/NodeCpuChart.php index 476b8b533..89d1cb254 100644 --- a/app/Filament/Resources/NodeResource/Widgets/NodeCpuChart.php +++ b/app/Filament/Resources/NodeResource/Widgets/NodeCpuChart.php @@ -12,6 +12,7 @@ use Illuminate\Support\Number; class NodeCpuChart extends ChartWidget { protected static ?string $pollingInterval = '5s'; + protected static ?string $maxHeight = '300px'; public ?Model $record = null; diff --git a/app/Filament/Resources/NodeResource/Widgets/NodeMemoryChart.php b/app/Filament/Resources/NodeResource/Widgets/NodeMemoryChart.php index 9d75fd116..0cabbed51 100644 --- a/app/Filament/Resources/NodeResource/Widgets/NodeMemoryChart.php +++ b/app/Filament/Resources/NodeResource/Widgets/NodeMemoryChart.php @@ -12,6 +12,7 @@ use Illuminate\Support\Number; class NodeMemoryChart extends ChartWidget { protected static ?string $pollingInterval = '5s'; + protected static ?string $maxHeight = '300px'; public ?Model $record = null; diff --git a/app/Filament/Resources/NodeResource/Widgets/NodeStorageChart.php b/app/Filament/Resources/NodeResource/Widgets/NodeStorageChart.php index b841d84ef..61db8c98d 100644 --- a/app/Filament/Resources/NodeResource/Widgets/NodeStorageChart.php +++ b/app/Filament/Resources/NodeResource/Widgets/NodeStorageChart.php @@ -9,7 +9,9 @@ use Illuminate\Database\Eloquent\Model; class NodeStorageChart extends ChartWidget { protected static ?string $heading = 'Storage'; + protected static ?string $pollingInterval = '60s'; + protected static ?string $maxHeight = '300px'; public ?Model $record = null; diff --git a/app/Filament/Resources/ServerResource/Pages/CreateServer.php b/app/Filament/Resources/ServerResource/Pages/CreateServer.php index df9d3b033..99fd1d433 100644 --- a/app/Filament/Resources/ServerResource/Pages/CreateServer.php +++ b/app/Filament/Resources/ServerResource/Pages/CreateServer.php @@ -45,6 +45,7 @@ use LogicException; class CreateServer extends CreateRecord { protected static string $resource = ServerResource::class; + protected static bool $canCreateAnother = false; public ?Node $node = null; diff --git a/app/Filament/Resources/ServerResource/Pages/EditServer.php b/app/Filament/Resources/ServerResource/Pages/EditServer.php index ff7e063da..fe1be6276 100644 --- a/app/Filament/Resources/ServerResource/Pages/EditServer.php +++ b/app/Filament/Resources/ServerResource/Pages/EditServer.php @@ -741,6 +741,7 @@ class EditServer extends EditRecord ]); } + protected function getHeaderActions(): array { return [ @@ -763,6 +764,7 @@ class EditServer extends EditRecord ]; } + protected function getFormActions(): array { return []; diff --git a/app/Filament/Resources/ServerResource/Pages/ListServers.php b/app/Filament/Resources/ServerResource/Pages/ListServers.php index 326499898..dd6fc4a16 100644 --- a/app/Filament/Resources/ServerResource/Pages/ListServers.php +++ b/app/Filament/Resources/ServerResource/Pages/ListServers.php @@ -96,6 +96,7 @@ class ListServers extends ListRecords ->button(), ]); } + protected function getHeaderActions(): array { return [ diff --git a/app/Filament/Resources/UserResource/Pages/EditUser.php b/app/Filament/Resources/UserResource/Pages/EditUser.php index 777f20d73..3fa6a5571 100644 --- a/app/Filament/Resources/UserResource/Pages/EditUser.php +++ b/app/Filament/Resources/UserResource/Pages/EditUser.php @@ -18,6 +18,7 @@ use Illuminate\Support\Facades\Hash; class EditUser extends EditRecord { protected static string $resource = UserResource::class; + public function form(Form $form): Form { return $form @@ -46,6 +47,7 @@ class EditUser extends EditRecord ])->columns(), ]); } + protected function getHeaderActions(): array { return [ diff --git a/app/Filament/Resources/UserResource/Pages/ListUsers.php b/app/Filament/Resources/UserResource/Pages/ListUsers.php index 9f12d8a77..510530236 100644 --- a/app/Filament/Resources/UserResource/Pages/ListUsers.php +++ b/app/Filament/Resources/UserResource/Pages/ListUsers.php @@ -78,6 +78,7 @@ class ListUsers extends ListRecords ]), ]); } + protected function getHeaderActions(): array { return [ diff --git a/app/Http/Controllers/Admin/Eggs/EggController.php b/app/Http/Controllers/Admin/Eggs/EggController.php index 692ff7942..2f3de5ae1 100644 --- a/app/Http/Controllers/Admin/Eggs/EggController.php +++ b/app/Http/Controllers/Admin/Eggs/EggController.php @@ -127,7 +127,7 @@ class EggController extends Controller /** * Normalizes a string of docker image data into the expected egg format. */ - protected function normalizeDockerImages(string $input = null): array + protected function normalizeDockerImages(?string $input = null): array { $data = array_map(fn ($value) => trim($value), explode("\n", $input ?? '')); diff --git a/app/Http/Controllers/Admin/Nodes/NodeViewController.php b/app/Http/Controllers/Admin/Nodes/NodeViewController.php index 95dc7ede0..115b7b6b1 100644 --- a/app/Http/Controllers/Admin/Nodes/NodeViewController.php +++ b/app/Http/Controllers/Admin/Nodes/NodeViewController.php @@ -15,6 +15,7 @@ class NodeViewController extends Controller use JavascriptInjection; public const THRESHOLD_PERCENTAGE_LOW = 75; + public const THRESHOLD_PERCENTAGE_MEDIUM = 90; /** diff --git a/app/Http/Controllers/Api/Application/ApplicationApiController.php b/app/Http/Controllers/Api/Application/ApplicationApiController.php index 87c721a74..007810580 100644 --- a/app/Http/Controllers/Api/Application/ApplicationApiController.php +++ b/app/Http/Controllers/Api/Application/ApplicationApiController.php @@ -51,8 +51,7 @@ abstract class ApplicationApiController extends Controller * * @template T of \App\Transformers\Api\Application\BaseTransformer * - * @param class-string $abstract - * + * @param class-string $abstract * @return T * * @noinspection PhpDocSignatureInspection diff --git a/app/Http/Controllers/Api/Client/ClientApiController.php b/app/Http/Controllers/Api/Client/ClientApiController.php index 4cf081fec..8d409a754 100644 --- a/app/Http/Controllers/Api/Client/ClientApiController.php +++ b/app/Http/Controllers/Api/Client/ClientApiController.php @@ -41,8 +41,7 @@ abstract class ClientApiController extends ApplicationApiController * * @template T of \App\Transformers\Api\Client\BaseClientTransformer * - * @param class-string $abstract - * + * @param class-string $abstract * @return T * * @noinspection PhpDocSignatureInspection diff --git a/app/Http/Controllers/Auth/AbstractLoginController.php b/app/Http/Controllers/Auth/AbstractLoginController.php index e62f9fab8..4a6fa719f 100644 --- a/app/Http/Controllers/Auth/AbstractLoginController.php +++ b/app/Http/Controllers/Auth/AbstractLoginController.php @@ -51,7 +51,7 @@ abstract class AbstractLoginController extends Controller * * @throws \App\Exceptions\DisplayException */ - protected function sendFailedLoginResponse(Request $request, Authenticatable $user = null, string $message = null): never + protected function sendFailedLoginResponse(Request $request, ?Authenticatable $user = null, ?string $message = null): never { $this->incrementLoginAttempts($request); $this->fireFailedLoginEvent($user, [ @@ -91,7 +91,7 @@ abstract class AbstractLoginController extends Controller /** * Determine if the user is logging in using an email or username. */ - protected function getField(string $input = null): string + protected function getField(?string $input = null): string { return ($input && str_contains($input, '@')) ? 'email' : 'username'; } @@ -99,7 +99,7 @@ abstract class AbstractLoginController extends Controller /** * Fire a failed login event. */ - protected function fireFailedLoginEvent(Authenticatable $user = null, array $credentials = []): void + protected function fireFailedLoginEvent(?Authenticatable $user = null, array $credentials = []): void { Event::dispatch(new Failed('auth', $user, $credentials)); } diff --git a/app/Http/Controllers/Auth/ResetPasswordController.php b/app/Http/Controllers/Auth/ResetPasswordController.php index 11dcc0346..da8f5b793 100644 --- a/app/Http/Controllers/Auth/ResetPasswordController.php +++ b/app/Http/Controllers/Auth/ResetPasswordController.php @@ -64,8 +64,8 @@ class ResetPasswordController extends Controller * account do not automatically log them in. In those cases, send the user back to the login * form with a note telling them their password was changed and to log back in. * - * @param \Illuminate\Contracts\Auth\CanResetPassword|\App\Models\User $user - * @param string $password + * @param \Illuminate\Contracts\Auth\CanResetPassword|\App\Models\User $user + * @param string $password * * @throws \App\Exceptions\Model\DataValidationException */ diff --git a/app/Http/Middleware/RedirectIfAuthenticated.php b/app/Http/Middleware/RedirectIfAuthenticated.php index 38af84f7e..f645f552e 100644 --- a/app/Http/Middleware/RedirectIfAuthenticated.php +++ b/app/Http/Middleware/RedirectIfAuthenticated.php @@ -17,7 +17,7 @@ class RedirectIfAuthenticated /** * Handle an incoming request. */ - public function handle(Request $request, \Closure $next, string $guard = null): mixed + public function handle(Request $request, \Closure $next, ?string $guard = null): mixed { if ($this->authManager->guard($guard)->check()) { return redirect()->route('index'); diff --git a/app/Http/Middleware/RequireTwoFactorAuthentication.php b/app/Http/Middleware/RequireTwoFactorAuthentication.php index 470cc73b3..58ff1564d 100644 --- a/app/Http/Middleware/RequireTwoFactorAuthentication.php +++ b/app/Http/Middleware/RequireTwoFactorAuthentication.php @@ -10,7 +10,9 @@ use App\Exceptions\Http\TwoFactorAuthRequiredException; class RequireTwoFactorAuthentication { public const LEVEL_NONE = 0; + public const LEVEL_ADMIN = 1; + public const LEVEL_ALL = 2; /** diff --git a/app/Http/Requests/Admin/AdminFormRequest.php b/app/Http/Requests/Admin/AdminFormRequest.php index 54e9f5e92..adfb97fb8 100644 --- a/app/Http/Requests/Admin/AdminFormRequest.php +++ b/app/Http/Requests/Admin/AdminFormRequest.php @@ -28,7 +28,7 @@ abstract class AdminFormRequest extends FormRequest * Return only the fields that we are interested in from the request. * This will include empty fields as a null value. */ - public function normalize(array $only = null): array + public function normalize(?array $only = null): array { return $this->only($only ?? array_keys($this->rules())); } diff --git a/app/Http/Requests/Admin/Settings/MailSettingsFormRequest.php b/app/Http/Requests/Admin/Settings/MailSettingsFormRequest.php index 9e62869d8..38fa792d5 100644 --- a/app/Http/Requests/Admin/Settings/MailSettingsFormRequest.php +++ b/app/Http/Requests/Admin/Settings/MailSettingsFormRequest.php @@ -27,7 +27,7 @@ class MailSettingsFormRequest extends AdminFormRequest * Override the default normalization function for this type of request * as we need to accept empty values on the keys. */ - public function normalize(array $only = null): array + public function normalize(?array $only = null): array { $keys = array_flip(array_keys($this->rules())); diff --git a/app/Http/Requests/Api/Application/ApplicationApiRequest.php b/app/Http/Requests/Api/Application/ApplicationApiRequest.php index a0e17c15d..b8feb094d 100644 --- a/app/Http/Requests/Api/Application/ApplicationApiRequest.php +++ b/app/Http/Requests/Api/Application/ApplicationApiRequest.php @@ -74,8 +74,7 @@ abstract class ApplicationApiRequest extends FormRequest * * @template T of \Illuminate\Database\Eloquent\Model * - * @param class-string $expect - * + * @param class-string $expect * @return T * * @noinspection PhpDocSignatureInspection diff --git a/app/Http/Requests/Api/Application/DatabaseHosts/StoreDatabaseHostRequest.php b/app/Http/Requests/Api/Application/DatabaseHosts/StoreDatabaseHostRequest.php index aedd5109b..435a6d86b 100644 --- a/app/Http/Requests/Api/Application/DatabaseHosts/StoreDatabaseHostRequest.php +++ b/app/Http/Requests/Api/Application/DatabaseHosts/StoreDatabaseHostRequest.php @@ -12,7 +12,7 @@ class StoreDatabaseHostRequest extends ApplicationApiRequest protected int $permission = AdminAcl::WRITE; - public function rules(array $rules = null): array + public function rules(?array $rules = null): array { return $rules ?? DatabaseHost::getRules(); } diff --git a/app/Http/Requests/Api/Application/DatabaseHosts/UpdateDatabaseHostRequest.php b/app/Http/Requests/Api/Application/DatabaseHosts/UpdateDatabaseHostRequest.php index 83c74ac3b..f14b9b90f 100644 --- a/app/Http/Requests/Api/Application/DatabaseHosts/UpdateDatabaseHostRequest.php +++ b/app/Http/Requests/Api/Application/DatabaseHosts/UpdateDatabaseHostRequest.php @@ -6,7 +6,7 @@ use App\Models\DatabaseHost; class UpdateDatabaseHostRequest extends StoreDatabaseHostRequest { - public function rules(array $rules = null): array + public function rules(?array $rules = null): array { /** @var DatabaseHost $databaseHost */ $databaseHost = $this->route()->parameter('database_host'); diff --git a/app/Http/Requests/Api/Application/Mounts/UpdateMountRequest.php b/app/Http/Requests/Api/Application/Mounts/UpdateMountRequest.php index e111553d4..05e7d0a23 100644 --- a/app/Http/Requests/Api/Application/Mounts/UpdateMountRequest.php +++ b/app/Http/Requests/Api/Application/Mounts/UpdateMountRequest.php @@ -9,7 +9,7 @@ class UpdateMountRequest extends StoreMountRequest /** * Apply validation rules to this request. */ - public function rules(array $rules = null): array + public function rules(?array $rules = null): array { /** @var Mount $mount */ $mount = $this->route()->parameter('mount'); diff --git a/app/Http/Requests/Api/Application/Nodes/StoreNodeRequest.php b/app/Http/Requests/Api/Application/Nodes/StoreNodeRequest.php index 913204b83..eae324233 100644 --- a/app/Http/Requests/Api/Application/Nodes/StoreNodeRequest.php +++ b/app/Http/Requests/Api/Application/Nodes/StoreNodeRequest.php @@ -15,7 +15,7 @@ class StoreNodeRequest extends ApplicationApiRequest /** * Validation rules to apply to this request. */ - public function rules(array $rules = null): array + public function rules(?array $rules = null): array { return collect($rules ?? Node::getRules())->only([ 'public', diff --git a/app/Http/Requests/Api/Application/Nodes/UpdateNodeRequest.php b/app/Http/Requests/Api/Application/Nodes/UpdateNodeRequest.php index a59039d99..5907860a2 100644 --- a/app/Http/Requests/Api/Application/Nodes/UpdateNodeRequest.php +++ b/app/Http/Requests/Api/Application/Nodes/UpdateNodeRequest.php @@ -10,7 +10,7 @@ class UpdateNodeRequest extends StoreNodeRequest * Apply validation rules to this request. Uses the parent class rules() * function but passes in the rules for updating rather than creating. */ - public function rules(array $rules = null): array + public function rules(?array $rules = null): array { /** @var Node $node */ $node = $this->route()->parameter('node'); diff --git a/app/Http/Requests/Api/Application/Roles/StoreRoleRequest.php b/app/Http/Requests/Api/Application/Roles/StoreRoleRequest.php index 7968449a7..4cf01400e 100644 --- a/app/Http/Requests/Api/Application/Roles/StoreRoleRequest.php +++ b/app/Http/Requests/Api/Application/Roles/StoreRoleRequest.php @@ -11,7 +11,7 @@ class StoreRoleRequest extends ApplicationApiRequest protected int $permission = AdminAcl::WRITE; - public function rules(array $rules = null): array + public function rules(?array $rules = null): array { return [ 'name' => 'required|string', diff --git a/app/Http/Requests/Api/Application/Users/AssignUserRolesRequest.php b/app/Http/Requests/Api/Application/Users/AssignUserRolesRequest.php index c0af95102..61e191c20 100644 --- a/app/Http/Requests/Api/Application/Users/AssignUserRolesRequest.php +++ b/app/Http/Requests/Api/Application/Users/AssignUserRolesRequest.php @@ -7,7 +7,7 @@ class AssignUserRolesRequest extends StoreUserRequest /** * Return the validation rules for this request. */ - public function rules(array $rules = null): array + public function rules(?array $rules = null): array { return [ 'roles' => 'array', diff --git a/app/Http/Requests/Api/Application/Users/StoreUserRequest.php b/app/Http/Requests/Api/Application/Users/StoreUserRequest.php index 43603639c..cf1b6c244 100644 --- a/app/Http/Requests/Api/Application/Users/StoreUserRequest.php +++ b/app/Http/Requests/Api/Application/Users/StoreUserRequest.php @@ -15,7 +15,7 @@ class StoreUserRequest extends ApplicationApiRequest /** * Return the validation rules for this request. */ - public function rules(array $rules = null): array + public function rules(?array $rules = null): array { $rules = $rules ?? User::getRules(); diff --git a/app/Http/Requests/Api/Application/Users/UpdateUserRequest.php b/app/Http/Requests/Api/Application/Users/UpdateUserRequest.php index c7a919bee..9ec5067a5 100644 --- a/app/Http/Requests/Api/Application/Users/UpdateUserRequest.php +++ b/app/Http/Requests/Api/Application/Users/UpdateUserRequest.php @@ -9,7 +9,7 @@ class UpdateUserRequest extends StoreUserRequest /** * Return the validation rules for this request. */ - public function rules(array $rules = null): array + public function rules(?array $rules = null): array { $user = $this->parameter('user', User::class); diff --git a/app/Jobs/NodeStatistics.php b/app/Jobs/NodeStatistics.php index 19fae9b9d..9546f0ba0 100644 --- a/app/Jobs/NodeStatistics.php +++ b/app/Jobs/NodeStatistics.php @@ -42,5 +42,4 @@ class NodeStatistics implements ShouldQueue } } } - } diff --git a/app/Jobs/Schedule/RunTaskJob.php b/app/Jobs/Schedule/RunTaskJob.php index 167980ac9..158950c45 100644 --- a/app/Jobs/Schedule/RunTaskJob.php +++ b/app/Jobs/Schedule/RunTaskJob.php @@ -90,7 +90,7 @@ class RunTaskJob extends Job implements ShouldQueue /** * Handle a failure while sending the action to the daemon or otherwise processing the job. */ - public function failed(\Exception $exception = null): void + public function failed(?\Exception $exception = null): void { $this->markTaskNotQueued(); $this->markScheduleComplete(); diff --git a/app/Livewire/NodeSystemInformation.php b/app/Livewire/NodeSystemInformation.php index 54b4cd827..55f71f7ce 100644 --- a/app/Livewire/NodeSystemInformation.php +++ b/app/Livewire/NodeSystemInformation.php @@ -9,6 +9,7 @@ use Livewire\Component; class NodeSystemInformation extends Component { public Node $node; + public string $sizeClasses; public function render(): View diff --git a/app/Models/ActivityLogSubject.php b/app/Models/ActivityLogSubject.php index 92aa3d455..f6a7291fa 100644 --- a/app/Models/ActivityLogSubject.php +++ b/app/Models/ActivityLogSubject.php @@ -26,6 +26,7 @@ use Illuminate\Database\Eloquent\SoftDeletingScope; class ActivityLogSubject extends Pivot { public $incrementing = true; + public $timestamps = false; protected $table = 'activity_log_subjects'; diff --git a/app/Models/ApiKey.php b/app/Models/ApiKey.php index 52d78a97b..96c714f24 100644 --- a/app/Models/ApiKey.php +++ b/app/Models/ApiKey.php @@ -63,21 +63,28 @@ class ApiKey extends Model * API representation using fractal. */ public const RESOURCE_NAME = 'api_key'; + /** * Different API keys that can exist on the system. */ public const TYPE_NONE = 0; + public const TYPE_ACCOUNT = 1; + /* @deprecated */ public const TYPE_APPLICATION = 2; + /* @deprecated */ public const TYPE_DAEMON_USER = 3; + /* @deprecated */ public const TYPE_DAEMON_APPLICATION = 4; + /** * The length of API key identifiers. */ public const IDENTIFIER_LENGTH = 16; + /** * The length of the actual API key that is encrypted and stored * in the database. diff --git a/app/Models/Backup.php b/app/Models/Backup.php index 3f2a931d1..d6e4be65a 100644 --- a/app/Models/Backup.php +++ b/app/Models/Backup.php @@ -32,6 +32,7 @@ class Backup extends Model public const RESOURCE_NAME = 'backup'; public const ADAPTER_DAEMON = 'wings'; + public const ADAPTER_AWS_S3 = 's3'; protected $table = 'backups'; diff --git a/app/Models/Egg.php b/app/Models/Egg.php index e8c672064..001be85e3 100644 --- a/app/Models/Egg.php +++ b/app/Models/Egg.php @@ -70,6 +70,7 @@ class Egg extends Model * than leaving it null. */ public const FEATURE_EULA_POPUP = 'eula'; + public const FEATURE_FASTDL = 'fastdl'; /** diff --git a/app/Models/Filters/AdminServerFilter.php b/app/Models/Filters/AdminServerFilter.php index bebde0ee9..e90f17e08 100644 --- a/app/Models/Filters/AdminServerFilter.php +++ b/app/Models/Filters/AdminServerFilter.php @@ -11,7 +11,7 @@ class AdminServerFilter implements Filter * A multi-column filter for the servers table that allows an administrative user to search * across UUID, name, owner username, and owner email. * - * @param string $value + * @param string $value */ public function __invoke(Builder $query, $value, string $property): void { diff --git a/app/Models/Filters/MultiFieldServerFilter.php b/app/Models/Filters/MultiFieldServerFilter.php index 4523825f4..89bb15f49 100644 --- a/app/Models/Filters/MultiFieldServerFilter.php +++ b/app/Models/Filters/MultiFieldServerFilter.php @@ -19,7 +19,7 @@ class MultiFieldServerFilter implements Filter * search across multiple columns. This allows us to provide a very generic search ability for * the frontend. * - * @param string $value + * @param string $value */ public function __invoke(Builder $query, $value, string $property): void { diff --git a/app/Models/Node.php b/app/Models/Node.php index 5a60eb96f..64f44e3af 100644 --- a/app/Models/Node.php +++ b/app/Models/Node.php @@ -54,6 +54,7 @@ class Node extends Model public const RESOURCE_NAME = 'node'; public const DAEMON_TOKEN_ID_LENGTH = 16; + public const DAEMON_TOKEN_LENGTH = 64; /** @@ -136,7 +137,9 @@ class Node extends Model } public int $servers_sum_memory = 0; + public int $servers_sum_disk = 0; + public int $servers_sum_cpu = 0; public function getRouteKeyName(): string diff --git a/app/Models/Objects/DeploymentObject.php b/app/Models/Objects/DeploymentObject.php index b7a4ebaf3..692ca7487 100644 --- a/app/Models/Objects/DeploymentObject.php +++ b/app/Models/Objects/DeploymentObject.php @@ -45,5 +45,4 @@ class DeploymentObject return $this; } - } diff --git a/app/Models/Permission.php b/app/Models/Permission.php index ab9fef260..29cbd826d 100644 --- a/app/Models/Permission.php +++ b/app/Models/Permission.php @@ -16,51 +16,81 @@ class Permission extends Model * Constants defining different permissions available. */ public const ACTION_WEBSOCKET_CONNECT = 'websocket.connect'; + public const ACTION_CONTROL_CONSOLE = 'control.console'; + public const ACTION_CONTROL_START = 'control.start'; + public const ACTION_CONTROL_STOP = 'control.stop'; + public const ACTION_CONTROL_RESTART = 'control.restart'; public const ACTION_DATABASE_READ = 'database.read'; + public const ACTION_DATABASE_CREATE = 'database.create'; + public const ACTION_DATABASE_UPDATE = 'database.update'; + public const ACTION_DATABASE_DELETE = 'database.delete'; + public const ACTION_DATABASE_VIEW_PASSWORD = 'database.view_password'; public const ACTION_SCHEDULE_READ = 'schedule.read'; + public const ACTION_SCHEDULE_CREATE = 'schedule.create'; + public const ACTION_SCHEDULE_UPDATE = 'schedule.update'; + public const ACTION_SCHEDULE_DELETE = 'schedule.delete'; public const ACTION_USER_READ = 'user.read'; + public const ACTION_USER_CREATE = 'user.create'; + public const ACTION_USER_UPDATE = 'user.update'; + public const ACTION_USER_DELETE = 'user.delete'; public const ACTION_BACKUP_READ = 'backup.read'; + public const ACTION_BACKUP_CREATE = 'backup.create'; + public const ACTION_BACKUP_DELETE = 'backup.delete'; + public const ACTION_BACKUP_DOWNLOAD = 'backup.download'; + public const ACTION_BACKUP_RESTORE = 'backup.restore'; public const ACTION_ALLOCATION_READ = 'allocation.read'; + public const ACTION_ALLOCATION_CREATE = 'allocation.create'; + public const ACTION_ALLOCATION_UPDATE = 'allocation.update'; + public const ACTION_ALLOCATION_DELETE = 'allocation.delete'; public const ACTION_FILE_READ = 'file.read'; + public const ACTION_FILE_READ_CONTENT = 'file.read-content'; + public const ACTION_FILE_CREATE = 'file.create'; + public const ACTION_FILE_UPDATE = 'file.update'; + public const ACTION_FILE_DELETE = 'file.delete'; + public const ACTION_FILE_ARCHIVE = 'file.archive'; + public const ACTION_FILE_SFTP = 'file.sftp'; public const ACTION_STARTUP_READ = 'startup.read'; + public const ACTION_STARTUP_UPDATE = 'startup.update'; + public const ACTION_STARTUP_DOCKER_IMAGE = 'startup.docker-image'; public const ACTION_SETTINGS_RENAME = 'settings.rename'; + public const ACTION_SETTINGS_REINSTALL = 'settings.reinstall'; public const ACTION_ACTIVITY_READ = 'activity.read'; diff --git a/app/Models/Server.php b/app/Models/Server.php index 1ace74961..67b719032 100644 --- a/app/Models/Server.php +++ b/app/Models/Server.php @@ -71,6 +71,7 @@ use App\Exceptions\Http\Server\ServerStateConflictException; * @property \App\Models\User $user * @property \Illuminate\Database\Eloquent\Collection|\App\Models\EggVariable[] $variables * @property int|null $variables_count + * * @method static \Database\Factories\ServerFactory factory(...$parameters) * @method static \Illuminate\Database\Eloquent\Builder|Server newModelQuery() * @method static \Illuminate\Database\Eloquent\Builder|Server newQuery() @@ -101,6 +102,7 @@ use App\Exceptions\Http\Server\ServerStateConflictException; * @method static \Illuminate\Database\Eloquent\Builder|Server whereUpdatedAt($value) * @method static \Illuminate\Database\Eloquent\Builder|Server whereUuid($value) * @method static \Illuminate\Database\Eloquent\Builder|Server whereuuid_short($value) + * * @property array|null $docker_labels * @property string|null $ports * @property-read mixed $condition @@ -108,10 +110,12 @@ use App\Exceptions\Http\Server\ServerStateConflictException; * @property-read int|null $egg_variables_count * @property-read \Illuminate\Database\Eloquent\Collection $serverVariables * @property-read int|null $server_variables_count + * * @method static \Illuminate\Database\Eloquent\Builder|Server whereDockerLabels($value) * @method static \Illuminate\Database\Eloquent\Builder|Server whereInstalledAt($value) * @method static \Illuminate\Database\Eloquent\Builder|Server wherePorts($value) * @method static \Illuminate\Database\Eloquent\Builder|Server whereUuidShort($value) + * * @mixin \Eloquent */ class Server extends Model diff --git a/app/Models/Task.php b/app/Models/Task.php index 254d38ece..202a3165a 100644 --- a/app/Models/Task.php +++ b/app/Models/Task.php @@ -31,8 +31,11 @@ class Task extends Model * The default actions that can exist for a task */ public const ACTION_POWER = 'power'; + public const ACTION_COMMAND = 'command'; + public const ACTION_BACKUP = 'backup'; + public const ACTION_DELETE_FILES = 'delete_files'; /** diff --git a/app/Models/User.php b/app/Models/User.php index 45f8ee87c..45545db34 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -99,6 +99,7 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac use Notifiable; public const USER_LEVEL_USER = 0; + public const USER_LEVEL_ADMIN = 1; /** @@ -233,7 +234,7 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac /** * Send the password reset notification. * - * @param string $token + * @param string $token */ public function sendPasswordResetNotification($token): void { diff --git a/app/Repositories/Daemon/DaemonBackupRepository.php b/app/Repositories/Daemon/DaemonBackupRepository.php index ce9e394e5..ff34c2acd 100644 --- a/app/Repositories/Daemon/DaemonBackupRepository.php +++ b/app/Repositories/Daemon/DaemonBackupRepository.php @@ -51,7 +51,7 @@ class DaemonBackupRepository extends DaemonRepository * * @throws \App\Exceptions\Http\Connection\DaemonConnectionException */ - public function restore(Backup $backup, string $url = null, bool $truncate = false): Response + public function restore(Backup $backup, ?string $url = null, bool $truncate = false): Response { Assert::isInstanceOf($this->server, Server::class); diff --git a/app/Repositories/Daemon/DaemonFileRepository.php b/app/Repositories/Daemon/DaemonFileRepository.php index e97261eb1..a65013fb3 100644 --- a/app/Repositories/Daemon/DaemonFileRepository.php +++ b/app/Repositories/Daemon/DaemonFileRepository.php @@ -16,13 +16,13 @@ class DaemonFileRepository extends DaemonRepository /** * Return the contents of a given file. * - * @param int|null $notLargerThan the maximum content length in bytes + * @param int|null $notLargerThan the maximum content length in bytes * * @throws \GuzzleHttp\Exception\TransferException * @throws \App\Exceptions\Http\Server\FileSizeTooLargeException * @throws \App\Exceptions\Http\Connection\DaemonConnectionException */ - public function getContent(string $path, int $notLargerThan = null): string + public function getContent(string $path, ?int $notLargerThan = null): string { Assert::isInstanceOf($this->server, Server::class); diff --git a/app/Rules/Username.php b/app/Rules/Username.php index 591df389c..f888da103 100644 --- a/app/Rules/Username.php +++ b/app/Rules/Username.php @@ -17,8 +17,8 @@ class Username implements Rule * * Allowed characters: a-z0-9_-. * - * @param string $attribute - * @param mixed $value + * @param string $attribute + * @param mixed $value */ public function passes($attribute, $value): bool { diff --git a/app/Services/Acl/Api/AdminAcl.php b/app/Services/Acl/Api/AdminAcl.php index dd58e317c..90ec6480a 100644 --- a/app/Services/Acl/Api/AdminAcl.php +++ b/app/Services/Acl/Api/AdminAcl.php @@ -17,7 +17,9 @@ class AdminAcl * implements a read/write/none permissions scheme for all endpoints. */ public const NONE = 0; + public const READ = 1; + public const WRITE = 2; /** @@ -25,13 +27,21 @@ class AdminAcl * set for each key. These are stored in the database as r_{resource}. */ public const RESOURCE_SERVERS = 'servers'; + public const RESOURCE_NODES = 'nodes'; + public const RESOURCE_ALLOCATIONS = 'allocations'; + public const RESOURCE_USERS = 'users'; + public const RESOURCE_EGGS = 'eggs'; + public const RESOURCE_DATABASE_HOSTS = 'database_hosts'; + public const RESOURCE_SERVER_DATABASES = 'server_databases'; + public const RESOURCE_MOUNTS = 'mounts'; + public const RESOURCE_ROLES = 'roles'; /** diff --git a/app/Services/Activity/ActivityLogBatchService.php b/app/Services/Activity/ActivityLogBatchService.php index cb2e91b5c..df237286f 100644 --- a/app/Services/Activity/ActivityLogBatchService.php +++ b/app/Services/Activity/ActivityLogBatchService.php @@ -7,6 +7,7 @@ use Ramsey\Uuid\Uuid; class ActivityLogBatchService { protected int $transaction = 0; + protected ?string $uuid = null; /** diff --git a/app/Services/Activity/ActivityLogService.php b/app/Services/Activity/ActivityLogService.php index 514791218..7de267a3e 100644 --- a/app/Services/Activity/ActivityLogService.php +++ b/app/Services/Activity/ActivityLogService.php @@ -64,7 +64,7 @@ class ActivityLogService * * @template T extends \Illuminate\Database\Eloquent\Model|\Illuminate\Contracts\Auth\Authenticatable * - * @param T|T[]|null $subjects + * @param T|T[]|null $subjects */ public function subject(...$subjects): self { @@ -100,8 +100,8 @@ class ActivityLogService /** * Sets a custom property on the activity log instance. * - * @param string|array $key - * @param mixed $value + * @param string|array $key + * @param mixed $value */ public function property($key, $value = null): self { @@ -130,7 +130,7 @@ class ActivityLogService * performing this action it will be logged to the disk but will not interrupt * the code flow. */ - public function log(string $description = null): ActivityLog + public function log(?string $description = null): ActivityLog { $activity = $this->getActivity(); diff --git a/app/Services/Allocations/AssignmentService.php b/app/Services/Allocations/AssignmentService.php index 33ed4aa74..23f28e122 100644 --- a/app/Services/Allocations/AssignmentService.php +++ b/app/Services/Allocations/AssignmentService.php @@ -16,10 +16,15 @@ use App\Exceptions\Service\Allocation\TooManyPortsInRangeException; class AssignmentService { public const CIDR_MAX_BITS = 25; + public const CIDR_MIN_BITS = 32; + public const PORT_FLOOR = 1024; + public const PORT_CEIL = 65535; + public const PORT_RANGE_LIMIT = 1000; + public const PORT_RANGE_REGEX = '/^(\d{4,5})-(\d{4,5})$/'; /** @@ -38,7 +43,7 @@ class AssignmentService * @throws \App\Exceptions\Service\Allocation\PortOutOfRangeException * @throws \App\Exceptions\Service\Allocation\TooManyPortsInRangeException */ - public function handle(Node $node, array $data, Server $server = null): array + public function handle(Node $node, array $data, ?Server $server = null): array { $explode = explode('/', $data['allocation_ip']); if (count($explode) !== 1) { diff --git a/app/Services/Backups/InitiateBackupService.php b/app/Services/Backups/InitiateBackupService.php index 447c57535..fa15db88a 100644 --- a/app/Services/Backups/InitiateBackupService.php +++ b/app/Services/Backups/InitiateBackupService.php @@ -43,7 +43,7 @@ class InitiateBackupService /** * Sets the files to be ignored by this backup. * - * @param string[]|null $ignored + * @param string[]|null $ignored */ public function setIgnoredFiles(?array $ignored): self { @@ -70,7 +70,7 @@ class InitiateBackupService * @throws \App\Exceptions\Service\Backup\TooManyBackupsException * @throws \Symfony\Component\HttpKernel\Exception\TooManyRequestsHttpException */ - public function handle(Server $server, string $name = null, bool $override = false): Backup + public function handle(Server $server, ?string $name = null, bool $override = false): Backup { $limit = config('backups.throttles.limit'); $period = config('backups.throttles.period'); diff --git a/app/Services/Eggs/Sharing/EggImporterService.php b/app/Services/Eggs/Sharing/EggImporterService.php index dc54525a6..e539a7f28 100644 --- a/app/Services/Eggs/Sharing/EggImporterService.php +++ b/app/Services/Eggs/Sharing/EggImporterService.php @@ -34,7 +34,7 @@ class EggImporterService * * @throws \App\Exceptions\Service\InvalidFileUploadException|\Throwable */ - public function fromFile(UploadedFile $file, Egg $egg = null): Egg + public function fromFile(UploadedFile $file, ?Egg $egg = null): Egg { $parsed = $this->parseFile($file); @@ -75,7 +75,7 @@ class EggImporterService * * @throws \App\Exceptions\Service\InvalidFileUploadException|\Throwable */ - public function fromUrl(string $url, Egg $egg = null): Egg + public function fromUrl(string $url, ?Egg $egg = null): Egg { $info = pathinfo($url); $tmpDir = TemporaryDirectory::make()->deleteWhenDestroyed(); diff --git a/app/Services/Files/DeleteFilesService.php b/app/Services/Files/DeleteFilesService.php index 2b1be5fda..1692923ed 100644 --- a/app/Services/Files/DeleteFilesService.php +++ b/app/Services/Files/DeleteFilesService.php @@ -19,6 +19,7 @@ class DeleteFilesService /** * Deletes the given files. + * * @throws DaemonConnectionException */ public function handle(Server $server, array $files): void diff --git a/app/Services/Servers/ServerConfigurationStructureService.php b/app/Services/Servers/ServerConfigurationStructureService.php index 43b8c9736..7ac714ed5 100644 --- a/app/Services/Servers/ServerConfigurationStructureService.php +++ b/app/Services/Servers/ServerConfigurationStructureService.php @@ -93,5 +93,4 @@ class ServerConfigurationStructureService return $response; } - } diff --git a/app/Services/Servers/ServerCreationService.php b/app/Services/Servers/ServerCreationService.php index 7fd3e8b67..18eb790e5 100644 --- a/app/Services/Servers/ServerCreationService.php +++ b/app/Services/Servers/ServerCreationService.php @@ -45,7 +45,7 @@ class ServerCreationService * @throws \Illuminate\Validation\ValidationException * @throws \App\Exceptions\Service\Deployment\NoViableAllocationException */ - public function handle(array $data, DeploymentObject $deployment = null): Server + public function handle(array $data, ?DeploymentObject $deployment = null): Server { if (!isset($data['oom_killer']) && isset($data['oom_disabled'])) { $data['oom_killer'] = !$data['oom_disabled']; diff --git a/app/Services/Servers/SuspensionService.php b/app/Services/Servers/SuspensionService.php index 4557fae3d..0209db3fc 100644 --- a/app/Services/Servers/SuspensionService.php +++ b/app/Services/Servers/SuspensionService.php @@ -12,6 +12,7 @@ use Symfony\Component\HttpKernel\Exception\ConflictHttpException; class SuspensionService { public const ACTION_SUSPEND = 'suspend'; + public const ACTION_UNSUSPEND = 'unsuspend'; /** diff --git a/app/Services/Users/ToggleTwoFactorService.php b/app/Services/Users/ToggleTwoFactorService.php index 64518e39b..ca5df2dcb 100644 --- a/app/Services/Users/ToggleTwoFactorService.php +++ b/app/Services/Users/ToggleTwoFactorService.php @@ -30,7 +30,7 @@ class ToggleTwoFactorService * @throws \PragmaRX\Google2FA\Exceptions\SecretKeyTooShortException * @throws \App\Exceptions\Service\User\TwoFactorAuthenticationTokenInvalid */ - public function handle(User $user, string $token, bool $toggleState = null): array + public function handle(User $user, string $token, ?bool $toggleState = null): array { $isValidToken = $this->google2FA->verifyKey($user->totp_secret, $token, config()->get('panel.auth.2fa.window')); diff --git a/app/Traits/EnvironmentWriterTrait.php b/app/Traits/EnvironmentWriterTrait.php index 460d8000e..cb5bef047 100644 --- a/app/Traits/EnvironmentWriterTrait.php +++ b/app/Traits/EnvironmentWriterTrait.php @@ -22,6 +22,7 @@ trait EnvironmentWriterTrait /** * Update the .env file for the application using the passed in values. + * * @throws Exception */ public function writeToEnvironment(array $values = []): void diff --git a/app/Transformers/Api/Application/BaseTransformer.php b/app/Transformers/Api/Application/BaseTransformer.php index 324d0f9d1..ec4bb9d3c 100644 --- a/app/Transformers/Api/Application/BaseTransformer.php +++ b/app/Transformers/Api/Application/BaseTransformer.php @@ -90,8 +90,7 @@ abstract class BaseTransformer extends TransformerAbstract * * @template T of \App\Transformers\Api\Application\BaseTransformer * - * @param class-string $abstract - * + * @param class-string $abstract * @return T * * @throws \App\Exceptions\Transformer\InvalidTransformerLevelException diff --git a/app/Transformers/Api/Client/ActivityLogTransformer.php b/app/Transformers/Api/Client/ActivityLogTransformer.php index 7a60592ae..a54cb1f30 100644 --- a/app/Transformers/Api/Client/ActivityLogTransformer.php +++ b/app/Transformers/Api/Client/ActivityLogTransformer.php @@ -112,7 +112,7 @@ class ActivityLogTransformer extends BaseClientTransformer * Determines if the user can view the IP address in the output either because they are the * actor that performed the action, or because they are an administrator on the Panel. */ - protected function canViewIP(Model $actor = null): bool + protected function canViewIP(?Model $actor = null): bool { return $actor?->is($this->request->user()) || $this->request->user()->isRootAdmin(); } diff --git a/app/Transformers/Api/Client/BaseClientTransformer.php b/app/Transformers/Api/Client/BaseClientTransformer.php index c490d1bfd..9ee56cfaf 100644 --- a/app/Transformers/Api/Client/BaseClientTransformer.php +++ b/app/Transformers/Api/Client/BaseClientTransformer.php @@ -24,7 +24,7 @@ abstract class BaseClientTransformer extends BaseApplicationTransformer * * @noinspection PhpParameterNameChangedDuringInheritanceInspection */ - protected function authorize(string $ability, Server $server = null): bool + protected function authorize(string $ability, ?Server $server = null): bool { Assert::isInstanceOf($server, Server::class); diff --git a/pint.json b/pint.json index 4d7ccf113..99fa80d3a 100644 --- a/pint.json +++ b/pint.json @@ -1,12 +1,8 @@ { "preset": "laravel", "rules": { - "class_attributes_separation": false, "concat_space": false, "not_operator_with_successor_space": false, - "nullable_type_declaration_for_default_null_value": false, - "ordered_imports": false, - "phpdoc_align": false, - "phpdoc_separation": false + "ordered_imports": false } } diff --git a/tests/Assertions/AssertsActivityLogged.php b/tests/Assertions/AssertsActivityLogged.php index db352bc97..23a3461b1 100644 --- a/tests/Assertions/AssertsActivityLogged.php +++ b/tests/Assertions/AssertsActivityLogged.php @@ -11,7 +11,7 @@ use App\Models\ActivityLogSubject; trait AssertsActivityLogged { /** - * @param \Illuminate\Database\Eloquent\Model|array $subjects + * @param \Illuminate\Database\Eloquent\Model|array $subjects */ public function assertActivityFor(string $event, ?Model $actor, ...$subjects): void { diff --git a/tests/Integration/Api/Client/ClientApiIntegrationTestCase.php b/tests/Integration/Api/Client/ClientApiIntegrationTestCase.php index 4fb417408..d6dee00da 100644 --- a/tests/Integration/Api/Client/ClientApiIntegrationTestCase.php +++ b/tests/Integration/Api/Client/ClientApiIntegrationTestCase.php @@ -47,7 +47,7 @@ abstract class ClientApiIntegrationTestCase extends IntegrationTestCase /** * Returns a link to the specific resource using the client API. */ - protected function link(mixed $model, string $append = null): string + protected function link(mixed $model, ?string $append = null): string { switch (get_class($model)) { case Server::class: diff --git a/tests/Integration/Api/Client/Server/PowerControllerTest.php b/tests/Integration/Api/Client/Server/PowerControllerTest.php index 5cadb3772..94d3e7326 100644 --- a/tests/Integration/Api/Client/Server/PowerControllerTest.php +++ b/tests/Integration/Api/Client/Server/PowerControllerTest.php @@ -14,7 +14,7 @@ class PowerControllerTest extends ClientApiIntegrationTestCase * an error in response. This checks against the specific permission needed to send * the command to the server. * - * @param string[] $permissions + * @param string[] $permissions * * @dataProvider invalidPermissionDataProvider */ diff --git a/tests/Integration/Api/Remote/SftpAuthenticationControllerTest.php b/tests/Integration/Api/Remote/SftpAuthenticationControllerTest.php index 031eedce7..3236266dc 100644 --- a/tests/Integration/Api/Remote/SftpAuthenticationControllerTest.php +++ b/tests/Integration/Api/Remote/SftpAuthenticationControllerTest.php @@ -226,7 +226,7 @@ class SftpAuthenticationControllerTest extends IntegrationTestCase /** * Sets the authorization header for the rest of the test. */ - protected function setAuthorization(Node $node = null): void + protected function setAuthorization(?Node $node = null): void { $node = $node ?? $this->server->node; diff --git a/tests/Traits/Http/RequestMockHelpers.php b/tests/Traits/Http/RequestMockHelpers.php index 22f60e74f..46a71e26a 100644 --- a/tests/Traits/Http/RequestMockHelpers.php +++ b/tests/Traits/Http/RequestMockHelpers.php @@ -27,7 +27,7 @@ trait RequestMockHelpers /** * Configure the user model that the request mock should return with. */ - public function setRequestUserModel(User $user = null): void + public function setRequestUserModel(?User $user = null): void { $this->request->shouldReceive('user')->andReturn($user); } @@ -80,7 +80,7 @@ trait RequestMockHelpers * * @deprecated */ - protected function setRequestUser(User $user = null): User + protected function setRequestUser(?User $user = null): User { $user = $user instanceof User ? $user : User::factory()->make(); $this->request->shouldReceive('user')->withNoArgs()->andReturn($user); diff --git a/tests/Traits/Integration/CreatesTestModels.php b/tests/Traits/Integration/CreatesTestModels.php index 12d645934..0e28cb40e 100644 --- a/tests/Traits/Integration/CreatesTestModels.php +++ b/tests/Traits/Integration/CreatesTestModels.php @@ -65,8 +65,7 @@ trait CreatesTestModels * Generates a user and a server for that user. If an array of permissions is passed it * is assumed that the user is actually a subuser of the server. * - * @param string[] $permissions - * + * @param string[] $permissions * @return array{\App\Models\User, \App\Models\Server} */ public function generateTestAccount(array $permissions = []): array