From 5f9ee09ebd3769f3a58184d386488eae21b468db Mon Sep 17 00:00:00 2001 From: MartinOscar <40749467+RMartinOscar@users.noreply.github.com> Date: Mon, 14 Oct 2024 22:13:01 +0200 Subject: [PATCH 01/33] Add yarn timeout & cleanup --- Dockerfile | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8c99bcc252..3dfc99c97c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,7 +7,9 @@ WORKDIR /build COPY . ./ -RUN yarn install --frozen-lockfile && yarn run build:production +RUN yarn config set network-timeout 300000 \ + && yarn install --frozen-lockfile \ + && yarn run build:production FROM php:8.3-fpm-alpine # FROM --platform=$TARGETOS/$TARGETARCH php:8.3-fpm-alpine @@ -36,8 +38,8 @@ RUN touch .env RUN composer install --no-dev --optimize-autoloader # Set file permissions -RUN chmod -R 755 /var/www/html/storage \ - && chmod -R 755 /var/www/html/bootstrap/cache +RUN chmod -R 755 storage \ + && chmod -R 755 bootstrap/cache # Add scheduler to cron RUN echo "* * * * * php /var/www/html/artisan schedule:run >> /dev/null 2>&1" | crontab -u www-data - @@ -49,8 +51,7 @@ RUN cp .github/docker/supervisord.conf /etc/supervisord.conf && \ HEALTHCHECK --interval=5m --timeout=10s --start-period=5s --retries=3 \ CMD curl -f http://localhost/up || exit 1 -EXPOSE 80:2019 -EXPOSE 443 +EXPOSE 80 443 VOLUME /pelican-data From 04b251d1258498b62cb69d72fafea893f0d831a9 Mon Sep 17 00:00:00 2001 From: RMartinOscar <40749467+RMartinOscar@users.noreply.github.com> Date: Mon, 14 Oct 2024 20:51:22 +0000 Subject: [PATCH 02/33] Disable Caddy admin endpoint --- Caddyfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Caddyfile b/Caddyfile index 1c835bf057..e307609598 100644 --- a/Caddyfile +++ b/Caddyfile @@ -1,4 +1,5 @@ { + admin off email {$ADMIN_EMAIL} } From b14f6e1645a480b5c9f0bf1bc1690a615279398e Mon Sep 17 00:00:00 2001 From: MartinOscar <40749467+RMartinOscar@users.noreply.github.com> Date: Mon, 14 Oct 2024 23:05:47 +0200 Subject: [PATCH 03/33] Update Dockerfile --- Dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3dfc99c97c..c759649f16 100644 --- a/Dockerfile +++ b/Dockerfile @@ -38,8 +38,7 @@ RUN touch .env RUN composer install --no-dev --optimize-autoloader # Set file permissions -RUN chmod -R 755 storage \ - && chmod -R 755 bootstrap/cache +RUN chmod -R 755 storage bootstrap/cache # Add scheduler to cron RUN echo "* * * * * php /var/www/html/artisan schedule:run >> /dev/null 2>&1" | crontab -u www-data - From c5c05150d889286a3fddc7352007591a8922bdb0 Mon Sep 17 00:00:00 2001 From: Boy132 Date: Tue, 15 Oct 2024 22:35:59 +0200 Subject: [PATCH 04/33] Remove no longer needed `View::share` (#625) * remove no longer needed `View::share` * hardcode values so the old admin area doesn't break * add todo comment --- app/Providers/AppServiceProvider.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 20a6b0dd51..c2f3b7a9d0 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -7,7 +7,6 @@ use App\Models\ApiKey; use App\Models\Node; use App\Models\User; -use App\Services\Helpers\SoftwareVersionService; use Dedoc\Scramble\Scramble; use Dedoc\Scramble\Support\Generator\OpenApi; use Dedoc\Scramble\Support\Generator\SecurityScheme; @@ -32,9 +31,9 @@ class AppServiceProvider extends ServiceProvider */ public function boot(): void { - $versionData = app(SoftwareVersionService::class)->versionData(); - View::share('appVersion', $versionData['version'] ?? 'undefined'); - View::share('appIsGit', $versionData['is_git'] ?? false); + // TODO: remove when old admin area gets yeeted + View::share('appVersion', config('app.version')); + View::share('appIsGit', false); Paginator::useBootstrap(); From f2063d750684dd7cd2364ad9fed88f33da39a7f4 Mon Sep 17 00:00:00 2001 From: Boy132 Date: Tue, 15 Oct 2024 22:36:35 +0200 Subject: [PATCH 05/33] Follow up installer fixes (#621) * enable installer on docker first run * add SESSION_COOKIE to compose file * `APP_ENVIRONMENT_ONLY` is long gone * session env vars no longer needed after #624 * set defaults to null if sqlite is selected --- .github/docker/entrypoint.sh | 3 +++ .../Pages/Installer/Steps/DatabaseStep.php | 14 +++++++------- compose.yml | 2 -- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.github/docker/entrypoint.sh b/.github/docker/entrypoint.sh index b6aac4daae..9a801e2d94 100644 --- a/.github/docker/entrypoint.sh +++ b/.github/docker/entrypoint.sh @@ -21,6 +21,9 @@ else echo -e "APP_KEY exists in environment, using that." echo -e "APP_KEY=$APP_KEY" > /pelican-data/.env fi + + ## enable installer + echo -e "APP_INSTALLED=false" >> /pelican-data/.env fi mkdir /pelican-data/database diff --git a/app/Filament/Pages/Installer/Steps/DatabaseStep.php b/app/Filament/Pages/Installer/Steps/DatabaseStep.php index 29c47b3290..5a0d6b7368 100644 --- a/app/Filament/Pages/Installer/Steps/DatabaseStep.php +++ b/app/Filament/Pages/Installer/Steps/DatabaseStep.php @@ -30,25 +30,25 @@ public static function make(PanelInstaller $installer): Step ->label('Database Host') ->hintIcon('tabler-question-mark') ->hintIconTooltip('The host of your database. Make sure it is reachable.') - ->required() - ->default(env('DB_HOST', '127.0.0.1')) + ->required(fn (Get $get) => $get('env_general.DB_CONNECTION') !== 'sqlite') + ->default(fn (Get $get) => $get('env_general.DB_CONNECTION') !== 'sqlite' ? env('DB_HOST', '127.0.0.1') : null) ->hidden(fn (Get $get) => $get('env_general.DB_CONNECTION') === 'sqlite'), TextInput::make('env_database.DB_PORT') ->label('Database Port') ->hintIcon('tabler-question-mark') ->hintIconTooltip('The port of your database.') - ->required() + ->required(fn (Get $get) => $get('env_general.DB_CONNECTION') !== 'sqlite') ->numeric() ->minValue(1) ->maxValue(65535) - ->default(env('DB_PORT', 3306)) + ->default(fn (Get $get) => $get('env_general.DB_CONNECTION') !== 'sqlite' ? env('DB_PORT', 3306) : null) ->hidden(fn (Get $get) => $get('env_general.DB_CONNECTION') === 'sqlite'), TextInput::make('env_database.DB_USERNAME') ->label('Database Username') ->hintIcon('tabler-question-mark') ->hintIconTooltip('The name of your database user.') - ->required() - ->default(env('DB_USERNAME', 'pelican')) + ->required(fn (Get $get) => $get('env_general.DB_CONNECTION') !== 'sqlite') + ->default(fn (Get $get) => $get('env_general.DB_CONNECTION') !== 'sqlite' ? env('DB_USERNAME', 'pelican') : null) ->hidden(fn (Get $get) => $get('env_general.DB_CONNECTION') === 'sqlite'), TextInput::make('env_database.DB_PASSWORD') ->label('Database Password') @@ -56,7 +56,7 @@ public static function make(PanelInstaller $installer): Step ->hintIconTooltip('The password of your database user. Can be empty.') ->password() ->revealable() - ->default(env('DB_PASSWORD')) + ->default(fn (Get $get) => $get('env_general.DB_CONNECTION') !== 'sqlite' ? env('DB_PASSWORD') : null) ->hidden(fn (Get $get) => $get('env_general.DB_CONNECTION') === 'sqlite'), ]) ->afterValidation(function (Get $get) use ($installer) { diff --git a/compose.yml b/compose.yml index 23d2f2a397..6dab7145e3 100644 --- a/compose.yml +++ b/compose.yml @@ -5,9 +5,7 @@ x-common: ADMIN_EMAIL: "USEYOUROWNEMAILHERE@example.com" APP_DEBUG: "false" - APP_ENVIRONMENT_ONLY: "false" APP_ENV: "production" - SESSION_DRIVER: "file" mail: &mail-environment From 71116e81ba897ed80bda1ce0f6727f7c49902eb7 Mon Sep 17 00:00:00 2001 From: Boy132 Date: Tue, 15 Oct 2024 22:37:05 +0200 Subject: [PATCH 06/33] Cleanup `.env.example` and configs (#624) * add back some configs to add some defaults * cleanup .env.example --- .env.example | 31 ++----------------------------- config/logging.php | 7 +++++++ config/mail.php | 7 +++++++ config/session.php | 9 +++++++++ 4 files changed, 25 insertions(+), 29 deletions(-) create mode 100644 config/logging.php create mode 100644 config/session.php diff --git a/.env.example b/.env.example index c242132286..f6911efe38 100644 --- a/.env.example +++ b/.env.example @@ -1,34 +1,7 @@ APP_ENV=production APP_DEBUG=false APP_KEY= -APP_TIMEZONE=UTC APP_URL=http://panel.test -APP_LOCALE=en APP_INSTALLED=false - -LOG_CHANNEL=daily -LOG_STACK=single -LOG_DEPRECATIONS_CHANNEL=null -LOG_LEVEL=debug - -DB_CONNECTION=sqlite - -CACHE_STORE=file -QUEUE_CONNECTION=database -SESSION_DRIVER=file - -MAIL_MAILER=log -MAIL_HOST=smtp.example.com -MAIL_PORT=25 -MAIL_USERNAME= -MAIL_PASSWORD= -MAIL_ENCRYPTION=tls -MAIL_FROM_ADDRESS=no-reply@example.com -MAIL_FROM_NAME="Pelican Admin" -# Set this to your domain to prevent it defaulting to 'localhost', causing mail servers such as Gmail to reject your mail -# MAIL_EHLO_DOMAIN=panel.example.com - -SESSION_ENCRYPT=false -SESSION_PATH=/ -SESSION_DOMAIN=null -SESSION_COOKIE=pelican_session +APP_TIMEZONE=UTC +APP_LOCALE=en diff --git a/config/logging.php b/config/logging.php new file mode 100644 index 0000000000..492c0a890c --- /dev/null +++ b/config/logging.php @@ -0,0 +1,7 @@ + env('LOG_CHANNEL', 'daily'), + +]; diff --git a/config/mail.php b/config/mail.php index c6a0657b31..22b1b4e763 100644 --- a/config/mail.php +++ b/config/mail.php @@ -2,6 +2,13 @@ return [ + 'default' => env('MAIL_MAILER', 'log'), + + 'from' => [ + 'address' => env('MAIL_FROM_ADDRESS', 'no-reply@example.com'), + 'name' => env('MAIL_FROM_NAME', 'Pelican Admin'), + ], + 'mailers' => [ 'mailgun' => [ 'transport' => 'mailgun', diff --git a/config/session.php b/config/session.php new file mode 100644 index 0000000000..cf4a46ff83 --- /dev/null +++ b/config/session.php @@ -0,0 +1,9 @@ + env('SESSION_DRIVER', 'file'), + + 'cookie' => env('SESSION_COOKIE', 'pelican_session'), + +]; From f357c9501fd4d158b7f98f4eedc91665749024c7 Mon Sep 17 00:00:00 2001 From: Boy132 Date: Tue, 15 Oct 2024 22:54:06 +0200 Subject: [PATCH 07/33] Auto-check eggs for update (#620) * add command to check eggs for update * add "update" button to ListEggs * fix "unset" * rename class * add confirmation modal to update button --- .../Commands/Egg/CheckEggUpdatesCommand.php | 46 +++++++++++++++++++ app/Console/Kernel.php | 10 ++-- .../Resources/EggResource/Pages/ListEggs.php | 36 ++++++++++++++- 3 files changed, 86 insertions(+), 6 deletions(-) create mode 100644 app/Console/Commands/Egg/CheckEggUpdatesCommand.php diff --git a/app/Console/Commands/Egg/CheckEggUpdatesCommand.php b/app/Console/Commands/Egg/CheckEggUpdatesCommand.php new file mode 100644 index 0000000000..f2d5e589ea --- /dev/null +++ b/app/Console/Commands/Egg/CheckEggUpdatesCommand.php @@ -0,0 +1,46 @@ +update_url)) { + $this->comment("{$egg->name}: Skipping (no update url set)"); + + continue; + } + + $currentJson = json_decode($exporterService->handle($egg->id)); + unset($currentJson->exported_at); + + $updatedJson = json_decode(file_get_contents($egg->update_url)); + unset($updatedJson->exported_at); + + if (md5(json_encode($currentJson)) === md5(json_encode($updatedJson))) { + $this->info("{$egg->name}: Up-to-date"); + cache()->put("eggs.{$egg->uuid}.update", false, now()->addHour()); + } else { + $this->warn("{$egg->name}: Found update"); + cache()->put("eggs.{$egg->uuid}.update", true, now()->addHour()); + } + } catch (Exception $exception) { + $this->error("{$egg->name}: Error ({$exception->getMessage()})"); + } + } + } +} diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 4a9bbee17d..3c2fc96fad 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -2,15 +2,16 @@ namespace App\Console; +use App\Console\Commands\Egg\CheckEggUpdatesCommand; +use App\Console\Commands\Maintenance\CleanServiceBackupFilesCommand; +use App\Console\Commands\Maintenance\PruneImagesCommand; +use App\Console\Commands\Maintenance\PruneOrphanedBackupsCommand; +use App\Console\Commands\Schedule\ProcessRunnableCommand; use App\Jobs\NodeStatistics; use App\Models\ActivityLog; use Illuminate\Console\Scheduling\Schedule; use Illuminate\Database\Console\PruneCommand; use Illuminate\Foundation\Console\Kernel as ConsoleKernel; -use App\Console\Commands\Schedule\ProcessRunnableCommand; -use App\Console\Commands\Maintenance\PruneOrphanedBackupsCommand; -use App\Console\Commands\Maintenance\CleanServiceBackupFilesCommand; -use App\Console\Commands\Maintenance\PruneImagesCommand; class Kernel extends ConsoleKernel { @@ -35,6 +36,7 @@ protected function schedule(Schedule $schedule): void $schedule->command(CleanServiceBackupFilesCommand::class)->daily(); $schedule->command(PruneImagesCommand::class)->daily(); + $schedule->command(CheckEggUpdatesCommand::class)->hourly(); $schedule->job(new NodeStatistics())->everyFiveSeconds()->withoutOverlapping(); diff --git a/app/Filament/Resources/EggResource/Pages/ListEggs.php b/app/Filament/Resources/EggResource/Pages/ListEggs.php index 1a6a3b6509..792eaa1622 100644 --- a/app/Filament/Resources/EggResource/Pages/ListEggs.php +++ b/app/Filament/Resources/EggResource/Pages/ListEggs.php @@ -14,7 +14,7 @@ use Filament\Forms\Components\TextInput; use Filament\Notifications\Notification; use Filament\Resources\Pages\ListRecords; -use Filament\Tables; +use Filament\Tables\Actions\Action; use Filament\Tables\Actions\BulkActionGroup; use Filament\Tables\Actions\DeleteBulkAction; use Filament\Tables\Actions\EditAction; @@ -49,7 +49,7 @@ public function table(Table $table): Table ]) ->actions([ EditAction::make(), - Tables\Actions\Action::make('export') + Action::make('export') ->icon('tabler-download') ->label('Export') ->color('primary') @@ -57,6 +57,38 @@ public function table(Table $table): Table echo $service->handle($egg->id); }, 'egg-' . $egg->getKebabName() . '.json')) ->authorize(fn () => auth()->user()->can('export egg')), + Action::make('update') + ->icon('tabler-cloud-download') + ->label('Update') + ->color('success') + ->requiresConfirmation() + ->modalHeading('Are you sure you want to update this egg?') + ->modalDescription('If you made any changes to the egg they will be overwritten!') + ->modalIconColor('danger') + ->modalSubmitAction(fn (Actions\StaticAction $action) => $action->color('danger')) + ->action(function (Egg $egg) { + try { + app(EggImporterService::class)->fromUrl($egg->update_url, $egg); + cache()->forget("eggs.{$egg->uuid}.update"); + } catch (Exception $exception) { + Notification::make() + ->title('Egg Update failed') + ->body($exception->getMessage()) + ->danger() + ->send(); + + report($exception); + + return; + } + + Notification::make() + ->title('Egg updated') + ->success() + ->send(); + }) + ->authorize(fn () => auth()->user()->can('import egg')) + ->visible(fn (Egg $egg) => cache()->get("eggs.{$egg->uuid}.update", false)), ]) ->bulkActions([ BulkActionGroup::make([ From ff0215afed03323e47c43f76e1797927b508b8b9 Mon Sep 17 00:00:00 2001 From: Boy132 Date: Fri, 18 Oct 2024 08:24:14 +0200 Subject: [PATCH 08/33] Add permission check to delete button on EditServer (#633) --- app/Filament/Resources/ServerResource/Pages/EditServer.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/Filament/Resources/ServerResource/Pages/EditServer.php b/app/Filament/Resources/ServerResource/Pages/EditServer.php index 0fdb603fa7..51a59591d2 100644 --- a/app/Filament/Resources/ServerResource/Pages/EditServer.php +++ b/app/Filament/Resources/ServerResource/Pages/EditServer.php @@ -753,7 +753,8 @@ protected function getHeaderActions(): array resolve(ServerDeletionService::class)->handle($server); return redirect(ListServers::getUrl()); - }), + }) + ->authorize(fn (Server $server) => auth()->user()->can('delete server', $server)), Actions\Action::make('console') ->label('Console') ->icon('tabler-terminal') From 207d875df8d19be0d08a225df593af8c04bf0ff6 Mon Sep 17 00:00:00 2001 From: Boy132 Date: Fri, 18 Oct 2024 08:24:49 +0200 Subject: [PATCH 09/33] Fix default value for dns check on EditNode (#635) --- .../Resources/NodeResource/Pages/EditNode.php | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/app/Filament/Resources/NodeResource/Pages/EditNode.php b/app/Filament/Resources/NodeResource/Pages/EditNode.php index 004c96a205..e2c5f2c324 100644 --- a/app/Filament/Resources/NodeResource/Pages/EditNode.php +++ b/app/Filament/Resources/NodeResource/Pages/EditNode.php @@ -83,7 +83,7 @@ public function form(Forms\Form $form): Forms\Form if (request()->isSecure()) { return ' Your panel is currently secured via an SSL certificate and that means your nodes require one too. - You must use a domain name, because you cannot get SSL certificates for IP Addresses + You must use a domain name, because you cannot get SSL certificates for IP Addresses. '; } @@ -98,7 +98,7 @@ public function form(Forms\Form $form): Forms\Form ->hintColor('danger') ->hint(function ($state) { if (is_ip($state) && request()->isSecure()) { - return 'You cannot connect to an IP Address over SSL'; + return 'You cannot connect to an IP Address over SSL!'; } return ''; @@ -130,11 +130,9 @@ public function form(Forms\Form $form): Forms\Form $set('dns', false); }) ->maxLength(255), - TextInput::make('ip') ->disabled() ->hidden(), - ToggleButtons::make('dns') ->label('DNS Record Check') ->helperText('This lets you know if your DNS record correctly points to an IP Address.') @@ -157,7 +155,6 @@ public function form(Forms\Form $form): Forms\Form 'md' => 1, 'lg' => 1, ]), - TextInput::make('daemon_listen') ->columnSpan([ 'default' => 1, @@ -172,7 +169,6 @@ public function form(Forms\Form $form): Forms\Form ->default(8080) ->required() ->integer(), - TextInput::make('name') ->label('Display Name') ->columnSpan([ @@ -184,7 +180,6 @@ public function form(Forms\Form $form): Forms\Form ->required() ->helperText('This name is for display only and can be changed later.') ->maxLength(100), - ToggleButtons::make('scheme') ->label('Communicate over SSL') ->columnSpan([ @@ -441,6 +436,16 @@ protected function mutateFormDataBeforeFill(array $data): array $data['config'] = $node->getYamlConfiguration(); + if (!is_ip($node->fqdn)) { + $validRecords = gethostbynamel($node->fqdn); + if ($validRecords) { + $data['dns'] = true; + $data['ip'] = collect($validRecords)->first(); + } else { + $data['dns'] = false; + } + } + return $data; } @@ -448,6 +453,7 @@ protected function getFormActions(): array { return []; } + protected function getHeaderActions(): array { return [ @@ -467,6 +473,7 @@ protected function getColumnSpan() { return null; } + protected function getColumnStart() { return null; From 54ea55d42606bbf6564fb160e61254dfb2ee0d28 Mon Sep 17 00:00:00 2001 From: Lance Pioch Date: Sat, 19 Oct 2024 17:22:03 -0400 Subject: [PATCH 10/33] Enforce DI --- .../Commands/Egg/CheckEggUpdatesCommand.php | 5 +-- app/Exceptions/DisplayException.php | 1 + app/Exceptions/Handler.php | 1 + app/Filament/Pages/Dashboard.php | 18 +++++---- .../Pages/Installer/PanelInstaller.php | 4 +- .../Pages/Installer/Steps/AdminUserStep.php | 3 +- .../Pages/CreateDatabaseHost.php | 9 ++++- .../Pages/EditDatabaseHost.php | 9 ++++- .../Resources/EggResource/Pages/EditEgg.php | 5 +-- .../Resources/EggResource/Pages/ListEggs.php | 10 ++--- .../AllocationsRelationManager.php | 2 +- .../ServerResource/Pages/CreateServer.php | 21 ++++++---- .../ServerResource/Pages/EditServer.php | 4 +- .../AllocationsRelationManager.php | 2 +- .../UserResource/Pages/EditProfile.php | 21 +++++----- .../UserResource/Pages/ListUsers.php | 4 +- .../ServersRelationManager.php | 8 ++-- app/Http/Middleware/VerifyReCaptcha.php | 13 ++++--- app/Models/Node.php | 1 + app/PHPStan/ForbiddenGlobalFunctionsRule.php | 38 +++++++++++++++++++ app/Providers/AppServiceProvider.php | 5 ++- app/Traits/CheckMigrationsTrait.php | 2 +- app/Traits/Helpers/AvailableLanguages.php | 1 + .../Api/Application/BaseTransformer.php | 1 + phpstan.neon | 9 ++--- 25 files changed, 128 insertions(+), 69 deletions(-) create mode 100644 app/PHPStan/ForbiddenGlobalFunctionsRule.php diff --git a/app/Console/Commands/Egg/CheckEggUpdatesCommand.php b/app/Console/Commands/Egg/CheckEggUpdatesCommand.php index f2d5e589ea..fa7c83ac0f 100644 --- a/app/Console/Commands/Egg/CheckEggUpdatesCommand.php +++ b/app/Console/Commands/Egg/CheckEggUpdatesCommand.php @@ -11,11 +11,8 @@ class CheckEggUpdatesCommand extends Command { protected $signature = 'p:egg:check-updates'; - public function handle(): void + public function handle(EggExporterService $exporterService): void { - /** @var EggExporterService $exporterService */ - $exporterService = app(EggExporterService::class); - $eggs = Egg::all(); foreach ($eggs as $egg) { try { diff --git a/app/Exceptions/DisplayException.php b/app/Exceptions/DisplayException.php index 6c44c356c1..b5123ebade 100644 --- a/app/Exceptions/DisplayException.php +++ b/app/Exceptions/DisplayException.php @@ -62,6 +62,7 @@ public function render(Request $request) return response()->json(Handler::toArray($this), $this->getStatusCode(), $this->getHeaders()); } + // @phpstan-ignore-next-line app(AlertsMessageBag::class)->danger($this->getMessage())->flash(); return redirect()->back()->withInput(); diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index d30475f668..d30d2ab2c8 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -273,6 +273,7 @@ protected function extractPrevious(\Throwable $e): array */ public static function toArray(\Throwable $e): array { + // @phpstan-ignore-next-line return (new self(app()))->convertExceptionToArray($e); } } diff --git a/app/Filament/Pages/Dashboard.php b/app/Filament/Pages/Dashboard.php index af76c00f54..5415cea799 100644 --- a/app/Filament/Pages/Dashboard.php +++ b/app/Filament/Pages/Dashboard.php @@ -28,16 +28,20 @@ public function getTitle(): string public string $activeTab = 'nodes'; - public function getViewData(): array + private SoftwareVersionService $softwareVersionService; + + public function mount(SoftwareVersionService $softwareVersionService): void { - /** @var SoftwareVersionService $softwareVersionService */ - $softwareVersionService = app(SoftwareVersionService::class); + $this->softwareVersionService = $softwareVersionService; + } + public function getViewData(): array + { return [ 'inDevelopment' => config('app.version') === 'canary', - 'version' => $softwareVersionService->versionData()['version'], - 'latestVersion' => $softwareVersionService->getPanel(), - 'isLatest' => $softwareVersionService->isLatestPanel(), + 'version' => $this->softwareVersionService->versionData()['version'], + 'latestVersion' => $this->softwareVersionService->getPanel(), + 'isLatest' => $this->softwareVersionService->isLatestPanel(), 'eggsCount' => Egg::query()->count(), 'nodesList' => ListNodes::getUrl(), 'nodesCount' => Node::query()->count(), @@ -67,7 +71,7 @@ public function getViewData(): array CreateAction::make() ->label(trans('dashboard/index.sections.intro-support.button_donate')) ->icon('tabler-cash') - ->url($softwareVersionService->getDonations(), true) + ->url($this->softwareVersionService->getDonations(), true) ->color('success'), ], 'helpActions' => [ diff --git a/app/Filament/Pages/Installer/PanelInstaller.php b/app/Filament/Pages/Installer/PanelInstaller.php index 55da7add71..5beab724d6 100644 --- a/app/Filament/Pages/Installer/PanelInstaller.php +++ b/app/Filament/Pages/Installer/PanelInstaller.php @@ -159,12 +159,12 @@ public function runMigrations(string $driver): void } } - public function createAdminUser(): void + public function createAdminUser(UserCreationService $userCreationService): void { try { $userData = array_get($this->data, 'user'); $userData['root_admin'] = true; - $this->user = app(UserCreationService::class)->handle($userData); + $this->user = $userCreationService->handle($userData); } catch (Exception $exception) { report($exception); diff --git a/app/Filament/Pages/Installer/Steps/AdminUserStep.php b/app/Filament/Pages/Installer/Steps/AdminUserStep.php index f5c2a19b34..5bdfe38d94 100644 --- a/app/Filament/Pages/Installer/Steps/AdminUserStep.php +++ b/app/Filament/Pages/Installer/Steps/AdminUserStep.php @@ -3,6 +3,7 @@ namespace App\Filament\Pages\Installer\Steps; use App\Filament\Pages\Installer\PanelInstaller; +use App\Services\Users\UserCreationService; use Filament\Forms\Components\TextInput; use Filament\Forms\Components\Wizard\Step; @@ -28,6 +29,6 @@ public static function make(PanelInstaller $installer): Step ->password() ->revealable(), ]) - ->afterValidation(fn () => $installer->createAdminUser()); + ->afterValidation(fn (UserCreationService $service) => $installer->createAdminUser($service)); } } diff --git a/app/Filament/Resources/DatabaseHostResource/Pages/CreateDatabaseHost.php b/app/Filament/Resources/DatabaseHostResource/Pages/CreateDatabaseHost.php index d3e07bcb93..9817a75379 100644 --- a/app/Filament/Resources/DatabaseHostResource/Pages/CreateDatabaseHost.php +++ b/app/Filament/Resources/DatabaseHostResource/Pages/CreateDatabaseHost.php @@ -16,6 +16,8 @@ class CreateDatabaseHost extends CreateRecord { + private HostCreationService $service; + protected static string $resource = DatabaseHostResource::class; protected ?string $heading = 'Database Hosts'; @@ -24,6 +26,11 @@ class CreateDatabaseHost extends CreateRecord protected ?string $subheading = '(database servers that can have individual databases)'; + public function boot(HostCreationService $service) + { + $this->service = $service; + } + public function form(Form $form): Form { return $form @@ -94,7 +101,7 @@ protected function getFormActions(): array protected function handleRecordCreation(array $data): Model { - return resolve(HostCreationService::class)->handle($data); + return $this->service->handle($data); } public function exception($e, $stopPropagation): void diff --git a/app/Filament/Resources/DatabaseHostResource/Pages/EditDatabaseHost.php b/app/Filament/Resources/DatabaseHostResource/Pages/EditDatabaseHost.php index 862c33b8cb..de802ae654 100644 --- a/app/Filament/Resources/DatabaseHostResource/Pages/EditDatabaseHost.php +++ b/app/Filament/Resources/DatabaseHostResource/Pages/EditDatabaseHost.php @@ -21,6 +21,13 @@ class EditDatabaseHost extends EditRecord { protected static string $resource = DatabaseHostResource::class; + private HostUpdateService $hostUpdateService; + + public function boot(HostUpdateService $hostUpdateService) + { + $this->hostUpdateService = $hostUpdateService; + } + public function form(Form $form): Form { return $form @@ -99,7 +106,7 @@ public function getRelationManagers(): array protected function handleRecordUpdate($record, array $data): Model { - return resolve(HostUpdateService::class)->handle($record->id, $data); + return $this->hostUpdateService->handle($record->id, $data); } public function exception($e, $stopPropagation): void diff --git a/app/Filament/Resources/EggResource/Pages/EditEgg.php b/app/Filament/Resources/EggResource/Pages/EditEgg.php index d1d59c0640..28a09103c0 100644 --- a/app/Filament/Resources/EggResource/Pages/EditEgg.php +++ b/app/Filament/Resources/EggResource/Pages/EditEgg.php @@ -280,10 +280,7 @@ protected function getHeaderActions(): array ->contained(false), ]) - ->action(function (array $data, Egg $egg): void { - /** @var EggImporterService $eggImportService */ - $eggImportService = resolve(EggImporterService::class); - + ->action(function (array $data, Egg $egg, EggImporterService $eggImportService): void { if (!empty($data['egg'])) { try { $eggImportService->fromFile($data['egg'], $egg); diff --git a/app/Filament/Resources/EggResource/Pages/ListEggs.php b/app/Filament/Resources/EggResource/Pages/ListEggs.php index 792eaa1622..98132fedc5 100644 --- a/app/Filament/Resources/EggResource/Pages/ListEggs.php +++ b/app/Filament/Resources/EggResource/Pages/ListEggs.php @@ -66,9 +66,10 @@ public function table(Table $table): Table ->modalDescription('If you made any changes to the egg they will be overwritten!') ->modalIconColor('danger') ->modalSubmitAction(fn (Actions\StaticAction $action) => $action->color('danger')) - ->action(function (Egg $egg) { + ->action(function (Egg $egg, EggImporterService $eggImporterService) { try { - app(EggImporterService::class)->fromUrl($egg->update_url, $egg); + $eggImporterService->fromUrl($egg->update_url, $egg); + cache()->forget("eggs.{$egg->uuid}.update"); } catch (Exception $exception) { Notification::make() @@ -129,10 +130,7 @@ protected function getHeaderActions(): array ->contained(false), ]) - ->action(function (array $data): void { - /** @var EggImporterService $eggImportService */ - $eggImportService = resolve(EggImporterService::class); - + ->action(function (array $data, EggImporterService $eggImportService): void { if (!empty($data['egg'])) { /** @var TemporaryUploadedFile[] $eggFile */ $eggFile = $data['egg']; diff --git a/app/Filament/Resources/NodeResource/RelationManagers/AllocationsRelationManager.php b/app/Filament/Resources/NodeResource/RelationManagers/AllocationsRelationManager.php index 01cc5e50e5..5cdf2b1721 100644 --- a/app/Filament/Resources/NodeResource/RelationManagers/AllocationsRelationManager.php +++ b/app/Filament/Resources/NodeResource/RelationManagers/AllocationsRelationManager.php @@ -148,7 +148,7 @@ public function table(Table $table): Table ->splitKeys(['Tab', ' ', ',']) ->required(), ]) - ->action(fn (array $data) => resolve(AssignmentService::class)->handle($this->getOwnerRecord(), $data)), + ->action(fn (array $data, AssignmentService $service) => $service->handle($this->getOwnerRecord(), $data)), ]) ->bulkActions([ BulkActionGroup::make([ diff --git a/app/Filament/Resources/ServerResource/Pages/CreateServer.php b/app/Filament/Resources/ServerResource/Pages/CreateServer.php index c1f6aa22e6..c914f1201c 100644 --- a/app/Filament/Resources/ServerResource/Pages/CreateServer.php +++ b/app/Filament/Resources/ServerResource/Pages/CreateServer.php @@ -49,6 +49,13 @@ class CreateServer extends CreateRecord public ?Node $node = null; + private ServerCreationService $serverCreationService; + + public function boot(ServerCreationService $serverCreationService) + { + $this->serverCreationService = $serverCreationService; + } + public function form(Form $form): Form { return $form @@ -118,8 +125,9 @@ public function form(Form $form): Form ->hintIconTooltip('Providing a user password is optional. New user email will prompt users to create a password the first time they login.') ->password(), ]) - ->createOptionUsing(function ($data) { - resolve(UserCreationService::class)->handle($data); + ->createOptionUsing(function ($data, UserCreationService $service) { + $service->handle($data); + $this->refreshForm(); }) ->required(), @@ -262,9 +270,9 @@ public function form(Form $form): Form ->splitKeys(['Tab', ' ', ',']) ->required(), ]) - ->createOptionUsing(function (array $data, Get $get): int { + ->createOptionUsing(function (array $data, Get $get, AssignmentService $assignmentService): int { return collect( - resolve(AssignmentService::class)->handle(Node::find($get('node_id')), $data) + $assignmentService->handle(Node::find($get('node_id')), $data) )->first(); }) ->required(), @@ -825,10 +833,7 @@ protected function handleRecordCreation(array $data): Model { $data['allocation_additional'] = collect($data['allocation_additional'])->filter()->all(); - /** @var ServerCreationService $service */ - $service = resolve(ServerCreationService::class); - - return $service->handle($data); + return $this->serverCreationService->handle($data); } private function shouldHideComponent(Get $get, Component $component): bool diff --git a/app/Filament/Resources/ServerResource/Pages/EditServer.php b/app/Filament/Resources/ServerResource/Pages/EditServer.php index 51a59591d2..92f3e778f2 100644 --- a/app/Filament/Resources/ServerResource/Pages/EditServer.php +++ b/app/Filament/Resources/ServerResource/Pages/EditServer.php @@ -749,8 +749,8 @@ protected function getHeaderActions(): array ->color('danger') ->label('Delete') ->requiresConfirmation() - ->action(function (Server $server) { - resolve(ServerDeletionService::class)->handle($server); + ->action(function (Server $server, ServerDeletionService $service) { + $service->handle($server); return redirect(ListServers::getUrl()); }) diff --git a/app/Filament/Resources/ServerResource/RelationManagers/AllocationsRelationManager.php b/app/Filament/Resources/ServerResource/RelationManagers/AllocationsRelationManager.php index 2060c127f3..aa6658b4d3 100644 --- a/app/Filament/Resources/ServerResource/RelationManagers/AllocationsRelationManager.php +++ b/app/Filament/Resources/ServerResource/RelationManagers/AllocationsRelationManager.php @@ -144,7 +144,7 @@ public function table(Table $table): Table ->splitKeys(['Tab', ' ', ',']) ->required(), ]) - ->action(fn (array $data) => resolve(AssignmentService::class)->handle($this->getOwnerRecord()->node, $data, $this->getOwnerRecord())), + ->action(fn (array $data, AssignmentService $service) => $service->handle($this->getOwnerRecord()->node, $data, $this->getOwnerRecord())), AssociateAction::make() ->multiple() ->associateAnother(false) diff --git a/app/Filament/Resources/UserResource/Pages/EditProfile.php b/app/Filament/Resources/UserResource/Pages/EditProfile.php index f5c5f5828d..c571301aef 100644 --- a/app/Filament/Resources/UserResource/Pages/EditProfile.php +++ b/app/Filament/Resources/UserResource/Pages/EditProfile.php @@ -38,6 +38,13 @@ */ class EditProfile extends \Filament\Pages\Auth\EditProfile { + private ToggleTwoFactorService $toggleTwoFactorService; + + public function boot(ToggleTwoFactorService $toggleTwoFactorService): void + { + $this->toggleTwoFactorService = $toggleTwoFactorService; + } + protected function getForms(): array { return [ @@ -106,7 +113,7 @@ protected function getForms(): array Tab::make('2FA') ->icon('tabler-shield-lock') - ->schema(function () { + ->schema(function (TwoFactorSetupService $setupService) { if ($this->getUser()->use_totp) { return [ Placeholder::make('2fa-already-enabled') @@ -124,8 +131,6 @@ protected function getForms(): array ->helperText('Enter your current 2FA code to disable Two Factor Authentication'), ]; } - /** @var TwoFactorSetupService */ - $setupService = app(TwoFactorSetupService::class); ['image_url_data' => $url, 'secret' => $secret] = cache()->remember( "users.{$this->getUser()->id}.2fa.state", @@ -277,20 +282,14 @@ protected function getForms(): array protected function handleRecordUpdate($record, $data): Model { if ($token = $data['2facode'] ?? null) { - /** @var ToggleTwoFactorService $service */ - $service = resolve(ToggleTwoFactorService::class); - - $tokens = $service->handle($record, $token, true); + $tokens = $this->toggleTwoFactorService->handle($record, $token, true); cache()->set("users.$record->id.2fa.tokens", implode("\n", $tokens), now()->addSeconds(15)); $this->redirectRoute('filament.admin.auth.profile', ['tab' => '-2fa-tab']); } if ($token = $data['2fa-disable-code'] ?? null) { - /** @var ToggleTwoFactorService $service */ - $service = resolve(ToggleTwoFactorService::class); - - $service->handle($record, $token, false); + $this->toggleTwoFactorService->handle($record, $token, false); cache()->forget("users.$record->id.2fa.state"); } diff --git a/app/Filament/Resources/UserResource/Pages/ListUsers.php b/app/Filament/Resources/UserResource/Pages/ListUsers.php index 3d9a1af185..9f12d8a77e 100644 --- a/app/Filament/Resources/UserResource/Pages/ListUsers.php +++ b/app/Filament/Resources/UserResource/Pages/ListUsers.php @@ -110,13 +110,11 @@ protected function getHeaderActions(): array ]), ]) ->successRedirectUrl(route('filament.admin.resources.users.index')) - ->action(function (array $data) { + ->action(function (array $data, UserCreationService $creationService) { $roles = $data['roles']; $roles = collect($roles)->map(fn ($role) => Role::findById($role)); unset($data['roles']); - /** @var UserCreationService $creationService */ - $creationService = resolve(UserCreationService::class); $user = $creationService->handle($data); $user->syncRoles($roles); diff --git a/app/Filament/Resources/UserResource/RelationManagers/ServersRelationManager.php b/app/Filament/Resources/UserResource/RelationManagers/ServersRelationManager.php index 98c69ba185..01a73c3738 100644 --- a/app/Filament/Resources/UserResource/RelationManagers/ServersRelationManager.php +++ b/app/Filament/Resources/UserResource/RelationManagers/ServersRelationManager.php @@ -32,18 +32,18 @@ public function table(Table $table): Table ) ->label('Suspend All Servers') ->color('warning') - ->action(function () use ($user) { + ->action(function (SuspensionService $suspensionService) use ($user) { foreach ($user->servers()->whereNot('status', ServerState::Suspended)->get() as $server) { - resolve(SuspensionService::class)->toggle($server); + $suspensionService->toggle($server); } }), Actions\Action::make('toggleUnsuspend') ->hidden(fn () => $user->servers()->where('status', ServerState::Suspended)->count() === 0) ->label('Unsuspend All Servers') ->color('primary') - ->action(function () use ($user) { + ->action(function (SuspensionService $suspensionService) use ($user) { foreach ($user->servers()->where('status', ServerState::Suspended)->get() as $server) { - resolve(SuspensionService::class)->toggle($server, SuspensionService::ACTION_UNSUSPEND); + $suspensionService->toggle($server, SuspensionService::ACTION_UNSUSPEND); } }), ]) diff --git a/app/Http/Middleware/VerifyReCaptcha.php b/app/Http/Middleware/VerifyReCaptcha.php index bfe09ce984..4ba454ce4c 100644 --- a/app/Http/Middleware/VerifyReCaptcha.php +++ b/app/Http/Middleware/VerifyReCaptcha.php @@ -3,23 +3,26 @@ namespace App\Http\Middleware; use GuzzleHttp\Client; +use Illuminate\Foundation\Application; use Illuminate\Http\Request; use Illuminate\Http\Response; use App\Events\Auth\FailedCaptcha; use Symfony\Component\HttpKernel\Exception\HttpException; -class VerifyReCaptcha +readonly class VerifyReCaptcha { - /** - * Handle an incoming request. - */ + public function __construct(private Application $app) + { + + } + public function handle(Request $request, \Closure $next): mixed { if (!config('recaptcha.enabled')) { return $next($request); } - if (app()->isLocal()) { + if ($this->app->isLocal()) { return $next($request); } diff --git a/app/Models/Node.php b/app/Models/Node.php index 0a9613196d..6cee145d24 100644 --- a/app/Models/Node.php +++ b/app/Models/Node.php @@ -294,6 +294,7 @@ public function systemInformation(): array { return once(function () { try { + // @phpstan-ignore-next-line return resolve(DaemonConfigurationRepository::class) ->setNode($this) ->getSystemInformation(connectTimeout: 3); diff --git a/app/PHPStan/ForbiddenGlobalFunctionsRule.php b/app/PHPStan/ForbiddenGlobalFunctionsRule.php new file mode 100644 index 0000000000..545cc60fb7 --- /dev/null +++ b/app/PHPStan/ForbiddenGlobalFunctionsRule.php @@ -0,0 +1,38 @@ +forbiddenFunctions = $forbiddenFunctions; + } + + public function getNodeType(): string + { + return FuncCall::class; + } + + public function processNode(Node $node, Scope $scope): array + { + /** @var FuncCall $node */ + if ($node->name instanceof Node\Name) { + $functionName = (string) $node->name; + if (in_array($functionName, $this->forbiddenFunctions, true)) { + return [ + sprintf('Usage of global function "%s" is forbidden.', $functionName), + ]; + } + } + + return []; + } +} diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index c2f3b7a9d0..4ead65cbbd 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -13,6 +13,7 @@ use Filament\Support\Colors\Color; use Filament\Support\Facades\FilamentColor; use Illuminate\Database\Eloquent\Relations\Relation; +use Illuminate\Foundation\Application; use Illuminate\Pagination\Paginator; use Illuminate\Support\Facades\Broadcast; use Illuminate\Support\Facades\Event; @@ -29,7 +30,7 @@ class AppServiceProvider extends ServiceProvider /** * Bootstrap any application services. */ - public function boot(): void + public function boot(Application $app): void { // TODO: remove when old admin area gets yeeted View::share('appVersion', config('app.version')); @@ -64,7 +65,7 @@ public function boot(): void ->asJson() ->withToken($node->daemon_token) ->withHeaders($headers) - ->withOptions(['verify' => (bool) app()->environment('production')]) + ->withOptions(['verify' => (bool) $app->environment('production')]) ->timeout(config('panel.guzzle.timeout')) ->connectTimeout(config('panel.guzzle.connect_timeout')) ->baseUrl($node->getConnectionAddress()) diff --git a/app/Traits/CheckMigrationsTrait.php b/app/Traits/CheckMigrationsTrait.php index ee2de8f3a8..1f849e8aa9 100644 --- a/app/Traits/CheckMigrationsTrait.php +++ b/app/Traits/CheckMigrationsTrait.php @@ -12,7 +12,7 @@ trait CheckMigrationsTrait protected function hasCompletedMigrations(): bool { /** @var Migrator $migrator */ - $migrator = app()->make('migrator'); + $migrator = app()->make('migrator'); // @phpstan-ignore-line $files = $migrator->getMigrationFiles(database_path('migrations')); diff --git a/app/Traits/Helpers/AvailableLanguages.php b/app/Traits/Helpers/AvailableLanguages.php index 53b45c5a60..aafffbbab1 100644 --- a/app/Traits/Helpers/AvailableLanguages.php +++ b/app/Traits/Helpers/AvailableLanguages.php @@ -51,6 +51,7 @@ public function isLanguageTranslated(string $countryCode = 'en'): bool */ private function getFilesystemInstance(): Filesystem { + // @phpstan-ignore-next-line return $this->filesystem = $this->filesystem ?: app()->make(Filesystem::class); } } diff --git a/app/Transformers/Api/Application/BaseTransformer.php b/app/Transformers/Api/Application/BaseTransformer.php index 62ee4ceeb6..324d0f9d1f 100644 --- a/app/Transformers/Api/Application/BaseTransformer.php +++ b/app/Transformers/Api/Application/BaseTransformer.php @@ -54,6 +54,7 @@ public function setRequest(Request $request): self */ public static function fromRequest(Request $request): self { + // @phpstan-ignore-next-line return app(static::class)->setRequest($request); } diff --git a/phpstan.neon b/phpstan.neon index 58b6c8e913..36efb8e7a1 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,6 +1,9 @@ includes: - vendor/larastan/larastan/extension.neon +rules: + - App\PHPStan\ForbiddenGlobalFunctionsRule + parameters: paths: @@ -13,8 +16,4 @@ parameters: # Prologue\Alerts defines its methods from its configuration file dynamically - '#^Call to an undefined method Prologue\\Alerts\\AlertsMessageBag::(danger|success|info|warning)\(\)\.$#' -# excludePaths: -# - ./*/*/FileToBeExcluded.php -# -# checkMissingIterableValueType: false - + # checkMissingIterableValueType: false From 75e89b2d4c61c9ae730e57c129766e59012f926e Mon Sep 17 00:00:00 2001 From: Lance Pioch Date: Sat, 19 Oct 2024 17:25:02 -0400 Subject: [PATCH 11/33] Prevent double ci checks --- .github/workflows/ci.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 5e2ee88471..f5fede50b7 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -3,10 +3,8 @@ name: Tests on: push: branches: - - '**' + - main pull_request: - branches: - - '**' jobs: mysql: From c0a41acf1f1c9f415afca82e8f9c317df32bd7c8 Mon Sep 17 00:00:00 2001 From: Lance Pioch Date: Sat, 19 Oct 2024 18:29:44 -0400 Subject: [PATCH 12/33] Add class_attributes_separation --- app/Exceptions/DisplayException.php | 3 ++ .../TwoFactorAuthenticationTokenInvalid.php | 1 + app/Extensions/DynamicDatabaseConnection.php | 2 ++ app/Filament/Pages/Settings.php | 1 + app/Filament/Resources/ApiKeyResource.php | 3 ++ .../Resources/DatabaseHostResource.php | 1 + .../DatabasesRelationManager.php | 1 + app/Filament/Resources/DatabaseResource.php | 1 + .../Resources/EggResource/Pages/CreateEgg.php | 1 + .../Resources/EggResource/Pages/ListEggs.php | 1 + app/Filament/Resources/MountResource.php | 1 + .../MountResource/Pages/EditMount.php | 1 + .../MountResource/Pages/ListMounts.php | 2 ++ .../NodeResource/Widgets/NodeCpuChart.php | 1 + .../NodeResource/Widgets/NodeMemoryChart.php | 1 + .../NodeResource/Widgets/NodeStorageChart.php | 2 ++ .../ServerResource/Pages/CreateServer.php | 1 + .../ServerResource/Pages/EditServer.php | 2 ++ .../ServerResource/Pages/ListServers.php | 1 + .../Resources/UserResource/Pages/EditUser.php | 2 ++ .../UserResource/Pages/ListUsers.php | 1 + .../Admin/Nodes/NodeViewController.php | 1 + .../RequireTwoFactorAuthentication.php | 2 ++ app/Jobs/NodeStatistics.php | 1 - app/Livewire/NodeSystemInformation.php | 1 + app/Models/ActivityLogSubject.php | 1 + app/Models/ApiKey.php | 7 +++++ app/Models/Backup.php | 1 + app/Models/Egg.php | 1 + app/Models/Node.php | 3 ++ app/Models/Objects/DeploymentObject.php | 1 - app/Models/Permission.php | 30 +++++++++++++++++++ app/Models/Task.php | 3 ++ app/Models/User.php | 1 + app/Services/Acl/Api/AdminAcl.php | 10 +++++++ .../Activity/ActivityLogBatchService.php | 1 + .../Allocations/AssignmentService.php | 5 ++++ .../ServerConfigurationStructureService.php | 1 - app/Services/Servers/SuspensionService.php | 1 + pint.json | 1 - 40 files changed, 98 insertions(+), 4 deletions(-) diff --git a/app/Exceptions/DisplayException.php b/app/Exceptions/DisplayException.php index 6c44c356c1..025c45fe59 100644 --- a/app/Exceptions/DisplayException.php +++ b/app/Exceptions/DisplayException.php @@ -14,8 +14,11 @@ 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/Service/User/TwoFactorAuthenticationTokenInvalid.php b/app/Exceptions/Service/User/TwoFactorAuthenticationTokenInvalid.php index d5f09884c4..0c058d0d86 100644 --- a/app/Exceptions/Service/User/TwoFactorAuthenticationTokenInvalid.php +++ b/app/Exceptions/Service/User/TwoFactorAuthenticationTokenInvalid.php @@ -7,6 +7,7 @@ class TwoFactorAuthenticationTokenInvalid extends DisplayException { public string $title = 'Invalid 2FA Code'; + public string $icon = 'tabler-2fa'; public function __construct() diff --git a/app/Extensions/DynamicDatabaseConnection.php b/app/Extensions/DynamicDatabaseConnection.php index d144074273..147f78064e 100644 --- a/app/Extensions/DynamicDatabaseConnection.php +++ b/app/Extensions/DynamicDatabaseConnection.php @@ -7,7 +7,9 @@ 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 f3ef2c2b9a..f8d18a01c2 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 ba2a851cac..11ebc6813d 100644 --- a/app/Filament/Resources/ApiKeyResource.php +++ b/app/Filament/Resources/ApiKeyResource.php @@ -9,8 +9,11 @@ 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 7576fbc3a8..790895983a 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 4dfcdd955b..13b32602f8 100644 --- a/app/Filament/Resources/DatabaseHostResource/RelationManagers/DatabasesRelationManager.php +++ b/app/Filament/Resources/DatabaseHostResource/RelationManagers/DatabasesRelationManager.php @@ -40,6 +40,7 @@ public function form(Form $form): Form ->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 92580dfdff..912f6fe939 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 a663540cb5..4ec91ea24c 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 792eaa1622..a7f84b2749 100644 --- a/app/Filament/Resources/EggResource/Pages/ListEggs.php +++ b/app/Filament/Resources/EggResource/Pages/ListEggs.php @@ -97,6 +97,7 @@ public function table(Table $table): Table ]), ]); } + protected function getHeaderActions(): array { return [ diff --git a/app/Filament/Resources/MountResource.php b/app/Filament/Resources/MountResource.php index a2d7a187e3..a30f586e1a 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 71c6febb5c..e44fb581b4 100644 --- a/app/Filament/Resources/MountResource/Pages/EditMount.php +++ b/app/Filament/Resources/MountResource/Pages/EditMount.php @@ -96,6 +96,7 @@ public function form(Form $form): Form '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 d39c5d972d..10bfbc6dd0 100644 --- a/app/Filament/Resources/MountResource/Pages/ListMounts.php +++ b/app/Filament/Resources/MountResource/Pages/ListMounts.php @@ -17,6 +17,7 @@ class ListMounts extends ListRecords { protected static string $resource = MountResource::class; + public function table(Table $table): Table { return $table @@ -56,6 +57,7 @@ public function table(Table $table): Table ->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 476b8b5336..89d1cb254f 100644 --- a/app/Filament/Resources/NodeResource/Widgets/NodeCpuChart.php +++ b/app/Filament/Resources/NodeResource/Widgets/NodeCpuChart.php @@ -12,6 +12,7 @@ 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 9d75fd1167..0cabbed517 100644 --- a/app/Filament/Resources/NodeResource/Widgets/NodeMemoryChart.php +++ b/app/Filament/Resources/NodeResource/Widgets/NodeMemoryChart.php @@ -12,6 +12,7 @@ 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 b841d84ef0..61db8c98d0 100644 --- a/app/Filament/Resources/NodeResource/Widgets/NodeStorageChart.php +++ b/app/Filament/Resources/NodeResource/Widgets/NodeStorageChart.php @@ -9,7 +9,9 @@ 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 c1f6aa22e6..b8ac8a5209 100644 --- a/app/Filament/Resources/ServerResource/Pages/CreateServer.php +++ b/app/Filament/Resources/ServerResource/Pages/CreateServer.php @@ -45,6 +45,7 @@ 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 51a59591d2..267fd998f1 100644 --- a/app/Filament/Resources/ServerResource/Pages/EditServer.php +++ b/app/Filament/Resources/ServerResource/Pages/EditServer.php @@ -741,6 +741,7 @@ protected function transferServer(Form $form): Form ]); } + protected function getHeaderActions(): array { return [ @@ -763,6 +764,7 @@ protected function getHeaderActions(): array ]; } + protected function getFormActions(): array { return []; diff --git a/app/Filament/Resources/ServerResource/Pages/ListServers.php b/app/Filament/Resources/ServerResource/Pages/ListServers.php index 326499898a..dd6fc4a16a 100644 --- a/app/Filament/Resources/ServerResource/Pages/ListServers.php +++ b/app/Filament/Resources/ServerResource/Pages/ListServers.php @@ -96,6 +96,7 @@ public function table(Table $table): Table ->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 777f20d730..3fa6a55712 100644 --- a/app/Filament/Resources/UserResource/Pages/EditUser.php +++ b/app/Filament/Resources/UserResource/Pages/EditUser.php @@ -18,6 +18,7 @@ class EditUser extends EditRecord { protected static string $resource = UserResource::class; + public function form(Form $form): Form { return $form @@ -46,6 +47,7 @@ public function form(Form $form): Form ])->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 3d9a1af185..c386d4ce61 100644 --- a/app/Filament/Resources/UserResource/Pages/ListUsers.php +++ b/app/Filament/Resources/UserResource/Pages/ListUsers.php @@ -78,6 +78,7 @@ public function table(Table $table): Table ]), ]); } + protected function getHeaderActions(): array { return [ diff --git a/app/Http/Controllers/Admin/Nodes/NodeViewController.php b/app/Http/Controllers/Admin/Nodes/NodeViewController.php index 95dc7ede0a..115b7b6b1d 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/Middleware/RequireTwoFactorAuthentication.php b/app/Http/Middleware/RequireTwoFactorAuthentication.php index 470cc73b30..58ff1564d6 100644 --- a/app/Http/Middleware/RequireTwoFactorAuthentication.php +++ b/app/Http/Middleware/RequireTwoFactorAuthentication.php @@ -10,7 +10,9 @@ class RequireTwoFactorAuthentication { public const LEVEL_NONE = 0; + public const LEVEL_ADMIN = 1; + public const LEVEL_ALL = 2; /** diff --git a/app/Jobs/NodeStatistics.php b/app/Jobs/NodeStatistics.php index 19fae9b9db..9546f0ba0d 100644 --- a/app/Jobs/NodeStatistics.php +++ b/app/Jobs/NodeStatistics.php @@ -42,5 +42,4 @@ public function handle(): void } } } - } diff --git a/app/Livewire/NodeSystemInformation.php b/app/Livewire/NodeSystemInformation.php index b291902510..4f2a5de0a6 100644 --- a/app/Livewire/NodeSystemInformation.php +++ b/app/Livewire/NodeSystemInformation.php @@ -8,6 +8,7 @@ class NodeSystemInformation extends Component { public Node $node; + public string $sizeClasses; public function render() diff --git a/app/Models/ActivityLogSubject.php b/app/Models/ActivityLogSubject.php index 037d344f05..b4b31e58ff 100644 --- a/app/Models/ActivityLogSubject.php +++ b/app/Models/ActivityLogSubject.php @@ -25,6 +25,7 @@ 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 52d78a97bb..96c714f246 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 3f2a931d1e..d6e4be65a2 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 e8c672064f..001be85e3f 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/Node.php b/app/Models/Node.php index 0a9613196d..da54160913 100644 --- a/app/Models/Node.php +++ b/app/Models/Node.php @@ -53,6 +53,7 @@ class Node extends Model public const RESOURCE_NAME = 'node'; public const DAEMON_TOKEN_ID_LENGTH = 16; + public const DAEMON_TOKEN_LENGTH = 64; /** @@ -135,7 +136,9 @@ protected function casts(): array } 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 b7a4ebaf3f..692ca74873 100644 --- a/app/Models/Objects/DeploymentObject.php +++ b/app/Models/Objects/DeploymentObject.php @@ -45,5 +45,4 @@ public function setTags(array $tags): self return $this; } - } diff --git a/app/Models/Permission.php b/app/Models/Permission.php index ab9fef2607..29cbd826d3 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/Task.php b/app/Models/Task.php index 254d38ece8..202a3165ab 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 395f4994fa..3b4eff193f 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; /** diff --git a/app/Services/Acl/Api/AdminAcl.php b/app/Services/Acl/Api/AdminAcl.php index dd58e317c6..90ec6480ae 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 cb2e91b5c4..df237286fb 100644 --- a/app/Services/Activity/ActivityLogBatchService.php +++ b/app/Services/Activity/ActivityLogBatchService.php @@ -7,6 +7,7 @@ class ActivityLogBatchService { protected int $transaction = 0; + protected ?string $uuid = null; /** diff --git a/app/Services/Allocations/AssignmentService.php b/app/Services/Allocations/AssignmentService.php index 33ed4aa748..be4c041311 100644 --- a/app/Services/Allocations/AssignmentService.php +++ b/app/Services/Allocations/AssignmentService.php @@ -16,10 +16,15 @@ 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})$/'; /** diff --git a/app/Services/Servers/ServerConfigurationStructureService.php b/app/Services/Servers/ServerConfigurationStructureService.php index 43b8c97364..7ac714ed51 100644 --- a/app/Services/Servers/ServerConfigurationStructureService.php +++ b/app/Services/Servers/ServerConfigurationStructureService.php @@ -93,5 +93,4 @@ protected function returnFormat(Server $server): array return $response; } - } diff --git a/app/Services/Servers/SuspensionService.php b/app/Services/Servers/SuspensionService.php index aef02b7b2e..b175bccb6d 100644 --- a/app/Services/Servers/SuspensionService.php +++ b/app/Services/Servers/SuspensionService.php @@ -12,6 +12,7 @@ class SuspensionService { public const ACTION_SUSPEND = 'suspend'; + public const ACTION_UNSUSPEND = 'unsuspend'; /** diff --git a/pint.json b/pint.json index 4d7ccf1135..17de52db66 100644 --- a/pint.json +++ b/pint.json @@ -1,7 +1,6 @@ { "preset": "laravel", "rules": { - "class_attributes_separation": false, "concat_space": false, "not_operator_with_successor_space": false, "nullable_type_declaration_for_default_null_value": false, From 96acd268bee7005fe1691b572a4674575604d437 Mon Sep 17 00:00:00 2001 From: Lance Pioch Date: Sat, 19 Oct 2024 18:30:34 -0400 Subject: [PATCH 13/33] Add concat_space rule --- .../Environment/AppSettingsCommand.php | 2 +- .../Environment/EmailSettingsCommand.php | 2 +- .../Environment/QueueWorkerServiceCommand.php | 6 +-- .../Maintenance/PruneImagesCommand.php | 2 +- .../Schedule/ProcessRunnableCommand.php | 2 +- app/Console/Commands/UpgradeCommand.php | 8 +-- app/Console/Kernel.php | 2 +- app/Exceptions/Handler.php | 4 +- app/Extensions/Backups/BackupManager.php | 2 +- app/Extensions/DynamicDatabaseConnection.php | 2 +- app/Extensions/Themes/Theme.php | 6 +-- .../Pages/Installer/Steps/CompletedStep.php | 4 +- .../Installer/Steps/RequirementsStep.php | 8 +-- .../ApiKeyResource/Pages/ListApiKeys.php | 2 +- .../DatabasesRelationManager.php | 4 +- .../Resources/EggResource/Pages/EditEgg.php | 2 +- .../Resources/EggResource/Pages/ListEggs.php | 2 +- .../NodeResource/Widgets/NodeCpuChart.php | 4 +- .../NodeResource/Widgets/NodeMemoryChart.php | 10 ++-- app/Filament/Resources/RoleResource.php | 18 +++---- .../ServerResource/Pages/CreateServer.php | 16 +++--- .../ServerResource/Pages/EditServer.php | 14 +++--- .../UserResource/Pages/EditProfile.php | 2 +- .../UserResource/Pages/ListUsers.php | 4 +- .../Admin/Eggs/EggShareController.php | 2 +- .../Admin/NodeAutoDeployController.php | 2 +- .../Admin/Servers/CreateServerController.php | 2 +- .../Controllers/Admin/ServersController.php | 2 +- .../Api/Client/Servers/FileController.php | 2 +- .../Client/Servers/FileUploadController.php | 2 +- .../Client/Servers/WebsocketController.php | 4 +- .../Remote/Backups/BackupStatusController.php | 2 +- .../Remote/SftpAuthenticationController.php | 2 +- app/Http/Controllers/Auth/OAuthController.php | 2 +- .../Middleware/Api/AuthenticateIPAccess.php | 2 +- .../Client/Server/ResourceBelongsToServer.php | 2 +- app/Http/Middleware/Api/IsValidJson.php | 2 +- .../RequireTwoFactorAuthentication.php | 2 +- .../Api/StoreApplicationApiKeyRequest.php | 2 +- .../Admin/Egg/EggVariableFormRequest.php | 2 +- .../Api/Client/Account/StoreApiKeyRequest.php | 2 +- app/Jobs/Schedule/RunTaskJob.php | 2 +- app/Models/ApiKey.php | 50 +++++++++---------- app/Models/EggVariable.php | 2 +- app/Models/Filters/MultiFieldServerFilter.php | 2 +- app/Models/Node.php | 4 +- app/Models/User.php | 4 +- app/Notifications/AccountCreated.php | 10 ++-- app/Notifications/AddedToServer.php | 6 +-- app/Notifications/MailTested.php | 2 +- app/Notifications/RemovedFromServer.php | 4 +- app/Notifications/SendPasswordReset.php | 2 +- app/Notifications/ServerInstalled.php | 4 +- app/Policies/DefaultPolicies.php | 10 ++-- .../Daemon/DaemonConfigurationRepository.php | 2 +- .../Daemon/DaemonServerRepository.php | 4 +- app/Services/Acl/Api/AdminAcl.php | 2 +- app/Services/Backups/DownloadLinkService.php | 2 +- app/Services/Files/DeleteFilesService.php | 2 +- app/Services/Helpers/AssetHashService.php | 4 +- .../Helpers/SoftwareVersionService.php | 4 +- .../Servers/StartupCommandService.php | 2 +- .../Servers/TransferServerService.php | 4 +- .../Servers/VariableValidatorService.php | 4 +- .../Subusers/SubuserCreationService.php | 2 +- app/Traits/EnvironmentWriterTrait.php | 6 +-- .../Api/Client/ActivityLogTransformer.php | 4 +- .../Api/Client/UserTransformer.php | 2 +- bootstrap/tests.php | 16 +++--- database/Factories/NodeFactory.php | 2 +- database/Factories/UserFactory.php | 4 +- database/Seeders/EggSeeder.php | 8 +-- ..._ChangeServiceVariablesValidationRules.php | 2 +- ...dPermissionsToPointToNewScheduleSystem.php | 4 +- ...628_RemoveDaemonSecretFromServersTable.php | 2 +- ...22_RemoveDaemonSecretFromSubusersTable.php | 2 +- ..._merge_permissions_table_into_subusers.php | 4 +- ...4_store_node_tokens_as_encrypted_value.php | 2 +- pint.json | 1 - tests/Assertions/AssertsActivityLogged.php | 2 +- .../MiddlewareAttributeAssertionsTrait.php | 4 +- .../ApplicationApiIntegrationTestCase.php | 4 +- .../Api/Application/EggControllerTest.php | 6 +-- .../Users/ExternalUserControllerTest.php | 4 +- .../Application/Users/UserControllerTest.php | 12 ++--- .../Api/Client/AccountControllerTest.php | 4 +- .../Api/Client/ApiKeyControllerTest.php | 8 +-- .../Client/ClientApiIntegrationTestCase.php | 2 +- .../Api/Client/ClientControllerTest.php | 2 +- .../AllocationAuthorizationTest.php | 12 ++--- .../Server/Backup/BackupAuthorizationTest.php | 12 ++--- .../Database/DatabaseAuthorizationTest.php | 12 ++--- .../Schedule/GetServerSchedulesTest.php | 10 ++-- .../Schedule/ScheduleAuthorizationTest.php | 12 ++--- .../Startup/GetStartupAndVariablesTest.php | 6 +-- .../Startup/UpdateStartupVariableTest.php | 16 +++--- .../Subuser/CreateServerSubuserTest.php | 18 +++---- .../Server/Subuser/DeleteSubuserTest.php | 8 +-- .../Subuser/SubuserAuthorizationTest.php | 6 +-- .../Api/Daemon/DaemonAuthenticateTest.php | 4 +- .../SftpAuthenticationControllerTest.php | 10 ++-- .../Controllers/Admin/UserControllerTest.php | 6 +-- .../DatabaseManagementServiceTest.php | 2 +- tests/Traits/Http/RequestMockHelpers.php | 2 +- tests/Traits/MocksUuids.php | 2 +- 105 files changed, 271 insertions(+), 272 deletions(-) diff --git a/app/Console/Commands/Environment/AppSettingsCommand.php b/app/Console/Commands/Environment/AppSettingsCommand.php index a16f381763..d1ce5c00e4 100644 --- a/app/Console/Commands/Environment/AppSettingsCommand.php +++ b/app/Console/Commands/Environment/AppSettingsCommand.php @@ -16,7 +16,7 @@ public function handle(): void $path = base_path('.env'); if (!file_exists($path)) { $this->comment('Copying example .env file'); - copy($path . '.example', $path); + copy($path.'.example', $path); } if (!config('app.key')) { diff --git a/app/Console/Commands/Environment/EmailSettingsCommand.php b/app/Console/Commands/Environment/EmailSettingsCommand.php index 87c8186c14..a1ec5f7c27 100644 --- a/app/Console/Commands/Environment/EmailSettingsCommand.php +++ b/app/Console/Commands/Environment/EmailSettingsCommand.php @@ -44,7 +44,7 @@ public function handle(): void env('MAIL_MAILER', env('MAIL_DRIVER', 'smtp')), ); - $method = 'setup' . studly_case($this->variables['MAIL_MAILER']) . 'DriverVariables'; + $method = 'setup'.studly_case($this->variables['MAIL_MAILER']).'DriverVariables'; if (method_exists($this, $method)) { $this->{$method}(); } diff --git a/app/Console/Commands/Environment/QueueWorkerServiceCommand.php b/app/Console/Commands/Environment/QueueWorkerServiceCommand.php index dbf1aa7354..83266155b0 100644 --- a/app/Console/Commands/Environment/QueueWorkerServiceCommand.php +++ b/app/Console/Commands/Environment/QueueWorkerServiceCommand.php @@ -19,7 +19,7 @@ class QueueWorkerServiceCommand extends Command public function handle(): void { $serviceName = $this->option('service-name') ?? $this->ask('Queue worker service name', 'pelican-queue'); - $path = '/etc/systemd/system/' . $serviceName . '.service'; + $path = '/etc/systemd/system/'.$serviceName.'.service'; $fileExists = file_exists($path); if ($fileExists && !$this->option('overwrite') && !$this->confirm('The service file already exists. Do you want to overwrite it?')) { @@ -65,7 +65,7 @@ public function handle(): void if ($fileExists) { $result = Process::run("systemctl restart $serviceName.service"); if ($result->failed()) { - $this->error('Error restarting service: ' . $result->errorOutput()); + $this->error('Error restarting service: '.$result->errorOutput()); return; } @@ -74,7 +74,7 @@ public function handle(): void } else { $result = Process::run("systemctl enable --now $serviceName.service"); if ($result->failed()) { - $this->error('Error enabling service: ' . $result->errorOutput()); + $this->error('Error enabling service: '.$result->errorOutput()); return; } diff --git a/app/Console/Commands/Maintenance/PruneImagesCommand.php b/app/Console/Commands/Maintenance/PruneImagesCommand.php index 23f613fa38..a2f8c36ce7 100644 --- a/app/Console/Commands/Maintenance/PruneImagesCommand.php +++ b/app/Console/Commands/Maintenance/PruneImagesCommand.php @@ -50,7 +50,7 @@ private function cleanupImages(int|Node $node): void $count = count($response['ImagesDeleted']); $useBinaryPrefix = config('panel.use_binary_prefix'); - $space = round($useBinaryPrefix ? $response['SpaceReclaimed'] / 1024 / 1024 : $response['SpaceReclaimed'] / 1000 / 1000, 2) . ($useBinaryPrefix ? ' MiB' : ' MB'); + $space = round($useBinaryPrefix ? $response['SpaceReclaimed'] / 1024 / 1024 : $response['SpaceReclaimed'] / 1000 / 1000, 2).($useBinaryPrefix ? ' MiB' : ' MB'); $this->info("Node {$node->id}: Cleaned up {$count} dangling docker images. ({$space})"); } catch (Exception $exception) { diff --git a/app/Console/Commands/Schedule/ProcessRunnableCommand.php b/app/Console/Commands/Schedule/ProcessRunnableCommand.php index d1d71ae024..67ee89f3d6 100644 --- a/app/Console/Commands/Schedule/ProcessRunnableCommand.php +++ b/app/Console/Commands/Schedule/ProcessRunnableCommand.php @@ -67,7 +67,7 @@ protected function processSchedule(Schedule $schedule) } catch (\Throwable|\Exception $exception) { logger()->error($exception, ['schedule_id' => $schedule->id]); - $this->error(__('commands.schedule.process.no_tasks') . " #$schedule->id: " . $exception->getMessage()); + $this->error(__('commands.schedule.process.no_tasks')." #$schedule->id: ".$exception->getMessage()); } } } diff --git a/app/Console/Commands/UpgradeCommand.php b/app/Console/Commands/UpgradeCommand.php index 75a3c185f7..8f97d6dd34 100644 --- a/app/Console/Commands/UpgradeCommand.php +++ b/app/Console/Commands/UpgradeCommand.php @@ -40,7 +40,7 @@ public function handle(): void } if (version_compare(PHP_VERSION, '7.4.0') < 0) { - $this->error(__('commands.upgrade.php_version') . ' [' . PHP_VERSION . '].'); + $this->error(__('commands.upgrade.php_version').' ['.PHP_VERSION.'].'); } $user = 'www-data'; @@ -125,7 +125,7 @@ public function handle(): void $command[] = '--no-dev'; } - $this->line('$upgrader> ' . implode(' ', $command)); + $this->line('$upgrader> '.implode(' ', $command)); $process = new Process($command); $process->setTimeout(10 * 60); $process->run(function ($type, $buffer) { @@ -134,7 +134,7 @@ public function handle(): void }); /** @var \Illuminate\Foundation\Application $app */ - $app = require __DIR__ . '/../../../bootstrap/app.php'; + $app = require __DIR__.'/../../../bootstrap/app.php'; /** @var \App\Console\Kernel $kernel */ $kernel = $app->make(Kernel::class); $kernel->bootstrap(); @@ -192,6 +192,6 @@ protected function getUrl(): string return $this->option('url'); } - return sprintf(self::DEFAULT_URL, $this->option('release') ? 'download/v' . $this->option('release') : 'latest/download'); + return sprintf(self::DEFAULT_URL, $this->option('release') ? 'download/v'.$this->option('release') : 'latest/download'); } } diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 3c2fc96fad..f4a17cefc8 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -20,7 +20,7 @@ class Kernel extends ConsoleKernel */ protected function commands(): void { - $this->load(__DIR__ . '/Commands'); + $this->load(__DIR__.'/Commands'); } /** diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index d30475f668..a8cc206d94 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -108,7 +108,7 @@ class_basename($exception), $exception->getLine() ); - return $message . "\nStack trace:\n" . trim($cleanedStack); + return $message."\nStack trace:\n".trim($cleanedStack); } /** @@ -160,7 +160,7 @@ public function invalidJson($request, ValidationException $exception): JsonRespo 'source_field' => $field, 'rule' => str_replace(self::PANEL_RULE_STRING, 'p_', Arr::get( $codes, - str_replace('.', '_', $field) . '.' . $key + str_replace('.', '_', $field).'.'.$key )), ]; diff --git a/app/Extensions/Backups/BackupManager.php b/app/Extensions/Backups/BackupManager.php index ad1cfdbbc4..8fcb1e198a 100644 --- a/app/Extensions/Backups/BackupManager.php +++ b/app/Extensions/Backups/BackupManager.php @@ -74,7 +74,7 @@ protected function resolve(string $name): FilesystemAdapter return $this->callCustomCreator($config); } - $adapterMethod = 'create' . Str::studly($adapter) . 'Adapter'; + $adapterMethod = 'create'.Str::studly($adapter).'Adapter'; if (method_exists($this, $adapterMethod)) { $instance = $this->{$adapterMethod}($config); diff --git a/app/Extensions/DynamicDatabaseConnection.php b/app/Extensions/DynamicDatabaseConnection.php index 147f78064e..b4409ed4b0 100644 --- a/app/Extensions/DynamicDatabaseConnection.php +++ b/app/Extensions/DynamicDatabaseConnection.php @@ -21,7 +21,7 @@ public function set(string $connection, DatabaseHost|int $host, string $database $host = DatabaseHost::query()->findOrFail($host); } - config()->set('database.connections.' . $connection, [ + config()->set('database.connections.'.$connection, [ 'driver' => self::DB_DRIVER, 'host' => $host->host, 'port' => $host->port, diff --git a/app/Extensions/Themes/Theme.php b/app/Extensions/Themes/Theme.php index 2badc3dcb0..92b587fb79 100644 --- a/app/Extensions/Themes/Theme.php +++ b/app/Extensions/Themes/Theme.php @@ -6,16 +6,16 @@ class Theme { public function js($path): string { - return sprintf('' . PHP_EOL, $this->getUrl($path)); + return sprintf(''.PHP_EOL, $this->getUrl($path)); } public function css($path): string { - return sprintf('' . PHP_EOL, $this->getUrl($path)); + return sprintf(''.PHP_EOL, $this->getUrl($path)); } protected function getUrl($path): string { - return '/themes/panel/' . ltrim($path, '/'); + return '/themes/panel/'.ltrim($path, '/'); } } diff --git a/app/Filament/Pages/Installer/Steps/CompletedStep.php b/app/Filament/Pages/Installer/Steps/CompletedStep.php index 50f9a780cf..8b91c76864 100644 --- a/app/Filament/Pages/Installer/Steps/CompletedStep.php +++ b/app/Filament/Pages/Installer/Steps/CompletedStep.php @@ -21,12 +21,12 @@ public static function make(): Step ->label(new HtmlString('Run the following command to setup your crontab. Note that www-data is your webserver user. On some systems this username might be different!')) ->disabled() ->hintAction(CopyAction::make()) - ->default('(crontab -l -u www-data 2>/dev/null; echo "* * * * * php ' . base_path() . '/artisan schedule:run >> /dev/null 2>&1") | crontab -u www-data -'), + ->default('(crontab -l -u www-data 2>/dev/null; echo "* * * * * php '.base_path().'/artisan schedule:run >> /dev/null 2>&1") | crontab -u www-data -'), TextInput::make('queueService') ->label(new HtmlString('To setup the queue worker service you simply have to run the following command.')) ->disabled() ->hintAction(CopyAction::make()) - ->default('sudo php ' . base_path() . '/artisan p:environment:queue-service'), + ->default('sudo php '.base_path().'/artisan p:environment:queue-service'), Placeholder::make('') ->content('After you finished these two last tasks you can click on "Finish" and use your new panel! Have fun!'), ]); diff --git a/app/Filament/Pages/Installer/Steps/RequirementsStep.php b/app/Filament/Pages/Installer/Steps/RequirementsStep.php index 5e6d6988d1..d2afd4b378 100644 --- a/app/Filament/Pages/Installer/Steps/RequirementsStep.php +++ b/app/Filament/Pages/Installer/Steps/RequirementsStep.php @@ -18,12 +18,12 @@ public static function make(): Step $fields = [ Section::make('PHP Version') - ->description(self::MIN_PHP_VERSION . ' or newer') + ->description(self::MIN_PHP_VERSION.' or newer') ->icon($correctPhpVersion ? 'tabler-check' : 'tabler-x') ->iconColor($correctPhpVersion ? 'success' : 'danger') ->schema([ Placeholder::make('') - ->content('Your PHP Version is ' . PHP_VERSION . '.'), + ->content('Your PHP Version is '.PHP_VERSION.'.'), ]), ]; @@ -49,7 +49,7 @@ public static function make(): Step ->content('All needed PHP Extensions are installed.') ->visible($allExtensionsInstalled), Placeholder::make('') - ->content('The following PHP Extensions are missing: ' . implode(', ', array_keys($phpExtensions, false))) + ->content('The following PHP Extensions are missing: '.implode(', ', array_keys($phpExtensions, false))) ->visible(!$allExtensionsInstalled), ]); @@ -68,7 +68,7 @@ public static function make(): Step ->content('All Folders have the correct permissions.') ->visible($correctFolderPermissions), Placeholder::make('') - ->content('The following Folders have wrong permissions: ' . implode(', ', array_keys($folderPermissions, false))) + ->content('The following Folders have wrong permissions: '.implode(', ', array_keys($folderPermissions, false))) ->visible(!$correctFolderPermissions), ]); diff --git a/app/Filament/Resources/ApiKeyResource/Pages/ListApiKeys.php b/app/Filament/Resources/ApiKeyResource/Pages/ListApiKeys.php index aa0b9cdb5c..8ef0cdd3cb 100644 --- a/app/Filament/Resources/ApiKeyResource/Pages/ListApiKeys.php +++ b/app/Filament/Resources/ApiKeyResource/Pages/ListApiKeys.php @@ -24,7 +24,7 @@ public function table(Table $table): Table TextColumn::make('key') ->copyable() ->icon('tabler-clipboard-text') - ->state(fn (ApiKey $key) => $key->identifier . $key->token), + ->state(fn (ApiKey $key) => $key->identifier.$key->token), TextColumn::make('memo') ->label('Description') diff --git a/app/Filament/Resources/DatabaseHostResource/RelationManagers/DatabasesRelationManager.php b/app/Filament/Resources/DatabaseHostResource/RelationManagers/DatabasesRelationManager.php index 13b32602f8..3b209d7f7c 100644 --- a/app/Filament/Resources/DatabaseHostResource/RelationManagers/DatabasesRelationManager.php +++ b/app/Filament/Resources/DatabaseHostResource/RelationManagers/DatabasesRelationManager.php @@ -37,7 +37,7 @@ public function form(Form $form): Form TextInput::make('JDBC') ->label('JDBC Connection String') ->columnSpanFull() - ->formatStateUsing(fn (Get $get, Database $database) => 'jdbc:mysql://' . $get('username') . ':' . urlencode($database->password) . '@' . $database->host->host . ':' . $database->host->port . '/' . $get('database')), + ->formatStateUsing(fn (Get $get, Database $database) => 'jdbc:mysql://'.$get('username').':'.urlencode($database->password).'@'.$database->host->host.':'.$database->host->port.'/'.$get('database')), ]); } @@ -64,7 +64,7 @@ public function table(Table $table): Table protected function rotatePassword(DatabasePasswordService $service, Database $database, $set, $get): void { $newPassword = $service->handle($database); - $jdbcString = 'jdbc:mysql://' . $get('username') . ':' . urlencode($newPassword) . '@' . $database->host->host . ':' . $database->host->port . '/' . $get('database'); + $jdbcString = 'jdbc:mysql://'.$get('username').':'.urlencode($newPassword).'@'.$database->host->host.':'.$database->host->port.'/'.$get('database'); $set('password', $newPassword); $set('JDBC', $jdbcString); diff --git a/app/Filament/Resources/EggResource/Pages/EditEgg.php b/app/Filament/Resources/EggResource/Pages/EditEgg.php index d1d59c0640..b9b839cb1f 100644 --- a/app/Filament/Resources/EggResource/Pages/EditEgg.php +++ b/app/Filament/Resources/EggResource/Pages/EditEgg.php @@ -249,7 +249,7 @@ protected function getHeaderActions(): array ->color('primary') ->action(fn (EggExporterService $service, Egg $egg) => response()->streamDownload(function () use ($service, $egg) { echo $service->handle($egg->id); - }, 'egg-' . $egg->getKebabName() . '.json')) + }, 'egg-'.$egg->getKebabName().'.json')) ->authorize(fn () => auth()->user()->can('export egg')), Actions\Action::make('importEgg') ->label('Import') diff --git a/app/Filament/Resources/EggResource/Pages/ListEggs.php b/app/Filament/Resources/EggResource/Pages/ListEggs.php index a7f84b2749..0903379e52 100644 --- a/app/Filament/Resources/EggResource/Pages/ListEggs.php +++ b/app/Filament/Resources/EggResource/Pages/ListEggs.php @@ -55,7 +55,7 @@ public function table(Table $table): Table ->color('primary') ->action(fn (EggExporterService $service, Egg $egg) => response()->streamDownload(function () use ($service, $egg) { echo $service->handle($egg->id); - }, 'egg-' . $egg->getKebabName() . '.json')) + }, 'egg-'.$egg->getKebabName().'.json')) ->authorize(fn () => auth()->user()->can('export egg')), Action::make('update') ->icon('tabler-cloud-download') diff --git a/app/Filament/Resources/NodeResource/Widgets/NodeCpuChart.php b/app/Filament/Resources/NodeResource/Widgets/NodeCpuChart.php index 89d1cb254f..78119aaf5c 100644 --- a/app/Filament/Resources/NodeResource/Widgets/NodeCpuChart.php +++ b/app/Filament/Resources/NodeResource/Widgets/NodeCpuChart.php @@ -76,8 +76,8 @@ public function getHeading(): string $threads = $node->systemInformation()['cpu_count'] ?? 0; $cpu = Number::format(collect(cache()->get("nodes.$node->id.cpu_percent"))->last() * $threads, maxPrecision: 2, locale: auth()->user()->language); - $max = Number::format($threads * 100, locale: auth()->user()->language) . '%'; + $max = Number::format($threads * 100, locale: auth()->user()->language).'%'; - return 'CPU - ' . $cpu . '% Of ' . $max; + return 'CPU - '.$cpu.'% Of '.$max; } } diff --git a/app/Filament/Resources/NodeResource/Widgets/NodeMemoryChart.php b/app/Filament/Resources/NodeResource/Widgets/NodeMemoryChart.php index 0cabbed517..e1c19099b5 100644 --- a/app/Filament/Resources/NodeResource/Widgets/NodeMemoryChart.php +++ b/app/Filament/Resources/NodeResource/Widgets/NodeMemoryChart.php @@ -75,13 +75,13 @@ public function getHeading(): string $totalMemory = collect(cache()->get("nodes.$node->id.memory_total"))->last(); $used = config('panel.use_binary_prefix') - ? Number::format($latestMemoryUsed / 1024 / 1024 / 1024, maxPrecision: 2, locale: auth()->user()->language) .' GiB' - : Number::format($latestMemoryUsed / 1000 / 1000 / 1000, maxPrecision: 2, locale: auth()->user()->language) . ' GB'; + ? Number::format($latestMemoryUsed / 1024 / 1024 / 1024, maxPrecision: 2, locale: auth()->user()->language).' GiB' + : Number::format($latestMemoryUsed / 1000 / 1000 / 1000, maxPrecision: 2, locale: auth()->user()->language).' GB'; $total = config('panel.use_binary_prefix') - ? Number::format($totalMemory / 1024 / 1024 / 1024, maxPrecision: 2, locale: auth()->user()->language) .' GiB' - : Number::format($totalMemory / 1000 / 1000 / 1000, maxPrecision: 2, locale: auth()->user()->language) . ' GB'; + ? Number::format($totalMemory / 1024 / 1024 / 1024, maxPrecision: 2, locale: auth()->user()->language).' GiB' + : Number::format($totalMemory / 1000 / 1000 / 1000, maxPrecision: 2, locale: auth()->user()->language).' GB'; - return 'Memory - ' . $used . ' Of ' . $total; + return 'Memory - '.$used.' Of '.$total; } } diff --git a/app/Filament/Resources/RoleResource.php b/app/Filament/Resources/RoleResource.php index 306c9676da..8980902224 100644 --- a/app/Filament/Resources/RoleResource.php +++ b/app/Filament/Resources/RoleResource.php @@ -40,12 +40,12 @@ public static function form(Form $form): Form $options = []; foreach (RolePermissionPrefixes::cases() as $prefix) { - $options[$prefix->value . ' ' . strtolower($model->value)] = Str::headline($prefix->value); + $options[$prefix->value.' '.strtolower($model->value)] = Str::headline($prefix->value); } if (array_key_exists($model->value, Role::MODEL_SPECIFIC_PERMISSIONS)) { foreach (Role::MODEL_SPECIFIC_PERMISSIONS[$model->value] as $permission) { - $options[$permission . ' ' . strtolower($model->value)] = Str::headline($permission); + $options[$permission.' '.strtolower($model->value)] = Str::headline($permission); } } @@ -56,7 +56,7 @@ public static function form(Form $form): Form $options = []; foreach ($prefixes as $prefix) { - $options[$prefix . ' ' . strtolower($model)] = Str::headline($prefix); + $options[$prefix.' '.strtolower($model)] = Str::headline($prefix); } $permissions[] = self::makeSection($model, $options); @@ -88,10 +88,10 @@ private static function makeSection(string $model, array $options): Section { $icon = null; - if (class_exists('\App\Filament\Resources\\' . $model . 'Resource')) { - $icon = ('\App\Filament\Resources\\' . $model . 'Resource')::getNavigationIcon(); - } elseif (class_exists('\App\Filament\Pages\\' . $model)) { - $icon = ('\App\Filament\Pages\\' . $model)::getNavigationIcon(); + if (class_exists('\App\Filament\Resources\\'.$model.'Resource')) { + $icon = ('\App\Filament\Resources\\'.$model.'Resource')::getNavigationIcon(); + } elseif (class_exists('\App\Filament\Pages\\'.$model)) { + $icon = ('\App\Filament\Pages\\'.$model)::getNavigationIcon(); } return Section::make(Str::headline(Str::plural($model))) @@ -101,11 +101,11 @@ private static function makeSection(string $model, array $options): Section ->icon($icon) ->headerActions([ Action::make('count') - ->label(fn (Get $get) => count($get(strtolower($model) . '_list'))) + ->label(fn (Get $get) => count($get(strtolower($model).'_list'))) ->badge(), ]) ->schema([ - CheckboxList::make(strtolower($model) . '_list') + CheckboxList::make(strtolower($model).'_list') ->label('') ->options($options) ->columns() diff --git a/app/Filament/Resources/ServerResource/Pages/CreateServer.php b/app/Filament/Resources/ServerResource/Pages/CreateServer.php index b8ac8a5209..61696804f5 100644 --- a/app/Filament/Resources/ServerResource/Pages/CreateServer.php +++ b/app/Filament/Resources/ServerResource/Pages/CreateServer.php @@ -70,14 +70,14 @@ public function form(Form $form): Form ->prefixIcon('tabler-server') ->label('Name') ->suffixAction(Forms\Components\Actions\Action::make('random') - ->icon('tabler-dice-' . random_int(1, 6)) + ->icon('tabler-dice-'.random_int(1, 6)) ->action(function (Set $set, Get $get) { $egg = Egg::find($get('egg_id')); - $prefix = $egg ? str($egg->name)->lower()->kebab() . '-' : ''; + $prefix = $egg ? str($egg->name)->lower()->kebab().'-' : ''; $word = (new RandomWordService())->word(); - $set('name', $prefix . $word); + $set('name', $prefix.$word); })) ->columnSpan([ 'default' => 2, @@ -101,7 +101,7 @@ public function form(Form $form): Form ]) ->relationship('user', 'username') ->searchable(['username', 'email']) - ->getOptionLabelFromRecordUsing(fn (User $user) => "$user->email | $user->username " . ($user->isRootAdmin() ? '(admin)' : '')) + ->getOptionLabelFromRecordUsing(fn (User $user) => "$user->email | $user->username ".($user->isRootAdmin() ? '(admin)' : '')) ->createOptionForm([ TextInput::make('username') ->alphaNum() @@ -163,7 +163,7 @@ public function form(Form $form): Form $set('allocation_additional.needstobeastringhere.extra_allocations', null); }) ->getOptionLabelFromRecordUsing( - fn (Allocation $allocation) => "$allocation->ip:$allocation->port" . + fn (Allocation $allocation) => "$allocation->ip:$allocation->port". ($allocation->ip_alias ? " ($allocation->ip_alias)" : '') ) ->placeholder(function (Get $get) { @@ -293,7 +293,7 @@ public function form(Form $form): Form ->disabled(fn (Get $get) => $get('../../node_id') === null) ->searchable(['ip', 'port', 'ip_alias']) ->getOptionLabelFromRecordUsing( - fn (Allocation $allocation) => "$allocation->ip:$allocation->port" . + fn (Allocation $allocation) => "$allocation->ip:$allocation->port". ($allocation->ip_alias ? " ($allocation->ip_alias)" : '') ) ->placeholder('Select additional Allocations') @@ -498,7 +498,7 @@ public function form(Form $form): Form ->hintIcon('tabler-code') ->label(fn (Get $get) => $get('name')) ->hintIconTooltip(fn (Get $get) => implode('|', $get('rules'))) - ->prefix(fn (Get $get) => '{{' . $get('env_variable') . '}}') + ->prefix(fn (Get $get) => '{{'.$get('env_variable').'}}') ->helperText(fn (Get $get) => empty($get('description')) ? '—' : $get('description')) ->afterStateUpdated(function (Set $set, Get $get, $state) { $environment = $get($envPath = '../../environment'); @@ -846,7 +846,7 @@ private function shouldHideComponent(Get $get, Component $component): bool return !$containsRuleIn; } - throw new Exception('Component type not supported: ' . $component::class); + throw new Exception('Component type not supported: '.$component::class); } private function getSelectOptionsFromRules(Get $get): array diff --git a/app/Filament/Resources/ServerResource/Pages/EditServer.php b/app/Filament/Resources/ServerResource/Pages/EditServer.php index 267fd998f1..33a90ace09 100644 --- a/app/Filament/Resources/ServerResource/Pages/EditServer.php +++ b/app/Filament/Resources/ServerResource/Pages/EditServer.php @@ -66,14 +66,14 @@ public function form(Form $form): Form ->prefixIcon('tabler-server') ->label('Display Name') ->suffixAction(Action::make('random') - ->icon('tabler-dice-' . random_int(1, 6)) + ->icon('tabler-dice-'.random_int(1, 6)) ->action(function (Set $set, Get $get) { $egg = Egg::find($get('egg_id')); - $prefix = $egg ? str($egg->name)->lower()->kebab() . '-' : ''; + $prefix = $egg ? str($egg->name)->lower()->kebab().'-' : ''; $word = (new RandomWordService())->word(); - $set('name', $prefix . $word); + $set('name', $prefix.$word); })) ->columnSpan([ 'default' => 2, @@ -541,7 +541,7 @@ public function form(Form $form): Form ->hintIcon('tabler-code') ->label(fn (ServerVariable $serverVariable) => $serverVariable->variable->name) ->hintIconTooltip(fn (ServerVariable $serverVariable) => implode('|', $serverVariable->variable->rules)) - ->prefix(fn (ServerVariable $serverVariable) => '{{' . $serverVariable->variable->env_variable . '}}') + ->prefix(fn (ServerVariable $serverVariable) => '{{'.$serverVariable->variable->env_variable.'}}') ->helperText(fn (ServerVariable $serverVariable) => empty($serverVariable->variable->description) ? '—' : $serverVariable->variable->description); } @@ -606,7 +606,7 @@ public function form(Form $form): Form ->disabled() ->label('JDBC Connection String') ->columnSpan(2) - ->formatStateUsing(fn (Get $get, $record) => 'jdbc:mysql://' . $get('username') . ':' . urlencode($record->password) . '@' . $record->host->host . ':' . $record->host->port . '/' . $get('database')), + ->formatStateUsing(fn (Get $get, $record) => 'jdbc:mysql://'.$get('username').':'.urlencode($record->password).'@'.$record->host->host.':'.$record->host->port.'/'.$get('database')), ]) ->relationship('databases') ->deletable(false) @@ -800,7 +800,7 @@ private function shouldHideComponent(ServerVariable $serverVariable, Forms\Compo return $containsRuleIn; } - throw new Exception('Component type not supported: ' . $component::class); + throw new Exception('Component type not supported: '.$component::class); } private function getSelectOptionsFromRules(ServerVariable $serverVariable): array @@ -818,7 +818,7 @@ private function getSelectOptionsFromRules(ServerVariable $serverVariable): arra protected function rotatePassword(DatabasePasswordService $service, $record, $set, $get): void { $newPassword = $service->handle($record); - $jdbcString = 'jdbc:mysql://' . $get('username') . ':' . urlencode($newPassword) . '@' . $record->host->host . ':' . $record->host->port . '/' . $get('database'); + $jdbcString = 'jdbc:mysql://'.$get('username').':'.urlencode($newPassword).'@'.$record->host->host.':'.$record->host->port.'/'.$get('database'); $set('password', $newPassword); $set('JDBC', $jdbcString); diff --git a/app/Filament/Resources/UserResource/Pages/EditProfile.php b/app/Filament/Resources/UserResource/Pages/EditProfile.php index f5c5f5828d..20bd0f61f8 100644 --- a/app/Filament/Resources/UserResource/Pages/EditProfile.php +++ b/app/Filament/Resources/UserResource/Pages/EditProfile.php @@ -178,7 +178,7 @@ protected function getForms(): array ->content(fn () => new HtmlString("
$image
")) - ->helperText('Setup Key: '. $secret), + ->helperText('Setup Key: '.$secret), TextInput::make('2facode') ->label('Code') ->requiredWith('2fapassword') diff --git a/app/Filament/Resources/UserResource/Pages/ListUsers.php b/app/Filament/Resources/UserResource/Pages/ListUsers.php index c386d4ce61..03df515545 100644 --- a/app/Filament/Resources/UserResource/Pages/ListUsers.php +++ b/app/Filament/Resources/UserResource/Pages/ListUsers.php @@ -33,7 +33,7 @@ public function table(Table $table): Table ->visibleFrom('lg') ->label('') ->extraImgAttributes(['class' => 'rounded-full']) - ->defaultImageUrl(fn (User $user) => 'https://gravatar.com/avatar/' . md5(strtolower($user->email))), + ->defaultImageUrl(fn (User $user) => 'https://gravatar.com/avatar/'.md5(strtolower($user->email))), TextColumn::make('external_id') ->searchable() ->hidden(), @@ -55,7 +55,7 @@ public function table(Table $table): Table ->counts('roles') ->icon('tabler-users-group') ->label('Roles') - ->formatStateUsing(fn (User $user, $state) => $state . ($user->isRootAdmin() ? ' (Root Admin)' : '')), + ->formatStateUsing(fn (User $user, $state) => $state.($user->isRootAdmin() ? ' (Root Admin)' : '')), TextColumn::make('servers_count') ->counts('servers') ->icon('tabler-server') diff --git a/app/Http/Controllers/Admin/Eggs/EggShareController.php b/app/Http/Controllers/Admin/Eggs/EggShareController.php index 993064b65c..56f38f4f7d 100644 --- a/app/Http/Controllers/Admin/Eggs/EggShareController.php +++ b/app/Http/Controllers/Admin/Eggs/EggShareController.php @@ -30,7 +30,7 @@ public function export(Egg $egg): Response return response($this->exporterService->handle($egg->id), 200, [ 'Content-Transfer-Encoding' => 'binary', 'Content-Description' => 'File Transfer', - 'Content-Disposition' => 'attachment; filename=egg-' . $filename . '.json', + 'Content-Disposition' => 'attachment; filename=egg-'.$filename.'.json', 'Content-Type' => 'application/json', ]); } diff --git a/app/Http/Controllers/Admin/NodeAutoDeployController.php b/app/Http/Controllers/Admin/NodeAutoDeployController.php index 1029706c35..b61e41acbb 100644 --- a/app/Http/Controllers/Admin/NodeAutoDeployController.php +++ b/app/Http/Controllers/Admin/NodeAutoDeployController.php @@ -56,7 +56,7 @@ public function __invoke(Request $request, Node $node): JsonResponse return new JsonResponse([ 'node' => $node->id, - 'token' => $key->identifier . $key->token, + 'token' => $key->identifier.$key->token, ]); } } diff --git a/app/Http/Controllers/Admin/Servers/CreateServerController.php b/app/Http/Controllers/Admin/Servers/CreateServerController.php index c59e22fbeb..7e7c191759 100644 --- a/app/Http/Controllers/Admin/Servers/CreateServerController.php +++ b/app/Http/Controllers/Admin/Servers/CreateServerController.php @@ -67,6 +67,6 @@ public function store(ServerFormRequest $request): RedirectResponse $this->alert->success(trans('admin/server.alerts.server_created'))->flash(); - return new RedirectResponse('/admin/servers/view/' . $server->id); + return new RedirectResponse('/admin/servers/view/'.$server->id); } } diff --git a/app/Http/Controllers/Admin/ServersController.php b/app/Http/Controllers/Admin/ServersController.php index 9ddd9c7e61..4cb398bbed 100644 --- a/app/Http/Controllers/Admin/ServersController.php +++ b/app/Http/Controllers/Admin/ServersController.php @@ -115,7 +115,7 @@ public function manageSuspension(Request $request, Server $server): RedirectResp { $this->suspensionService->toggle($server, $request->input('action')); $this->alert->success(trans('admin/server.alerts.suspension_toggled', [ - 'status' => $request->input('action') . 'ed', + 'status' => $request->input('action').'ed', ]))->flash(); return redirect()->route('admin.servers.view.manage', $server->id); diff --git a/app/Http/Controllers/Api/Client/Servers/FileController.php b/app/Http/Controllers/Api/Client/Servers/FileController.php index 09d354a362..bd175aef50 100644 --- a/app/Http/Controllers/Api/Client/Servers/FileController.php +++ b/app/Http/Controllers/Api/Client/Servers/FileController.php @@ -83,7 +83,7 @@ public function download(GetFileContentsRequest $request, Server $server): array 'file_path' => rawurldecode($request->get('file')), 'server_uuid' => $server->uuid, ]) - ->handle($server->node, $request->user()->id . $server->uuid); + ->handle($server->node, $request->user()->id.$server->uuid); Activity::event('server:file.download')->property('file', $request->get('file'))->log(); diff --git a/app/Http/Controllers/Api/Client/Servers/FileUploadController.php b/app/Http/Controllers/Api/Client/Servers/FileUploadController.php index e48dd75bdf..9ee74fb44c 100644 --- a/app/Http/Controllers/Api/Client/Servers/FileUploadController.php +++ b/app/Http/Controllers/Api/Client/Servers/FileUploadController.php @@ -43,7 +43,7 @@ protected function getUploadUrl(Server $server, User $user): string ->setExpiresAt(CarbonImmutable::now()->addMinutes(15)) ->setUser($user) ->setClaims(['server_uuid' => $server->uuid]) - ->handle($server->node, $user->id . $server->uuid); + ->handle($server->node, $user->id.$server->uuid); return sprintf( '%s/upload/file?token=%s', diff --git a/app/Http/Controllers/Api/Client/Servers/WebsocketController.php b/app/Http/Controllers/Api/Client/Servers/WebsocketController.php index 0fb062e962..8d636872d1 100644 --- a/app/Http/Controllers/Api/Client/Servers/WebsocketController.php +++ b/app/Http/Controllers/Api/Client/Servers/WebsocketController.php @@ -59,14 +59,14 @@ public function __invoke(ClientApiRequest $request, Server $server): JsonRespons 'server_uuid' => $server->uuid, 'permissions' => $permissions, ]) - ->handle($node, $user->id . $server->uuid); + ->handle($node, $user->id.$server->uuid); $socket = str_replace(['https://', 'http://'], ['wss://', 'ws://'], $node->getConnectionAddress()); return new JsonResponse([ 'data' => [ 'token' => $token->toString(), - 'socket' => $socket . sprintf('/api/servers/%s/ws', $server->uuid), + 'socket' => $socket.sprintf('/api/servers/%s/ws', $server->uuid), ], ]); } diff --git a/app/Http/Controllers/Api/Remote/Backups/BackupStatusController.php b/app/Http/Controllers/Api/Remote/Backups/BackupStatusController.php index 4f32689ecf..47350c69d2 100644 --- a/app/Http/Controllers/Api/Remote/Backups/BackupStatusController.php +++ b/app/Http/Controllers/Api/Remote/Backups/BackupStatusController.php @@ -64,7 +64,7 @@ public function index(ReportBackupCompleteRequest $request, string $backup): Jso // deleted easily. Also does not make sense to have a locked backup on the system // that is failed. 'is_locked' => $successful ? $model->is_locked : false, - 'checksum' => $successful ? ($request->input('checksum_type') . ':' . $request->input('checksum')) : null, + 'checksum' => $successful ? ($request->input('checksum_type').':'.$request->input('checksum')) : null, 'bytes' => $successful ? $request->input('size') : 0, 'completed_at' => CarbonImmutable::now(), ])->save(); diff --git a/app/Http/Controllers/Api/Remote/SftpAuthenticationController.php b/app/Http/Controllers/Api/Remote/SftpAuthenticationController.php index 9b59704f15..f9e63dfb52 100644 --- a/app/Http/Controllers/Api/Remote/SftpAuthenticationController.php +++ b/app/Http/Controllers/Api/Remote/SftpAuthenticationController.php @@ -160,6 +160,6 @@ protected function throttleKey(Request $request): string { $username = explode('.', strrev($request->input('username', ''))); - return strtolower(strrev($username[0] ?? '') . '|' . $request->ip()); + return strtolower(strrev($username[0] ?? '').'|'.$request->ip()); } } diff --git a/app/Http/Controllers/Auth/OAuthController.php b/app/Http/Controllers/Auth/OAuthController.php index 2989761efc..34f0b3bbc3 100644 --- a/app/Http/Controllers/Auth/OAuthController.php +++ b/app/Http/Controllers/Auth/OAuthController.php @@ -48,7 +48,7 @@ protected function callback(Request $request, string $driver): RedirectResponse } try { - $user = User::query()->whereJsonContains('oauth->'. $driver, $oauthUser->getId())->firstOrFail(); + $user = User::query()->whereJsonContains('oauth->'.$driver, $oauthUser->getId())->firstOrFail(); $this->auth->guard()->login($user, true); } catch (Exception $e) { diff --git a/app/Http/Middleware/Api/AuthenticateIPAccess.php b/app/Http/Middleware/Api/AuthenticateIPAccess.php index c9f3bf7dc4..a1c6d47105 100644 --- a/app/Http/Middleware/Api/AuthenticateIPAccess.php +++ b/app/Http/Middleware/Api/AuthenticateIPAccess.php @@ -43,6 +43,6 @@ public function handle(Request $request, \Closure $next): mixed ->property('identifier', $token->identifier) ->log(); - throw new AccessDeniedHttpException('This IP address (' . $request->ip() . ') does not have permission to access the API using these credentials.'); + throw new AccessDeniedHttpException('This IP address ('.$request->ip().') does not have permission to access the API using these credentials.'); } } diff --git a/app/Http/Middleware/Api/Client/Server/ResourceBelongsToServer.php b/app/Http/Middleware/Api/Client/Server/ResourceBelongsToServer.php index 0ead01f1d5..d7754d36e9 100644 --- a/app/Http/Middleware/Api/Client/Server/ResourceBelongsToServer.php +++ b/app/Http/Middleware/Api/Client/Server/ResourceBelongsToServer.php @@ -80,7 +80,7 @@ public function handle(Request $request, \Closure $next): mixed default: // Don't return a 404 here since we want to make sure no one relies // on this middleware in a context in which it will not work. Fail safe. - throw new \InvalidArgumentException('There is no handler configured for a resource of this type: ' . get_class($model)); + throw new \InvalidArgumentException('There is no handler configured for a resource of this type: '.get_class($model)); } } diff --git a/app/Http/Middleware/Api/IsValidJson.php b/app/Http/Middleware/Api/IsValidJson.php index 86bb34ff28..77bd25fe8f 100644 --- a/app/Http/Middleware/Api/IsValidJson.php +++ b/app/Http/Middleware/Api/IsValidJson.php @@ -18,7 +18,7 @@ public function handle(Request $request, \Closure $next): mixed try { json_decode($request->getContent(), true, 512, JSON_THROW_ON_ERROR); } catch (\JsonException $exception) { - throw new BadRequestHttpException('The JSON data passed in the request appears to be malformed: ' . $exception->getMessage()); + throw new BadRequestHttpException('The JSON data passed in the request appears to be malformed: '.$exception->getMessage()); } } diff --git a/app/Http/Middleware/RequireTwoFactorAuthentication.php b/app/Http/Middleware/RequireTwoFactorAuthentication.php index 58ff1564d6..bfbab44387 100644 --- a/app/Http/Middleware/RequireTwoFactorAuthentication.php +++ b/app/Http/Middleware/RequireTwoFactorAuthentication.php @@ -38,7 +38,7 @@ public function __construct(private AlertsMessageBag $alert) public function handle(Request $request, \Closure $next): mixed { $user = $request->user(); - $uri = rtrim($request->getRequestUri(), '/') . '/'; + $uri = rtrim($request->getRequestUri(), '/').'/'; $current = $request->route()->getName(); if (!$user || Str::startsWith($uri, ['/auth/']) || Str::startsWith($current, ['auth.', 'account.'])) { diff --git a/app/Http/Requests/Admin/Api/StoreApplicationApiKeyRequest.php b/app/Http/Requests/Admin/Api/StoreApplicationApiKeyRequest.php index 83f80f267d..b092ead913 100644 --- a/app/Http/Requests/Admin/Api/StoreApplicationApiKeyRequest.php +++ b/app/Http/Requests/Admin/Api/StoreApplicationApiKeyRequest.php @@ -17,7 +17,7 @@ public function rules(): array $modelRules = ApiKey::getRules(); return collect(AdminAcl::getResourceList())->mapWithKeys(function ($resource) use ($modelRules) { - return [AdminAcl::COLUMN_IDENTIFIER . $resource => $modelRules['r_' . $resource]]; + return [AdminAcl::COLUMN_IDENTIFIER.$resource => $modelRules['r_'.$resource]]; })->merge(['memo' => $modelRules['memo']])->toArray(); } diff --git a/app/Http/Requests/Admin/Egg/EggVariableFormRequest.php b/app/Http/Requests/Admin/Egg/EggVariableFormRequest.php index c6720aa2cc..b7e64daaaa 100644 --- a/app/Http/Requests/Admin/Egg/EggVariableFormRequest.php +++ b/app/Http/Requests/Admin/Egg/EggVariableFormRequest.php @@ -15,7 +15,7 @@ public function rules(): array return [ 'name' => 'required|string|min:1|max:255', 'description' => 'sometimes|nullable|string', - 'env_variable' => 'required|regex:/^[\w]{1,255}$/|notIn:' . EggVariable::RESERVED_ENV_NAMES, + 'env_variable' => 'required|regex:/^[\w]{1,255}$/|notIn:'.EggVariable::RESERVED_ENV_NAMES, 'options' => 'sometimes|required|array', 'rules' => 'bail|required|string', 'default_value' => 'present', diff --git a/app/Http/Requests/Api/Client/Account/StoreApiKeyRequest.php b/app/Http/Requests/Api/Client/Account/StoreApiKeyRequest.php index e0034fcfed..8668322140 100644 --- a/app/Http/Requests/Api/Client/Account/StoreApiKeyRequest.php +++ b/app/Http/Requests/Api/Client/Account/StoreApiKeyRequest.php @@ -39,7 +39,7 @@ public function withValidator(Validator $validator): void throw $exception; } } finally { - $validator->errors()->addIf(!$valid, "allowed_ips.{$index}", '"' . $ip . '" is not a valid IP address or CIDR range.'); + $validator->errors()->addIf(!$valid, "allowed_ips.{$index}", '"'.$ip.'" is not a valid IP address or CIDR range.'); } } }); diff --git a/app/Jobs/Schedule/RunTaskJob.php b/app/Jobs/Schedule/RunTaskJob.php index 6a660e5c05..ea0c84486d 100644 --- a/app/Jobs/Schedule/RunTaskJob.php +++ b/app/Jobs/Schedule/RunTaskJob.php @@ -73,7 +73,7 @@ public function handle( $deleteFilesService->handle($server, explode(PHP_EOL, $this->task->payload)); break; default: - throw new \InvalidArgumentException('Invalid task action provided: ' . $this->task->action); + throw new \InvalidArgumentException('Invalid task action provided: '.$this->task->action); } } catch (\Exception $exception) { // If this isn't a DaemonConnectionException on a task that allows for failures diff --git a/app/Models/ApiKey.php b/app/Models/ApiKey.php index 96c714f246..6593803e29 100644 --- a/app/Models/ApiKey.php +++ b/app/Models/ApiKey.php @@ -110,14 +110,14 @@ class ApiKey extends Model 'memo', 'last_used_at', 'expires_at', - 'r_' . AdminAcl::RESOURCE_USERS, - 'r_' . AdminAcl::RESOURCE_ALLOCATIONS, - 'r_' . AdminAcl::RESOURCE_DATABASE_HOSTS, - 'r_' . AdminAcl::RESOURCE_SERVER_DATABASES, - 'r_' . AdminAcl::RESOURCE_EGGS, - 'r_' . AdminAcl::RESOURCE_NODES, - 'r_' . AdminAcl::RESOURCE_SERVERS, - 'r_' . AdminAcl::RESOURCE_MOUNTS, + 'r_'.AdminAcl::RESOURCE_USERS, + 'r_'.AdminAcl::RESOURCE_ALLOCATIONS, + 'r_'.AdminAcl::RESOURCE_DATABASE_HOSTS, + 'r_'.AdminAcl::RESOURCE_SERVER_DATABASES, + 'r_'.AdminAcl::RESOURCE_EGGS, + 'r_'.AdminAcl::RESOURCE_NODES, + 'r_'.AdminAcl::RESOURCE_SERVERS, + 'r_'.AdminAcl::RESOURCE_MOUNTS, ]; /** @@ -146,14 +146,14 @@ class ApiKey extends Model 'allowed_ips.*' => 'string', 'last_used_at' => 'nullable|date', 'expires_at' => 'nullable|date', - 'r_' . AdminAcl::RESOURCE_USERS => 'integer|min:0|max:3', - 'r_' . AdminAcl::RESOURCE_ALLOCATIONS => 'integer|min:0|max:3', - 'r_' . AdminAcl::RESOURCE_DATABASE_HOSTS => 'integer|min:0|max:3', - 'r_' . AdminAcl::RESOURCE_SERVER_DATABASES => 'integer|min:0|max:3', - 'r_' . AdminAcl::RESOURCE_EGGS => 'integer|min:0|max:3', - 'r_' . AdminAcl::RESOURCE_NODES => 'integer|min:0|max:3', - 'r_' . AdminAcl::RESOURCE_SERVERS => 'integer|min:0|max:3', - 'r_' . AdminAcl::RESOURCE_MOUNTS => 'integer|min:0|max:3', + 'r_'.AdminAcl::RESOURCE_USERS => 'integer|min:0|max:3', + 'r_'.AdminAcl::RESOURCE_ALLOCATIONS => 'integer|min:0|max:3', + 'r_'.AdminAcl::RESOURCE_DATABASE_HOSTS => 'integer|min:0|max:3', + 'r_'.AdminAcl::RESOURCE_SERVER_DATABASES => 'integer|min:0|max:3', + 'r_'.AdminAcl::RESOURCE_EGGS => 'integer|min:0|max:3', + 'r_'.AdminAcl::RESOURCE_NODES => 'integer|min:0|max:3', + 'r_'.AdminAcl::RESOURCE_SERVERS => 'integer|min:0|max:3', + 'r_'.AdminAcl::RESOURCE_MOUNTS => 'integer|min:0|max:3', ]; protected function casts(): array @@ -166,14 +166,14 @@ protected function casts(): array 'token' => 'encrypted', self::CREATED_AT => 'datetime', self::UPDATED_AT => 'datetime', - 'r_' . AdminAcl::RESOURCE_USERS => 'int', - 'r_' . AdminAcl::RESOURCE_ALLOCATIONS => 'int', - 'r_' . AdminAcl::RESOURCE_DATABASE_HOSTS => 'int', - 'r_' . AdminAcl::RESOURCE_SERVER_DATABASES => 'int', - 'r_' . AdminAcl::RESOURCE_EGGS => 'int', - 'r_' . AdminAcl::RESOURCE_NODES => 'int', - 'r_' . AdminAcl::RESOURCE_SERVERS => 'int', - 'r_' . AdminAcl::RESOURCE_MOUNTS => 'int', + 'r_'.AdminAcl::RESOURCE_USERS => 'int', + 'r_'.AdminAcl::RESOURCE_ALLOCATIONS => 'int', + 'r_'.AdminAcl::RESOURCE_DATABASE_HOSTS => 'int', + 'r_'.AdminAcl::RESOURCE_SERVER_DATABASES => 'int', + 'r_'.AdminAcl::RESOURCE_EGGS => 'int', + 'r_'.AdminAcl::RESOURCE_NODES => 'int', + 'r_'.AdminAcl::RESOURCE_SERVERS => 'int', + 'r_'.AdminAcl::RESOURCE_MOUNTS => 'int', ]; } @@ -227,6 +227,6 @@ public static function generateTokenIdentifier(int $type): string { $prefix = self::getPrefixForType($type); - return $prefix . Str::random(self::IDENTIFIER_LENGTH - strlen($prefix)); + return $prefix.Str::random(self::IDENTIFIER_LENGTH - strlen($prefix)); } } diff --git a/app/Models/EggVariable.php b/app/Models/EggVariable.php index 2d3a4fb2c5..b56213c1a1 100644 --- a/app/Models/EggVariable.php +++ b/app/Models/EggVariable.php @@ -54,7 +54,7 @@ class EggVariable extends Model 'sort' => 'nullable', 'name' => 'required|string|between:1,255', 'description' => 'string', - 'env_variable' => 'required|alphaDash|between:1,255|notIn:' . self::RESERVED_ENV_NAMES, + 'env_variable' => 'required|alphaDash|between:1,255|notIn:'.self::RESERVED_ENV_NAMES, 'default_value' => 'string', 'user_viewable' => 'boolean', 'user_editable' => 'boolean', diff --git a/app/Models/Filters/MultiFieldServerFilter.php b/app/Models/Filters/MultiFieldServerFilter.php index da3f91f6d5..0ab266574a 100644 --- a/app/Models/Filters/MultiFieldServerFilter.php +++ b/app/Models/Filters/MultiFieldServerFilter.php @@ -48,7 +48,7 @@ function (Builder $builder) use ($parts) { }, // Otherwise, just try to search for that specific port in the allocations. function (Builder $builder) use ($value) { - $builder->orWhere('allocations.port', 'LIKE', substr($value, 1) . '%'); + $builder->orWhere('allocations.port', 'LIKE', substr($value, 1).'%'); } ); }) diff --git a/app/Models/Node.php b/app/Models/Node.php index da54160913..59a337f2b9 100644 --- a/app/Models/Node.php +++ b/app/Models/Node.php @@ -184,8 +184,8 @@ public function getConfiguration(): array 'port' => $this->daemon_listen, 'ssl' => [ 'enabled' => (!$this->behind_proxy && $this->scheme === 'https'), - 'cert' => '/etc/letsencrypt/live/' . Str::lower($this->fqdn) . '/fullchain.pem', - 'key' => '/etc/letsencrypt/live/' . Str::lower($this->fqdn) . '/privkey.pem', + 'cert' => '/etc/letsencrypt/live/'.Str::lower($this->fqdn).'/fullchain.pem', + 'key' => '/etc/letsencrypt/live/'.Str::lower($this->fqdn).'/privkey.pem', ], 'upload_limit' => $this->upload_size, ], diff --git a/app/Models/User.php b/app/Models/User.php index 3b4eff193f..5bc8fa6323 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -259,7 +259,7 @@ public function setUsernameAttribute(string $value) */ public function getNameAttribute(): string { - return trim($this->name_first . ' ' . $this->name_last); + return trim($this->name_first.' '.$this->name_last); } /** @@ -379,7 +379,7 @@ public function getFilamentName(): string public function getFilamentAvatarUrl(): ?string { - return 'https://gravatar.com/avatar/' . md5(strtolower($this->email)); + return 'https://gravatar.com/avatar/'.md5(strtolower($this->email)); } public function canTarget(IlluminateModel $user): bool diff --git a/app/Notifications/AccountCreated.php b/app/Notifications/AccountCreated.php index 0123435f7f..0f7cb77a71 100644 --- a/app/Notifications/AccountCreated.php +++ b/app/Notifications/AccountCreated.php @@ -33,13 +33,13 @@ public function via(): array public function toMail(): MailMessage { $message = (new MailMessage()) - ->greeting('Hello ' . $this->user->name . '!') - ->line('You are receiving this email because an account has been created for you on ' . config('app.name') . '.') - ->line('Username: ' . $this->user->username) - ->line('Email: ' . $this->user->email); + ->greeting('Hello '.$this->user->name.'!') + ->line('You are receiving this email because an account has been created for you on '.config('app.name').'.') + ->line('Username: '.$this->user->username) + ->line('Email: '.$this->user->email); if (!is_null($this->token)) { - return $message->action('Setup Your Account', url('/auth/password/reset/' . $this->token . '?email=' . urlencode($this->user->email))); + return $message->action('Setup Your Account', url('/auth/password/reset/'.$this->token.'?email='.urlencode($this->user->email))); } return $message; diff --git a/app/Notifications/AddedToServer.php b/app/Notifications/AddedToServer.php index 647c338229..56ddd4a400 100644 --- a/app/Notifications/AddedToServer.php +++ b/app/Notifications/AddedToServer.php @@ -35,9 +35,9 @@ public function via(): array public function toMail(): MailMessage { return (new MailMessage()) - ->greeting('Hello ' . $this->server->user . '!') + ->greeting('Hello '.$this->server->user.'!') ->line('You have been added as a subuser for the following server, allowing you certain control over the server.') - ->line('Server Name: ' . $this->server->name) - ->action('Visit Server', url('/server/' . $this->server->uuid_short)); + ->line('Server Name: '.$this->server->name) + ->action('Visit Server', url('/server/'.$this->server->uuid_short)); } } diff --git a/app/Notifications/MailTested.php b/app/Notifications/MailTested.php index 3bb816bf79..0dcbb4e9ca 100644 --- a/app/Notifications/MailTested.php +++ b/app/Notifications/MailTested.php @@ -21,7 +21,7 @@ public function toMail(): MailMessage { return (new MailMessage()) ->subject('Panel Test Message') - ->greeting('Hello ' . $this->user->name . '!') + ->greeting('Hello '.$this->user->name.'!') ->line('This is a test of the Panel mail system. You\'re good to go!'); } } diff --git a/app/Notifications/RemovedFromServer.php b/app/Notifications/RemovedFromServer.php index 668d8f28a5..6c7899d6ab 100644 --- a/app/Notifications/RemovedFromServer.php +++ b/app/Notifications/RemovedFromServer.php @@ -36,9 +36,9 @@ public function toMail(): MailMessage { return (new MailMessage()) ->error() - ->greeting('Hello ' . $this->server->user . '.') + ->greeting('Hello '.$this->server->user.'.') ->line('You have been removed as a subuser for the following server.') - ->line('Server Name: ' . $this->server->name) + ->line('Server Name: '.$this->server->name) ->action('Visit Panel', route('index')); } } diff --git a/app/Notifications/SendPasswordReset.php b/app/Notifications/SendPasswordReset.php index 434d1dd489..381b731a78 100644 --- a/app/Notifications/SendPasswordReset.php +++ b/app/Notifications/SendPasswordReset.php @@ -34,7 +34,7 @@ public function toMail(mixed $notifiable): MailMessage return (new MailMessage()) ->subject('Reset Password') ->line('You are receiving this email because we received a password reset request for your account.') - ->action('Reset Password', url('/auth/password/reset/' . $this->token . '?email=' . urlencode($notifiable->email))) + ->action('Reset Password', url('/auth/password/reset/'.$this->token.'?email='.urlencode($notifiable->email))) ->line('If you did not request a password reset, no further action is required.'); } } diff --git a/app/Notifications/ServerInstalled.php b/app/Notifications/ServerInstalled.php index fa6500afab..f23371bc3f 100644 --- a/app/Notifications/ServerInstalled.php +++ b/app/Notifications/ServerInstalled.php @@ -51,9 +51,9 @@ public function via(): array public function toMail(): MailMessage { return (new MailMessage()) - ->greeting('Hello ' . $this->user->username . '.') + ->greeting('Hello '.$this->user->username.'.') ->line('Your server has finished installing and is now ready for you to use.') - ->line('Server Name: ' . $this->server->name) + ->line('Server Name: '.$this->server->name) ->action('Login and Begin Using', route('index')); } } diff --git a/app/Policies/DefaultPolicies.php b/app/Policies/DefaultPolicies.php index 3035cae198..e1d2890ab6 100644 --- a/app/Policies/DefaultPolicies.php +++ b/app/Policies/DefaultPolicies.php @@ -12,7 +12,7 @@ trait DefaultPolicies */ public function viewAny(User $user): bool { - return $user->can('viewList ' . $this->modelName); + return $user->can('viewList '.$this->modelName); } /** @@ -20,7 +20,7 @@ public function viewAny(User $user): bool */ public function view(User $user, Model $model): bool { - return $user->can('view ' . $this->modelName, $model); + return $user->can('view '.$this->modelName, $model); } /** @@ -28,7 +28,7 @@ public function view(User $user, Model $model): bool */ public function create(User $user): bool { - return $user->can('create ' . $this->modelName); + return $user->can('create '.$this->modelName); } /** @@ -36,7 +36,7 @@ public function create(User $user): bool */ public function update(User $user, Model $model): bool { - return $user->can('update ' . $this->modelName, $model); + return $user->can('update '.$this->modelName, $model); } /** @@ -44,6 +44,6 @@ public function update(User $user, Model $model): bool */ public function delete(User $user, Model $model): bool { - return $user->can('delete ' . $this->modelName, $model); + return $user->can('delete '.$this->modelName, $model); } } diff --git a/app/Repositories/Daemon/DaemonConfigurationRepository.php b/app/Repositories/Daemon/DaemonConfigurationRepository.php index 52cda56dd4..86b8418ea7 100644 --- a/app/Repositories/Daemon/DaemonConfigurationRepository.php +++ b/app/Repositories/Daemon/DaemonConfigurationRepository.php @@ -19,7 +19,7 @@ public function getSystemInformation(?int $version = null, $connectTimeout = 5): $response = $this ->getHttpClient() ->connectTimeout($connectTimeout) - ->get('/api/system' . (!is_null($version) ? '?v=' . $version : '')); + ->get('/api/system'.(!is_null($version) ? '?v='.$version : '')); } catch (TransferException $exception) { throw new DaemonConnectionException($exception); } diff --git a/app/Repositories/Daemon/DaemonServerRepository.php b/app/Repositories/Daemon/DaemonServerRepository.php index ce91ece2bf..8656adc744 100644 --- a/app/Repositories/Daemon/DaemonServerRepository.php +++ b/app/Repositories/Daemon/DaemonServerRepository.php @@ -96,7 +96,7 @@ public function delete(): void Assert::isInstanceOf($this->server, Server::class); try { - $this->getHttpClient()->delete('/api/servers/' . $this->server->uuid); + $this->getHttpClient()->delete('/api/servers/'.$this->server->uuid); } catch (TransferException $exception) { throw new DaemonConnectionException($exception); } @@ -192,7 +192,7 @@ public function revokeUserJTI(int $id): void { Assert::isInstanceOf($this->server, Server::class); - $this->revokeJTIs([md5($id . $this->server->uuid)]); + $this->revokeJTIs([md5($id.$this->server->uuid)]); } /** diff --git a/app/Services/Acl/Api/AdminAcl.php b/app/Services/Acl/Api/AdminAcl.php index 90ec6480ae..fc7b176ca7 100644 --- a/app/Services/Acl/Api/AdminAcl.php +++ b/app/Services/Acl/Api/AdminAcl.php @@ -62,7 +62,7 @@ public static function can(int $permission, int $action = self::READ): bool */ public static function check(ApiKey $key, string $resource, int $action = self::READ): bool { - return self::can(data_get($key, self::COLUMN_IDENTIFIER . $resource, self::NONE), $action); + return self::can(data_get($key, self::COLUMN_IDENTIFIER.$resource, self::NONE), $action); } /** diff --git a/app/Services/Backups/DownloadLinkService.php b/app/Services/Backups/DownloadLinkService.php index a167a1bb24..ed38672665 100644 --- a/app/Services/Backups/DownloadLinkService.php +++ b/app/Services/Backups/DownloadLinkService.php @@ -34,7 +34,7 @@ public function handle(Backup $backup, User $user): string 'backup_uuid' => $backup->uuid, 'server_uuid' => $backup->server->uuid, ]) - ->handle($backup->server->node, $user->id . $backup->server->uuid); + ->handle($backup->server->node, $user->id.$backup->server->uuid); return sprintf('%s/download/backup?token=%s', $backup->server->node->getConnectionAddress(), $token->toString()); } diff --git a/app/Services/Files/DeleteFilesService.php b/app/Services/Files/DeleteFilesService.php index 2b1be5fda1..907c12c31a 100644 --- a/app/Services/Files/DeleteFilesService.php +++ b/app/Services/Files/DeleteFilesService.php @@ -29,7 +29,7 @@ public function handle(Server $server, array $files): void $pattern = basename($line); collect($this->daemonFileRepository->setServer($server)->getDirectory($path))->each(function ($item) use ($path, $pattern, $filesToDelete) { if (Str::is($pattern, $item['name'])) { - $filesToDelete->push($path . '/' . $item['name']); + $filesToDelete->push($path.'/'.$item['name']); } }); } diff --git a/app/Services/Helpers/AssetHashService.php b/app/Services/Helpers/AssetHashService.php index f94c32f3ba..304dabdfcd 100644 --- a/app/Services/Helpers/AssetHashService.php +++ b/app/Services/Helpers/AssetHashService.php @@ -70,7 +70,7 @@ public function css(string $resource): string $output .= " $key=\"$value\""; } - return $output . '>'; + return $output.'>'; } /** @@ -92,7 +92,7 @@ public function js(string $resource): string $output .= " $key=\"$value\""; } - return $output . '>'; + return $output.'>'; } /** diff --git a/app/Services/Helpers/SoftwareVersionService.php b/app/Services/Helpers/SoftwareVersionService.php index 7d50203bf1..18c212d991 100644 --- a/app/Services/Helpers/SoftwareVersionService.php +++ b/app/Services/Helpers/SoftwareVersionService.php @@ -127,13 +127,13 @@ public function versionData(): array $head = explode(' ', file_get_contents(base_path('.git/HEAD'))); if (array_key_exists(1, $head)) { - $path = base_path('.git/' . trim($head[1])); + $path = base_path('.git/'.trim($head[1])); } } if (isset($path) && file_exists($path)) { return [ - 'version' => 'canary (' . substr(file_get_contents($path), 0, 8) . ')', + 'version' => 'canary ('.substr(file_get_contents($path), 0, 8).')', 'is_git' => true, ]; } diff --git a/app/Services/Servers/StartupCommandService.php b/app/Services/Servers/StartupCommandService.php index 4703eb0753..1c6ff1be2d 100644 --- a/app/Services/Servers/StartupCommandService.php +++ b/app/Services/Servers/StartupCommandService.php @@ -15,7 +15,7 @@ public function handle(Server $server, bool $hideAllValues = false): string $replace = [$server->memory, $server->allocation->ip, $server->allocation->port]; foreach ($server->variables as $variable) { - $find[] = '{{' . $variable->env_variable . '}}'; + $find[] = '{{'.$variable->env_variable.'}}'; $replace[] = ($variable->user_viewable && !$hideAllValues) ? ($variable->server_value ?? $variable->default_value) : '[hidden]'; } diff --git a/app/Services/Servers/TransferServerService.php b/app/Services/Servers/TransferServerService.php index 4312369dd7..070f84f321 100644 --- a/app/Services/Servers/TransferServerService.php +++ b/app/Services/Servers/TransferServerService.php @@ -31,8 +31,8 @@ private function notify(Server $server, Plain $token): void Http::daemon($server->node)->post('/api/transfer', [ 'json' => [ 'server_id' => $server->uuid, - 'url' => $server->node->getConnectionAddress() . "/api/servers/$server->uuid/archive", - 'token' => 'Bearer ' . $token->toString(), + 'url' => $server->node->getConnectionAddress()."/api/servers/$server->uuid/archive", + 'token' => 'Bearer '.$token->toString(), 'server' => [ 'uuid' => $server->uuid, 'start_on_completion' => false, diff --git a/app/Services/Servers/VariableValidatorService.php b/app/Services/Servers/VariableValidatorService.php index 75f4a59b14..904e494d90 100644 --- a/app/Services/Servers/VariableValidatorService.php +++ b/app/Services/Servers/VariableValidatorService.php @@ -40,8 +40,8 @@ public function handle(int $egg, array $fields = []): Collection $data = $rules = $customAttributes = []; foreach ($variables as $variable) { $data['environment'][$variable->env_variable] = array_get($fields, $variable->env_variable); - $rules['environment.' . $variable->env_variable] = $variable->rules; - $customAttributes['environment.' . $variable->env_variable] = trans('validation.internal.variable_value', ['env' => $variable->name]); + $rules['environment.'.$variable->env_variable] = $variable->rules; + $customAttributes['environment.'.$variable->env_variable] = trans('validation.internal.variable_value', ['env' => $variable->name]); } $validator = $this->validator->make($data, $rules, [], $customAttributes); diff --git a/app/Services/Subusers/SubuserCreationService.php b/app/Services/Subusers/SubuserCreationService.php index 0f9508ba72..0439afd52d 100644 --- a/app/Services/Subusers/SubuserCreationService.php +++ b/app/Services/Subusers/SubuserCreationService.php @@ -39,7 +39,7 @@ public function handle(Server $server, string $email, array $permissions): Subus if (!$user) { // Just cap the username generated at 64 characters at most and then append a random string // to the end to make it "unique"... - $username = substr(preg_replace('/([^\w\.-]+)/', '', strtok($email, '@')), 0, 64) . Str::random(3); + $username = substr(preg_replace('/([^\w\.-]+)/', '', strtok($email, '@')), 0, 64).Str::random(3); $user = $this->userCreationService->handle([ 'email' => $email, diff --git a/app/Traits/EnvironmentWriterTrait.php b/app/Traits/EnvironmentWriterTrait.php index 460d8000e1..2eaca0e6fe 100644 --- a/app/Traits/EnvironmentWriterTrait.php +++ b/app/Traits/EnvironmentWriterTrait.php @@ -36,10 +36,10 @@ public function writeToEnvironment(array $values = []): void $key = strtoupper($key); $saveValue = sprintf('%s=%s', $key, $this->escapeEnvironmentValue($value ?? '')); - if (preg_match_all('/^' . $key . '=(.*)$/m', $saveContents) < 1) { - $saveContents = $saveContents . PHP_EOL . $saveValue; + if (preg_match_all('/^'.$key.'=(.*)$/m', $saveContents) < 1) { + $saveContents = $saveContents.PHP_EOL.$saveValue; } else { - $saveContents = preg_replace('/^' . $key . '=(.*)$/m', $saveValue, $saveContents); + $saveContents = preg_replace('/^'.$key.'=(.*)$/m', $saveValue, $saveContents); } }); diff --git a/app/Transformers/Api/Client/ActivityLogTransformer.php b/app/Transformers/Api/Client/ActivityLogTransformer.php index 58d5f13ae5..1d38507ec7 100644 --- a/app/Transformers/Api/Client/ActivityLogTransformer.php +++ b/app/Transformers/Api/Client/ActivityLogTransformer.php @@ -62,7 +62,7 @@ protected function properties(ActivityLog $model): object if (!is_array($value)) { // Perform some directory normalization at this point. if ($key === 'directory') { - $value = str_replace('//', '/', '/' . trim($value, '/') . '/'); + $value = str_replace('//', '/', '/'.trim($value, '/').'/'); } return [$key => $value]; @@ -94,7 +94,7 @@ protected function hasAdditionalMetadata(ActivityLog $model): bool return false; } - $str = trans('activity.' . str_replace(':', '.', $model->event)); + $str = trans('activity.'.str_replace(':', '.', $model->event)); preg_match_all('/:(?[\w.-]+\w)(?:[^\w:]?|$)/', $str, $matches); $exclude = array_merge($matches['key'], ['ip', 'useragent', 'using_sftp']); diff --git a/app/Transformers/Api/Client/UserTransformer.php b/app/Transformers/Api/Client/UserTransformer.php index f875463e56..06160a7225 100644 --- a/app/Transformers/Api/Client/UserTransformer.php +++ b/app/Transformers/Api/Client/UserTransformer.php @@ -28,7 +28,7 @@ public function transform(User $user): array 'first_name' => $user->name_first, 'last_name' => $user->name_last, 'language' => $user->language, - 'image' => 'https://gravatar.com/avatar/' . md5(Str::lower($user->email)), // deprecated + 'image' => 'https://gravatar.com/avatar/'.md5(Str::lower($user->email)), // deprecated 'admin' => $user->isRootAdmin(), // deprecated, use "root_admin" 'root_admin' => $user->isRootAdmin(), '2fa_enabled' => (bool) $user->use_totp, diff --git a/bootstrap/tests.php b/bootstrap/tests.php index a80e0b27f9..148613856d 100644 --- a/bootstrap/tests.php +++ b/bootstrap/tests.php @@ -5,9 +5,9 @@ use Illuminate\Contracts\Console\Kernel; use Symfony\Component\Console\Output\ConsoleOutput; -require __DIR__ . '/../vendor/autoload.php'; +require __DIR__.'/../vendor/autoload.php'; -$app = require __DIR__ . '/app.php'; +$app = require __DIR__.'/app.php'; /** @var \App\Console\Kernel $kernel */ $kernel = $app->make(Kernel::class); @@ -23,10 +23,10 @@ $output = new ConsoleOutput(); -$prefix = 'database.connections.' . config('database.default'); +$prefix = 'database.connections.'.config('database.default'); if (!Str::contains(config("$prefix.database"), 'test')) { - $output->writeln(PHP_EOL . 'Cannot run test process against non-testing database.'); - $output->writeln(PHP_EOL . 'Environment is currently pointed at: "' . config("$prefix.database") . '".'); + $output->writeln(PHP_EOL.'Cannot run test process against non-testing database.'); + $output->writeln(PHP_EOL.'Environment is currently pointed at: "'.config("$prefix.database").'".'); exit(1); } @@ -35,11 +35,11 @@ * running the tests. */ if (!env('SKIP_MIGRATIONS')) { - $output->writeln(PHP_EOL . 'Refreshing database for Integration tests...'); + $output->writeln(PHP_EOL.'Refreshing database for Integration tests...'); $kernel->call('migrate:fresh'); - $output->writeln('Seeding database for Integration tests...' . PHP_EOL); + $output->writeln('Seeding database for Integration tests...'.PHP_EOL); $kernel->call('db:seed'); } else { - $output->writeln(PHP_EOL . 'Skipping database migrations...' . PHP_EOL); + $output->writeln(PHP_EOL.'Skipping database migrations...'.PHP_EOL); } diff --git a/database/Factories/NodeFactory.php b/database/Factories/NodeFactory.php index 19a1fbf7b1..7d0ac25a19 100644 --- a/database/Factories/NodeFactory.php +++ b/database/Factories/NodeFactory.php @@ -24,7 +24,7 @@ public function definition(): array return [ 'uuid' => Uuid::uuid4()->toString(), 'public' => true, - 'name' => 'FactoryNode_' . Str::random(10), + 'name' => 'FactoryNode_'.Str::random(10), 'fqdn' => $this->faker->unique()->ipv4(), 'scheme' => 'http', 'behind_proxy' => false, diff --git a/database/Factories/UserFactory.php b/database/Factories/UserFactory.php index 3c6003cc24..6284e7471b 100644 --- a/database/Factories/UserFactory.php +++ b/database/Factories/UserFactory.php @@ -27,8 +27,8 @@ public function definition(): array return [ 'external_id' => null, 'uuid' => Uuid::uuid4()->toString(), - 'username' => $this->faker->userName() . '_' . Str::random(10), - 'email' => Str::random(32) . '@example.com', + 'username' => $this->faker->userName().'_'.Str::random(10), + 'email' => Str::random(32).'@example.com', 'name_first' => $this->faker->firstName(), 'name_last' => $this->faker->lastName(), 'password' => $password ?: $password = bcrypt('password'), diff --git a/database/Seeders/EggSeeder.php b/database/Seeders/EggSeeder.php index dcbc4f25c1..3053bfa76b 100644 --- a/database/Seeders/EggSeeder.php +++ b/database/Seeders/EggSeeder.php @@ -47,9 +47,9 @@ public function run() */ protected function parseEggFiles($name) { - $files = new \DirectoryIterator(database_path('Seeders/eggs/' . kebab_case($name))); + $files = new \DirectoryIterator(database_path('Seeders/eggs/'.kebab_case($name))); - $this->command->alert('Updating Eggs for: ' . $name); + $this->command->alert('Updating Eggs for: '.$name); /** @var \DirectoryIterator $file */ foreach ($files as $file) { if (!$file->isFile() || !$file->isReadable()) { @@ -71,10 +71,10 @@ protected function parseEggFiles($name) if ($egg instanceof Egg) { $this->importerService->fromFile($file, $egg); - $this->command->info('Updated ' . $decoded['name']); + $this->command->info('Updated '.$decoded['name']); } else { $this->importerService->fromFile($file); - $this->command->comment('Created ' . $decoded['name']); + $this->command->comment('Created '.$decoded['name']); } } diff --git a/database/migrations/2017_03_11_215455_ChangeServiceVariablesValidationRules.php b/database/migrations/2017_03_11_215455_ChangeServiceVariablesValidationRules.php index b96b2ba24a..5d8d38e6da 100644 --- a/database/migrations/2017_03_11_215455_ChangeServiceVariablesValidationRules.php +++ b/database/migrations/2017_03_11_215455_ChangeServiceVariablesValidationRules.php @@ -17,7 +17,7 @@ public function up(): void DB::transaction(function () { foreach (DB::table('service_variables')->get() as $variable) { - $variable->rules = ($variable->required) ? 'required|regex:' . $variable->rules : 'regex:' . $variable->rules; + $variable->rules = ($variable->required) ? 'required|regex:'.$variable->rules : 'regex:'.$variable->rules; $variable->save(); } }); diff --git a/database/migrations/2017_09_13_211810_UpdateOldPermissionsToPointToNewScheduleSystem.php b/database/migrations/2017_09_13_211810_UpdateOldPermissionsToPointToNewScheduleSystem.php index aca8afb6c1..4e50c9a84d 100644 --- a/database/migrations/2017_09_13_211810_UpdateOldPermissionsToPointToNewScheduleSystem.php +++ b/database/migrations/2017_09_13_211810_UpdateOldPermissionsToPointToNewScheduleSystem.php @@ -17,7 +17,7 @@ public function up(): void continue; } - $newPermission = $parts[0] . '-' . str_replace('task', 'schedule', $parts[1]); + $newPermission = $parts[0].'-'.str_replace('task', 'schedule', $parts[1]); DB::table('permissions')->where('id', '=', $record->id)->update(['permission' => $newPermission]); } @@ -35,7 +35,7 @@ public function down(): void continue; } - $newPermission = $parts[0] . '-' . str_replace('schedule', 'task', $parts[1]); + $newPermission = $parts[0].'-'.str_replace('schedule', 'task', $parts[1]); DB::table('permissions')->where('id', '=', $record->id)->update(['permission' => $newPermission]); } diff --git a/database/migrations/2017_09_23_173628_RemoveDaemonSecretFromServersTable.php b/database/migrations/2017_09_23_173628_RemoveDaemonSecretFromServersTable.php index ab2e8056e7..e99078b667 100644 --- a/database/migrations/2017_09_23_173628_RemoveDaemonSecretFromServersTable.php +++ b/database/migrations/2017_09_23_173628_RemoveDaemonSecretFromServersTable.php @@ -21,7 +21,7 @@ public function up(): void $inserts[] = [ 'user_id' => $server->owner_id, 'server_id' => $server->id, - 'secret' => DaemonKeyRepositoryInterface::INTERNAL_KEY_IDENTIFIER . str_random(40), + 'secret' => DaemonKeyRepositoryInterface::INTERNAL_KEY_IDENTIFIER.str_random(40), 'expires_at' => Carbon::now()->addMinutes(config('panel.api.key_expire_time', 720))->toDateTimeString(), 'created_at' => Carbon::now()->toDateTimeString(), 'updated_at' => Carbon::now()->toDateTimeString(), diff --git a/database/migrations/2017_09_23_185022_RemoveDaemonSecretFromSubusersTable.php b/database/migrations/2017_09_23_185022_RemoveDaemonSecretFromSubusersTable.php index 9090be4072..60b0d63582 100644 --- a/database/migrations/2017_09_23_185022_RemoveDaemonSecretFromSubusersTable.php +++ b/database/migrations/2017_09_23_185022_RemoveDaemonSecretFromSubusersTable.php @@ -19,7 +19,7 @@ public function up(): void $inserts[] = [ 'user_id' => $subuser->user_id, 'server_id' => $subuser->server_id, - 'secret' => DaemonKeyRepositoryInterface::INTERNAL_KEY_IDENTIFIER . str_random(40), + 'secret' => DaemonKeyRepositoryInterface::INTERNAL_KEY_IDENTIFIER.str_random(40), 'expires_at' => Carbon::now()->addMinutes(config('panel.api.key_expire_time', 720))->toDateTimeString(), 'created_at' => Carbon::now()->toDateTimeString(), 'updated_at' => Carbon::now()->toDateTimeString(), diff --git a/database/migrations/2020_03_22_163911_merge_permissions_table_into_subusers.php b/database/migrations/2020_03_22_163911_merge_permissions_table_into_subusers.php index 6a9280b5f0..2a10ba96c8 100644 --- a/database/migrations/2020_03_22_163911_merge_permissions_table_into_subusers.php +++ b/database/migrations/2020_03_22_163911_merge_permissions_table_into_subusers.php @@ -112,9 +112,9 @@ public function down(): void } if (!empty($values)) { - $string = 'VALUES ' . implode(', ', array_fill(0, count($values) / 2, '(?, ?)')); + $string = 'VALUES '.implode(', ', array_fill(0, count($values) / 2, '(?, ?)')); - DB::insert('INSERT INTO permissions(`subuser_id`, `permission`) ' . $string, $values); + DB::insert('INSERT INTO permissions(`subuser_id`, `permission`) '.$string, $values); } } diff --git a/database/migrations/2020_04_10_141024_store_node_tokens_as_encrypted_value.php b/database/migrations/2020_04_10_141024_store_node_tokens_as_encrypted_value.php index 911461d709..d98bbc3c8a 100644 --- a/database/migrations/2020_04_10_141024_store_node_tokens_as_encrypted_value.php +++ b/database/migrations/2020_04_10_141024_store_node_tokens_as_encrypted_value.php @@ -53,7 +53,7 @@ public function down(): void DB::transaction(function () { foreach (DB::select('SELECT id, daemon_token_id, daemon_token FROM nodes') as $datum) { DB::update('UPDATE nodes SET daemon_token = ? WHERE id = ?', [ - $datum->daemon_token_id . decrypt($datum->daemon_token), + $datum->daemon_token_id.decrypt($datum->daemon_token), $datum->id, ]); } diff --git a/pint.json b/pint.json index 17de52db66..e6d2cafb88 100644 --- a/pint.json +++ b/pint.json @@ -1,7 +1,6 @@ { "preset": "laravel", "rules": { - "concat_space": false, "not_operator_with_successor_space": false, "nullable_type_declaration_for_default_null_value": false, "ordered_imports": false, diff --git a/tests/Assertions/AssertsActivityLogged.php b/tests/Assertions/AssertsActivityLogged.php index db352bc975..ecc33a8335 100644 --- a/tests/Assertions/AssertsActivityLogged.php +++ b/tests/Assertions/AssertsActivityLogged.php @@ -35,7 +35,7 @@ public function assertActivityLogged(string $event): void public function assertActivitySubjects(string $event, Model|array $subjects): void { if (is_array($subjects)) { - \Webmozart\Assert\Assert::lessThanEq(count(func_get_args()), 2, 'Invalid call to ' . __METHOD__ . ': cannot provide additional arguments if providing an array.'); + \Webmozart\Assert\Assert::lessThanEq(count(func_get_args()), 2, 'Invalid call to '.__METHOD__.': cannot provide additional arguments if providing an array.'); } else { $subjects = array_slice(func_get_args(), 1); } diff --git a/tests/Assertions/MiddlewareAttributeAssertionsTrait.php b/tests/Assertions/MiddlewareAttributeAssertionsTrait.php index ab24f0311e..4a8441abec 100644 --- a/tests/Assertions/MiddlewareAttributeAssertionsTrait.php +++ b/tests/Assertions/MiddlewareAttributeAssertionsTrait.php @@ -11,7 +11,7 @@ trait MiddlewareAttributeAssertionsTrait */ public function assertRequestHasAttribute(string $attribute): void { - Assert::assertTrue($this->request->attributes->has($attribute), 'Assert that request mock has ' . $attribute . ' attribute.'); + Assert::assertTrue($this->request->attributes->has($attribute), 'Assert that request mock has '.$attribute.' attribute.'); } /** @@ -19,7 +19,7 @@ public function assertRequestHasAttribute(string $attribute): void */ public function assertRequestMissingAttribute(string $attribute): void { - Assert::assertFalse($this->request->attributes->has($attribute), 'Assert that request mock does not have ' . $attribute . ' attribute.'); + Assert::assertFalse($this->request->attributes->has($attribute), 'Assert that request mock does not have '.$attribute.' attribute.'); } /** diff --git a/tests/Integration/Api/Application/ApplicationApiIntegrationTestCase.php b/tests/Integration/Api/Application/ApplicationApiIntegrationTestCase.php index c104a3eae9..02b674a9ad 100644 --- a/tests/Integration/Api/Application/ApplicationApiIntegrationTestCase.php +++ b/tests/Integration/Api/Application/ApplicationApiIntegrationTestCase.php @@ -38,7 +38,7 @@ protected function setUp(): void $this ->withHeader('Accept', 'application/vnd.panel.v1+json') - ->withHeader('Authorization', 'Bearer ' . $this->key->identifier . $this->key->token); + ->withHeader('Authorization', 'Bearer '.$this->key->identifier.$this->key->token); } public function getApiUser(): User @@ -58,7 +58,7 @@ protected function createNewDefaultApiKey(User $user, array $permissions = []): { $this->key = $this->createApiKey($user, $permissions); - $this->withHeader('Authorization', 'Bearer ' . $this->key->identifier . $this->key->token); + $this->withHeader('Authorization', 'Bearer '.$this->key->identifier.$this->key->token); return $this->key; } diff --git a/tests/Integration/Api/Application/EggControllerTest.php b/tests/Integration/Api/Application/EggControllerTest.php index 14a41cd6af..62ab2422f9 100644 --- a/tests/Integration/Api/Application/EggControllerTest.php +++ b/tests/Integration/Api/Application/EggControllerTest.php @@ -48,7 +48,7 @@ public function testListAllEggs(): void $this->assertSame( $expected, $actual, - 'Unable to find JSON fragment: ' . PHP_EOL . PHP_EOL . "[$expected]" . PHP_EOL . PHP_EOL . 'within' . PHP_EOL . PHP_EOL . "[$actual]." + 'Unable to find JSON fragment: '.PHP_EOL.PHP_EOL."[$expected]".PHP_EOL.PHP_EOL.'within'.PHP_EOL.PHP_EOL."[$actual]." ); } } @@ -60,7 +60,7 @@ public function testReturnSingleEgg(): void { $egg = Egg::query()->findOrFail(1); - $response = $this->getJson('/api/application/eggs/' . $egg->id); + $response = $this->getJson('/api/application/eggs/'.$egg->id); $response->assertStatus(Response::HTTP_OK); $response->assertJsonStructure([ 'object', @@ -82,7 +82,7 @@ public function testReturnSingleEggWithRelationships(): void { $egg = Egg::query()->findOrFail(1); - $response = $this->getJson('/api/application/eggs/' . $egg->id . '?include=servers,variables'); + $response = $this->getJson('/api/application/eggs/'.$egg->id.'?include=servers,variables'); $response->assertStatus(Response::HTTP_OK); $response->assertJsonStructure([ 'object', diff --git a/tests/Integration/Api/Application/Users/ExternalUserControllerTest.php b/tests/Integration/Api/Application/Users/ExternalUserControllerTest.php index 24f3996ebf..4ef873c433 100644 --- a/tests/Integration/Api/Application/Users/ExternalUserControllerTest.php +++ b/tests/Integration/Api/Application/Users/ExternalUserControllerTest.php @@ -16,7 +16,7 @@ public function testGetRemoteUser(): void { $user = User::factory()->create(['external_id' => Str::random()]); - $response = $this->getJson('/api/application/users/external/' . $user->external_id); + $response = $this->getJson('/api/application/users/external/'.$user->external_id); $response->assertStatus(Response::HTTP_OK); $response->assertJsonCount(2); $response->assertJsonStructure([ @@ -64,7 +64,7 @@ public function testErrorReturnedIfNoPermission(): void $user = User::factory()->create(['external_id' => Str::random()]); $this->createNewDefaultApiKey($this->getApiUser(), ['r_users' => 0]); - $response = $this->getJson('/api/application/users/external/' . $user->external_id); + $response = $this->getJson('/api/application/users/external/'.$user->external_id); $this->assertAccessDeniedJson($response); } } diff --git a/tests/Integration/Api/Application/Users/UserControllerTest.php b/tests/Integration/Api/Application/Users/UserControllerTest.php index 6787ff1f4e..04ba5c2e6e 100644 --- a/tests/Integration/Api/Application/Users/UserControllerTest.php +++ b/tests/Integration/Api/Application/Users/UserControllerTest.php @@ -89,7 +89,7 @@ public function testGetSingleUser(): void { $user = User::factory()->create(); - $response = $this->getJson('/api/application/users/' . $user->id); + $response = $this->getJson('/api/application/users/'.$user->id); $response->assertStatus(Response::HTTP_OK); $response->assertJsonCount(2); $response->assertJsonStructure([ @@ -124,7 +124,7 @@ public function testRelationshipsCanBeLoaded(): void $user = User::factory()->create(); $server = $this->createServerModel(['user_id' => $user->id]); - $response = $this->getJson('/api/application/users/' . $user->id . '?include=servers'); + $response = $this->getJson('/api/application/users/'.$user->id.'?include=servers'); $response->assertStatus(Response::HTTP_OK); $response->assertJsonCount(2); $response->assertJsonStructure([ @@ -157,7 +157,7 @@ public function testKeyWithoutPermissionCannotLoadRelationship(): void $user = User::factory()->create(); $this->createServerModel(['user_id' => $user->id]); - $response = $this->getJson('/api/application/users/' . $user->id . '?include=servers'); + $response = $this->getJson('/api/application/users/'.$user->id.'?include=servers'); $response->assertStatus(Response::HTTP_OK); $response->assertJsonCount(2)->assertJsonCount(1, 'attributes.relationships'); $response->assertJsonStructure([ @@ -199,7 +199,7 @@ public function testErrorReturnedIfNoPermission(): void $user = User::factory()->create(); $this->createNewDefaultApiKey($this->getApiUser(), ['r_users' => 0]); - $response = $this->getJson('/api/application/users/' . $user->id); + $response = $this->getJson('/api/application/users/'.$user->id); $this->assertAccessDeniedJson($response); } @@ -242,7 +242,7 @@ public function testUpdateUser(): void { $user = User::factory()->create(); - $response = $this->patchJson('/api/application/users/' . $user->id, [ + $response = $this->patchJson('/api/application/users/'.$user->id, [ 'username' => 'new.test.name', 'email' => 'new@emailtest.com', 'first_name' => $user->name_first, @@ -272,7 +272,7 @@ public function testDeleteUser(): void $user = User::factory()->create(); $this->assertDatabaseHas('users', ['id' => $user->id]); - $response = $this->delete('/api/application/users/' . $user->id); + $response = $this->delete('/api/application/users/'.$user->id); $response->assertStatus(Response::HTTP_NO_CONTENT); $this->assertDatabaseMissing('users', ['id' => $user->id]); diff --git a/tests/Integration/Api/Client/AccountControllerTest.php b/tests/Integration/Api/Client/AccountControllerTest.php index ccca6818d5..38ce80fa96 100644 --- a/tests/Integration/Api/Client/AccountControllerTest.php +++ b/tests/Integration/Api/Client/AccountControllerTest.php @@ -28,7 +28,7 @@ public function testAccountDetailsAreReturned(): void 'first_name' => $user->name_first, 'last_name' => $user->name_last, 'language' => 'en', - 'image' => 'https://gravatar.com/avatar/' . md5(Str::lower($user->email)), + 'image' => 'https://gravatar.com/avatar/'.md5(Str::lower($user->email)), 'admin' => false, 'root_admin' => false, '2fa_enabled' => false, @@ -47,7 +47,7 @@ public function testEmailIsUpdated(): void $user = User::factory()->create(); $response = $this->actingAs($user)->putJson('/api/client/account/email', [ - 'email' => $email = Str::random() . '@example.com', + 'email' => $email = Str::random().'@example.com', 'password' => 'password', ]); diff --git a/tests/Integration/Api/Client/ApiKeyControllerTest.php b/tests/Integration/Api/Client/ApiKeyControllerTest.php index 462875c59b..27662a1735 100644 --- a/tests/Integration/Api/Client/ApiKeyControllerTest.php +++ b/tests/Integration/Api/Client/ApiKeyControllerTest.php @@ -83,7 +83,7 @@ public function testApiKeyCannotSpecifyMoreThanFiftyIps(): void { $ips = []; for ($i = 0; $i < 100; $i++) { - $ips[] = '127.0.0.' . $i; + $ips[] = '127.0.0.'.$i; } $this->actingAs(User::factory()->create()) @@ -162,7 +162,7 @@ public function testApiKeyCanBeDeleted(): void 'key_type' => ApiKey::TYPE_ACCOUNT, ]); - $response = $this->actingAs($user)->delete('/api/client/account/api-keys/' . $key->identifier); + $response = $this->actingAs($user)->delete('/api/client/account/api-keys/'.$key->identifier); $response->assertStatus(Response::HTTP_NO_CONTENT); $this->assertDatabaseMissing('api_keys', ['id' => $key->id]); @@ -205,7 +205,7 @@ public function testApiKeyBelongingToAnotherUserCannotBeDeleted(): void ]); $this->actingAs($user) - ->deleteJson('/api/client/account/api-keys/' . $key->identifier) + ->deleteJson('/api/client/account/api-keys/'.$key->identifier) ->assertNotFound(); $this->assertDatabaseHas('api_keys', ['id' => $key->id]); @@ -226,7 +226,7 @@ public function testApplicationApiKeyCannotBeDeleted(): void ]); $this->actingAs($user) - ->deleteJson('/api/client/account/api-keys/' . $key->identifier) + ->deleteJson('/api/client/account/api-keys/'.$key->identifier) ->assertNotFound(); $this->assertDatabaseHas('api_keys', ['id' => $key->id]); diff --git a/tests/Integration/Api/Client/ClientApiIntegrationTestCase.php b/tests/Integration/Api/Client/ClientApiIntegrationTestCase.php index e909bb41ec..44c06e5700 100644 --- a/tests/Integration/Api/Client/ClientApiIntegrationTestCase.php +++ b/tests/Integration/Api/Client/ClientApiIntegrationTestCase.php @@ -69,7 +69,7 @@ protected function link(mixed $model, string $append = null): string throw new \InvalidArgumentException(sprintf('Cannot create link for Model of type %s', class_basename($model))); } - return $link . ($append ? '/' . ltrim($append, '/') : ''); + return $link.($append ? '/'.ltrim($append, '/') : ''); } /** diff --git a/tests/Integration/Api/Client/ClientControllerTest.php b/tests/Integration/Api/Client/ClientControllerTest.php index e4059f6947..4e5e26b272 100644 --- a/tests/Integration/Api/Client/ClientControllerTest.php +++ b/tests/Integration/Api/Client/ClientControllerTest.php @@ -298,7 +298,7 @@ public function testNoServersAreReturnedIfAdminFilterIsPassedByRegularUser(strin $this->createServerModel(['user_id' => $users[1]->id]); $this->createServerModel(['user_id' => $users[2]->id]); - $response = $this->actingAs($users[0])->getJson('/api/client?type=' . $type); + $response = $this->actingAs($users[0])->getJson('/api/client?type='.$type); $response->assertOk(); $response->assertJsonCount(0, 'data'); diff --git a/tests/Integration/Api/Client/Server/Allocation/AllocationAuthorizationTest.php b/tests/Integration/Api/Client/Server/Allocation/AllocationAuthorizationTest.php index 6cd798e165..f1d93f8ad3 100644 --- a/tests/Integration/Api/Client/Server/Allocation/AllocationAuthorizationTest.php +++ b/tests/Integration/Api/Client/Server/Allocation/AllocationAuthorizationTest.php @@ -30,20 +30,20 @@ public function testAccessToAServersAllocationsIsRestrictedProperly(string $meth // This is the only valid call for this test, accessing the allocation for the same // server that the API user is the owner of. - $response = $this->actingAs($user)->json($method, $this->link($server1, '/network/allocations/' . $allocation1->id . $endpoint)); + $response = $this->actingAs($user)->json($method, $this->link($server1, '/network/allocations/'.$allocation1->id.$endpoint)); $this->assertTrue($response->status() <= 204 || $response->status() === 400 || $response->status() === 422); // This request fails because the allocation is valid for that server but the user // making the request is not authorized to perform that action. - $this->actingAs($user)->json($method, $this->link($server2, '/network/allocations/' . $allocation2->id . $endpoint))->assertForbidden(); + $this->actingAs($user)->json($method, $this->link($server2, '/network/allocations/'.$allocation2->id.$endpoint))->assertForbidden(); // Both of these should report a 404 error due to the allocations being linked to // servers that are not the same as the server in the request, or are assigned // to a server for which the user making the request has no access to. - $this->actingAs($user)->json($method, $this->link($server1, '/network/allocations/' . $allocation2->id . $endpoint))->assertNotFound(); - $this->actingAs($user)->json($method, $this->link($server1, '/network/allocations/' . $allocation3->id . $endpoint))->assertNotFound(); - $this->actingAs($user)->json($method, $this->link($server2, '/network/allocations/' . $allocation3->id . $endpoint))->assertNotFound(); - $this->actingAs($user)->json($method, $this->link($server3, '/network/allocations/' . $allocation3->id . $endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server1, '/network/allocations/'.$allocation2->id.$endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server1, '/network/allocations/'.$allocation3->id.$endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server2, '/network/allocations/'.$allocation3->id.$endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server3, '/network/allocations/'.$allocation3->id.$endpoint))->assertNotFound(); } public static function methodDataProvider(): array diff --git a/tests/Integration/Api/Client/Server/Backup/BackupAuthorizationTest.php b/tests/Integration/Api/Client/Server/Backup/BackupAuthorizationTest.php index 472364d78e..c91c2e3a10 100644 --- a/tests/Integration/Api/Client/Server/Backup/BackupAuthorizationTest.php +++ b/tests/Integration/Api/Client/Server/Backup/BackupAuthorizationTest.php @@ -38,20 +38,20 @@ public function testAccessToAServersBackupIsRestrictedProperly(string $method, s // This is the only valid call for this test, accessing the backup for the same // server that the API user is the owner of. - $this->actingAs($user)->json($method, $this->link($server1, '/backups/' . $backup1->uuid . $endpoint)) + $this->actingAs($user)->json($method, $this->link($server1, '/backups/'.$backup1->uuid.$endpoint)) ->assertStatus($method === 'DELETE' ? 204 : 200); // This request fails because the backup is valid for that server but the user // making the request is not authorized to perform that action. - $this->actingAs($user)->json($method, $this->link($server2, '/backups/' . $backup2->uuid . $endpoint))->assertForbidden(); + $this->actingAs($user)->json($method, $this->link($server2, '/backups/'.$backup2->uuid.$endpoint))->assertForbidden(); // Both of these should report a 404 error due to the backup being linked to // servers that are not the same as the server in the request, or are assigned // to a server for which the user making the request has no access to. - $this->actingAs($user)->json($method, $this->link($server1, '/backups/' . $backup2->uuid . $endpoint))->assertNotFound(); - $this->actingAs($user)->json($method, $this->link($server1, '/backups/' . $backup3->uuid . $endpoint))->assertNotFound(); - $this->actingAs($user)->json($method, $this->link($server2, '/backups/' . $backup3->uuid . $endpoint))->assertNotFound(); - $this->actingAs($user)->json($method, $this->link($server3, '/backups/' . $backup3->uuid . $endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server1, '/backups/'.$backup2->uuid.$endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server1, '/backups/'.$backup3->uuid.$endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server2, '/backups/'.$backup3->uuid.$endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server3, '/backups/'.$backup3->uuid.$endpoint))->assertNotFound(); } public static function methodDataProvider(): array diff --git a/tests/Integration/Api/Client/Server/Database/DatabaseAuthorizationTest.php b/tests/Integration/Api/Client/Server/Database/DatabaseAuthorizationTest.php index b95778104a..2c8320812f 100644 --- a/tests/Integration/Api/Client/Server/Database/DatabaseAuthorizationTest.php +++ b/tests/Integration/Api/Client/Server/Database/DatabaseAuthorizationTest.php @@ -40,20 +40,20 @@ public function testAccessToAServersDatabasesIsRestrictedProperly(string $method // This is the only valid call for this test, accessing the database for the same // server that the API user is the owner of. - $this->actingAs($user)->json($method, $this->link($server1, '/databases/' . $database1->id . $endpoint)) + $this->actingAs($user)->json($method, $this->link($server1, '/databases/'.$database1->id.$endpoint)) ->assertStatus($method === 'DELETE' ? 204 : 200); // This request fails because the database is valid for that server but the user // making the request is not authorized to perform that action. - $this->actingAs($user)->json($method, $this->link($server2, '/databases/' . $database2->id . $endpoint))->assertForbidden(); + $this->actingAs($user)->json($method, $this->link($server2, '/databases/'.$database2->id.$endpoint))->assertForbidden(); // Both of these should report a 404 error due to the database being linked to // servers that are not the same as the server in the request, or are assigned // to a server for which the user making the request has no access to. - $this->actingAs($user)->json($method, $this->link($server1, '/databases/' . $database2->id . $endpoint))->assertNotFound(); - $this->actingAs($user)->json($method, $this->link($server1, '/databases/' . $database3->id . $endpoint))->assertNotFound(); - $this->actingAs($user)->json($method, $this->link($server2, '/databases/' . $database3->id . $endpoint))->assertNotFound(); - $this->actingAs($user)->json($method, $this->link($server3, '/databases/' . $database3->id . $endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server1, '/databases/'.$database2->id.$endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server1, '/databases/'.$database3->id.$endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server2, '/databases/'.$database3->id.$endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server3, '/databases/'.$database3->id.$endpoint))->assertNotFound(); } public static function methodDataProvider(): array diff --git a/tests/Integration/Api/Client/Server/Schedule/GetServerSchedulesTest.php b/tests/Integration/Api/Client/Server/Schedule/GetServerSchedulesTest.php index 7d019178bf..5900e67f25 100644 --- a/tests/Integration/Api/Client/Server/Schedule/GetServerSchedulesTest.php +++ b/tests/Integration/Api/Client/Server/Schedule/GetServerSchedulesTest.php @@ -47,13 +47,13 @@ public function testServerSchedulesAreReturned(array $permissions, bool $individ $response->assertJsonCount(1, 'data'); } - $response->assertJsonCount(1, $prefix . 'attributes.relationships.tasks.data'); + $response->assertJsonCount(1, $prefix.'attributes.relationships.tasks.data'); - $response->assertJsonPath($prefix . 'object', Schedule::RESOURCE_NAME); - $response->assertJsonPath($prefix . 'attributes.relationships.tasks.data.0.object', Task::RESOURCE_NAME); + $response->assertJsonPath($prefix.'object', Schedule::RESOURCE_NAME); + $response->assertJsonPath($prefix.'attributes.relationships.tasks.data.0.object', Task::RESOURCE_NAME); - $this->assertJsonTransformedWith($response->json($prefix . 'attributes'), $schedule); - $this->assertJsonTransformedWith($response->json($prefix . 'attributes.relationships.tasks.data.0.attributes'), $task); + $this->assertJsonTransformedWith($response->json($prefix.'attributes'), $schedule); + $this->assertJsonTransformedWith($response->json($prefix.'attributes.relationships.tasks.data.0.attributes'), $task); } /** diff --git a/tests/Integration/Api/Client/Server/Schedule/ScheduleAuthorizationTest.php b/tests/Integration/Api/Client/Server/Schedule/ScheduleAuthorizationTest.php index b6777a7488..011187e71d 100644 --- a/tests/Integration/Api/Client/Server/Schedule/ScheduleAuthorizationTest.php +++ b/tests/Integration/Api/Client/Server/Schedule/ScheduleAuthorizationTest.php @@ -38,20 +38,20 @@ public function testAccessToAServersSchedulesIsRestrictedProperly(string $method // This is the only valid call for this test, accessing the schedule for the same // server that the API user is the owner of. - $response = $this->actingAs($user)->json($method, $this->link($server1, '/schedules/' . $schedule1->id . $endpoint)); + $response = $this->actingAs($user)->json($method, $this->link($server1, '/schedules/'.$schedule1->id.$endpoint)); $this->assertTrue($response->status() <= 204 || $response->status() === 400 || $response->status() === 422); // This request fails because the schedule is valid for that server but the user // making the request is not authorized to perform that action. - $this->actingAs($user)->json($method, $this->link($server2, '/schedules/' . $schedule2->id . $endpoint))->assertForbidden(); + $this->actingAs($user)->json($method, $this->link($server2, '/schedules/'.$schedule2->id.$endpoint))->assertForbidden(); // Both of these should report a 404 error due to the schedules being linked to // servers that are not the same as the server in the request, or are assigned // to a server for which the user making the request has no access to. - $this->actingAs($user)->json($method, $this->link($server1, '/schedules/' . $schedule2->id . $endpoint))->assertNotFound(); - $this->actingAs($user)->json($method, $this->link($server1, '/schedules/' . $schedule3->id . $endpoint))->assertNotFound(); - $this->actingAs($user)->json($method, $this->link($server2, '/schedules/' . $schedule3->id . $endpoint))->assertNotFound(); - $this->actingAs($user)->json($method, $this->link($server3, '/schedules/' . $schedule3->id . $endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server1, '/schedules/'.$schedule2->id.$endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server1, '/schedules/'.$schedule3->id.$endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server2, '/schedules/'.$schedule3->id.$endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server3, '/schedules/'.$schedule3->id.$endpoint))->assertNotFound(); } public static function methodDataProvider(): array diff --git a/tests/Integration/Api/Client/Server/Startup/GetStartupAndVariablesTest.php b/tests/Integration/Api/Client/Server/Startup/GetStartupAndVariablesTest.php index 88cc6ed6f2..b11d06346c 100644 --- a/tests/Integration/Api/Client/Server/Startup/GetStartupAndVariablesTest.php +++ b/tests/Integration/Api/Client/Server/Startup/GetStartupAndVariablesTest.php @@ -33,7 +33,7 @@ public function testStartupVariablesAreReturnedForServer(array $permissions): vo ])->save(); $server = $server->refresh(); - $response = $this->actingAs($user)->getJson($this->link($server) . '/startup'); + $response = $this->actingAs($user)->getJson($this->link($server).'/startup'); $response->assertOk(); $response->assertJsonPath('meta.startup_command', 'java bungeecord.jar --version [hidden]'); @@ -52,10 +52,10 @@ public function testStartupVariablesAreReturnedForServer(array $permissions): vo public function testStartupDataIsNotReturnedWithoutPermission(): void { [$user, $server] = $this->generateTestAccount([Permission::ACTION_WEBSOCKET_CONNECT]); - $this->actingAs($user)->getJson($this->link($server) . '/startup')->assertForbidden(); + $this->actingAs($user)->getJson($this->link($server).'/startup')->assertForbidden(); $user2 = User::factory()->create(); - $this->actingAs($user2)->getJson($this->link($server) . '/startup')->assertNotFound(); + $this->actingAs($user2)->getJson($this->link($server).'/startup')->assertNotFound(); } public static function permissionsDataProvider(): array diff --git a/tests/Integration/Api/Client/Server/Startup/UpdateStartupVariableTest.php b/tests/Integration/Api/Client/Server/Startup/UpdateStartupVariableTest.php index e9c8af97ce..c5471ec11f 100644 --- a/tests/Integration/Api/Client/Server/Startup/UpdateStartupVariableTest.php +++ b/tests/Integration/Api/Client/Server/Startup/UpdateStartupVariableTest.php @@ -23,7 +23,7 @@ public function testStartupVariableCanBeUpdated(array $permissions): void 'startup' => 'java {{SERVER_JARFILE}} --version {{BUNGEE_VERSION}}', ])->save(); - $response = $this->actingAs($user)->putJson($this->link($server) . '/startup/variable', [ + $response = $this->actingAs($user)->putJson($this->link($server).'/startup/variable', [ 'key' => 'BUNGEE_VERSION', 'value' => '1.2.3', ]); @@ -32,7 +32,7 @@ public function testStartupVariableCanBeUpdated(array $permissions): void $response->assertJsonPath('errors.0.code', 'ValidationException'); $response->assertJsonPath('errors.0.detail', 'The value may only contain letters and numbers.'); - $response = $this->actingAs($user)->putJson($this->link($server) . '/startup/variable', [ + $response = $this->actingAs($user)->putJson($this->link($server).'/startup/variable', [ 'key' => 'BUNGEE_VERSION', 'value' => '123', ]); @@ -62,7 +62,7 @@ public function testStartupVariableCannotBeUpdatedIfNotUserViewableOrEditable(ar $server->fill(['egg_id' => $egg->id])->save(); $server->refresh(); - $response = $this->actingAs($user)->putJson($this->link($server) . '/startup/variable', [ + $response = $this->actingAs($user)->putJson($this->link($server).'/startup/variable', [ 'key' => 'BUNGEE_VERSION', 'value' => '123', ]); @@ -71,7 +71,7 @@ public function testStartupVariableCannotBeUpdatedIfNotUserViewableOrEditable(ar $response->assertJsonPath('errors.0.code', 'BadRequestHttpException'); $response->assertJsonPath('errors.0.detail', 'The environment variable you are trying to edit does not exist.'); - $response = $this->actingAs($user)->putJson($this->link($server) . '/startup/variable', [ + $response = $this->actingAs($user)->putJson($this->link($server).'/startup/variable', [ 'key' => 'SERVER_JARFILE', 'value' => 'server2.jar', ]); @@ -100,7 +100,7 @@ public function testHiddenVariablesAreNotReturnedInStartupCommandWhenUpdatingVar $server->refresh(); - $response = $this->actingAs($user)->putJson($this->link($server) . '/startup/variable', [ + $response = $this->actingAs($user)->putJson($this->link($server).'/startup/variable', [ 'key' => 'SERVER_JARFILE', 'value' => 'server2.jar', ]); @@ -125,7 +125,7 @@ public function testEggVariableWithNullableStringIsNotRequired(): void $server->fill(['egg_id' => $egg->id])->save(); $server->refresh(); - $response = $this->actingAs($user)->putJson($this->link($server) . '/startup/variable', [ + $response = $this->actingAs($user)->putJson($this->link($server).'/startup/variable', [ 'key' => 'BUNGEE_VERSION', 'value' => '', ]); @@ -141,10 +141,10 @@ public function testEggVariableWithNullableStringIsNotRequired(): void public function testStartupVariableCannotBeUpdatedIfNotUserViewable(): void { [$user, $server] = $this->generateTestAccount([Permission::ACTION_WEBSOCKET_CONNECT]); - $this->actingAs($user)->putJson($this->link($server) . '/startup/variable')->assertForbidden(); + $this->actingAs($user)->putJson($this->link($server).'/startup/variable')->assertForbidden(); $user2 = User::factory()->create(); - $this->actingAs($user2)->putJson($this->link($server) . '/startup/variable')->assertNotFound(); + $this->actingAs($user2)->putJson($this->link($server).'/startup/variable')->assertNotFound(); } public static function permissionsDataProvider(): array diff --git a/tests/Integration/Api/Client/Server/Subuser/CreateServerSubuserTest.php b/tests/Integration/Api/Client/Server/Subuser/CreateServerSubuserTest.php index 7175a7cc73..f9c6595f40 100644 --- a/tests/Integration/Api/Client/Server/Subuser/CreateServerSubuserTest.php +++ b/tests/Integration/Api/Client/Server/Subuser/CreateServerSubuserTest.php @@ -23,7 +23,7 @@ public function testSubuserCanBeCreated(array $permissions): void { [$user, $server] = $this->generateTestAccount($permissions); - $response = $this->actingAs($user)->postJson($this->link($server) . '/users', [ + $response = $this->actingAs($user)->postJson($this->link($server).'/users', [ 'email' => $email = $this->faker->email(), 'permissions' => [ Permission::ACTION_USER_CREATE, @@ -60,7 +60,7 @@ public function testErrorIsReturnedIfAssigningPermissionsNotAssignedToSelf(): vo Permission::ACTION_CONTROL_CONSOLE, ]); - $response = $this->actingAs($user)->postJson($this->link($server) . '/users', [ + $response = $this->actingAs($user)->postJson($this->link($server).'/users', [ 'email' => $this->faker->email(), 'permissions' => [ Permission::ACTION_USER_CREATE, @@ -80,9 +80,9 @@ public function testSubuserWithExcessivelyLongEmailCannotBeCreated(): void { [$user, $server] = $this->generateTestAccount(); - $email = str_repeat(Str::random(35), 7) . '@gmail.com'; // 255 is the hard limit for the column in MySQL. + $email = str_repeat(Str::random(35), 7).'@gmail.com'; // 255 is the hard limit for the column in MySQL. - $response = $this->actingAs($user)->postJson($this->link($server) . '/users', [ + $response = $this->actingAs($user)->postJson($this->link($server).'/users', [ 'email' => $email, 'permissions' => [ Permission::ACTION_USER_CREATE, @@ -91,8 +91,8 @@ public function testSubuserWithExcessivelyLongEmailCannotBeCreated(): void $response->assertOk(); - $response = $this->actingAs($user)->postJson($this->link($server) . '/users', [ - 'email' => $email . '.au', + $response = $this->actingAs($user)->postJson($this->link($server).'/users', [ + 'email' => $email.'.au', 'permissions' => [ Permission::ACTION_USER_CREATE, ], @@ -114,7 +114,7 @@ public function testCreatingSubuserWithSameEmailAsExistingUserWorks(): void /** @var \App\Models\User $existing */ $existing = User::factory()->create(['email' => $this->faker->email()]); - $response = $this->actingAs($user)->postJson($this->link($server) . '/users', [ + $response = $this->actingAs($user)->postJson($this->link($server).'/users', [ 'email' => $existing->email, 'permissions' => [ Permission::ACTION_USER_CREATE, @@ -134,7 +134,7 @@ public function testAddingSubuserThatAlreadyIsAssignedReturnsError(): void { [$user, $server] = $this->generateTestAccount(); - $response = $this->actingAs($user)->postJson($this->link($server) . '/users', [ + $response = $this->actingAs($user)->postJson($this->link($server).'/users', [ 'email' => $email = $this->faker->email(), 'permissions' => [ Permission::ACTION_USER_CREATE, @@ -143,7 +143,7 @@ public function testAddingSubuserThatAlreadyIsAssignedReturnsError(): void $response->assertOk(); - $response = $this->actingAs($user)->postJson($this->link($server) . '/users', [ + $response = $this->actingAs($user)->postJson($this->link($server).'/users', [ 'email' => $email, 'permissions' => [ Permission::ACTION_USER_CREATE, diff --git a/tests/Integration/Api/Client/Server/Subuser/DeleteSubuserTest.php b/tests/Integration/Api/Client/Server/Subuser/DeleteSubuserTest.php index bbd97f4b3d..21067ad1be 100644 --- a/tests/Integration/Api/Client/Server/Subuser/DeleteSubuserTest.php +++ b/tests/Integration/Api/Client/Server/Subuser/DeleteSubuserTest.php @@ -31,7 +31,7 @@ public function testCorrectSubuserIsDeletedFromServer(): void $real = Uuid::uuid4()->toString(); // Generate a UUID that lines up with a user in the database if it were to be cast to an int. - $uuid = $differentUser->id . substr($real, strlen((string) $differentUser->id)); + $uuid = $differentUser->id.substr($real, strlen((string) $differentUser->id)); /** @var \App\Models\User $subuser */ $subuser = User::factory()->create(['uuid' => $uuid]); @@ -44,11 +44,11 @@ public function testCorrectSubuserIsDeletedFromServer(): void $mock->expects('setServer->revokeUserJTI')->with($subuser->id)->andReturnUndefined(); - $this->actingAs($user)->deleteJson($this->link($server) . "/users/$subuser->uuid")->assertNoContent(); + $this->actingAs($user)->deleteJson($this->link($server)."/users/$subuser->uuid")->assertNoContent(); // Try the same test, but this time with a UUID that if cast to an int (shouldn't) line up with // anything in the database. - $uuid = '18180000' . substr(Uuid::uuid4()->toString(), 8); + $uuid = '18180000'.substr(Uuid::uuid4()->toString(), 8); /** @var \App\Models\User $subuser */ $subuser = User::factory()->create(['uuid' => $uuid]); @@ -60,6 +60,6 @@ public function testCorrectSubuserIsDeletedFromServer(): void $mock->expects('setServer->revokeUserJTI')->with($subuser->id)->andReturnUndefined(); - $this->actingAs($user)->deleteJson($this->link($server) . "/users/$subuser->uuid")->assertNoContent(); + $this->actingAs($user)->deleteJson($this->link($server)."/users/$subuser->uuid")->assertNoContent(); } } diff --git a/tests/Integration/Api/Client/Server/Subuser/SubuserAuthorizationTest.php b/tests/Integration/Api/Client/Server/Subuser/SubuserAuthorizationTest.php index ab844d0b3b..03bd42ee96 100644 --- a/tests/Integration/Api/Client/Server/Subuser/SubuserAuthorizationTest.php +++ b/tests/Integration/Api/Client/Server/Subuser/SubuserAuthorizationTest.php @@ -41,12 +41,12 @@ public function testUserCannotAccessResourceBelongingToOtherServers(string $meth } // This route is acceptable since they're accessing a subuser on their own server. - $this->actingAs($user)->json($method, $this->link($server1, '/users/' . $internal->uuid))->assertStatus($method === 'POST' ? 422 : ($method === 'DELETE' ? 204 : 200)); + $this->actingAs($user)->json($method, $this->link($server1, '/users/'.$internal->uuid))->assertStatus($method === 'POST' ? 422 : ($method === 'DELETE' ? 204 : 200)); // This route can be revealed since the subuser belongs to the correct server, but // errors out with a 403 since $user does not have the right permissions for this. - $this->actingAs($user)->json($method, $this->link($server2, '/users/' . $internal->uuid))->assertForbidden(); - $this->actingAs($user)->json($method, $this->link($server3, '/users/' . $internal->uuid))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server2, '/users/'.$internal->uuid))->assertForbidden(); + $this->actingAs($user)->json($method, $this->link($server3, '/users/'.$internal->uuid))->assertNotFound(); } public static function methodDataProvider(): array diff --git a/tests/Integration/Api/Daemon/DaemonAuthenticateTest.php b/tests/Integration/Api/Daemon/DaemonAuthenticateTest.php index b18b3e5e81..1dde922845 100644 --- a/tests/Integration/Api/Daemon/DaemonAuthenticateTest.php +++ b/tests/Integration/Api/Daemon/DaemonAuthenticateTest.php @@ -69,7 +69,7 @@ public function testResponseShouldFailIfTokenIsNotValid(): void $this->expectException(AccessDeniedHttpException::class); $this->request->expects('route->getName')->withNoArgs()->andReturn('random.route'); - $this->request->expects('bearerToken')->withNoArgs()->andReturn($node->daemon_token_id . '.random_string_123'); + $this->request->expects('bearerToken')->withNoArgs()->andReturn($node->daemon_token_id.'.random_string_123'); $this->getMiddleware()->handle($this->request, $this->getClosureAssertions()); } @@ -98,7 +98,7 @@ public function testSuccessfulMiddlewareProcess(): void $node->save(); $this->request->expects('route->getName')->withNoArgs()->andReturn('random.route'); - $this->request->expects('bearerToken')->withNoArgs()->andReturn($node->daemon_token_id . '.the_same'); + $this->request->expects('bearerToken')->withNoArgs()->andReturn($node->daemon_token_id.'.the_same'); $this->getMiddleware()->handle($this->request, $this->getClosureAssertions()); $this->assertRequestHasAttribute('node'); diff --git a/tests/Integration/Api/Remote/SftpAuthenticationControllerTest.php b/tests/Integration/Api/Remote/SftpAuthenticationControllerTest.php index 031eedce70..994a601a91 100644 --- a/tests/Integration/Api/Remote/SftpAuthenticationControllerTest.php +++ b/tests/Integration/Api/Remote/SftpAuthenticationControllerTest.php @@ -143,7 +143,7 @@ public function testRequestIsDeniedIfUserLacksSftpPermission(): void $this->setAuthorization($server->node); $this->postJson('/api/remote/sftp/auth', [ - 'username' => $user->username . '.' . $server->uuid_short, + 'username' => $user->username.'.'.$server->uuid_short, 'password' => 'foobar', ]) ->assertForbidden() @@ -173,7 +173,7 @@ public function testUserPermissionsAreReturnedCorrectly(): void $this->setAuthorization($server->node); $data = [ - 'username' => $user->username . '.' . $server->uuid_short, + 'username' => $user->username.'.'.$server->uuid_short, 'password' => 'foobar', ]; @@ -188,7 +188,7 @@ public function testUserPermissionsAreReturnedCorrectly(): void ->assertJsonPath('permissions.0', '*'); $this->setAuthorization(); - $data['username'] = $user->username . '.' . $this->server->uuid_short; + $data['username'] = $user->username.'.'.$this->server->uuid_short; $this->post('/api/remote/sftp/auth', $data) ->assertOk() @@ -220,7 +220,7 @@ public static function serverStateDataProvider(): array */ protected function getUsername(bool $long = false): string { - return $this->user->username . '.' . ($long ? $this->server->uuid : $this->server->uuid_short); + return $this->user->username.'.'.($long ? $this->server->uuid : $this->server->uuid_short); } /** @@ -230,6 +230,6 @@ protected function setAuthorization(Node $node = null): void { $node = $node ?? $this->server->node; - $this->withHeader('Authorization', 'Bearer ' . $node->daemon_token_id . '.' . $node->daemon_token); + $this->withHeader('Authorization', 'Bearer '.$node->daemon_token_id.'.'.$node->daemon_token); } } diff --git a/tests/Integration/Http/Controllers/Admin/UserControllerTest.php b/tests/Integration/Http/Controllers/Admin/UserControllerTest.php index cbd263501e..b82aa61aba 100644 --- a/tests/Integration/Http/Controllers/Admin/UserControllerTest.php +++ b/tests/Integration/Http/Controllers/Admin/UserControllerTest.php @@ -21,8 +21,8 @@ public function testIndexReturnsExpectedData(): void { $unique = Str::random(); $users = [ - User::factory()->create(['username' => $unique . '_1']), - User::factory()->create(['username' => $unique . '_2']), + User::factory()->create(['username' => $unique.'_1']), + User::factory()->create(['username' => $unique.'_2']), ]; $servers = [ @@ -38,7 +38,7 @@ public function testIndexReturnsExpectedData(): void /** @var \App\Http\Controllers\Admin\UserController $controller */ $controller = $this->app->make(UserController::class); - $request = Request::create('/admin/users?filter[username]=' . $unique); + $request = Request::create('/admin/users?filter[username]='.$unique); $this->app->instance(Request::class, $request); $data = $controller->index($request)->getData(); diff --git a/tests/Integration/Services/Databases/DatabaseManagementServiceTest.php b/tests/Integration/Services/Databases/DatabaseManagementServiceTest.php index 060ed9f10f..1584c20006 100644 --- a/tests/Integration/Services/Databases/DatabaseManagementServiceTest.php +++ b/tests/Integration/Services/Databases/DatabaseManagementServiceTest.php @@ -29,7 +29,7 @@ public function testUniqueDatabaseNameIsGeneratedCorrectly(): void { $this->assertSame('s1_example', DatabaseManagementService::generateUniqueDatabaseName('example', 1)); $this->assertSame('s123_something_else', DatabaseManagementService::generateUniqueDatabaseName('something_else', 123)); - $this->assertSame('s123_' . str_repeat('a', 43), DatabaseManagementService::generateUniqueDatabaseName(str_repeat('a', 100), 123)); + $this->assertSame('s123_'.str_repeat('a', 43), DatabaseManagementService::generateUniqueDatabaseName(str_repeat('a', 100), 123)); } /** diff --git a/tests/Traits/Http/RequestMockHelpers.php b/tests/Traits/Http/RequestMockHelpers.php index 22f60e74f6..b2fa0e917c 100644 --- a/tests/Traits/Http/RequestMockHelpers.php +++ b/tests/Traits/Http/RequestMockHelpers.php @@ -68,7 +68,7 @@ protected function buildRequestMock(): void { $this->request = m::mock($this->requestMockClass); if (!$this->request instanceof Request) { - throw new \InvalidArgumentException('Request mock class must be an instance of ' . Request::class . ' when mocked.'); + throw new \InvalidArgumentException('Request mock class must be an instance of '.Request::class.' when mocked.'); } $this->request->attributes = new ParameterBag(); diff --git a/tests/Traits/MocksUuids.php b/tests/Traits/MocksUuids.php index 8cfa4b7ce4..8b6d2b0a82 100644 --- a/tests/Traits/MocksUuids.php +++ b/tests/Traits/MocksUuids.php @@ -19,7 +19,7 @@ trait MocksUuids public function setKnownUuidFactory(): void { $uuid = Uuid::fromString($this->getKnownUuid()); - $factoryMock = m::mock(UuidFactory::class . '[uuid4]', [ + $factoryMock = m::mock(UuidFactory::class.'[uuid4]', [ 'uuid4' => $uuid, ]); From 1bf6a880fbb0f51a3f0019e5b45522ac36a7b0cd Mon Sep 17 00:00:00 2001 From: Lance Pioch Date: Sat, 19 Oct 2024 18:41:08 -0400 Subject: [PATCH 14/33] Add nullable_type_declaration_for_default_null_value rule --- app/Exceptions/Http/HttpForbiddenException.php | 2 +- app/Exceptions/Http/Server/ServerStateConflictException.php | 2 +- app/Exceptions/Http/TwoFactorAuthRequiredException.php | 2 +- app/Exceptions/Service/ServiceLimitExceededException.php | 2 +- app/Extensions/Backups/BackupManager.php | 2 +- app/Http/Controllers/Admin/Eggs/EggController.php | 2 +- app/Http/Controllers/Auth/AbstractLoginController.php | 6 +++--- app/Http/Middleware/RedirectIfAuthenticated.php | 2 +- app/Http/Requests/Admin/AdminFormRequest.php | 2 +- .../Requests/Admin/Settings/MailSettingsFormRequest.php | 2 +- .../Application/DatabaseHosts/StoreDatabaseHostRequest.php | 2 +- .../Application/DatabaseHosts/UpdateDatabaseHostRequest.php | 2 +- .../Requests/Api/Application/Mounts/UpdateMountRequest.php | 2 +- .../Requests/Api/Application/Nodes/StoreNodeRequest.php | 2 +- .../Requests/Api/Application/Nodes/UpdateNodeRequest.php | 2 +- .../Requests/Api/Application/Roles/StoreRoleRequest.php | 2 +- .../Api/Application/Users/AssignUserRolesRequest.php | 2 +- .../Requests/Api/Application/Users/StoreUserRequest.php | 2 +- .../Requests/Api/Application/Users/UpdateUserRequest.php | 2 +- app/Jobs/Schedule/RunTaskJob.php | 2 +- app/Repositories/Daemon/DaemonBackupRepository.php | 2 +- app/Repositories/Daemon/DaemonFileRepository.php | 2 +- app/Services/Activity/ActivityLogService.php | 2 +- app/Services/Allocations/AssignmentService.php | 2 +- app/Services/Backups/InitiateBackupService.php | 2 +- app/Services/Eggs/Sharing/EggImporterService.php | 4 ++-- app/Services/Servers/ServerCreationService.php | 2 +- app/Services/Users/ToggleTwoFactorService.php | 2 +- app/Transformers/Api/Client/ActivityLogTransformer.php | 2 +- app/Transformers/Api/Client/BaseClientTransformer.php | 2 +- pint.json | 1 - .../Integration/Api/Client/ClientApiIntegrationTestCase.php | 2 +- .../Api/Remote/SftpAuthenticationControllerTest.php | 2 +- tests/Traits/Http/RequestMockHelpers.php | 4 ++-- 34 files changed, 37 insertions(+), 38 deletions(-) diff --git a/app/Exceptions/Http/HttpForbiddenException.php b/app/Exceptions/Http/HttpForbiddenException.php index b0536257e0..318ab3b6c7 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 1e20082a33..c5b53b4daf 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 6b9804812b..fb9c09ebc1 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 3609be97da..2570197d6d 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/Extensions/Backups/BackupManager.php b/app/Extensions/Backups/BackupManager.php index 8fcb1e198a..b26f8f4c5b 100644 --- a/app/Extensions/Backups/BackupManager.php +++ b/app/Extensions/Backups/BackupManager.php @@ -34,7 +34,7 @@ public function __construct(protected Application $app) /** * 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()); } diff --git a/app/Http/Controllers/Admin/Eggs/EggController.php b/app/Http/Controllers/Admin/Eggs/EggController.php index 692ff79424..2f3de5ae1c 100644 --- a/app/Http/Controllers/Admin/Eggs/EggController.php +++ b/app/Http/Controllers/Admin/Eggs/EggController.php @@ -127,7 +127,7 @@ public function destroy(Egg $egg): RedirectResponse /** * 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/Auth/AbstractLoginController.php b/app/Http/Controllers/Auth/AbstractLoginController.php index e5b50d0adf..f72e7ba6ca 100644 --- a/app/Http/Controllers/Auth/AbstractLoginController.php +++ b/app/Http/Controllers/Auth/AbstractLoginController.php @@ -51,7 +51,7 @@ public function __construct() * * @throws \App\Exceptions\DisplayException */ - protected function sendFailedLoginResponse(Request $request, Authenticatable $user = null, string $message = null) + protected function sendFailedLoginResponse(Request $request, ?Authenticatable $user = null, ?string $message = null) { $this->incrementLoginAttempts($request); $this->fireFailedLoginEvent($user, [ @@ -91,7 +91,7 @@ protected function sendLoginResponse(User $user, Request $request): JsonResponse /** * 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 @@ protected function getField(string $input = null): string /** * Fire a failed login event. */ - protected function fireFailedLoginEvent(Authenticatable $user = null, array $credentials = []) + protected function fireFailedLoginEvent(?Authenticatable $user = null, array $credentials = []) { Event::dispatch(new Failed('auth', $user, $credentials)); } diff --git a/app/Http/Middleware/RedirectIfAuthenticated.php b/app/Http/Middleware/RedirectIfAuthenticated.php index 38af84f7e0..f645f552ed 100644 --- a/app/Http/Middleware/RedirectIfAuthenticated.php +++ b/app/Http/Middleware/RedirectIfAuthenticated.php @@ -17,7 +17,7 @@ public function __construct(private AuthManager $authManager) /** * 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/Requests/Admin/AdminFormRequest.php b/app/Http/Requests/Admin/AdminFormRequest.php index 54e9f5e92c..adfb97fb8e 100644 --- a/app/Http/Requests/Admin/AdminFormRequest.php +++ b/app/Http/Requests/Admin/AdminFormRequest.php @@ -28,7 +28,7 @@ public function authorize(): bool * 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 9e62869d83..38fa792d5d 100644 --- a/app/Http/Requests/Admin/Settings/MailSettingsFormRequest.php +++ b/app/Http/Requests/Admin/Settings/MailSettingsFormRequest.php @@ -27,7 +27,7 @@ public function rules(): array * 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/DatabaseHosts/StoreDatabaseHostRequest.php b/app/Http/Requests/Api/Application/DatabaseHosts/StoreDatabaseHostRequest.php index aedd5109ba..435a6d86bf 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 111560bbfd..95b006546d 100644 --- a/app/Http/Requests/Api/Application/DatabaseHosts/UpdateDatabaseHostRequest.php +++ b/app/Http/Requests/Api/Application/DatabaseHosts/UpdateDatabaseHostRequest.php @@ -6,7 +6,7 @@ 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 7f76ec4201..e843f2c705 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 913204b836..eae3242335 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 ab636dff02..388b2fd478 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 7968449a73..4cf01400ec 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 c0af95102b..61e191c203 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 43603639c4..cf1b6c244e 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 ecccbdd5aa..2db4cd0490 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 { $userId = $this->parameter('user', User::class)->id; diff --git a/app/Jobs/Schedule/RunTaskJob.php b/app/Jobs/Schedule/RunTaskJob.php index ea0c84486d..d4b0cabcea 100644 --- a/app/Jobs/Schedule/RunTaskJob.php +++ b/app/Jobs/Schedule/RunTaskJob.php @@ -90,7 +90,7 @@ public function handle( /** * Handle a failure while sending the action to the daemon or otherwise processing the job. */ - public function failed(\Exception $exception = null) + public function failed(?\Exception $exception = null) { $this->markTaskNotQueued(); $this->markScheduleComplete(); diff --git a/app/Repositories/Daemon/DaemonBackupRepository.php b/app/Repositories/Daemon/DaemonBackupRepository.php index bbe852e809..9d9c4bafa5 100644 --- a/app/Repositories/Daemon/DaemonBackupRepository.php +++ b/app/Repositories/Daemon/DaemonBackupRepository.php @@ -50,7 +50,7 @@ public function backup(Backup $backup) * * @throws \App\Exceptions\Http\Connection\DaemonConnectionException */ - public function restore(Backup $backup, string $url = null, bool $truncate = false) + public function restore(Backup $backup, ?string $url = null, bool $truncate = false) { Assert::isInstanceOf($this->server, Server::class); diff --git a/app/Repositories/Daemon/DaemonFileRepository.php b/app/Repositories/Daemon/DaemonFileRepository.php index 7667f482e8..ca6fc7399f 100644 --- a/app/Repositories/Daemon/DaemonFileRepository.php +++ b/app/Repositories/Daemon/DaemonFileRepository.php @@ -21,7 +21,7 @@ class DaemonFileRepository extends DaemonRepository * @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/Services/Activity/ActivityLogService.php b/app/Services/Activity/ActivityLogService.php index 37b7ae43b5..170278558a 100644 --- a/app/Services/Activity/ActivityLogService.php +++ b/app/Services/Activity/ActivityLogService.php @@ -130,7 +130,7 @@ public function withRequestMetadata(): self * 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 be4c041311..23f28e1224 100644 --- a/app/Services/Allocations/AssignmentService.php +++ b/app/Services/Allocations/AssignmentService.php @@ -43,7 +43,7 @@ public function __construct(protected ConnectionInterface $connection) * @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 447c575359..69807a9422 100644 --- a/app/Services/Backups/InitiateBackupService.php +++ b/app/Services/Backups/InitiateBackupService.php @@ -70,7 +70,7 @@ public function setIgnoredFiles(?array $ignored): self * @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 dc54525a6e..e539a7f282 100644 --- a/app/Services/Eggs/Sharing/EggImporterService.php +++ b/app/Services/Eggs/Sharing/EggImporterService.php @@ -34,7 +34,7 @@ public function __construct(protected ConnectionInterface $connection) * * @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 @@ public function fromFile(UploadedFile $file, Egg $egg = null): Egg * * @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/Servers/ServerCreationService.php b/app/Services/Servers/ServerCreationService.php index 7fd3e8b67a..18eb790e53 100644 --- a/app/Services/Servers/ServerCreationService.php +++ b/app/Services/Servers/ServerCreationService.php @@ -45,7 +45,7 @@ public function __construct( * @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/Users/ToggleTwoFactorService.php b/app/Services/Users/ToggleTwoFactorService.php index 64518e39bf..ca5df2dcbd 100644 --- a/app/Services/Users/ToggleTwoFactorService.php +++ b/app/Services/Users/ToggleTwoFactorService.php @@ -30,7 +30,7 @@ public function __construct( * @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/Transformers/Api/Client/ActivityLogTransformer.php b/app/Transformers/Api/Client/ActivityLogTransformer.php index 1d38507ec7..8ae8881426 100644 --- a/app/Transformers/Api/Client/ActivityLogTransformer.php +++ b/app/Transformers/Api/Client/ActivityLogTransformer.php @@ -111,7 +111,7 @@ protected function hasAdditionalMetadata(ActivityLog $model): bool * 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 c490d1bfdc..9ee56cfaf1 100644 --- a/app/Transformers/Api/Client/BaseClientTransformer.php +++ b/app/Transformers/Api/Client/BaseClientTransformer.php @@ -24,7 +24,7 @@ public function getUser(): User * * @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 e6d2cafb88..606e3351a3 100644 --- a/pint.json +++ b/pint.json @@ -2,7 +2,6 @@ "preset": "laravel", "rules": { "not_operator_with_successor_space": false, - "nullable_type_declaration_for_default_null_value": false, "ordered_imports": false, "phpdoc_align": false, "phpdoc_separation": false diff --git a/tests/Integration/Api/Client/ClientApiIntegrationTestCase.php b/tests/Integration/Api/Client/ClientApiIntegrationTestCase.php index 44c06e5700..86e9a202d1 100644 --- a/tests/Integration/Api/Client/ClientApiIntegrationTestCase.php +++ b/tests/Integration/Api/Client/ClientApiIntegrationTestCase.php @@ -47,7 +47,7 @@ protected function createTestResponse($response, $request): \Illuminate\Testing\ /** * 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/Remote/SftpAuthenticationControllerTest.php b/tests/Integration/Api/Remote/SftpAuthenticationControllerTest.php index 994a601a91..da340cbb4f 100644 --- a/tests/Integration/Api/Remote/SftpAuthenticationControllerTest.php +++ b/tests/Integration/Api/Remote/SftpAuthenticationControllerTest.php @@ -226,7 +226,7 @@ protected function getUsername(bool $long = false): string /** * 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 b2fa0e917c..d4da1bb238 100644 --- a/tests/Traits/Http/RequestMockHelpers.php +++ b/tests/Traits/Http/RequestMockHelpers.php @@ -27,7 +27,7 @@ public function setRequestMockClass(string $class): void /** * 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 @@ protected function buildRequestMock(): void * * @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); From d21740d4589218dc8a7176edd665a1419a24373a Mon Sep 17 00:00:00 2001 From: Lance Pioch Date: Sat, 19 Oct 2024 18:42:23 -0400 Subject: [PATCH 15/33] Add phpdoc_align rule --- app/Exceptions/Handler.php | 6 +++--- app/Extensions/Backups/BackupManager.php | 2 +- .../Api/Application/ApplicationApiController.php | 2 +- app/Http/Controllers/Api/Client/ClientApiController.php | 2 +- app/Http/Controllers/Auth/ForgotPasswordController.php | 2 +- app/Http/Controllers/Auth/ResetPasswordController.php | 4 ++-- app/Http/Requests/Api/Application/ApplicationApiRequest.php | 2 +- app/Models/Filters/AdminServerFilter.php | 2 +- app/Models/Filters/MultiFieldServerFilter.php | 2 +- app/Models/User.php | 2 +- app/Repositories/Daemon/DaemonFileRepository.php | 2 +- app/Rules/Username.php | 4 ++-- app/Services/Activity/ActivityLogService.php | 6 +++--- app/Services/Backups/InitiateBackupService.php | 2 +- app/Transformers/Api/Application/BaseTransformer.php | 2 +- pint.json | 1 - tests/Assertions/AssertsActivityLogged.php | 2 +- tests/Integration/Api/Client/Server/PowerControllerTest.php | 2 +- tests/Traits/Integration/CreatesTestModels.php | 2 +- 19 files changed, 24 insertions(+), 25 deletions(-) diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index a8cc206d94..f3bc40cd38 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -114,7 +114,7 @@ class_basename($exception), /** * Render an exception into an HTTP response. * - * @param \Illuminate\Http\Request $request + * @param \Illuminate\Http\Request $request * * @throws \Throwable */ @@ -140,7 +140,7 @@ public function render($request, \Throwable $e): Response * 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 @@ public static function isReportable(\Exception $exception): bool /** * 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/Extensions/Backups/BackupManager.php b/app/Extensions/Backups/BackupManager.php index b26f8f4c5b..16c704b97a 100644 --- a/app/Extensions/Backups/BackupManager.php +++ b/app/Extensions/Backups/BackupManager.php @@ -145,7 +145,7 @@ public function setDefaultAdapter(string $name): void /** * Unset the given adapter instances. * - * @param string|string[] $adapter + * @param string|string[] $adapter */ public function forget(array|string $adapter): self { diff --git a/app/Http/Controllers/Api/Application/ApplicationApiController.php b/app/Http/Controllers/Api/Application/ApplicationApiController.php index 174e6243a4..e94de98896 100644 --- a/app/Http/Controllers/Api/Application/ApplicationApiController.php +++ b/app/Http/Controllers/Api/Application/ApplicationApiController.php @@ -51,7 +51,7 @@ public function loadDependencies(Fractal $fractal, Request $request) * * @template T of \App\Transformers\Api\Application\BaseTransformer * - * @param class-string $abstract + * @param class-string $abstract * * @return T * diff --git a/app/Http/Controllers/Api/Client/ClientApiController.php b/app/Http/Controllers/Api/Client/ClientApiController.php index 4cf081fec3..a78e754875 100644 --- a/app/Http/Controllers/Api/Client/ClientApiController.php +++ b/app/Http/Controllers/Api/Client/ClientApiController.php @@ -41,7 +41,7 @@ protected function parseIncludes(): array * * @template T of \App\Transformers\Api\Client\BaseClientTransformer * - * @param class-string $abstract + * @param class-string $abstract * * @return T * diff --git a/app/Http/Controllers/Auth/ForgotPasswordController.php b/app/Http/Controllers/Auth/ForgotPasswordController.php index 21ef4fee85..5c8d3d5d4c 100644 --- a/app/Http/Controllers/Auth/ForgotPasswordController.php +++ b/app/Http/Controllers/Auth/ForgotPasswordController.php @@ -29,7 +29,7 @@ protected function sendResetLinkFailedResponse(Request $request, $response): Jso /** * Get the response for a successful password reset link. * - * @param string $response + * @param string $response */ protected function sendResetLinkResponse(Request $request, $response): JsonResponse { diff --git a/app/Http/Controllers/Auth/ResetPasswordController.php b/app/Http/Controllers/Auth/ResetPasswordController.php index b4c338ee98..c8dbd898ee 100644 --- a/app/Http/Controllers/Auth/ResetPasswordController.php +++ b/app/Http/Controllers/Auth/ResetPasswordController.php @@ -64,8 +64,8 @@ function ($user, $password) { * 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/Requests/Api/Application/ApplicationApiRequest.php b/app/Http/Requests/Api/Application/ApplicationApiRequest.php index a0e17c15dd..33c9581b18 100644 --- a/app/Http/Requests/Api/Application/ApplicationApiRequest.php +++ b/app/Http/Requests/Api/Application/ApplicationApiRequest.php @@ -74,7 +74,7 @@ public function withValidator(Validator $validator): void * * @template T of \Illuminate\Database\Eloquent\Model * - * @param class-string $expect + * @param class-string $expect * * @return T * diff --git a/app/Models/Filters/AdminServerFilter.php b/app/Models/Filters/AdminServerFilter.php index d3c1eea606..bca17499f7 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) { diff --git a/app/Models/Filters/MultiFieldServerFilter.php b/app/Models/Filters/MultiFieldServerFilter.php index 0ab266574a..6039c450b8 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) { diff --git a/app/Models/User.php b/app/Models/User.php index 5bc8fa6323..04ecbb0c43 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -234,7 +234,7 @@ public function toReactObject(): array /** * Send the password reset notification. * - * @param string $token + * @param string $token */ public function sendPasswordResetNotification($token) { diff --git a/app/Repositories/Daemon/DaemonFileRepository.php b/app/Repositories/Daemon/DaemonFileRepository.php index ca6fc7399f..a414b8db7f 100644 --- a/app/Repositories/Daemon/DaemonFileRepository.php +++ b/app/Repositories/Daemon/DaemonFileRepository.php @@ -15,7 +15,7 @@ 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 diff --git a/app/Rules/Username.php b/app/Rules/Username.php index 591df389c2..f888da1037 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/Activity/ActivityLogService.php b/app/Services/Activity/ActivityLogService.php index 170278558a..38f742b721 100644 --- a/app/Services/Activity/ActivityLogService.php +++ b/app/Services/Activity/ActivityLogService.php @@ -64,7 +64,7 @@ public function description(?string $description): self * * @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 @@ public function actor(Model $actor): self /** * 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 { diff --git a/app/Services/Backups/InitiateBackupService.php b/app/Services/Backups/InitiateBackupService.php index 69807a9422..fa15db88ac 100644 --- a/app/Services/Backups/InitiateBackupService.php +++ b/app/Services/Backups/InitiateBackupService.php @@ -43,7 +43,7 @@ public function setIsLocked(bool $isLocked): self /** * Sets the files to be ignored by this backup. * - * @param string[]|null $ignored + * @param string[]|null $ignored */ public function setIgnoredFiles(?array $ignored): self { diff --git a/app/Transformers/Api/Application/BaseTransformer.php b/app/Transformers/Api/Application/BaseTransformer.php index 62ee4ceeb6..2fb5917c0b 100644 --- a/app/Transformers/Api/Application/BaseTransformer.php +++ b/app/Transformers/Api/Application/BaseTransformer.php @@ -89,7 +89,7 @@ protected function authorize(string $resource): bool * * @template T of \App\Transformers\Api\Application\BaseTransformer * - * @param class-string $abstract + * @param class-string $abstract * * @return T * diff --git a/pint.json b/pint.json index 606e3351a3..aa20e37a0f 100644 --- a/pint.json +++ b/pint.json @@ -3,7 +3,6 @@ "rules": { "not_operator_with_successor_space": false, "ordered_imports": false, - "phpdoc_align": false, "phpdoc_separation": false } } diff --git a/tests/Assertions/AssertsActivityLogged.php b/tests/Assertions/AssertsActivityLogged.php index ecc33a8335..ed33729e4d 100644 --- a/tests/Assertions/AssertsActivityLogged.php +++ b/tests/Assertions/AssertsActivityLogged.php @@ -11,7 +11,7 @@ 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/Server/PowerControllerTest.php b/tests/Integration/Api/Client/Server/PowerControllerTest.php index 5cadb37729..94d3e7326c 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/Traits/Integration/CreatesTestModels.php b/tests/Traits/Integration/CreatesTestModels.php index 12d6459347..3bede405e3 100644 --- a/tests/Traits/Integration/CreatesTestModels.php +++ b/tests/Traits/Integration/CreatesTestModels.php @@ -65,7 +65,7 @@ public function createServerModel(array $attributes = []): Server * 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} */ From 466f9f7edcc225fee30c47ea4b5b61f43437268d Mon Sep 17 00:00:00 2001 From: Lance Pioch Date: Sat, 19 Oct 2024 18:46:05 -0400 Subject: [PATCH 16/33] Add phpdoc_separation rule --- .../Controllers/Api/Application/ApplicationApiController.php | 1 - app/Http/Controllers/Api/Client/ClientApiController.php | 1 - app/Http/Requests/Api/Application/ApplicationApiRequest.php | 1 - app/Models/Server.php | 4 ++++ app/Services/Files/DeleteFilesService.php | 1 + app/Traits/EnvironmentWriterTrait.php | 1 + app/Transformers/Api/Application/BaseTransformer.php | 1 - pint.json | 3 +-- tests/Traits/Integration/CreatesTestModels.php | 1 - 9 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/Http/Controllers/Api/Application/ApplicationApiController.php b/app/Http/Controllers/Api/Application/ApplicationApiController.php index e94de98896..6e1b4112c3 100644 --- a/app/Http/Controllers/Api/Application/ApplicationApiController.php +++ b/app/Http/Controllers/Api/Application/ApplicationApiController.php @@ -52,7 +52,6 @@ public function loadDependencies(Fractal $fractal, Request $request) * @template T of \App\Transformers\Api\Application\BaseTransformer * * @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 a78e754875..8d409a754e 100644 --- a/app/Http/Controllers/Api/Client/ClientApiController.php +++ b/app/Http/Controllers/Api/Client/ClientApiController.php @@ -42,7 +42,6 @@ protected function parseIncludes(): array * @template T of \App\Transformers\Api\Client\BaseClientTransformer * * @param class-string $abstract - * * @return T * * @noinspection PhpDocSignatureInspection diff --git a/app/Http/Requests/Api/Application/ApplicationApiRequest.php b/app/Http/Requests/Api/Application/ApplicationApiRequest.php index 33c9581b18..b8feb094dd 100644 --- a/app/Http/Requests/Api/Application/ApplicationApiRequest.php +++ b/app/Http/Requests/Api/Application/ApplicationApiRequest.php @@ -75,7 +75,6 @@ public function withValidator(Validator $validator): void * @template T of \Illuminate\Database\Eloquent\Model * * @param class-string $expect - * * @return T * * @noinspection PhpDocSignatureInspection diff --git a/app/Models/Server.php b/app/Models/Server.php index a0c341c6d4..7cbc633d66 100644 --- a/app/Models/Server.php +++ b/app/Models/Server.php @@ -71,6 +71,7 @@ * @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 @@ * @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 @@ * @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/Services/Files/DeleteFilesService.php b/app/Services/Files/DeleteFilesService.php index 907c12c31a..f0a4f202c2 100644 --- a/app/Services/Files/DeleteFilesService.php +++ b/app/Services/Files/DeleteFilesService.php @@ -19,6 +19,7 @@ public function __construct( /** * Deletes the given files. + * * @throws DaemonConnectionException */ public function handle(Server $server, array $files): void diff --git a/app/Traits/EnvironmentWriterTrait.php b/app/Traits/EnvironmentWriterTrait.php index 2eaca0e6fe..2011165716 100644 --- a/app/Traits/EnvironmentWriterTrait.php +++ b/app/Traits/EnvironmentWriterTrait.php @@ -22,6 +22,7 @@ public function escapeEnvironmentValue(string $value): string /** * 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 2fb5917c0b..748b8a1d9c 100644 --- a/app/Transformers/Api/Application/BaseTransformer.php +++ b/app/Transformers/Api/Application/BaseTransformer.php @@ -90,7 +90,6 @@ protected function authorize(string $resource): bool * @template T of \App\Transformers\Api\Application\BaseTransformer * * @param class-string $abstract - * * @return T * * @throws \App\Exceptions\Transformer\InvalidTransformerLevelException diff --git a/pint.json b/pint.json index aa20e37a0f..9427029f83 100644 --- a/pint.json +++ b/pint.json @@ -2,7 +2,6 @@ "preset": "laravel", "rules": { "not_operator_with_successor_space": false, - "ordered_imports": false, - "phpdoc_separation": false + "ordered_imports": false } } diff --git a/tests/Traits/Integration/CreatesTestModels.php b/tests/Traits/Integration/CreatesTestModels.php index 3bede405e3..0e28cb40e7 100644 --- a/tests/Traits/Integration/CreatesTestModels.php +++ b/tests/Traits/Integration/CreatesTestModels.php @@ -66,7 +66,6 @@ public function createServerModel(array $attributes = []): Server * is assumed that the user is actually a subuser of the server. * * @param string[] $permissions - * * @return array{\App\Models\User, \App\Models\Server} */ public function generateTestAccount(array $permissions = []): array From 8740f0f645fb5756e92d03e2056c3eb70a21c379 Mon Sep 17 00:00:00 2001 From: notCharles Date: Sat, 19 Oct 2024 18:52:08 -0400 Subject: [PATCH 17/33] Change MaxWidth --- app/Providers/Filament/AdminPanelProvider.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/Providers/Filament/AdminPanelProvider.php b/app/Providers/Filament/AdminPanelProvider.php index 0aef2f030a..7bae858564 100644 --- a/app/Providers/Filament/AdminPanelProvider.php +++ b/app/Providers/Filament/AdminPanelProvider.php @@ -9,6 +9,7 @@ use Filament\Http\Middleware\DispatchServingFilamentEvent; use Filament\Panel; use Filament\PanelProvider; +use Filament\Support\Enums\MaxWidth; use Filament\Support\Facades\FilamentAsset; use Filament\Widgets; use Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse; @@ -43,6 +44,8 @@ public function panel(Panel $panel): Panel ->brandLogo(config('app.logo')) ->brandLogoHeight('2rem') ->profile(EditProfile::class, false) + ->maxContentWidth(MaxWidth::ScreenTwoExtraLarge) + ->spa() ->discoverResources(in: app_path('Filament/Resources'), for: 'App\\Filament\\Resources') ->discoverPages(in: app_path('Filament/Pages'), for: 'App\\Filament\\Pages') ->discoverClusters(in: app_path('Filament/Clusters'), for: 'App\\Filament\\Clusters') From c7a307af6eab55e1ab81e9abef2cae9658220c3c Mon Sep 17 00:00:00 2001 From: Lance Pioch Date: Sat, 19 Oct 2024 21:00:11 -0400 Subject: [PATCH 18/33] Enforce return and parameter types --- .../Environment/EmailSettingsCommand.php | 8 ++++---- .../Schedule/ProcessRunnableCommand.php | 2 +- app/Console/Commands/UpgradeCommand.php | 2 +- app/Exceptions/DisplayException.php | 12 +++++++----- app/Extensions/Themes/Theme.php | 6 +++--- app/Filament/Pages/Installer/PanelInstaller.php | 7 ++++--- .../Pages/Installer/Steps/DatabaseStep.php | 2 +- .../Pages/Installer/Steps/RedisStep.php | 2 +- app/Filament/Resources/ApiKeyResource.php | 3 ++- .../Pages/CreateDatabaseHost.php | 4 +++- .../Pages/EditDatabaseHost.php | 12 +++++++++--- .../DatabasesRelationManager.php | 3 ++- .../Resources/NodeResource/Pages/EditNode.php | 4 ++-- .../ServerResource/Pages/EditServer.php | 2 +- .../UserResource/Pages/EditProfile.php | 10 ++++++++-- .../Controllers/Admin/ServersController.php | 6 ++---- .../Application/ApplicationApiController.php | 2 +- .../Api/Remote/ActivityProcessingController.php | 2 +- .../Auth/AbstractLoginController.php | 4 ++-- .../Auth/ForgotPasswordController.php | 4 ++-- .../Auth/LoginCheckpointController.php | 2 +- app/Http/Controllers/Auth/LoginController.php | 4 +++- .../Auth/ResetPasswordController.php | 2 +- app/Http/Middleware/EnsureStatefulRequests.php | 2 +- app/Http/Requests/Admin/Egg/EggFormRequest.php | 3 ++- .../DatabaseHosts/UpdateDatabaseHostRequest.php | 2 +- .../Application/Mounts/UpdateMountRequest.php | 2 +- .../Api/Application/Nodes/UpdateNodeRequest.php | 2 +- .../Api/Application/Users/UpdateUserRequest.php | 4 ++-- .../Client/Servers/Subusers/SubuserRequest.php | 2 +- app/Jobs/Schedule/RunTaskJob.php | 8 ++++---- app/Livewire/NodeSystemInformation.php | 5 +++-- app/Models/ActivityLog.php | 6 +++--- app/Models/ActivityLogSubject.php | 13 ++++--------- app/Models/Filters/AdminServerFilter.php | 2 +- app/Models/Filters/MultiFieldServerFilter.php | 2 +- app/Models/Model.php | 10 ++++------ app/Models/Mount.php | 4 ++-- app/Models/Node.php | 5 +++-- app/Models/Server.php | 4 ++-- app/Models/User.php | 4 ++-- app/Policies/ServerPolicy.php | 2 +- app/Providers/Filament/AdminPanelProvider.php | 2 +- .../Daemon/DaemonBackupRepository.php | 7 ++++--- .../Daemon/DaemonConfigurationRepository.php | 5 +++-- .../Daemon/DaemonFileRepository.php | 17 +++++++++-------- .../Daemon/DaemonPowerRepository.php | 3 ++- app/Services/Activity/ActivityLogService.php | 2 +- .../Deployment/FindViableNodesService.php | 2 +- app/Services/Servers/SuspensionService.php | 6 ++++-- app/Services/Servers/TransferServerService.php | 2 +- .../Controllers/PlainJavascriptInjection.php | 2 +- .../Api/Application/EggVariableTransformer.php | 2 +- .../Api/Application/MountTransformer.php | 2 +- .../Api/Application/ServerTransformer.php | 2 +- .../Api/Client/ActivityLogTransformer.php | 3 ++- database/Seeders/DatabaseSeeder.php | 2 +- database/Seeders/EggSeeder.php | 4 ++-- phpstan.neon | 13 +++++-------- .../Api/Client/ClientApiIntegrationTestCase.php | 2 +- tests/Integration/IntegrationTestCase.php | 2 +- 61 files changed, 143 insertions(+), 124 deletions(-) diff --git a/app/Console/Commands/Environment/EmailSettingsCommand.php b/app/Console/Commands/Environment/EmailSettingsCommand.php index 87c8186c14..23061bf04d 100644 --- a/app/Console/Commands/Environment/EmailSettingsCommand.php +++ b/app/Console/Commands/Environment/EmailSettingsCommand.php @@ -70,7 +70,7 @@ public function handle(): void /** * Handle variables for SMTP driver. */ - private function setupSmtpDriverVariables() + private function setupSmtpDriverVariables(): void { $this->variables['MAIL_HOST'] = $this->option('host') ?? $this->ask( trans('command/messages.environment.mail.ask_smtp_host'), @@ -101,7 +101,7 @@ private function setupSmtpDriverVariables() /** * Handle variables for mailgun driver. */ - private function setupMailgunDriverVariables() + private function setupMailgunDriverVariables(): void { $this->variables['MAILGUN_DOMAIN'] = $this->option('host') ?? $this->ask( trans('command/messages.environment.mail.ask_mailgun_domain'), @@ -122,7 +122,7 @@ private function setupMailgunDriverVariables() /** * Handle variables for mandrill driver. */ - private function setupMandrillDriverVariables() + private function setupMandrillDriverVariables(): void { $this->variables['MANDRILL_SECRET'] = $this->option('password') ?? $this->ask( trans('command/messages.environment.mail.ask_mandrill_secret'), @@ -133,7 +133,7 @@ private function setupMandrillDriverVariables() /** * Handle variables for postmark driver. */ - private function setupPostmarkDriverVariables() + private function setupPostmarkDriverVariables(): void { $this->variables['MAIL_DRIVER'] = 'smtp'; $this->variables['MAIL_HOST'] = 'smtp.postmarkapp.com'; diff --git a/app/Console/Commands/Schedule/ProcessRunnableCommand.php b/app/Console/Commands/Schedule/ProcessRunnableCommand.php index d1d71ae024..c11ade6c35 100644 --- a/app/Console/Commands/Schedule/ProcessRunnableCommand.php +++ b/app/Console/Commands/Schedule/ProcessRunnableCommand.php @@ -51,7 +51,7 @@ public function handle(): int * never throw an exception out, otherwise you'll end up killing the entire run group causing * any other schedules to not process correctly. */ - protected function processSchedule(Schedule $schedule) + protected function processSchedule(Schedule $schedule): void { if ($schedule->tasks->isEmpty()) { return; diff --git a/app/Console/Commands/UpgradeCommand.php b/app/Console/Commands/UpgradeCommand.php index 75a3c185f7..145e6e0c6f 100644 --- a/app/Console/Commands/UpgradeCommand.php +++ b/app/Console/Commands/UpgradeCommand.php @@ -178,7 +178,7 @@ public function handle(): void $this->info(__('commands.upgrade.success')); } - protected function withProgress(ProgressBar $bar, \Closure $callback) + protected function withProgress(ProgressBar $bar, \Closure $callback): void { $bar->clear(); $callback(); diff --git a/app/Exceptions/DisplayException.php b/app/Exceptions/DisplayException.php index 6c44c356c1..5dfe42a4a6 100644 --- a/app/Exceptions/DisplayException.php +++ b/app/Exceptions/DisplayException.php @@ -4,6 +4,8 @@ use Exception; use Filament\Notifications\Notification; +use Illuminate\Http\JsonResponse; +use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; use Psr\Log\LoggerInterface; use Illuminate\Http\Response; @@ -46,7 +48,7 @@ public function getHeaders(): array * and then redirecting them back to the page that they came from. If the * request originated from an API hit, return the error in JSONAPI spec format. */ - public function render(Request $request) + public function render(Request $request): bool|RedirectResponse|JsonResponse { if ($request->is('livewire/update')) { Notification::make() @@ -55,7 +57,7 @@ public function render(Request $request) ->danger() ->send(); - return; + return false; } if ($request->expectsJson()) { @@ -73,10 +75,10 @@ public function render(Request $request) * * @throws \Throwable */ - public function report() + public function report(): void { if (!$this->getPrevious() instanceof \Exception || !Handler::isReportable($this->getPrevious())) { - return null; + return; } try { @@ -85,6 +87,6 @@ public function report() throw $this->getPrevious(); } - return $logger->{$this->getErrorLevel()}($this->getPrevious()); + $logger->{$this->getErrorLevel()}($this->getPrevious()); } } diff --git a/app/Extensions/Themes/Theme.php b/app/Extensions/Themes/Theme.php index 2badc3dcb0..f6f55d8c86 100644 --- a/app/Extensions/Themes/Theme.php +++ b/app/Extensions/Themes/Theme.php @@ -4,17 +4,17 @@ class Theme { - public function js($path): string + public function js(string $path): string { return sprintf('' . PHP_EOL, $this->getUrl($path)); } - public function css($path): string + public function css(string $path): string { return sprintf('' . PHP_EOL, $this->getUrl($path)); } - protected function getUrl($path): string + protected function getUrl(string $path): string { return '/themes/panel/' . ltrim($path, '/'); } diff --git a/app/Filament/Pages/Installer/PanelInstaller.php b/app/Filament/Pages/Installer/PanelInstaller.php index 55da7add71..8a112a8348 100644 --- a/app/Filament/Pages/Installer/PanelInstaller.php +++ b/app/Filament/Pages/Installer/PanelInstaller.php @@ -24,6 +24,7 @@ use Filament\Pages\SimplePage; use Filament\Support\Enums\MaxWidth; use Filament\Support\Exceptions\Halt; +use Illuminate\Http\RedirectResponse; use Illuminate\Support\Facades\Artisan; use Illuminate\Support\Facades\Blade; use Illuminate\Support\HtmlString; @@ -37,7 +38,7 @@ class PanelInstaller extends SimplePage implements HasForms use EnvironmentWriterTrait; use InteractsWithForms; - public $data = []; + public array $data = []; protected static string $view = 'filament.pages.installer'; @@ -54,7 +55,7 @@ public static function isInstalled(): bool return env('APP_INSTALLED', true); } - public function mount() + public function mount(): void { abort_if(self::isInstalled(), 404); @@ -93,7 +94,7 @@ protected function getFormStatePath(): ?string return 'data'; } - public function submit() + public function submit(): RedirectResponse { // Disable installer $this->writeToEnvironment(['APP_INSTALLED' => 'true']); diff --git a/app/Filament/Pages/Installer/Steps/DatabaseStep.php b/app/Filament/Pages/Installer/Steps/DatabaseStep.php index 5a0d6b7368..04803352da 100644 --- a/app/Filament/Pages/Installer/Steps/DatabaseStep.php +++ b/app/Filament/Pages/Installer/Steps/DatabaseStep.php @@ -72,7 +72,7 @@ public static function make(PanelInstaller $installer): Step }); } - private static function testConnection(string $driver, $host, $port, $database, $username, $password): bool + private static function testConnection(string $driver, string $host, string $port, string $database, string $username, string $password): bool { if ($driver === 'sqlite') { return true; diff --git a/app/Filament/Pages/Installer/Steps/RedisStep.php b/app/Filament/Pages/Installer/Steps/RedisStep.php index 00ecb18afe..d160e0b700 100644 --- a/app/Filament/Pages/Installer/Steps/RedisStep.php +++ b/app/Filament/Pages/Installer/Steps/RedisStep.php @@ -56,7 +56,7 @@ public static function make(PanelInstaller $installer): Step }); } - private static function testConnection($host, $port, $username, $password): bool + private static function testConnection(string $host, string $port, string $username, string $password): bool { try { config()->set('database.redis._panel_install_test', [ diff --git a/app/Filament/Resources/ApiKeyResource.php b/app/Filament/Resources/ApiKeyResource.php index ba2a851cac..daefee22b1 100644 --- a/app/Filament/Resources/ApiKeyResource.php +++ b/app/Filament/Resources/ApiKeyResource.php @@ -5,6 +5,7 @@ use App\Filament\Resources\ApiKeyResource\Pages; use App\Models\ApiKey; use Filament\Resources\Resource; +use Illuminate\Database\Eloquent\Model; class ApiKeyResource extends Resource { @@ -18,7 +19,7 @@ public static function getNavigationBadge(): ?string return static::getModel()::where('key_type', '2')->count() ?: null; } - public static function canEdit($record): bool + public static function canEdit(Model $record): bool { return false; } diff --git a/app/Filament/Resources/DatabaseHostResource/Pages/CreateDatabaseHost.php b/app/Filament/Resources/DatabaseHostResource/Pages/CreateDatabaseHost.php index d3e07bcb93..e42e5e15ed 100644 --- a/app/Filament/Resources/DatabaseHostResource/Pages/CreateDatabaseHost.php +++ b/app/Filament/Resources/DatabaseHostResource/Pages/CreateDatabaseHost.php @@ -4,6 +4,8 @@ use App\Filament\Resources\DatabaseHostResource; use App\Services\Databases\Hosts\HostCreationService; +use Closure; +use Exception; use Filament\Forms; use Filament\Forms\Components\Section; use Filament\Forms\Components\Select; @@ -97,7 +99,7 @@ protected function handleRecordCreation(array $data): Model return resolve(HostCreationService::class)->handle($data); } - public function exception($e, $stopPropagation): void + public function exception(Exception $e, Closure $stopPropagation): void { if ($e instanceof PDOException) { Notification::make() diff --git a/app/Filament/Resources/DatabaseHostResource/Pages/EditDatabaseHost.php b/app/Filament/Resources/DatabaseHostResource/Pages/EditDatabaseHost.php index 862c33b8cb..8951cff8b7 100644 --- a/app/Filament/Resources/DatabaseHostResource/Pages/EditDatabaseHost.php +++ b/app/Filament/Resources/DatabaseHostResource/Pages/EditDatabaseHost.php @@ -6,6 +6,8 @@ use App\Filament\Resources\DatabaseHostResource\RelationManagers\DatabasesRelationManager; use App\Models\DatabaseHost; use App\Services\Databases\Hosts\HostUpdateService; +use Closure; +use Exception; use Filament\Actions; use Filament\Forms; use Filament\Forms\Components\Section; @@ -97,12 +99,16 @@ public function getRelationManagers(): array ]; } - protected function handleRecordUpdate($record, array $data): Model + protected function handleRecordUpdate(Model $record, array $data): Model { - return resolve(HostUpdateService::class)->handle($record->id, $data); + if (! $record instanceof DatabaseHost) { + return $record; + } + + return resolve(HostUpdateService::class)->handle($record, $data); } - public function exception($e, $stopPropagation): void + public function exception(Exception $e, Closure $stopPropagation): void { if ($e instanceof PDOException) { Notification::make() diff --git a/app/Filament/Resources/DatabaseHostResource/RelationManagers/DatabasesRelationManager.php b/app/Filament/Resources/DatabaseHostResource/RelationManagers/DatabasesRelationManager.php index 4dfcdd955b..bdd93d60d7 100644 --- a/app/Filament/Resources/DatabaseHostResource/RelationManagers/DatabasesRelationManager.php +++ b/app/Filament/Resources/DatabaseHostResource/RelationManagers/DatabasesRelationManager.php @@ -8,6 +8,7 @@ use Filament\Forms\Components\TextInput; use Filament\Forms\Form; use Filament\Forms\Get; +use Filament\Forms\Set; use Filament\Resources\RelationManagers\RelationManager; use Filament\Tables\Actions\DeleteAction; use Filament\Tables\Actions\ViewAction; @@ -60,7 +61,7 @@ public function table(Table $table): Table ]); } - protected function rotatePassword(DatabasePasswordService $service, Database $database, $set, $get): void + protected function rotatePassword(DatabasePasswordService $service, Database $database, Set $set, Get $get): void { $newPassword = $service->handle($database); $jdbcString = 'jdbc:mysql://' . $get('username') . ':' . urlencode($newPassword) . '@' . $database->host->host . ':' . $database->host->port . '/' . $get('database'); diff --git a/app/Filament/Resources/NodeResource/Pages/EditNode.php b/app/Filament/Resources/NodeResource/Pages/EditNode.php index e2c5f2c324..10d5d10626 100644 --- a/app/Filament/Resources/NodeResource/Pages/EditNode.php +++ b/app/Filament/Resources/NodeResource/Pages/EditNode.php @@ -469,12 +469,12 @@ protected function afterSave(): void $this->fillForm(); } - protected function getColumnSpan() + protected function getColumnSpan(): ?int { return null; } - protected function getColumnStart() + protected function getColumnStart(): ?int { return null; } diff --git a/app/Filament/Resources/ServerResource/Pages/EditServer.php b/app/Filament/Resources/ServerResource/Pages/EditServer.php index 51a59591d2..be746d6c30 100644 --- a/app/Filament/Resources/ServerResource/Pages/EditServer.php +++ b/app/Filament/Resources/ServerResource/Pages/EditServer.php @@ -813,7 +813,7 @@ private function getSelectOptionsFromRules(ServerVariable $serverVariable): arra ->all(); } - protected function rotatePassword(DatabasePasswordService $service, $record, $set, $get): void + protected function rotatePassword(DatabasePasswordService $service, Database $record, Set $set, Get $get): void { $newPassword = $service->handle($record); $jdbcString = 'jdbc:mysql://' . $get('username') . ':' . urlencode($newPassword) . '@' . $record->host->host . ':' . $record->host->port . '/' . $get('database'); diff --git a/app/Filament/Resources/UserResource/Pages/EditProfile.php b/app/Filament/Resources/UserResource/Pages/EditProfile.php index f5c5f5828d..9b22e88ee5 100644 --- a/app/Filament/Resources/UserResource/Pages/EditProfile.php +++ b/app/Filament/Resources/UserResource/Pages/EditProfile.php @@ -13,7 +13,9 @@ use chillerlan\QRCode\Common\Version; use chillerlan\QRCode\QRCode; use chillerlan\QRCode\QROptions; +use Closure; use DateTimeZone; +use Exception; use Filament\Forms\Components\Actions\Action; use Filament\Forms\Components\Grid; use Filament\Forms\Components\Placeholder; @@ -274,8 +276,12 @@ protected function getForms(): array ]; } - protected function handleRecordUpdate($record, $data): Model + protected function handleRecordUpdate(Model $record, array $data): Model { + if (! $record instanceof User) { + return $record; + } + if ($token = $data['2facode'] ?? null) { /** @var ToggleTwoFactorService $service */ $service = resolve(ToggleTwoFactorService::class); @@ -298,7 +304,7 @@ protected function handleRecordUpdate($record, $data): Model return parent::handleRecordUpdate($record, $data); } - public function exception($e, $stopPropagation): void + public function exception(Exception $e, Closure $stopPropagation): void { if ($e instanceof TwoFactorAuthenticationTokenInvalid) { Notification::make() diff --git a/app/Http/Controllers/Admin/ServersController.php b/app/Http/Controllers/Admin/ServersController.php index 9ddd9c7e61..9c7836e39a 100644 --- a/app/Http/Controllers/Admin/ServersController.php +++ b/app/Http/Controllers/Admin/ServersController.php @@ -70,7 +70,7 @@ public function setDetails(Request $request, Server $server): RedirectResponse * @throws \App\Exceptions\DisplayException * @throws \App\Exceptions\Model\DataValidationException */ - public function toggleInstall(Server $server) + public function toggleInstall(Server $server): void { if ($server->status === ServerState::InstallFailed) { throw new DisplayException(trans('admin/server.exceptions.marked_as_failed')); @@ -84,8 +84,6 @@ public function toggleInstall(Server $server) ->body(trans('admin/server.alerts.install_toggled')) ->success() ->send(); - - return null; } /** @@ -94,7 +92,7 @@ public function toggleInstall(Server $server) * @throws \App\Exceptions\DisplayException * @throws \App\Exceptions\Model\DataValidationException */ - public function reinstallServer(Server $server) + public function reinstallServer(Server $server): void { $this->reinstallService->handle($server); diff --git a/app/Http/Controllers/Api/Application/ApplicationApiController.php b/app/Http/Controllers/Api/Application/ApplicationApiController.php index 174e6243a4..87c721a74d 100644 --- a/app/Http/Controllers/Api/Application/ApplicationApiController.php +++ b/app/Http/Controllers/Api/Application/ApplicationApiController.php @@ -40,7 +40,7 @@ public function __construct() * Perform dependency injection of certain classes needed for core functionality * without littering the constructors of classes that extend this abstract. */ - public function loadDependencies(Fractal $fractal, Request $request) + public function loadDependencies(Fractal $fractal, Request $request): void { $this->fractal = $fractal; $this->request = $request; diff --git a/app/Http/Controllers/Api/Remote/ActivityProcessingController.php b/app/Http/Controllers/Api/Remote/ActivityProcessingController.php index e07584d23f..3b6badaa5a 100644 --- a/app/Http/Controllers/Api/Remote/ActivityProcessingController.php +++ b/app/Http/Controllers/Api/Remote/ActivityProcessingController.php @@ -14,7 +14,7 @@ class ActivityProcessingController extends Controller { - public function __invoke(ActivityEventRequest $request) + public function __invoke(ActivityEventRequest $request): void { $tz = Carbon::now()->getTimezone(); diff --git a/app/Http/Controllers/Auth/AbstractLoginController.php b/app/Http/Controllers/Auth/AbstractLoginController.php index e5b50d0adf..e62f9fab8a 100644 --- a/app/Http/Controllers/Auth/AbstractLoginController.php +++ b/app/Http/Controllers/Auth/AbstractLoginController.php @@ -51,7 +51,7 @@ public function __construct() * * @throws \App\Exceptions\DisplayException */ - protected function sendFailedLoginResponse(Request $request, Authenticatable $user = null, string $message = null) + protected function sendFailedLoginResponse(Request $request, Authenticatable $user = null, string $message = null): never { $this->incrementLoginAttempts($request); $this->fireFailedLoginEvent($user, [ @@ -99,7 +99,7 @@ protected function getField(string $input = null): string /** * Fire a failed login event. */ - protected function fireFailedLoginEvent(Authenticatable $user = null, array $credentials = []) + protected function fireFailedLoginEvent(Authenticatable $user = null, array $credentials = []): void { Event::dispatch(new Failed('auth', $user, $credentials)); } diff --git a/app/Http/Controllers/Auth/ForgotPasswordController.php b/app/Http/Controllers/Auth/ForgotPasswordController.php index 21ef4fee85..32a7049fce 100644 --- a/app/Http/Controllers/Auth/ForgotPasswordController.php +++ b/app/Http/Controllers/Auth/ForgotPasswordController.php @@ -16,7 +16,7 @@ class ForgotPasswordController extends Controller /** * Get the response for a failed password reset link. */ - protected function sendResetLinkFailedResponse(Request $request, $response): JsonResponse + protected function sendResetLinkFailedResponse(Request $request, string $response): JsonResponse { // As noted in #358 we will return success even if it failed // to avoid pointing out that an account does or does not @@ -31,7 +31,7 @@ protected function sendResetLinkFailedResponse(Request $request, $response): Jso * * @param string $response */ - protected function sendResetLinkResponse(Request $request, $response): JsonResponse + protected function sendResetLinkResponse(Request $request, string $response): JsonResponse { return response()->json([ 'status' => trans($response), diff --git a/app/Http/Controllers/Auth/LoginCheckpointController.php b/app/Http/Controllers/Auth/LoginCheckpointController.php index 540aca5a00..8797f533be 100644 --- a/app/Http/Controllers/Auth/LoginCheckpointController.php +++ b/app/Http/Controllers/Auth/LoginCheckpointController.php @@ -72,7 +72,7 @@ public function __invoke(LoginCheckpointRequest $request): JsonResponse } } - return $this->sendFailedLoginResponse($request, $user, !empty($recoveryToken) ? 'The recovery token provided is not valid.' : null); + $this->sendFailedLoginResponse($request, $user, !empty($recoveryToken) ? 'The recovery token provided is not valid.' : null); } /** diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index 28c3c4f5ee..ea2a595943 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -4,11 +4,13 @@ use App\Filament\Pages\Installer\PanelInstaller; use Carbon\CarbonImmutable; +use Illuminate\Http\RedirectResponse; use Illuminate\Support\Str; use Illuminate\Http\Request; use App\Models\User; use Illuminate\Http\JsonResponse; use App\Facades\Activity; +use Illuminate\View\View; class LoginController extends AbstractLoginController { @@ -17,7 +19,7 @@ class LoginController extends AbstractLoginController * base authentication view component. React will take over at this point and * turn the login area into an SPA. */ - public function index() + public function index(): View|RedirectResponse { if (!PanelInstaller::isInstalled()) { return redirect('/installer'); diff --git a/app/Http/Controllers/Auth/ResetPasswordController.php b/app/Http/Controllers/Auth/ResetPasswordController.php index b4c338ee98..11dcc03469 100644 --- a/app/Http/Controllers/Auth/ResetPasswordController.php +++ b/app/Http/Controllers/Auth/ResetPasswordController.php @@ -69,7 +69,7 @@ function ($user, $password) { * * @throws \App\Exceptions\Model\DataValidationException */ - protected function resetPassword($user, $password) + protected function resetPassword($user, $password): void { /** @var User $user */ $user->password = $this->hasher->make($password); diff --git a/app/Http/Middleware/EnsureStatefulRequests.php b/app/Http/Middleware/EnsureStatefulRequests.php index 66689fe11e..35c1795cc5 100644 --- a/app/Http/Middleware/EnsureStatefulRequests.php +++ b/app/Http/Middleware/EnsureStatefulRequests.php @@ -15,7 +15,7 @@ class EnsureStatefulRequests extends EnsureFrontendRequestsAreStateful * We don't want to support API usage using the cookies, except for requests stemming * from the front-end we control. */ - public static function fromFrontend($request) + public static function fromFrontend($request): bool { if (parent::fromFrontend($request)) { return true; diff --git a/app/Http/Requests/Admin/Egg/EggFormRequest.php b/app/Http/Requests/Admin/Egg/EggFormRequest.php index d1af8a0852..aae5ae0136 100644 --- a/app/Http/Requests/Admin/Egg/EggFormRequest.php +++ b/app/Http/Requests/Admin/Egg/EggFormRequest.php @@ -3,6 +3,7 @@ namespace App\Http\Requests\Admin\Egg; use App\Http\Requests\Admin\AdminFormRequest; +use Illuminate\Validation\Validator; class EggFormRequest extends AdminFormRequest { @@ -25,7 +26,7 @@ public function rules(): array return $rules; } - public function withValidator($validator) + public function withValidator(Validator $validator): void { $validator->sometimes('config_from', 'exists:eggs,id', function () { return (int) $this->input('config_from') !== 0; diff --git a/app/Http/Requests/Api/Application/DatabaseHosts/UpdateDatabaseHostRequest.php b/app/Http/Requests/Api/Application/DatabaseHosts/UpdateDatabaseHostRequest.php index 111560bbfd..83c74ac3bd 100644 --- a/app/Http/Requests/Api/Application/DatabaseHosts/UpdateDatabaseHostRequest.php +++ b/app/Http/Requests/Api/Application/DatabaseHosts/UpdateDatabaseHostRequest.php @@ -11,6 +11,6 @@ public function rules(array $rules = null): array /** @var DatabaseHost $databaseHost */ $databaseHost = $this->route()->parameter('database_host'); - return $rules ?? DatabaseHost::getRulesForUpdate($databaseHost->id); + return $rules ?? DatabaseHost::getRulesForUpdate($databaseHost); } } diff --git a/app/Http/Requests/Api/Application/Mounts/UpdateMountRequest.php b/app/Http/Requests/Api/Application/Mounts/UpdateMountRequest.php index 7f76ec4201..e111553d47 100644 --- a/app/Http/Requests/Api/Application/Mounts/UpdateMountRequest.php +++ b/app/Http/Requests/Api/Application/Mounts/UpdateMountRequest.php @@ -14,6 +14,6 @@ public function rules(array $rules = null): array /** @var Mount $mount */ $mount = $this->route()->parameter('mount'); - return Mount::getRulesForUpdate($mount->id); + return Mount::getRulesForUpdate($mount); } } diff --git a/app/Http/Requests/Api/Application/Nodes/UpdateNodeRequest.php b/app/Http/Requests/Api/Application/Nodes/UpdateNodeRequest.php index ab636dff02..a59039d995 100644 --- a/app/Http/Requests/Api/Application/Nodes/UpdateNodeRequest.php +++ b/app/Http/Requests/Api/Application/Nodes/UpdateNodeRequest.php @@ -15,6 +15,6 @@ public function rules(array $rules = null): array /** @var Node $node */ $node = $this->route()->parameter('node'); - return parent::rules(Node::getRulesForUpdate($node->id)); + return parent::rules(Node::getRulesForUpdate($node)); } } diff --git a/app/Http/Requests/Api/Application/Users/UpdateUserRequest.php b/app/Http/Requests/Api/Application/Users/UpdateUserRequest.php index ecccbdd5aa..c7a919beef 100644 --- a/app/Http/Requests/Api/Application/Users/UpdateUserRequest.php +++ b/app/Http/Requests/Api/Application/Users/UpdateUserRequest.php @@ -11,8 +11,8 @@ class UpdateUserRequest extends StoreUserRequest */ public function rules(array $rules = null): array { - $userId = $this->parameter('user', User::class)->id; + $user = $this->parameter('user', User::class); - return parent::rules(User::getRulesForUpdate($userId)); + return parent::rules(User::getRulesForUpdate($user)); } } diff --git a/app/Http/Requests/Api/Client/Servers/Subusers/SubuserRequest.php b/app/Http/Requests/Api/Client/Servers/Subusers/SubuserRequest.php index bd68fb8908..349db06168 100644 --- a/app/Http/Requests/Api/Client/Servers/Subusers/SubuserRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Subusers/SubuserRequest.php @@ -49,7 +49,7 @@ public function authorize(): bool * * @throws \Illuminate\Contracts\Container\BindingResolutionException */ - protected function validatePermissionsCanBeAssigned(array $permissions) + protected function validatePermissionsCanBeAssigned(array $permissions): void { $user = $this->user(); /** @var \App\Models\Server $server */ diff --git a/app/Jobs/Schedule/RunTaskJob.php b/app/Jobs/Schedule/RunTaskJob.php index 6a660e5c05..167980ac92 100644 --- a/app/Jobs/Schedule/RunTaskJob.php +++ b/app/Jobs/Schedule/RunTaskJob.php @@ -90,7 +90,7 @@ public function handle( /** * Handle a failure while sending the action to the daemon or otherwise processing the job. */ - public function failed(\Exception $exception = null) + public function failed(\Exception $exception = null): void { $this->markTaskNotQueued(); $this->markScheduleComplete(); @@ -99,7 +99,7 @@ public function failed(\Exception $exception = null) /** * Get the next task in the schedule and queue it for running after the defined period of wait time. */ - private function queueNextTask() + private function queueNextTask(): void { /** @var \App\Models\Task|null $nextTask */ $nextTask = Task::query()->where('schedule_id', $this->task->schedule_id) @@ -121,7 +121,7 @@ private function queueNextTask() /** * Marks the parent schedule as being complete. */ - private function markScheduleComplete() + private function markScheduleComplete(): void { $this->task->schedule()->update([ 'is_processing' => false, @@ -132,7 +132,7 @@ private function markScheduleComplete() /** * Mark a specific task as no longer being queued. */ - private function markTaskNotQueued() + private function markTaskNotQueued(): void { $this->task->update(['is_queued' => false]); } diff --git a/app/Livewire/NodeSystemInformation.php b/app/Livewire/NodeSystemInformation.php index b291902510..54b4cd827a 100644 --- a/app/Livewire/NodeSystemInformation.php +++ b/app/Livewire/NodeSystemInformation.php @@ -3,6 +3,7 @@ namespace App\Livewire; use App\Models\Node; +use Illuminate\View\View; use Livewire\Component; class NodeSystemInformation extends Component @@ -10,12 +11,12 @@ class NodeSystemInformation extends Component public Node $node; public string $sizeClasses; - public function render() + public function render(): View { return view('livewire.node-system-information'); } - public function placeholder() + public function placeholder(): string { return <<<'HTML'
diff --git a/app/Models/ActivityLog.php b/app/Models/ActivityLog.php index bb6149c142..20fb579e06 100644 --- a/app/Models/ActivityLog.php +++ b/app/Models/ActivityLog.php @@ -123,7 +123,7 @@ public function scopeForActor(Builder $builder, IlluminateModel $actor): Builder * * @see https://laravel.com/docs/9.x/eloquent#pruning-models */ - public function prunable() + public function prunable(): Builder { if (is_null(config('activity.prune_days'))) { throw new \LogicException('Cannot prune activity logs: no "prune_days" configuration value is set.'); @@ -136,7 +136,7 @@ public function prunable() * Boots the model event listeners. This will trigger an activity log event every * time a new model is inserted which can then be captured and worked with as needed. */ - protected static function boot() + protected static function boot(): void { parent::boot(); @@ -149,7 +149,7 @@ protected static function boot() }); } - public function htmlable() + public function htmlable(): string { $user = $this->actor; if (!$user instanceof User) { diff --git a/app/Models/ActivityLogSubject.php b/app/Models/ActivityLogSubject.php index 037d344f05..9e4e2777b8 100644 --- a/app/Models/ActivityLogSubject.php +++ b/app/Models/ActivityLogSubject.php @@ -3,8 +3,10 @@ namespace App\Models; use Illuminate\Database\Eloquent\Relations\BelongsTo; +use Illuminate\Database\Eloquent\Relations\MorphTo; use Illuminate\Database\Eloquent\Relations\Pivot; use Illuminate\Database\Eloquent\SoftDeletes; +use Illuminate\Database\Eloquent\SoftDeletingScope; /** * \App\Models\ActivityLogSubject. @@ -36,15 +38,8 @@ public function activityLog(): BelongsTo return $this->belongsTo(ActivityLog::class); } - public function subject() + public function subject(): MorphTo { - $morph = $this->morphTo(); - - if (in_array(SoftDeletes::class, class_uses_recursive($morph::class))) { - /** @var self|Backup|UserSSHKey $morph - cannot use traits in doc blocks */ - return $morph->withTrashed(); - } - - return $morph; + return $this->morphTo()->withoutGlobalScope(SoftDeletingScope::class); } } diff --git a/app/Models/Filters/AdminServerFilter.php b/app/Models/Filters/AdminServerFilter.php index d3c1eea606..bebde0ee93 100644 --- a/app/Models/Filters/AdminServerFilter.php +++ b/app/Models/Filters/AdminServerFilter.php @@ -13,7 +13,7 @@ class AdminServerFilter implements Filter * * @param string $value */ - public function __invoke(Builder $query, $value, string $property) + public function __invoke(Builder $query, $value, string $property): void { if ($query->getQuery()->from !== 'servers') { throw new \BadMethodCallException('Cannot use the AdminServerFilter against a non-server model.'); diff --git a/app/Models/Filters/MultiFieldServerFilter.php b/app/Models/Filters/MultiFieldServerFilter.php index da3f91f6d5..4523825f46 100644 --- a/app/Models/Filters/MultiFieldServerFilter.php +++ b/app/Models/Filters/MultiFieldServerFilter.php @@ -21,7 +21,7 @@ class MultiFieldServerFilter implements Filter * * @param string $value */ - public function __invoke(Builder $query, $value, string $property) + public function __invoke(Builder $query, $value, string $property): void { if ($query->getQuery()->from !== 'servers') { throw new \BadMethodCallException('Cannot use the MultiFieldServerFilter against a non-server model.'); diff --git a/app/Models/Model.php b/app/Models/Model.php index 536edf9b57..20bc2bf334 100644 --- a/app/Models/Model.php +++ b/app/Models/Model.php @@ -38,7 +38,7 @@ abstract class Model extends IlluminateModel * * @throws \Illuminate\Contracts\Container\BindingResolutionException */ - protected static function boot() + protected static function boot(): void { parent::boot(); @@ -69,7 +69,7 @@ public function getRouteKeyName(): string return 'uuid'; } - protected function asDateTime($value) + protected function asDateTime($value): Carbon { $timezone = auth()->user()?->timezone ?? config('app.timezone', 'UTC'); @@ -135,11 +135,9 @@ public static function getRulesForField(string $field): array * Returns the rules associated with the model, specifically for updating the given model * rather than just creating it. */ - public static function getRulesForUpdate($model, string $column = 'id'): array + public static function getRulesForUpdate(self $model): array { - if ($model instanceof Model) { - [$id, $column] = [$model->getKey(), $model->getKeyName()]; - } + [$id, $column] = [$model->getKey(), $model->getKeyName()]; $rules = static::getRules(); foreach ($rules as $key => &$data) { diff --git a/app/Models/Mount.php b/app/Models/Mount.php index 2236038059..60cb2b436c 100644 --- a/app/Models/Mount.php +++ b/app/Models/Mount.php @@ -70,7 +70,7 @@ public static function getRules(): array /** * Blacklisted source paths. */ - public static $invalidSourcePaths = [ + public static array $invalidSourcePaths = [ '/etc/pelican', '/var/lib/pelican/volumes', '/srv/daemon-data', @@ -79,7 +79,7 @@ public static function getRules(): array /** * Blacklisted target paths. */ - public static $invalidTargetPaths = [ + public static array $invalidTargetPaths = [ '/home/container', ]; diff --git a/app/Models/Node.php b/app/Models/Node.php index 0a9613196d..366d63fb9a 100644 --- a/app/Models/Node.php +++ b/app/Models/Node.php @@ -8,6 +8,7 @@ use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\HasManyThrough; use Illuminate\Notifications\Notifiable; +use Illuminate\Support\Collection; use Illuminate\Support\Facades\Http; use Illuminate\Support\Str; use Symfony\Component\Yaml\Yaml; @@ -268,7 +269,7 @@ public function isViable(int $memory, int $disk, int $cpu): bool return true; } - public static function getForServerCreation() + public static function getForServerCreation(): Collection { return self::with('allocations')->get()->map(function (Node $item) { $filtered = $item->getRelation('allocations')->where('server_id', null)->map(function ($map) { @@ -330,7 +331,7 @@ public function serverStatuses(): array return $statuses; } - public function statistics() + public function statistics(): array { $default = [ 'memory_total' => 0, diff --git a/app/Models/Server.php b/app/Models/Server.php index a0c341c6d4..1ace74961a 100644 --- a/app/Models/Server.php +++ b/app/Models/Server.php @@ -363,7 +363,7 @@ public function resolveChildRouteBinding($childType, $value, $field) * * @throws ServerStateConflictException */ - public function validateCurrentState() + public function validateCurrentState(): void { if ( $this->isSuspended() || @@ -382,7 +382,7 @@ public function validateCurrentState() * sure the server can be transferred and is not currently being transferred * or installed. */ - public function validateTransferState() + public function validateTransferState(): void { if ( !$this->isInstalled() || diff --git a/app/Models/User.php b/app/Models/User.php index 395f4994fa..45f8ee87c6 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -235,7 +235,7 @@ public function toReactObject(): array * * @param string $token */ - public function sendPasswordResetNotification($token) + public function sendPasswordResetNotification($token): void { Activity::event('auth:reset-password') ->withRequestMetadata() @@ -248,7 +248,7 @@ public function sendPasswordResetNotification($token) /** * Store the username as a lowercase string. */ - public function setUsernameAttribute(string $value) + public function setUsernameAttribute(string $value): void { $this->attributes['username'] = mb_strtolower($value); } diff --git a/app/Policies/ServerPolicy.php b/app/Policies/ServerPolicy.php index dbc2ae4028..dfa72c9b98 100644 --- a/app/Policies/ServerPolicy.php +++ b/app/Policies/ServerPolicy.php @@ -41,7 +41,7 @@ public function before(User $user, string $ability, string|Server $server): ?boo * not call the before() function if there isn't a function matching the * policy permission. */ - public function __call(string $name, mixed $arguments) + public function __call(string $name, mixed $arguments): void { // do nothing } diff --git a/app/Providers/Filament/AdminPanelProvider.php b/app/Providers/Filament/AdminPanelProvider.php index 7bae858564..f6b7c568b0 100644 --- a/app/Providers/Filament/AdminPanelProvider.php +++ b/app/Providers/Filament/AdminPanelProvider.php @@ -22,7 +22,7 @@ class AdminPanelProvider extends PanelProvider { - public function boot() + public function boot(): void { FilamentAsset::registerCssVariables([ 'sidebar-width' => '16rem !important', diff --git a/app/Repositories/Daemon/DaemonBackupRepository.php b/app/Repositories/Daemon/DaemonBackupRepository.php index bbe852e809..ce9e394e51 100644 --- a/app/Repositories/Daemon/DaemonBackupRepository.php +++ b/app/Repositories/Daemon/DaemonBackupRepository.php @@ -2,6 +2,7 @@ namespace App\Repositories\Daemon; +use Illuminate\Http\Client\Response; use Webmozart\Assert\Assert; use App\Models\Backup; use App\Models\Server; @@ -27,7 +28,7 @@ public function setBackupAdapter(string $adapter): self * * @throws \App\Exceptions\Http\Connection\DaemonConnectionException */ - public function backup(Backup $backup) + public function backup(Backup $backup): Response { Assert::isInstanceOf($this->server, Server::class); @@ -50,7 +51,7 @@ public function backup(Backup $backup) * * @throws \App\Exceptions\Http\Connection\DaemonConnectionException */ - public function restore(Backup $backup, string $url = null, bool $truncate = false) + public function restore(Backup $backup, string $url = null, bool $truncate = false): Response { Assert::isInstanceOf($this->server, Server::class); @@ -73,7 +74,7 @@ public function restore(Backup $backup, string $url = null, bool $truncate = fal * * @throws \App\Exceptions\Http\Connection\DaemonConnectionException */ - public function delete(Backup $backup) + public function delete(Backup $backup): Response { Assert::isInstanceOf($this->server, Server::class); diff --git a/app/Repositories/Daemon/DaemonConfigurationRepository.php b/app/Repositories/Daemon/DaemonConfigurationRepository.php index 52cda56dd4..910e95e58b 100644 --- a/app/Repositories/Daemon/DaemonConfigurationRepository.php +++ b/app/Repositories/Daemon/DaemonConfigurationRepository.php @@ -5,6 +5,7 @@ use App\Models\Node; use GuzzleHttp\Exception\TransferException; use App\Exceptions\Http\Connection\DaemonConnectionException; +use Illuminate\Http\Client\Response; class DaemonConfigurationRepository extends DaemonRepository { @@ -13,7 +14,7 @@ class DaemonConfigurationRepository extends DaemonRepository * * @throws \App\Exceptions\Http\Connection\DaemonConnectionException */ - public function getSystemInformation(?int $version = null, $connectTimeout = 5): array + public function getSystemInformation(?int $version = null, int $connectTimeout = 5): array { try { $response = $this @@ -34,7 +35,7 @@ public function getSystemInformation(?int $version = null, $connectTimeout = 5): * * @throws \App\Exceptions\Http\Connection\DaemonConnectionException */ - public function update(Node $node) + public function update(Node $node): Response { try { return $this->getHttpClient()->post( diff --git a/app/Repositories/Daemon/DaemonFileRepository.php b/app/Repositories/Daemon/DaemonFileRepository.php index 7667f482e8..e97261eb11 100644 --- a/app/Repositories/Daemon/DaemonFileRepository.php +++ b/app/Repositories/Daemon/DaemonFileRepository.php @@ -3,6 +3,7 @@ namespace App\Repositories\Daemon; use Carbon\CarbonInterval; +use Illuminate\Http\Client\Response; use Webmozart\Assert\Assert; use App\Models\Server; use GuzzleHttp\Exception\ClientException; @@ -48,7 +49,7 @@ public function getContent(string $path, int $notLargerThan = null): string * * @throws \App\Exceptions\Http\Connection\DaemonConnectionException */ - public function putContent(string $path, string $content) + public function putContent(string $path, string $content): Response { Assert::isInstanceOf($this->server, Server::class); @@ -88,7 +89,7 @@ public function getDirectory(string $path): array * * @throws \App\Exceptions\Http\Connection\DaemonConnectionException */ - public function createDirectory(string $name, string $path) + public function createDirectory(string $name, string $path): Response { Assert::isInstanceOf($this->server, Server::class); @@ -110,7 +111,7 @@ public function createDirectory(string $name, string $path) * * @throws \App\Exceptions\Http\Connection\DaemonConnectionException */ - public function renameFiles(?string $root, array $files) + public function renameFiles(?string $root, array $files): Response { Assert::isInstanceOf($this->server, Server::class); @@ -132,7 +133,7 @@ public function renameFiles(?string $root, array $files) * * @throws \App\Exceptions\Http\Connection\DaemonConnectionException */ - public function copyFile(string $location) + public function copyFile(string $location): Response { Assert::isInstanceOf($this->server, Server::class); @@ -153,7 +154,7 @@ public function copyFile(string $location) * * @throws \App\Exceptions\Http\Connection\DaemonConnectionException */ - public function deleteFiles(?string $root, array $files) + public function deleteFiles(?string $root, array $files): Response { Assert::isInstanceOf($this->server, Server::class); @@ -203,7 +204,7 @@ public function compressFiles(?string $root, array $files): array * * @throws \App\Exceptions\Http\Connection\DaemonConnectionException */ - public function decompressFile(?string $root, string $file) + public function decompressFile(?string $root, string $file): Response { Assert::isInstanceOf($this->server, Server::class); @@ -229,7 +230,7 @@ public function decompressFile(?string $root, string $file) * * @throws \App\Exceptions\Http\Connection\DaemonConnectionException */ - public function chmodFiles(?string $root, array $files) + public function chmodFiles(?string $root, array $files): Response { Assert::isInstanceOf($this->server, Server::class); @@ -251,7 +252,7 @@ public function chmodFiles(?string $root, array $files) * * @throws \App\Exceptions\Http\Connection\DaemonConnectionException */ - public function pull(string $url, ?string $directory, array $params = []) + public function pull(string $url, ?string $directory, array $params = []): Response { Assert::isInstanceOf($this->server, Server::class); diff --git a/app/Repositories/Daemon/DaemonPowerRepository.php b/app/Repositories/Daemon/DaemonPowerRepository.php index ca3e03c442..3b701be342 100644 --- a/app/Repositories/Daemon/DaemonPowerRepository.php +++ b/app/Repositories/Daemon/DaemonPowerRepository.php @@ -2,6 +2,7 @@ namespace App\Repositories\Daemon; +use Illuminate\Http\Client\Response; use Webmozart\Assert\Assert; use App\Models\Server; use GuzzleHttp\Exception\TransferException; @@ -14,7 +15,7 @@ class DaemonPowerRepository extends DaemonRepository * * @throws \App\Exceptions\Http\Connection\DaemonConnectionException */ - public function send(string $action) + public function send(string $action): Response { Assert::isInstanceOf($this->server, Server::class); diff --git a/app/Services/Activity/ActivityLogService.php b/app/Services/Activity/ActivityLogService.php index 37b7ae43b5..5147912180 100644 --- a/app/Services/Activity/ActivityLogService.php +++ b/app/Services/Activity/ActivityLogService.php @@ -168,7 +168,7 @@ public function clone(): self * * @throws \Throwable */ - public function transaction(\Closure $callback) + public function transaction(\Closure $callback): mixed { return $this->connection->transaction(function () use ($callback) { $response = $callback($this); diff --git a/app/Services/Deployment/FindViableNodesService.php b/app/Services/Deployment/FindViableNodesService.php index 4cffc71d28..d95c08c640 100644 --- a/app/Services/Deployment/FindViableNodesService.php +++ b/app/Services/Deployment/FindViableNodesService.php @@ -17,7 +17,7 @@ class FindViableNodesService * are tossed out, as are any nodes marked as non-public, meaning automatic * deployments should not be done against them. */ - public function handle(int $memory = 0, int $disk = 0, int $cpu = 0, $tags = []): Collection + public function handle(int $memory = 0, int $disk = 0, int $cpu = 0, array $tags = []): Collection { $nodes = Node::query() ->withSum('servers', 'memory') diff --git a/app/Services/Servers/SuspensionService.php b/app/Services/Servers/SuspensionService.php index aef02b7b2e..4557fae3d4 100644 --- a/app/Services/Servers/SuspensionService.php +++ b/app/Services/Servers/SuspensionService.php @@ -27,7 +27,7 @@ public function __construct( * * @throws \Throwable */ - public function toggle(Server $server, string $action = self::ACTION_SUSPEND) + public function toggle(Server $server, string $action = self::ACTION_SUSPEND): void { Assert::oneOf($action, [self::ACTION_SUSPEND, self::ACTION_UNSUSPEND]); @@ -36,7 +36,9 @@ public function toggle(Server $server, string $action = self::ACTION_SUSPEND) // suspended in the database. Additionally, nothing needs to happen if the server // is not suspended, and we try to un-suspend the instance. if ($isSuspending === $server->isSuspended()) { - return Notification::make()->danger()->title('Failed!')->body('Server is already suspended!')->send(); + Notification::make()->danger()->title('Failed!')->body('Server is already suspended!')->send(); + + return; } // Check if the server is currently being transferred. diff --git a/app/Services/Servers/TransferServerService.php b/app/Services/Servers/TransferServerService.php index 4312369dd7..8a7bcd3ea1 100644 --- a/app/Services/Servers/TransferServerService.php +++ b/app/Services/Servers/TransferServerService.php @@ -106,7 +106,7 @@ public function handle(Server $server, array $data): bool /** * Assigns the specified allocations to the specified server. */ - private function assignAllocationsToServer(Server $server, int $node_id, int $allocation_id, array $additional_allocations) + private function assignAllocationsToServer(Server $server, int $node_id, int $allocation_id, array $additional_allocations): void { $allocations = $additional_allocations; $allocations[] = $allocation_id; diff --git a/app/Traits/Controllers/PlainJavascriptInjection.php b/app/Traits/Controllers/PlainJavascriptInjection.php index 4b5169296b..e77686776c 100644 --- a/app/Traits/Controllers/PlainJavascriptInjection.php +++ b/app/Traits/Controllers/PlainJavascriptInjection.php @@ -9,7 +9,7 @@ trait PlainJavascriptInjection /** * Injects statistics into javascript. */ - public function injectJavascript($data) + public function injectJavascript($data): void { \JavaScript::put($data); } diff --git a/app/Transformers/Api/Application/EggVariableTransformer.php b/app/Transformers/Api/Application/EggVariableTransformer.php index 381b3102e1..d70299787b 100644 --- a/app/Transformers/Api/Application/EggVariableTransformer.php +++ b/app/Transformers/Api/Application/EggVariableTransformer.php @@ -15,7 +15,7 @@ public function getResourceName(): string return Egg::RESOURCE_NAME; } - public function transform(EggVariable $model) + public function transform(EggVariable $model): array { return $model->toArray(); } diff --git a/app/Transformers/Api/Application/MountTransformer.php b/app/Transformers/Api/Application/MountTransformer.php index c658f30fa2..18dbe36dcd 100644 --- a/app/Transformers/Api/Application/MountTransformer.php +++ b/app/Transformers/Api/Application/MountTransformer.php @@ -22,7 +22,7 @@ public function getResourceName(): string return Mount::RESOURCE_NAME; } - public function transform(Mount $model) + public function transform(Mount $model): array { return $model->toArray(); } diff --git a/app/Transformers/Api/Application/ServerTransformer.php b/app/Transformers/Api/Application/ServerTransformer.php index 90836cc248..b81baf2794 100644 --- a/app/Transformers/Api/Application/ServerTransformer.php +++ b/app/Transformers/Api/Application/ServerTransformer.php @@ -30,7 +30,7 @@ class ServerTransformer extends BaseTransformer /** * Perform dependency injection. */ - public function handle(EnvironmentService $environmentService) + public function handle(EnvironmentService $environmentService): void { $this->environmentService = $environmentService; } diff --git a/app/Transformers/Api/Client/ActivityLogTransformer.php b/app/Transformers/Api/Client/ActivityLogTransformer.php index 58d5f13ae5..7a60592ae0 100644 --- a/app/Transformers/Api/Client/ActivityLogTransformer.php +++ b/app/Transformers/Api/Client/ActivityLogTransformer.php @@ -6,6 +6,7 @@ use App\Models\User; use App\Models\ActivityLog; use Illuminate\Database\Eloquent\Model; +use League\Fractal\Resource\ResourceAbstract; class ActivityLogTransformer extends BaseClientTransformer { @@ -34,7 +35,7 @@ public function transform(ActivityLog $model): array ]; } - public function includeActor(ActivityLog $model) + public function includeActor(ActivityLog $model): ResourceAbstract { if (!$model->actor instanceof User) { return $this->null(); diff --git a/database/Seeders/DatabaseSeeder.php b/database/Seeders/DatabaseSeeder.php index 2f7f6694e1..b2e7c20e41 100644 --- a/database/Seeders/DatabaseSeeder.php +++ b/database/Seeders/DatabaseSeeder.php @@ -10,7 +10,7 @@ class DatabaseSeeder extends Seeder /** * Run the database seeds. */ - public function run() + public function run(): void { $this->call(EggSeeder::class); diff --git a/database/Seeders/EggSeeder.php b/database/Seeders/EggSeeder.php index dcbc4f25c1..d6a3743b7b 100644 --- a/database/Seeders/EggSeeder.php +++ b/database/Seeders/EggSeeder.php @@ -34,7 +34,7 @@ public function __construct( /** * Run the egg seeder. */ - public function run() + public function run(): void { foreach (static::$imports as $import) { /* @noinspection PhpParamsInspection */ @@ -45,7 +45,7 @@ public function run() /** * Loop through the list of egg files and import them. */ - protected function parseEggFiles($name) + protected function parseEggFiles($name): void { $files = new \DirectoryIterator(database_path('Seeders/eggs/' . kebab_case($name))); diff --git a/phpstan.neon b/phpstan.neon index 58b6c8e913..21d412e895 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -4,17 +4,14 @@ includes: parameters: paths: - - app/ + - app - # Level 9 is the highest level - level: 5 + level: 6 ignoreErrors: # Prologue\Alerts defines its methods from its configuration file dynamically - '#^Call to an undefined method Prologue\\Alerts\\AlertsMessageBag::(danger|success|info|warning)\(\)\.$#' -# excludePaths: -# - ./*/*/FileToBeExcluded.php -# -# checkMissingIterableValueType: false - + - '#no value type specified in iterable#' + - '#Unable to resolve the template type#' + - '#does not specify its types#' diff --git a/tests/Integration/Api/Client/ClientApiIntegrationTestCase.php b/tests/Integration/Api/Client/ClientApiIntegrationTestCase.php index e909bb41ec..4fb4174084 100644 --- a/tests/Integration/Api/Client/ClientApiIntegrationTestCase.php +++ b/tests/Integration/Api/Client/ClientApiIntegrationTestCase.php @@ -76,7 +76,7 @@ protected function link(mixed $model, string $append = null): string * Asserts that the data passed through matches the output of the data from the transformer. This * will remove the "relationships" key when performing the comparison. */ - protected function assertJsonTransformedWith(array $data, Model|EloquentModel $model) + protected function assertJsonTransformedWith(array $data, Model|EloquentModel $model): void { $reflect = new \ReflectionClass($model); $transformer = sprintf('\\App\\Transformers\\Api\\Client\\%sTransformer', $reflect->getShortName()); diff --git a/tests/Integration/IntegrationTestCase.php b/tests/Integration/IntegrationTestCase.php index b496eeaa0d..c608e2a8ea 100644 --- a/tests/Integration/IntegrationTestCase.php +++ b/tests/Integration/IntegrationTestCase.php @@ -43,7 +43,7 @@ protected function formatTimestamp(string $timestamp): string * * @return array */ - protected function connectionsToTransact() + protected function connectionsToTransact(): array { return [DB::getDriverName()]; } From deb660384039275610f389302942774f65d35c10 Mon Sep 17 00:00:00 2001 From: Lance Pioch Date: Sat, 19 Oct 2024 21:14:41 -0400 Subject: [PATCH 19/33] Revert "Add concat_space rule" This reverts commit 96acd268bee7005fe1691b572a4674575604d437. --- .../Environment/AppSettingsCommand.php | 2 +- .../Environment/EmailSettingsCommand.php | 2 +- .../Environment/QueueWorkerServiceCommand.php | 6 +-- .../Maintenance/PruneImagesCommand.php | 2 +- .../Schedule/ProcessRunnableCommand.php | 2 +- app/Console/Commands/UpgradeCommand.php | 8 +-- app/Console/Kernel.php | 2 +- app/Exceptions/Handler.php | 4 +- app/Extensions/Backups/BackupManager.php | 2 +- app/Extensions/DynamicDatabaseConnection.php | 2 +- app/Extensions/Themes/Theme.php | 6 +-- .../Pages/Installer/Steps/CompletedStep.php | 4 +- .../Installer/Steps/RequirementsStep.php | 8 +-- .../ApiKeyResource/Pages/ListApiKeys.php | 2 +- .../DatabasesRelationManager.php | 4 +- .../Resources/EggResource/Pages/EditEgg.php | 2 +- .../Resources/EggResource/Pages/ListEggs.php | 2 +- .../NodeResource/Widgets/NodeCpuChart.php | 4 +- .../NodeResource/Widgets/NodeMemoryChart.php | 10 ++-- app/Filament/Resources/RoleResource.php | 18 +++---- .../ServerResource/Pages/CreateServer.php | 16 +++--- .../ServerResource/Pages/EditServer.php | 14 +++--- .../UserResource/Pages/EditProfile.php | 2 +- .../UserResource/Pages/ListUsers.php | 4 +- .../Admin/Eggs/EggShareController.php | 2 +- .../Admin/NodeAutoDeployController.php | 2 +- .../Admin/Servers/CreateServerController.php | 2 +- .../Controllers/Admin/ServersController.php | 2 +- .../Api/Client/Servers/FileController.php | 2 +- .../Client/Servers/FileUploadController.php | 2 +- .../Client/Servers/WebsocketController.php | 4 +- .../Remote/Backups/BackupStatusController.php | 2 +- .../Remote/SftpAuthenticationController.php | 2 +- app/Http/Controllers/Auth/OAuthController.php | 2 +- .../Middleware/Api/AuthenticateIPAccess.php | 2 +- .../Client/Server/ResourceBelongsToServer.php | 2 +- app/Http/Middleware/Api/IsValidJson.php | 2 +- .../RequireTwoFactorAuthentication.php | 2 +- .../Api/StoreApplicationApiKeyRequest.php | 2 +- .../Admin/Egg/EggVariableFormRequest.php | 2 +- .../Api/Client/Account/StoreApiKeyRequest.php | 2 +- app/Jobs/Schedule/RunTaskJob.php | 2 +- app/Models/ApiKey.php | 50 +++++++++---------- app/Models/EggVariable.php | 2 +- app/Models/Filters/MultiFieldServerFilter.php | 2 +- app/Models/Node.php | 4 +- app/Models/User.php | 4 +- app/Notifications/AccountCreated.php | 10 ++-- app/Notifications/AddedToServer.php | 6 +-- app/Notifications/MailTested.php | 2 +- app/Notifications/RemovedFromServer.php | 4 +- app/Notifications/SendPasswordReset.php | 2 +- app/Notifications/ServerInstalled.php | 4 +- app/Policies/DefaultPolicies.php | 10 ++-- .../Daemon/DaemonConfigurationRepository.php | 2 +- .../Daemon/DaemonServerRepository.php | 4 +- app/Services/Acl/Api/AdminAcl.php | 2 +- app/Services/Backups/DownloadLinkService.php | 2 +- app/Services/Files/DeleteFilesService.php | 2 +- app/Services/Helpers/AssetHashService.php | 4 +- .../Helpers/SoftwareVersionService.php | 4 +- .../Servers/StartupCommandService.php | 2 +- .../Servers/TransferServerService.php | 4 +- .../Servers/VariableValidatorService.php | 4 +- .../Subusers/SubuserCreationService.php | 2 +- app/Traits/EnvironmentWriterTrait.php | 6 +-- .../Api/Client/ActivityLogTransformer.php | 4 +- .../Api/Client/UserTransformer.php | 2 +- bootstrap/tests.php | 16 +++--- database/Factories/NodeFactory.php | 2 +- database/Factories/UserFactory.php | 4 +- database/Seeders/EggSeeder.php | 8 +-- ..._ChangeServiceVariablesValidationRules.php | 2 +- ...dPermissionsToPointToNewScheduleSystem.php | 4 +- ...628_RemoveDaemonSecretFromServersTable.php | 2 +- ...22_RemoveDaemonSecretFromSubusersTable.php | 2 +- ..._merge_permissions_table_into_subusers.php | 4 +- ...4_store_node_tokens_as_encrypted_value.php | 2 +- pint.json | 1 + tests/Assertions/AssertsActivityLogged.php | 2 +- .../MiddlewareAttributeAssertionsTrait.php | 4 +- .../ApplicationApiIntegrationTestCase.php | 4 +- .../Api/Application/EggControllerTest.php | 6 +-- .../Users/ExternalUserControllerTest.php | 4 +- .../Application/Users/UserControllerTest.php | 12 ++--- .../Api/Client/AccountControllerTest.php | 4 +- .../Api/Client/ApiKeyControllerTest.php | 8 +-- .../Client/ClientApiIntegrationTestCase.php | 2 +- .../Api/Client/ClientControllerTest.php | 2 +- .../AllocationAuthorizationTest.php | 12 ++--- .../Server/Backup/BackupAuthorizationTest.php | 12 ++--- .../Database/DatabaseAuthorizationTest.php | 12 ++--- .../Schedule/GetServerSchedulesTest.php | 10 ++-- .../Schedule/ScheduleAuthorizationTest.php | 12 ++--- .../Startup/GetStartupAndVariablesTest.php | 6 +-- .../Startup/UpdateStartupVariableTest.php | 16 +++--- .../Subuser/CreateServerSubuserTest.php | 18 +++---- .../Server/Subuser/DeleteSubuserTest.php | 8 +-- .../Subuser/SubuserAuthorizationTest.php | 6 +-- .../Api/Daemon/DaemonAuthenticateTest.php | 4 +- .../SftpAuthenticationControllerTest.php | 10 ++-- .../Controllers/Admin/UserControllerTest.php | 6 +-- .../DatabaseManagementServiceTest.php | 2 +- tests/Traits/Http/RequestMockHelpers.php | 2 +- tests/Traits/MocksUuids.php | 2 +- 105 files changed, 272 insertions(+), 271 deletions(-) diff --git a/app/Console/Commands/Environment/AppSettingsCommand.php b/app/Console/Commands/Environment/AppSettingsCommand.php index d1ce5c00e4..a16f381763 100644 --- a/app/Console/Commands/Environment/AppSettingsCommand.php +++ b/app/Console/Commands/Environment/AppSettingsCommand.php @@ -16,7 +16,7 @@ public function handle(): void $path = base_path('.env'); if (!file_exists($path)) { $this->comment('Copying example .env file'); - copy($path.'.example', $path); + copy($path . '.example', $path); } if (!config('app.key')) { diff --git a/app/Console/Commands/Environment/EmailSettingsCommand.php b/app/Console/Commands/Environment/EmailSettingsCommand.php index a1ec5f7c27..87c8186c14 100644 --- a/app/Console/Commands/Environment/EmailSettingsCommand.php +++ b/app/Console/Commands/Environment/EmailSettingsCommand.php @@ -44,7 +44,7 @@ public function handle(): void env('MAIL_MAILER', env('MAIL_DRIVER', 'smtp')), ); - $method = 'setup'.studly_case($this->variables['MAIL_MAILER']).'DriverVariables'; + $method = 'setup' . studly_case($this->variables['MAIL_MAILER']) . 'DriverVariables'; if (method_exists($this, $method)) { $this->{$method}(); } diff --git a/app/Console/Commands/Environment/QueueWorkerServiceCommand.php b/app/Console/Commands/Environment/QueueWorkerServiceCommand.php index 83266155b0..dbf1aa7354 100644 --- a/app/Console/Commands/Environment/QueueWorkerServiceCommand.php +++ b/app/Console/Commands/Environment/QueueWorkerServiceCommand.php @@ -19,7 +19,7 @@ class QueueWorkerServiceCommand extends Command public function handle(): void { $serviceName = $this->option('service-name') ?? $this->ask('Queue worker service name', 'pelican-queue'); - $path = '/etc/systemd/system/'.$serviceName.'.service'; + $path = '/etc/systemd/system/' . $serviceName . '.service'; $fileExists = file_exists($path); if ($fileExists && !$this->option('overwrite') && !$this->confirm('The service file already exists. Do you want to overwrite it?')) { @@ -65,7 +65,7 @@ public function handle(): void if ($fileExists) { $result = Process::run("systemctl restart $serviceName.service"); if ($result->failed()) { - $this->error('Error restarting service: '.$result->errorOutput()); + $this->error('Error restarting service: ' . $result->errorOutput()); return; } @@ -74,7 +74,7 @@ public function handle(): void } else { $result = Process::run("systemctl enable --now $serviceName.service"); if ($result->failed()) { - $this->error('Error enabling service: '.$result->errorOutput()); + $this->error('Error enabling service: ' . $result->errorOutput()); return; } diff --git a/app/Console/Commands/Maintenance/PruneImagesCommand.php b/app/Console/Commands/Maintenance/PruneImagesCommand.php index a2f8c36ce7..23f613fa38 100644 --- a/app/Console/Commands/Maintenance/PruneImagesCommand.php +++ b/app/Console/Commands/Maintenance/PruneImagesCommand.php @@ -50,7 +50,7 @@ private function cleanupImages(int|Node $node): void $count = count($response['ImagesDeleted']); $useBinaryPrefix = config('panel.use_binary_prefix'); - $space = round($useBinaryPrefix ? $response['SpaceReclaimed'] / 1024 / 1024 : $response['SpaceReclaimed'] / 1000 / 1000, 2).($useBinaryPrefix ? ' MiB' : ' MB'); + $space = round($useBinaryPrefix ? $response['SpaceReclaimed'] / 1024 / 1024 : $response['SpaceReclaimed'] / 1000 / 1000, 2) . ($useBinaryPrefix ? ' MiB' : ' MB'); $this->info("Node {$node->id}: Cleaned up {$count} dangling docker images. ({$space})"); } catch (Exception $exception) { diff --git a/app/Console/Commands/Schedule/ProcessRunnableCommand.php b/app/Console/Commands/Schedule/ProcessRunnableCommand.php index 67ee89f3d6..d1d71ae024 100644 --- a/app/Console/Commands/Schedule/ProcessRunnableCommand.php +++ b/app/Console/Commands/Schedule/ProcessRunnableCommand.php @@ -67,7 +67,7 @@ protected function processSchedule(Schedule $schedule) } catch (\Throwable|\Exception $exception) { logger()->error($exception, ['schedule_id' => $schedule->id]); - $this->error(__('commands.schedule.process.no_tasks')." #$schedule->id: ".$exception->getMessage()); + $this->error(__('commands.schedule.process.no_tasks') . " #$schedule->id: " . $exception->getMessage()); } } } diff --git a/app/Console/Commands/UpgradeCommand.php b/app/Console/Commands/UpgradeCommand.php index 8f97d6dd34..75a3c185f7 100644 --- a/app/Console/Commands/UpgradeCommand.php +++ b/app/Console/Commands/UpgradeCommand.php @@ -40,7 +40,7 @@ public function handle(): void } if (version_compare(PHP_VERSION, '7.4.0') < 0) { - $this->error(__('commands.upgrade.php_version').' ['.PHP_VERSION.'].'); + $this->error(__('commands.upgrade.php_version') . ' [' . PHP_VERSION . '].'); } $user = 'www-data'; @@ -125,7 +125,7 @@ public function handle(): void $command[] = '--no-dev'; } - $this->line('$upgrader> '.implode(' ', $command)); + $this->line('$upgrader> ' . implode(' ', $command)); $process = new Process($command); $process->setTimeout(10 * 60); $process->run(function ($type, $buffer) { @@ -134,7 +134,7 @@ public function handle(): void }); /** @var \Illuminate\Foundation\Application $app */ - $app = require __DIR__.'/../../../bootstrap/app.php'; + $app = require __DIR__ . '/../../../bootstrap/app.php'; /** @var \App\Console\Kernel $kernel */ $kernel = $app->make(Kernel::class); $kernel->bootstrap(); @@ -192,6 +192,6 @@ protected function getUrl(): string return $this->option('url'); } - return sprintf(self::DEFAULT_URL, $this->option('release') ? 'download/v'.$this->option('release') : 'latest/download'); + return sprintf(self::DEFAULT_URL, $this->option('release') ? 'download/v' . $this->option('release') : 'latest/download'); } } diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index f4a17cefc8..3c2fc96fad 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -20,7 +20,7 @@ class Kernel extends ConsoleKernel */ protected function commands(): void { - $this->load(__DIR__.'/Commands'); + $this->load(__DIR__ . '/Commands'); } /** diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index f3bc40cd38..6327a214c1 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -108,7 +108,7 @@ class_basename($exception), $exception->getLine() ); - return $message."\nStack trace:\n".trim($cleanedStack); + return $message . "\nStack trace:\n" . trim($cleanedStack); } /** @@ -160,7 +160,7 @@ public function invalidJson($request, ValidationException $exception): JsonRespo 'source_field' => $field, 'rule' => str_replace(self::PANEL_RULE_STRING, 'p_', Arr::get( $codes, - str_replace('.', '_', $field).'.'.$key + str_replace('.', '_', $field) . '.' . $key )), ]; diff --git a/app/Extensions/Backups/BackupManager.php b/app/Extensions/Backups/BackupManager.php index 16c704b97a..9922a55c6f 100644 --- a/app/Extensions/Backups/BackupManager.php +++ b/app/Extensions/Backups/BackupManager.php @@ -74,7 +74,7 @@ protected function resolve(string $name): FilesystemAdapter return $this->callCustomCreator($config); } - $adapterMethod = 'create'.Str::studly($adapter).'Adapter'; + $adapterMethod = 'create' . Str::studly($adapter) . 'Adapter'; if (method_exists($this, $adapterMethod)) { $instance = $this->{$adapterMethod}($config); diff --git a/app/Extensions/DynamicDatabaseConnection.php b/app/Extensions/DynamicDatabaseConnection.php index b4409ed4b0..147f78064e 100644 --- a/app/Extensions/DynamicDatabaseConnection.php +++ b/app/Extensions/DynamicDatabaseConnection.php @@ -21,7 +21,7 @@ public function set(string $connection, DatabaseHost|int $host, string $database $host = DatabaseHost::query()->findOrFail($host); } - config()->set('database.connections.'.$connection, [ + config()->set('database.connections.' . $connection, [ 'driver' => self::DB_DRIVER, 'host' => $host->host, 'port' => $host->port, diff --git a/app/Extensions/Themes/Theme.php b/app/Extensions/Themes/Theme.php index 92b587fb79..2badc3dcb0 100644 --- a/app/Extensions/Themes/Theme.php +++ b/app/Extensions/Themes/Theme.php @@ -6,16 +6,16 @@ class Theme { public function js($path): string { - return sprintf(''.PHP_EOL, $this->getUrl($path)); + return sprintf('' . PHP_EOL, $this->getUrl($path)); } public function css($path): string { - return sprintf(''.PHP_EOL, $this->getUrl($path)); + return sprintf('' . PHP_EOL, $this->getUrl($path)); } protected function getUrl($path): string { - return '/themes/panel/'.ltrim($path, '/'); + return '/themes/panel/' . ltrim($path, '/'); } } diff --git a/app/Filament/Pages/Installer/Steps/CompletedStep.php b/app/Filament/Pages/Installer/Steps/CompletedStep.php index 8b91c76864..50f9a780cf 100644 --- a/app/Filament/Pages/Installer/Steps/CompletedStep.php +++ b/app/Filament/Pages/Installer/Steps/CompletedStep.php @@ -21,12 +21,12 @@ public static function make(): Step ->label(new HtmlString('Run the following command to setup your crontab. Note that www-data is your webserver user. On some systems this username might be different!')) ->disabled() ->hintAction(CopyAction::make()) - ->default('(crontab -l -u www-data 2>/dev/null; echo "* * * * * php '.base_path().'/artisan schedule:run >> /dev/null 2>&1") | crontab -u www-data -'), + ->default('(crontab -l -u www-data 2>/dev/null; echo "* * * * * php ' . base_path() . '/artisan schedule:run >> /dev/null 2>&1") | crontab -u www-data -'), TextInput::make('queueService') ->label(new HtmlString('To setup the queue worker service you simply have to run the following command.')) ->disabled() ->hintAction(CopyAction::make()) - ->default('sudo php '.base_path().'/artisan p:environment:queue-service'), + ->default('sudo php ' . base_path() . '/artisan p:environment:queue-service'), Placeholder::make('') ->content('After you finished these two last tasks you can click on "Finish" and use your new panel! Have fun!'), ]); diff --git a/app/Filament/Pages/Installer/Steps/RequirementsStep.php b/app/Filament/Pages/Installer/Steps/RequirementsStep.php index d2afd4b378..5e6d6988d1 100644 --- a/app/Filament/Pages/Installer/Steps/RequirementsStep.php +++ b/app/Filament/Pages/Installer/Steps/RequirementsStep.php @@ -18,12 +18,12 @@ public static function make(): Step $fields = [ Section::make('PHP Version') - ->description(self::MIN_PHP_VERSION.' or newer') + ->description(self::MIN_PHP_VERSION . ' or newer') ->icon($correctPhpVersion ? 'tabler-check' : 'tabler-x') ->iconColor($correctPhpVersion ? 'success' : 'danger') ->schema([ Placeholder::make('') - ->content('Your PHP Version is '.PHP_VERSION.'.'), + ->content('Your PHP Version is ' . PHP_VERSION . '.'), ]), ]; @@ -49,7 +49,7 @@ public static function make(): Step ->content('All needed PHP Extensions are installed.') ->visible($allExtensionsInstalled), Placeholder::make('') - ->content('The following PHP Extensions are missing: '.implode(', ', array_keys($phpExtensions, false))) + ->content('The following PHP Extensions are missing: ' . implode(', ', array_keys($phpExtensions, false))) ->visible(!$allExtensionsInstalled), ]); @@ -68,7 +68,7 @@ public static function make(): Step ->content('All Folders have the correct permissions.') ->visible($correctFolderPermissions), Placeholder::make('') - ->content('The following Folders have wrong permissions: '.implode(', ', array_keys($folderPermissions, false))) + ->content('The following Folders have wrong permissions: ' . implode(', ', array_keys($folderPermissions, false))) ->visible(!$correctFolderPermissions), ]); diff --git a/app/Filament/Resources/ApiKeyResource/Pages/ListApiKeys.php b/app/Filament/Resources/ApiKeyResource/Pages/ListApiKeys.php index 8ef0cdd3cb..aa0b9cdb5c 100644 --- a/app/Filament/Resources/ApiKeyResource/Pages/ListApiKeys.php +++ b/app/Filament/Resources/ApiKeyResource/Pages/ListApiKeys.php @@ -24,7 +24,7 @@ public function table(Table $table): Table TextColumn::make('key') ->copyable() ->icon('tabler-clipboard-text') - ->state(fn (ApiKey $key) => $key->identifier.$key->token), + ->state(fn (ApiKey $key) => $key->identifier . $key->token), TextColumn::make('memo') ->label('Description') diff --git a/app/Filament/Resources/DatabaseHostResource/RelationManagers/DatabasesRelationManager.php b/app/Filament/Resources/DatabaseHostResource/RelationManagers/DatabasesRelationManager.php index 3b209d7f7c..13b32602f8 100644 --- a/app/Filament/Resources/DatabaseHostResource/RelationManagers/DatabasesRelationManager.php +++ b/app/Filament/Resources/DatabaseHostResource/RelationManagers/DatabasesRelationManager.php @@ -37,7 +37,7 @@ public function form(Form $form): Form TextInput::make('JDBC') ->label('JDBC Connection String') ->columnSpanFull() - ->formatStateUsing(fn (Get $get, Database $database) => 'jdbc:mysql://'.$get('username').':'.urlencode($database->password).'@'.$database->host->host.':'.$database->host->port.'/'.$get('database')), + ->formatStateUsing(fn (Get $get, Database $database) => 'jdbc:mysql://' . $get('username') . ':' . urlencode($database->password) . '@' . $database->host->host . ':' . $database->host->port . '/' . $get('database')), ]); } @@ -64,7 +64,7 @@ public function table(Table $table): Table protected function rotatePassword(DatabasePasswordService $service, Database $database, $set, $get): void { $newPassword = $service->handle($database); - $jdbcString = 'jdbc:mysql://'.$get('username').':'.urlencode($newPassword).'@'.$database->host->host.':'.$database->host->port.'/'.$get('database'); + $jdbcString = 'jdbc:mysql://' . $get('username') . ':' . urlencode($newPassword) . '@' . $database->host->host . ':' . $database->host->port . '/' . $get('database'); $set('password', $newPassword); $set('JDBC', $jdbcString); diff --git a/app/Filament/Resources/EggResource/Pages/EditEgg.php b/app/Filament/Resources/EggResource/Pages/EditEgg.php index b9b839cb1f..d1d59c0640 100644 --- a/app/Filament/Resources/EggResource/Pages/EditEgg.php +++ b/app/Filament/Resources/EggResource/Pages/EditEgg.php @@ -249,7 +249,7 @@ protected function getHeaderActions(): array ->color('primary') ->action(fn (EggExporterService $service, Egg $egg) => response()->streamDownload(function () use ($service, $egg) { echo $service->handle($egg->id); - }, 'egg-'.$egg->getKebabName().'.json')) + }, 'egg-' . $egg->getKebabName() . '.json')) ->authorize(fn () => auth()->user()->can('export egg')), Actions\Action::make('importEgg') ->label('Import') diff --git a/app/Filament/Resources/EggResource/Pages/ListEggs.php b/app/Filament/Resources/EggResource/Pages/ListEggs.php index 0903379e52..a7f84b2749 100644 --- a/app/Filament/Resources/EggResource/Pages/ListEggs.php +++ b/app/Filament/Resources/EggResource/Pages/ListEggs.php @@ -55,7 +55,7 @@ public function table(Table $table): Table ->color('primary') ->action(fn (EggExporterService $service, Egg $egg) => response()->streamDownload(function () use ($service, $egg) { echo $service->handle($egg->id); - }, 'egg-'.$egg->getKebabName().'.json')) + }, 'egg-' . $egg->getKebabName() . '.json')) ->authorize(fn () => auth()->user()->can('export egg')), Action::make('update') ->icon('tabler-cloud-download') diff --git a/app/Filament/Resources/NodeResource/Widgets/NodeCpuChart.php b/app/Filament/Resources/NodeResource/Widgets/NodeCpuChart.php index 78119aaf5c..89d1cb254f 100644 --- a/app/Filament/Resources/NodeResource/Widgets/NodeCpuChart.php +++ b/app/Filament/Resources/NodeResource/Widgets/NodeCpuChart.php @@ -76,8 +76,8 @@ public function getHeading(): string $threads = $node->systemInformation()['cpu_count'] ?? 0; $cpu = Number::format(collect(cache()->get("nodes.$node->id.cpu_percent"))->last() * $threads, maxPrecision: 2, locale: auth()->user()->language); - $max = Number::format($threads * 100, locale: auth()->user()->language).'%'; + $max = Number::format($threads * 100, locale: auth()->user()->language) . '%'; - return 'CPU - '.$cpu.'% Of '.$max; + return 'CPU - ' . $cpu . '% Of ' . $max; } } diff --git a/app/Filament/Resources/NodeResource/Widgets/NodeMemoryChart.php b/app/Filament/Resources/NodeResource/Widgets/NodeMemoryChart.php index e1c19099b5..0cabbed517 100644 --- a/app/Filament/Resources/NodeResource/Widgets/NodeMemoryChart.php +++ b/app/Filament/Resources/NodeResource/Widgets/NodeMemoryChart.php @@ -75,13 +75,13 @@ public function getHeading(): string $totalMemory = collect(cache()->get("nodes.$node->id.memory_total"))->last(); $used = config('panel.use_binary_prefix') - ? Number::format($latestMemoryUsed / 1024 / 1024 / 1024, maxPrecision: 2, locale: auth()->user()->language).' GiB' - : Number::format($latestMemoryUsed / 1000 / 1000 / 1000, maxPrecision: 2, locale: auth()->user()->language).' GB'; + ? Number::format($latestMemoryUsed / 1024 / 1024 / 1024, maxPrecision: 2, locale: auth()->user()->language) .' GiB' + : Number::format($latestMemoryUsed / 1000 / 1000 / 1000, maxPrecision: 2, locale: auth()->user()->language) . ' GB'; $total = config('panel.use_binary_prefix') - ? Number::format($totalMemory / 1024 / 1024 / 1024, maxPrecision: 2, locale: auth()->user()->language).' GiB' - : Number::format($totalMemory / 1000 / 1000 / 1000, maxPrecision: 2, locale: auth()->user()->language).' GB'; + ? Number::format($totalMemory / 1024 / 1024 / 1024, maxPrecision: 2, locale: auth()->user()->language) .' GiB' + : Number::format($totalMemory / 1000 / 1000 / 1000, maxPrecision: 2, locale: auth()->user()->language) . ' GB'; - return 'Memory - '.$used.' Of '.$total; + return 'Memory - ' . $used . ' Of ' . $total; } } diff --git a/app/Filament/Resources/RoleResource.php b/app/Filament/Resources/RoleResource.php index 8980902224..306c9676da 100644 --- a/app/Filament/Resources/RoleResource.php +++ b/app/Filament/Resources/RoleResource.php @@ -40,12 +40,12 @@ public static function form(Form $form): Form $options = []; foreach (RolePermissionPrefixes::cases() as $prefix) { - $options[$prefix->value.' '.strtolower($model->value)] = Str::headline($prefix->value); + $options[$prefix->value . ' ' . strtolower($model->value)] = Str::headline($prefix->value); } if (array_key_exists($model->value, Role::MODEL_SPECIFIC_PERMISSIONS)) { foreach (Role::MODEL_SPECIFIC_PERMISSIONS[$model->value] as $permission) { - $options[$permission.' '.strtolower($model->value)] = Str::headline($permission); + $options[$permission . ' ' . strtolower($model->value)] = Str::headline($permission); } } @@ -56,7 +56,7 @@ public static function form(Form $form): Form $options = []; foreach ($prefixes as $prefix) { - $options[$prefix.' '.strtolower($model)] = Str::headline($prefix); + $options[$prefix . ' ' . strtolower($model)] = Str::headline($prefix); } $permissions[] = self::makeSection($model, $options); @@ -88,10 +88,10 @@ private static function makeSection(string $model, array $options): Section { $icon = null; - if (class_exists('\App\Filament\Resources\\'.$model.'Resource')) { - $icon = ('\App\Filament\Resources\\'.$model.'Resource')::getNavigationIcon(); - } elseif (class_exists('\App\Filament\Pages\\'.$model)) { - $icon = ('\App\Filament\Pages\\'.$model)::getNavigationIcon(); + if (class_exists('\App\Filament\Resources\\' . $model . 'Resource')) { + $icon = ('\App\Filament\Resources\\' . $model . 'Resource')::getNavigationIcon(); + } elseif (class_exists('\App\Filament\Pages\\' . $model)) { + $icon = ('\App\Filament\Pages\\' . $model)::getNavigationIcon(); } return Section::make(Str::headline(Str::plural($model))) @@ -101,11 +101,11 @@ private static function makeSection(string $model, array $options): Section ->icon($icon) ->headerActions([ Action::make('count') - ->label(fn (Get $get) => count($get(strtolower($model).'_list'))) + ->label(fn (Get $get) => count($get(strtolower($model) . '_list'))) ->badge(), ]) ->schema([ - CheckboxList::make(strtolower($model).'_list') + CheckboxList::make(strtolower($model) . '_list') ->label('') ->options($options) ->columns() diff --git a/app/Filament/Resources/ServerResource/Pages/CreateServer.php b/app/Filament/Resources/ServerResource/Pages/CreateServer.php index 61696804f5..b8ac8a5209 100644 --- a/app/Filament/Resources/ServerResource/Pages/CreateServer.php +++ b/app/Filament/Resources/ServerResource/Pages/CreateServer.php @@ -70,14 +70,14 @@ public function form(Form $form): Form ->prefixIcon('tabler-server') ->label('Name') ->suffixAction(Forms\Components\Actions\Action::make('random') - ->icon('tabler-dice-'.random_int(1, 6)) + ->icon('tabler-dice-' . random_int(1, 6)) ->action(function (Set $set, Get $get) { $egg = Egg::find($get('egg_id')); - $prefix = $egg ? str($egg->name)->lower()->kebab().'-' : ''; + $prefix = $egg ? str($egg->name)->lower()->kebab() . '-' : ''; $word = (new RandomWordService())->word(); - $set('name', $prefix.$word); + $set('name', $prefix . $word); })) ->columnSpan([ 'default' => 2, @@ -101,7 +101,7 @@ public function form(Form $form): Form ]) ->relationship('user', 'username') ->searchable(['username', 'email']) - ->getOptionLabelFromRecordUsing(fn (User $user) => "$user->email | $user->username ".($user->isRootAdmin() ? '(admin)' : '')) + ->getOptionLabelFromRecordUsing(fn (User $user) => "$user->email | $user->username " . ($user->isRootAdmin() ? '(admin)' : '')) ->createOptionForm([ TextInput::make('username') ->alphaNum() @@ -163,7 +163,7 @@ public function form(Form $form): Form $set('allocation_additional.needstobeastringhere.extra_allocations', null); }) ->getOptionLabelFromRecordUsing( - fn (Allocation $allocation) => "$allocation->ip:$allocation->port". + fn (Allocation $allocation) => "$allocation->ip:$allocation->port" . ($allocation->ip_alias ? " ($allocation->ip_alias)" : '') ) ->placeholder(function (Get $get) { @@ -293,7 +293,7 @@ public function form(Form $form): Form ->disabled(fn (Get $get) => $get('../../node_id') === null) ->searchable(['ip', 'port', 'ip_alias']) ->getOptionLabelFromRecordUsing( - fn (Allocation $allocation) => "$allocation->ip:$allocation->port". + fn (Allocation $allocation) => "$allocation->ip:$allocation->port" . ($allocation->ip_alias ? " ($allocation->ip_alias)" : '') ) ->placeholder('Select additional Allocations') @@ -498,7 +498,7 @@ public function form(Form $form): Form ->hintIcon('tabler-code') ->label(fn (Get $get) => $get('name')) ->hintIconTooltip(fn (Get $get) => implode('|', $get('rules'))) - ->prefix(fn (Get $get) => '{{'.$get('env_variable').'}}') + ->prefix(fn (Get $get) => '{{' . $get('env_variable') . '}}') ->helperText(fn (Get $get) => empty($get('description')) ? '—' : $get('description')) ->afterStateUpdated(function (Set $set, Get $get, $state) { $environment = $get($envPath = '../../environment'); @@ -846,7 +846,7 @@ private function shouldHideComponent(Get $get, Component $component): bool return !$containsRuleIn; } - throw new Exception('Component type not supported: '.$component::class); + throw new Exception('Component type not supported: ' . $component::class); } private function getSelectOptionsFromRules(Get $get): array diff --git a/app/Filament/Resources/ServerResource/Pages/EditServer.php b/app/Filament/Resources/ServerResource/Pages/EditServer.php index 33a90ace09..267fd998f1 100644 --- a/app/Filament/Resources/ServerResource/Pages/EditServer.php +++ b/app/Filament/Resources/ServerResource/Pages/EditServer.php @@ -66,14 +66,14 @@ public function form(Form $form): Form ->prefixIcon('tabler-server') ->label('Display Name') ->suffixAction(Action::make('random') - ->icon('tabler-dice-'.random_int(1, 6)) + ->icon('tabler-dice-' . random_int(1, 6)) ->action(function (Set $set, Get $get) { $egg = Egg::find($get('egg_id')); - $prefix = $egg ? str($egg->name)->lower()->kebab().'-' : ''; + $prefix = $egg ? str($egg->name)->lower()->kebab() . '-' : ''; $word = (new RandomWordService())->word(); - $set('name', $prefix.$word); + $set('name', $prefix . $word); })) ->columnSpan([ 'default' => 2, @@ -541,7 +541,7 @@ public function form(Form $form): Form ->hintIcon('tabler-code') ->label(fn (ServerVariable $serverVariable) => $serverVariable->variable->name) ->hintIconTooltip(fn (ServerVariable $serverVariable) => implode('|', $serverVariable->variable->rules)) - ->prefix(fn (ServerVariable $serverVariable) => '{{'.$serverVariable->variable->env_variable.'}}') + ->prefix(fn (ServerVariable $serverVariable) => '{{' . $serverVariable->variable->env_variable . '}}') ->helperText(fn (ServerVariable $serverVariable) => empty($serverVariable->variable->description) ? '—' : $serverVariable->variable->description); } @@ -606,7 +606,7 @@ public function form(Form $form): Form ->disabled() ->label('JDBC Connection String') ->columnSpan(2) - ->formatStateUsing(fn (Get $get, $record) => 'jdbc:mysql://'.$get('username').':'.urlencode($record->password).'@'.$record->host->host.':'.$record->host->port.'/'.$get('database')), + ->formatStateUsing(fn (Get $get, $record) => 'jdbc:mysql://' . $get('username') . ':' . urlencode($record->password) . '@' . $record->host->host . ':' . $record->host->port . '/' . $get('database')), ]) ->relationship('databases') ->deletable(false) @@ -800,7 +800,7 @@ private function shouldHideComponent(ServerVariable $serverVariable, Forms\Compo return $containsRuleIn; } - throw new Exception('Component type not supported: '.$component::class); + throw new Exception('Component type not supported: ' . $component::class); } private function getSelectOptionsFromRules(ServerVariable $serverVariable): array @@ -818,7 +818,7 @@ private function getSelectOptionsFromRules(ServerVariable $serverVariable): arra protected function rotatePassword(DatabasePasswordService $service, $record, $set, $get): void { $newPassword = $service->handle($record); - $jdbcString = 'jdbc:mysql://'.$get('username').':'.urlencode($newPassword).'@'.$record->host->host.':'.$record->host->port.'/'.$get('database'); + $jdbcString = 'jdbc:mysql://' . $get('username') . ':' . urlencode($newPassword) . '@' . $record->host->host . ':' . $record->host->port . '/' . $get('database'); $set('password', $newPassword); $set('JDBC', $jdbcString); diff --git a/app/Filament/Resources/UserResource/Pages/EditProfile.php b/app/Filament/Resources/UserResource/Pages/EditProfile.php index 20bd0f61f8..f5c5f5828d 100644 --- a/app/Filament/Resources/UserResource/Pages/EditProfile.php +++ b/app/Filament/Resources/UserResource/Pages/EditProfile.php @@ -178,7 +178,7 @@ protected function getForms(): array ->content(fn () => new HtmlString("
$image
")) - ->helperText('Setup Key: '.$secret), + ->helperText('Setup Key: '. $secret), TextInput::make('2facode') ->label('Code') ->requiredWith('2fapassword') diff --git a/app/Filament/Resources/UserResource/Pages/ListUsers.php b/app/Filament/Resources/UserResource/Pages/ListUsers.php index 03df515545..c386d4ce61 100644 --- a/app/Filament/Resources/UserResource/Pages/ListUsers.php +++ b/app/Filament/Resources/UserResource/Pages/ListUsers.php @@ -33,7 +33,7 @@ public function table(Table $table): Table ->visibleFrom('lg') ->label('') ->extraImgAttributes(['class' => 'rounded-full']) - ->defaultImageUrl(fn (User $user) => 'https://gravatar.com/avatar/'.md5(strtolower($user->email))), + ->defaultImageUrl(fn (User $user) => 'https://gravatar.com/avatar/' . md5(strtolower($user->email))), TextColumn::make('external_id') ->searchable() ->hidden(), @@ -55,7 +55,7 @@ public function table(Table $table): Table ->counts('roles') ->icon('tabler-users-group') ->label('Roles') - ->formatStateUsing(fn (User $user, $state) => $state.($user->isRootAdmin() ? ' (Root Admin)' : '')), + ->formatStateUsing(fn (User $user, $state) => $state . ($user->isRootAdmin() ? ' (Root Admin)' : '')), TextColumn::make('servers_count') ->counts('servers') ->icon('tabler-server') diff --git a/app/Http/Controllers/Admin/Eggs/EggShareController.php b/app/Http/Controllers/Admin/Eggs/EggShareController.php index 56f38f4f7d..993064b65c 100644 --- a/app/Http/Controllers/Admin/Eggs/EggShareController.php +++ b/app/Http/Controllers/Admin/Eggs/EggShareController.php @@ -30,7 +30,7 @@ public function export(Egg $egg): Response return response($this->exporterService->handle($egg->id), 200, [ 'Content-Transfer-Encoding' => 'binary', 'Content-Description' => 'File Transfer', - 'Content-Disposition' => 'attachment; filename=egg-'.$filename.'.json', + 'Content-Disposition' => 'attachment; filename=egg-' . $filename . '.json', 'Content-Type' => 'application/json', ]); } diff --git a/app/Http/Controllers/Admin/NodeAutoDeployController.php b/app/Http/Controllers/Admin/NodeAutoDeployController.php index b61e41acbb..1029706c35 100644 --- a/app/Http/Controllers/Admin/NodeAutoDeployController.php +++ b/app/Http/Controllers/Admin/NodeAutoDeployController.php @@ -56,7 +56,7 @@ public function __invoke(Request $request, Node $node): JsonResponse return new JsonResponse([ 'node' => $node->id, - 'token' => $key->identifier.$key->token, + 'token' => $key->identifier . $key->token, ]); } } diff --git a/app/Http/Controllers/Admin/Servers/CreateServerController.php b/app/Http/Controllers/Admin/Servers/CreateServerController.php index 7e7c191759..c59e22fbeb 100644 --- a/app/Http/Controllers/Admin/Servers/CreateServerController.php +++ b/app/Http/Controllers/Admin/Servers/CreateServerController.php @@ -67,6 +67,6 @@ public function store(ServerFormRequest $request): RedirectResponse $this->alert->success(trans('admin/server.alerts.server_created'))->flash(); - return new RedirectResponse('/admin/servers/view/'.$server->id); + return new RedirectResponse('/admin/servers/view/' . $server->id); } } diff --git a/app/Http/Controllers/Admin/ServersController.php b/app/Http/Controllers/Admin/ServersController.php index 4cb398bbed..9ddd9c7e61 100644 --- a/app/Http/Controllers/Admin/ServersController.php +++ b/app/Http/Controllers/Admin/ServersController.php @@ -115,7 +115,7 @@ public function manageSuspension(Request $request, Server $server): RedirectResp { $this->suspensionService->toggle($server, $request->input('action')); $this->alert->success(trans('admin/server.alerts.suspension_toggled', [ - 'status' => $request->input('action').'ed', + 'status' => $request->input('action') . 'ed', ]))->flash(); return redirect()->route('admin.servers.view.manage', $server->id); diff --git a/app/Http/Controllers/Api/Client/Servers/FileController.php b/app/Http/Controllers/Api/Client/Servers/FileController.php index bd175aef50..09d354a362 100644 --- a/app/Http/Controllers/Api/Client/Servers/FileController.php +++ b/app/Http/Controllers/Api/Client/Servers/FileController.php @@ -83,7 +83,7 @@ public function download(GetFileContentsRequest $request, Server $server): array 'file_path' => rawurldecode($request->get('file')), 'server_uuid' => $server->uuid, ]) - ->handle($server->node, $request->user()->id.$server->uuid); + ->handle($server->node, $request->user()->id . $server->uuid); Activity::event('server:file.download')->property('file', $request->get('file'))->log(); diff --git a/app/Http/Controllers/Api/Client/Servers/FileUploadController.php b/app/Http/Controllers/Api/Client/Servers/FileUploadController.php index 9ee74fb44c..e48dd75bdf 100644 --- a/app/Http/Controllers/Api/Client/Servers/FileUploadController.php +++ b/app/Http/Controllers/Api/Client/Servers/FileUploadController.php @@ -43,7 +43,7 @@ protected function getUploadUrl(Server $server, User $user): string ->setExpiresAt(CarbonImmutable::now()->addMinutes(15)) ->setUser($user) ->setClaims(['server_uuid' => $server->uuid]) - ->handle($server->node, $user->id.$server->uuid); + ->handle($server->node, $user->id . $server->uuid); return sprintf( '%s/upload/file?token=%s', diff --git a/app/Http/Controllers/Api/Client/Servers/WebsocketController.php b/app/Http/Controllers/Api/Client/Servers/WebsocketController.php index 8d636872d1..0fb062e962 100644 --- a/app/Http/Controllers/Api/Client/Servers/WebsocketController.php +++ b/app/Http/Controllers/Api/Client/Servers/WebsocketController.php @@ -59,14 +59,14 @@ public function __invoke(ClientApiRequest $request, Server $server): JsonRespons 'server_uuid' => $server->uuid, 'permissions' => $permissions, ]) - ->handle($node, $user->id.$server->uuid); + ->handle($node, $user->id . $server->uuid); $socket = str_replace(['https://', 'http://'], ['wss://', 'ws://'], $node->getConnectionAddress()); return new JsonResponse([ 'data' => [ 'token' => $token->toString(), - 'socket' => $socket.sprintf('/api/servers/%s/ws', $server->uuid), + 'socket' => $socket . sprintf('/api/servers/%s/ws', $server->uuid), ], ]); } diff --git a/app/Http/Controllers/Api/Remote/Backups/BackupStatusController.php b/app/Http/Controllers/Api/Remote/Backups/BackupStatusController.php index 47350c69d2..4f32689ecf 100644 --- a/app/Http/Controllers/Api/Remote/Backups/BackupStatusController.php +++ b/app/Http/Controllers/Api/Remote/Backups/BackupStatusController.php @@ -64,7 +64,7 @@ public function index(ReportBackupCompleteRequest $request, string $backup): Jso // deleted easily. Also does not make sense to have a locked backup on the system // that is failed. 'is_locked' => $successful ? $model->is_locked : false, - 'checksum' => $successful ? ($request->input('checksum_type').':'.$request->input('checksum')) : null, + 'checksum' => $successful ? ($request->input('checksum_type') . ':' . $request->input('checksum')) : null, 'bytes' => $successful ? $request->input('size') : 0, 'completed_at' => CarbonImmutable::now(), ])->save(); diff --git a/app/Http/Controllers/Api/Remote/SftpAuthenticationController.php b/app/Http/Controllers/Api/Remote/SftpAuthenticationController.php index f9e63dfb52..9b59704f15 100644 --- a/app/Http/Controllers/Api/Remote/SftpAuthenticationController.php +++ b/app/Http/Controllers/Api/Remote/SftpAuthenticationController.php @@ -160,6 +160,6 @@ protected function throttleKey(Request $request): string { $username = explode('.', strrev($request->input('username', ''))); - return strtolower(strrev($username[0] ?? '').'|'.$request->ip()); + return strtolower(strrev($username[0] ?? '') . '|' . $request->ip()); } } diff --git a/app/Http/Controllers/Auth/OAuthController.php b/app/Http/Controllers/Auth/OAuthController.php index 34f0b3bbc3..2989761efc 100644 --- a/app/Http/Controllers/Auth/OAuthController.php +++ b/app/Http/Controllers/Auth/OAuthController.php @@ -48,7 +48,7 @@ protected function callback(Request $request, string $driver): RedirectResponse } try { - $user = User::query()->whereJsonContains('oauth->'.$driver, $oauthUser->getId())->firstOrFail(); + $user = User::query()->whereJsonContains('oauth->'. $driver, $oauthUser->getId())->firstOrFail(); $this->auth->guard()->login($user, true); } catch (Exception $e) { diff --git a/app/Http/Middleware/Api/AuthenticateIPAccess.php b/app/Http/Middleware/Api/AuthenticateIPAccess.php index a1c6d47105..c9f3bf7dc4 100644 --- a/app/Http/Middleware/Api/AuthenticateIPAccess.php +++ b/app/Http/Middleware/Api/AuthenticateIPAccess.php @@ -43,6 +43,6 @@ public function handle(Request $request, \Closure $next): mixed ->property('identifier', $token->identifier) ->log(); - throw new AccessDeniedHttpException('This IP address ('.$request->ip().') does not have permission to access the API using these credentials.'); + throw new AccessDeniedHttpException('This IP address (' . $request->ip() . ') does not have permission to access the API using these credentials.'); } } diff --git a/app/Http/Middleware/Api/Client/Server/ResourceBelongsToServer.php b/app/Http/Middleware/Api/Client/Server/ResourceBelongsToServer.php index d7754d36e9..0ead01f1d5 100644 --- a/app/Http/Middleware/Api/Client/Server/ResourceBelongsToServer.php +++ b/app/Http/Middleware/Api/Client/Server/ResourceBelongsToServer.php @@ -80,7 +80,7 @@ public function handle(Request $request, \Closure $next): mixed default: // Don't return a 404 here since we want to make sure no one relies // on this middleware in a context in which it will not work. Fail safe. - throw new \InvalidArgumentException('There is no handler configured for a resource of this type: '.get_class($model)); + throw new \InvalidArgumentException('There is no handler configured for a resource of this type: ' . get_class($model)); } } diff --git a/app/Http/Middleware/Api/IsValidJson.php b/app/Http/Middleware/Api/IsValidJson.php index 77bd25fe8f..86bb34ff28 100644 --- a/app/Http/Middleware/Api/IsValidJson.php +++ b/app/Http/Middleware/Api/IsValidJson.php @@ -18,7 +18,7 @@ public function handle(Request $request, \Closure $next): mixed try { json_decode($request->getContent(), true, 512, JSON_THROW_ON_ERROR); } catch (\JsonException $exception) { - throw new BadRequestHttpException('The JSON data passed in the request appears to be malformed: '.$exception->getMessage()); + throw new BadRequestHttpException('The JSON data passed in the request appears to be malformed: ' . $exception->getMessage()); } } diff --git a/app/Http/Middleware/RequireTwoFactorAuthentication.php b/app/Http/Middleware/RequireTwoFactorAuthentication.php index bfbab44387..58ff1564d6 100644 --- a/app/Http/Middleware/RequireTwoFactorAuthentication.php +++ b/app/Http/Middleware/RequireTwoFactorAuthentication.php @@ -38,7 +38,7 @@ public function __construct(private AlertsMessageBag $alert) public function handle(Request $request, \Closure $next): mixed { $user = $request->user(); - $uri = rtrim($request->getRequestUri(), '/').'/'; + $uri = rtrim($request->getRequestUri(), '/') . '/'; $current = $request->route()->getName(); if (!$user || Str::startsWith($uri, ['/auth/']) || Str::startsWith($current, ['auth.', 'account.'])) { diff --git a/app/Http/Requests/Admin/Api/StoreApplicationApiKeyRequest.php b/app/Http/Requests/Admin/Api/StoreApplicationApiKeyRequest.php index b092ead913..83f80f267d 100644 --- a/app/Http/Requests/Admin/Api/StoreApplicationApiKeyRequest.php +++ b/app/Http/Requests/Admin/Api/StoreApplicationApiKeyRequest.php @@ -17,7 +17,7 @@ public function rules(): array $modelRules = ApiKey::getRules(); return collect(AdminAcl::getResourceList())->mapWithKeys(function ($resource) use ($modelRules) { - return [AdminAcl::COLUMN_IDENTIFIER.$resource => $modelRules['r_'.$resource]]; + return [AdminAcl::COLUMN_IDENTIFIER . $resource => $modelRules['r_' . $resource]]; })->merge(['memo' => $modelRules['memo']])->toArray(); } diff --git a/app/Http/Requests/Admin/Egg/EggVariableFormRequest.php b/app/Http/Requests/Admin/Egg/EggVariableFormRequest.php index b7e64daaaa..c6720aa2cc 100644 --- a/app/Http/Requests/Admin/Egg/EggVariableFormRequest.php +++ b/app/Http/Requests/Admin/Egg/EggVariableFormRequest.php @@ -15,7 +15,7 @@ public function rules(): array return [ 'name' => 'required|string|min:1|max:255', 'description' => 'sometimes|nullable|string', - 'env_variable' => 'required|regex:/^[\w]{1,255}$/|notIn:'.EggVariable::RESERVED_ENV_NAMES, + 'env_variable' => 'required|regex:/^[\w]{1,255}$/|notIn:' . EggVariable::RESERVED_ENV_NAMES, 'options' => 'sometimes|required|array', 'rules' => 'bail|required|string', 'default_value' => 'present', diff --git a/app/Http/Requests/Api/Client/Account/StoreApiKeyRequest.php b/app/Http/Requests/Api/Client/Account/StoreApiKeyRequest.php index 8668322140..e0034fcfed 100644 --- a/app/Http/Requests/Api/Client/Account/StoreApiKeyRequest.php +++ b/app/Http/Requests/Api/Client/Account/StoreApiKeyRequest.php @@ -39,7 +39,7 @@ public function withValidator(Validator $validator): void throw $exception; } } finally { - $validator->errors()->addIf(!$valid, "allowed_ips.{$index}", '"'.$ip.'" is not a valid IP address or CIDR range.'); + $validator->errors()->addIf(!$valid, "allowed_ips.{$index}", '"' . $ip . '" is not a valid IP address or CIDR range.'); } } }); diff --git a/app/Jobs/Schedule/RunTaskJob.php b/app/Jobs/Schedule/RunTaskJob.php index d4b0cabcea..e4a47ada75 100644 --- a/app/Jobs/Schedule/RunTaskJob.php +++ b/app/Jobs/Schedule/RunTaskJob.php @@ -73,7 +73,7 @@ public function handle( $deleteFilesService->handle($server, explode(PHP_EOL, $this->task->payload)); break; default: - throw new \InvalidArgumentException('Invalid task action provided: '.$this->task->action); + throw new \InvalidArgumentException('Invalid task action provided: ' . $this->task->action); } } catch (\Exception $exception) { // If this isn't a DaemonConnectionException on a task that allows for failures diff --git a/app/Models/ApiKey.php b/app/Models/ApiKey.php index 6593803e29..96c714f246 100644 --- a/app/Models/ApiKey.php +++ b/app/Models/ApiKey.php @@ -110,14 +110,14 @@ class ApiKey extends Model 'memo', 'last_used_at', 'expires_at', - 'r_'.AdminAcl::RESOURCE_USERS, - 'r_'.AdminAcl::RESOURCE_ALLOCATIONS, - 'r_'.AdminAcl::RESOURCE_DATABASE_HOSTS, - 'r_'.AdminAcl::RESOURCE_SERVER_DATABASES, - 'r_'.AdminAcl::RESOURCE_EGGS, - 'r_'.AdminAcl::RESOURCE_NODES, - 'r_'.AdminAcl::RESOURCE_SERVERS, - 'r_'.AdminAcl::RESOURCE_MOUNTS, + 'r_' . AdminAcl::RESOURCE_USERS, + 'r_' . AdminAcl::RESOURCE_ALLOCATIONS, + 'r_' . AdminAcl::RESOURCE_DATABASE_HOSTS, + 'r_' . AdminAcl::RESOURCE_SERVER_DATABASES, + 'r_' . AdminAcl::RESOURCE_EGGS, + 'r_' . AdminAcl::RESOURCE_NODES, + 'r_' . AdminAcl::RESOURCE_SERVERS, + 'r_' . AdminAcl::RESOURCE_MOUNTS, ]; /** @@ -146,14 +146,14 @@ class ApiKey extends Model 'allowed_ips.*' => 'string', 'last_used_at' => 'nullable|date', 'expires_at' => 'nullable|date', - 'r_'.AdminAcl::RESOURCE_USERS => 'integer|min:0|max:3', - 'r_'.AdminAcl::RESOURCE_ALLOCATIONS => 'integer|min:0|max:3', - 'r_'.AdminAcl::RESOURCE_DATABASE_HOSTS => 'integer|min:0|max:3', - 'r_'.AdminAcl::RESOURCE_SERVER_DATABASES => 'integer|min:0|max:3', - 'r_'.AdminAcl::RESOURCE_EGGS => 'integer|min:0|max:3', - 'r_'.AdminAcl::RESOURCE_NODES => 'integer|min:0|max:3', - 'r_'.AdminAcl::RESOURCE_SERVERS => 'integer|min:0|max:3', - 'r_'.AdminAcl::RESOURCE_MOUNTS => 'integer|min:0|max:3', + 'r_' . AdminAcl::RESOURCE_USERS => 'integer|min:0|max:3', + 'r_' . AdminAcl::RESOURCE_ALLOCATIONS => 'integer|min:0|max:3', + 'r_' . AdminAcl::RESOURCE_DATABASE_HOSTS => 'integer|min:0|max:3', + 'r_' . AdminAcl::RESOURCE_SERVER_DATABASES => 'integer|min:0|max:3', + 'r_' . AdminAcl::RESOURCE_EGGS => 'integer|min:0|max:3', + 'r_' . AdminAcl::RESOURCE_NODES => 'integer|min:0|max:3', + 'r_' . AdminAcl::RESOURCE_SERVERS => 'integer|min:0|max:3', + 'r_' . AdminAcl::RESOURCE_MOUNTS => 'integer|min:0|max:3', ]; protected function casts(): array @@ -166,14 +166,14 @@ protected function casts(): array 'token' => 'encrypted', self::CREATED_AT => 'datetime', self::UPDATED_AT => 'datetime', - 'r_'.AdminAcl::RESOURCE_USERS => 'int', - 'r_'.AdminAcl::RESOURCE_ALLOCATIONS => 'int', - 'r_'.AdminAcl::RESOURCE_DATABASE_HOSTS => 'int', - 'r_'.AdminAcl::RESOURCE_SERVER_DATABASES => 'int', - 'r_'.AdminAcl::RESOURCE_EGGS => 'int', - 'r_'.AdminAcl::RESOURCE_NODES => 'int', - 'r_'.AdminAcl::RESOURCE_SERVERS => 'int', - 'r_'.AdminAcl::RESOURCE_MOUNTS => 'int', + 'r_' . AdminAcl::RESOURCE_USERS => 'int', + 'r_' . AdminAcl::RESOURCE_ALLOCATIONS => 'int', + 'r_' . AdminAcl::RESOURCE_DATABASE_HOSTS => 'int', + 'r_' . AdminAcl::RESOURCE_SERVER_DATABASES => 'int', + 'r_' . AdminAcl::RESOURCE_EGGS => 'int', + 'r_' . AdminAcl::RESOURCE_NODES => 'int', + 'r_' . AdminAcl::RESOURCE_SERVERS => 'int', + 'r_' . AdminAcl::RESOURCE_MOUNTS => 'int', ]; } @@ -227,6 +227,6 @@ public static function generateTokenIdentifier(int $type): string { $prefix = self::getPrefixForType($type); - return $prefix.Str::random(self::IDENTIFIER_LENGTH - strlen($prefix)); + return $prefix . Str::random(self::IDENTIFIER_LENGTH - strlen($prefix)); } } diff --git a/app/Models/EggVariable.php b/app/Models/EggVariable.php index b56213c1a1..2d3a4fb2c5 100644 --- a/app/Models/EggVariable.php +++ b/app/Models/EggVariable.php @@ -54,7 +54,7 @@ class EggVariable extends Model 'sort' => 'nullable', 'name' => 'required|string|between:1,255', 'description' => 'string', - 'env_variable' => 'required|alphaDash|between:1,255|notIn:'.self::RESERVED_ENV_NAMES, + 'env_variable' => 'required|alphaDash|between:1,255|notIn:' . self::RESERVED_ENV_NAMES, 'default_value' => 'string', 'user_viewable' => 'boolean', 'user_editable' => 'boolean', diff --git a/app/Models/Filters/MultiFieldServerFilter.php b/app/Models/Filters/MultiFieldServerFilter.php index 6039c450b8..d2c552321a 100644 --- a/app/Models/Filters/MultiFieldServerFilter.php +++ b/app/Models/Filters/MultiFieldServerFilter.php @@ -48,7 +48,7 @@ function (Builder $builder) use ($parts) { }, // Otherwise, just try to search for that specific port in the allocations. function (Builder $builder) use ($value) { - $builder->orWhere('allocations.port', 'LIKE', substr($value, 1).'%'); + $builder->orWhere('allocations.port', 'LIKE', substr($value, 1) . '%'); } ); }) diff --git a/app/Models/Node.php b/app/Models/Node.php index 59a337f2b9..da54160913 100644 --- a/app/Models/Node.php +++ b/app/Models/Node.php @@ -184,8 +184,8 @@ public function getConfiguration(): array 'port' => $this->daemon_listen, 'ssl' => [ 'enabled' => (!$this->behind_proxy && $this->scheme === 'https'), - 'cert' => '/etc/letsencrypt/live/'.Str::lower($this->fqdn).'/fullchain.pem', - 'key' => '/etc/letsencrypt/live/'.Str::lower($this->fqdn).'/privkey.pem', + 'cert' => '/etc/letsencrypt/live/' . Str::lower($this->fqdn) . '/fullchain.pem', + 'key' => '/etc/letsencrypt/live/' . Str::lower($this->fqdn) . '/privkey.pem', ], 'upload_limit' => $this->upload_size, ], diff --git a/app/Models/User.php b/app/Models/User.php index 04ecbb0c43..3ccafe4040 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -259,7 +259,7 @@ public function setUsernameAttribute(string $value) */ public function getNameAttribute(): string { - return trim($this->name_first.' '.$this->name_last); + return trim($this->name_first . ' ' . $this->name_last); } /** @@ -379,7 +379,7 @@ public function getFilamentName(): string public function getFilamentAvatarUrl(): ?string { - return 'https://gravatar.com/avatar/'.md5(strtolower($this->email)); + return 'https://gravatar.com/avatar/' . md5(strtolower($this->email)); } public function canTarget(IlluminateModel $user): bool diff --git a/app/Notifications/AccountCreated.php b/app/Notifications/AccountCreated.php index 0f7cb77a71..0123435f7f 100644 --- a/app/Notifications/AccountCreated.php +++ b/app/Notifications/AccountCreated.php @@ -33,13 +33,13 @@ public function via(): array public function toMail(): MailMessage { $message = (new MailMessage()) - ->greeting('Hello '.$this->user->name.'!') - ->line('You are receiving this email because an account has been created for you on '.config('app.name').'.') - ->line('Username: '.$this->user->username) - ->line('Email: '.$this->user->email); + ->greeting('Hello ' . $this->user->name . '!') + ->line('You are receiving this email because an account has been created for you on ' . config('app.name') . '.') + ->line('Username: ' . $this->user->username) + ->line('Email: ' . $this->user->email); if (!is_null($this->token)) { - return $message->action('Setup Your Account', url('/auth/password/reset/'.$this->token.'?email='.urlencode($this->user->email))); + return $message->action('Setup Your Account', url('/auth/password/reset/' . $this->token . '?email=' . urlencode($this->user->email))); } return $message; diff --git a/app/Notifications/AddedToServer.php b/app/Notifications/AddedToServer.php index 56ddd4a400..647c338229 100644 --- a/app/Notifications/AddedToServer.php +++ b/app/Notifications/AddedToServer.php @@ -35,9 +35,9 @@ public function via(): array public function toMail(): MailMessage { return (new MailMessage()) - ->greeting('Hello '.$this->server->user.'!') + ->greeting('Hello ' . $this->server->user . '!') ->line('You have been added as a subuser for the following server, allowing you certain control over the server.') - ->line('Server Name: '.$this->server->name) - ->action('Visit Server', url('/server/'.$this->server->uuid_short)); + ->line('Server Name: ' . $this->server->name) + ->action('Visit Server', url('/server/' . $this->server->uuid_short)); } } diff --git a/app/Notifications/MailTested.php b/app/Notifications/MailTested.php index 0dcbb4e9ca..3bb816bf79 100644 --- a/app/Notifications/MailTested.php +++ b/app/Notifications/MailTested.php @@ -21,7 +21,7 @@ public function toMail(): MailMessage { return (new MailMessage()) ->subject('Panel Test Message') - ->greeting('Hello '.$this->user->name.'!') + ->greeting('Hello ' . $this->user->name . '!') ->line('This is a test of the Panel mail system. You\'re good to go!'); } } diff --git a/app/Notifications/RemovedFromServer.php b/app/Notifications/RemovedFromServer.php index 6c7899d6ab..668d8f28a5 100644 --- a/app/Notifications/RemovedFromServer.php +++ b/app/Notifications/RemovedFromServer.php @@ -36,9 +36,9 @@ public function toMail(): MailMessage { return (new MailMessage()) ->error() - ->greeting('Hello '.$this->server->user.'.') + ->greeting('Hello ' . $this->server->user . '.') ->line('You have been removed as a subuser for the following server.') - ->line('Server Name: '.$this->server->name) + ->line('Server Name: ' . $this->server->name) ->action('Visit Panel', route('index')); } } diff --git a/app/Notifications/SendPasswordReset.php b/app/Notifications/SendPasswordReset.php index 381b731a78..434d1dd489 100644 --- a/app/Notifications/SendPasswordReset.php +++ b/app/Notifications/SendPasswordReset.php @@ -34,7 +34,7 @@ public function toMail(mixed $notifiable): MailMessage return (new MailMessage()) ->subject('Reset Password') ->line('You are receiving this email because we received a password reset request for your account.') - ->action('Reset Password', url('/auth/password/reset/'.$this->token.'?email='.urlencode($notifiable->email))) + ->action('Reset Password', url('/auth/password/reset/' . $this->token . '?email=' . urlencode($notifiable->email))) ->line('If you did not request a password reset, no further action is required.'); } } diff --git a/app/Notifications/ServerInstalled.php b/app/Notifications/ServerInstalled.php index f23371bc3f..fa6500afab 100644 --- a/app/Notifications/ServerInstalled.php +++ b/app/Notifications/ServerInstalled.php @@ -51,9 +51,9 @@ public function via(): array public function toMail(): MailMessage { return (new MailMessage()) - ->greeting('Hello '.$this->user->username.'.') + ->greeting('Hello ' . $this->user->username . '.') ->line('Your server has finished installing and is now ready for you to use.') - ->line('Server Name: '.$this->server->name) + ->line('Server Name: ' . $this->server->name) ->action('Login and Begin Using', route('index')); } } diff --git a/app/Policies/DefaultPolicies.php b/app/Policies/DefaultPolicies.php index e1d2890ab6..3035cae198 100644 --- a/app/Policies/DefaultPolicies.php +++ b/app/Policies/DefaultPolicies.php @@ -12,7 +12,7 @@ trait DefaultPolicies */ public function viewAny(User $user): bool { - return $user->can('viewList '.$this->modelName); + return $user->can('viewList ' . $this->modelName); } /** @@ -20,7 +20,7 @@ public function viewAny(User $user): bool */ public function view(User $user, Model $model): bool { - return $user->can('view '.$this->modelName, $model); + return $user->can('view ' . $this->modelName, $model); } /** @@ -28,7 +28,7 @@ public function view(User $user, Model $model): bool */ public function create(User $user): bool { - return $user->can('create '.$this->modelName); + return $user->can('create ' . $this->modelName); } /** @@ -36,7 +36,7 @@ public function create(User $user): bool */ public function update(User $user, Model $model): bool { - return $user->can('update '.$this->modelName, $model); + return $user->can('update ' . $this->modelName, $model); } /** @@ -44,6 +44,6 @@ public function update(User $user, Model $model): bool */ public function delete(User $user, Model $model): bool { - return $user->can('delete '.$this->modelName, $model); + return $user->can('delete ' . $this->modelName, $model); } } diff --git a/app/Repositories/Daemon/DaemonConfigurationRepository.php b/app/Repositories/Daemon/DaemonConfigurationRepository.php index 86b8418ea7..52cda56dd4 100644 --- a/app/Repositories/Daemon/DaemonConfigurationRepository.php +++ b/app/Repositories/Daemon/DaemonConfigurationRepository.php @@ -19,7 +19,7 @@ public function getSystemInformation(?int $version = null, $connectTimeout = 5): $response = $this ->getHttpClient() ->connectTimeout($connectTimeout) - ->get('/api/system'.(!is_null($version) ? '?v='.$version : '')); + ->get('/api/system' . (!is_null($version) ? '?v=' . $version : '')); } catch (TransferException $exception) { throw new DaemonConnectionException($exception); } diff --git a/app/Repositories/Daemon/DaemonServerRepository.php b/app/Repositories/Daemon/DaemonServerRepository.php index 8656adc744..ce91ece2bf 100644 --- a/app/Repositories/Daemon/DaemonServerRepository.php +++ b/app/Repositories/Daemon/DaemonServerRepository.php @@ -96,7 +96,7 @@ public function delete(): void Assert::isInstanceOf($this->server, Server::class); try { - $this->getHttpClient()->delete('/api/servers/'.$this->server->uuid); + $this->getHttpClient()->delete('/api/servers/' . $this->server->uuid); } catch (TransferException $exception) { throw new DaemonConnectionException($exception); } @@ -192,7 +192,7 @@ public function revokeUserJTI(int $id): void { Assert::isInstanceOf($this->server, Server::class); - $this->revokeJTIs([md5($id.$this->server->uuid)]); + $this->revokeJTIs([md5($id . $this->server->uuid)]); } /** diff --git a/app/Services/Acl/Api/AdminAcl.php b/app/Services/Acl/Api/AdminAcl.php index fc7b176ca7..90ec6480ae 100644 --- a/app/Services/Acl/Api/AdminAcl.php +++ b/app/Services/Acl/Api/AdminAcl.php @@ -62,7 +62,7 @@ public static function can(int $permission, int $action = self::READ): bool */ public static function check(ApiKey $key, string $resource, int $action = self::READ): bool { - return self::can(data_get($key, self::COLUMN_IDENTIFIER.$resource, self::NONE), $action); + return self::can(data_get($key, self::COLUMN_IDENTIFIER . $resource, self::NONE), $action); } /** diff --git a/app/Services/Backups/DownloadLinkService.php b/app/Services/Backups/DownloadLinkService.php index ed38672665..a167a1bb24 100644 --- a/app/Services/Backups/DownloadLinkService.php +++ b/app/Services/Backups/DownloadLinkService.php @@ -34,7 +34,7 @@ public function handle(Backup $backup, User $user): string 'backup_uuid' => $backup->uuid, 'server_uuid' => $backup->server->uuid, ]) - ->handle($backup->server->node, $user->id.$backup->server->uuid); + ->handle($backup->server->node, $user->id . $backup->server->uuid); return sprintf('%s/download/backup?token=%s', $backup->server->node->getConnectionAddress(), $token->toString()); } diff --git a/app/Services/Files/DeleteFilesService.php b/app/Services/Files/DeleteFilesService.php index f0a4f202c2..1692923edd 100644 --- a/app/Services/Files/DeleteFilesService.php +++ b/app/Services/Files/DeleteFilesService.php @@ -30,7 +30,7 @@ public function handle(Server $server, array $files): void $pattern = basename($line); collect($this->daemonFileRepository->setServer($server)->getDirectory($path))->each(function ($item) use ($path, $pattern, $filesToDelete) { if (Str::is($pattern, $item['name'])) { - $filesToDelete->push($path.'/'.$item['name']); + $filesToDelete->push($path . '/' . $item['name']); } }); } diff --git a/app/Services/Helpers/AssetHashService.php b/app/Services/Helpers/AssetHashService.php index 304dabdfcd..f94c32f3ba 100644 --- a/app/Services/Helpers/AssetHashService.php +++ b/app/Services/Helpers/AssetHashService.php @@ -70,7 +70,7 @@ public function css(string $resource): string $output .= " $key=\"$value\""; } - return $output.'>'; + return $output . '>'; } /** @@ -92,7 +92,7 @@ public function js(string $resource): string $output .= " $key=\"$value\""; } - return $output.'>'; + return $output . '>'; } /** diff --git a/app/Services/Helpers/SoftwareVersionService.php b/app/Services/Helpers/SoftwareVersionService.php index 18c212d991..7d50203bf1 100644 --- a/app/Services/Helpers/SoftwareVersionService.php +++ b/app/Services/Helpers/SoftwareVersionService.php @@ -127,13 +127,13 @@ public function versionData(): array $head = explode(' ', file_get_contents(base_path('.git/HEAD'))); if (array_key_exists(1, $head)) { - $path = base_path('.git/'.trim($head[1])); + $path = base_path('.git/' . trim($head[1])); } } if (isset($path) && file_exists($path)) { return [ - 'version' => 'canary ('.substr(file_get_contents($path), 0, 8).')', + 'version' => 'canary (' . substr(file_get_contents($path), 0, 8) . ')', 'is_git' => true, ]; } diff --git a/app/Services/Servers/StartupCommandService.php b/app/Services/Servers/StartupCommandService.php index 1c6ff1be2d..4703eb0753 100644 --- a/app/Services/Servers/StartupCommandService.php +++ b/app/Services/Servers/StartupCommandService.php @@ -15,7 +15,7 @@ public function handle(Server $server, bool $hideAllValues = false): string $replace = [$server->memory, $server->allocation->ip, $server->allocation->port]; foreach ($server->variables as $variable) { - $find[] = '{{'.$variable->env_variable.'}}'; + $find[] = '{{' . $variable->env_variable . '}}'; $replace[] = ($variable->user_viewable && !$hideAllValues) ? ($variable->server_value ?? $variable->default_value) : '[hidden]'; } diff --git a/app/Services/Servers/TransferServerService.php b/app/Services/Servers/TransferServerService.php index 070f84f321..4312369dd7 100644 --- a/app/Services/Servers/TransferServerService.php +++ b/app/Services/Servers/TransferServerService.php @@ -31,8 +31,8 @@ private function notify(Server $server, Plain $token): void Http::daemon($server->node)->post('/api/transfer', [ 'json' => [ 'server_id' => $server->uuid, - 'url' => $server->node->getConnectionAddress()."/api/servers/$server->uuid/archive", - 'token' => 'Bearer '.$token->toString(), + 'url' => $server->node->getConnectionAddress() . "/api/servers/$server->uuid/archive", + 'token' => 'Bearer ' . $token->toString(), 'server' => [ 'uuid' => $server->uuid, 'start_on_completion' => false, diff --git a/app/Services/Servers/VariableValidatorService.php b/app/Services/Servers/VariableValidatorService.php index 904e494d90..75f4a59b14 100644 --- a/app/Services/Servers/VariableValidatorService.php +++ b/app/Services/Servers/VariableValidatorService.php @@ -40,8 +40,8 @@ public function handle(int $egg, array $fields = []): Collection $data = $rules = $customAttributes = []; foreach ($variables as $variable) { $data['environment'][$variable->env_variable] = array_get($fields, $variable->env_variable); - $rules['environment.'.$variable->env_variable] = $variable->rules; - $customAttributes['environment.'.$variable->env_variable] = trans('validation.internal.variable_value', ['env' => $variable->name]); + $rules['environment.' . $variable->env_variable] = $variable->rules; + $customAttributes['environment.' . $variable->env_variable] = trans('validation.internal.variable_value', ['env' => $variable->name]); } $validator = $this->validator->make($data, $rules, [], $customAttributes); diff --git a/app/Services/Subusers/SubuserCreationService.php b/app/Services/Subusers/SubuserCreationService.php index 0439afd52d..0f9508ba72 100644 --- a/app/Services/Subusers/SubuserCreationService.php +++ b/app/Services/Subusers/SubuserCreationService.php @@ -39,7 +39,7 @@ public function handle(Server $server, string $email, array $permissions): Subus if (!$user) { // Just cap the username generated at 64 characters at most and then append a random string // to the end to make it "unique"... - $username = substr(preg_replace('/([^\w\.-]+)/', '', strtok($email, '@')), 0, 64).Str::random(3); + $username = substr(preg_replace('/([^\w\.-]+)/', '', strtok($email, '@')), 0, 64) . Str::random(3); $user = $this->userCreationService->handle([ 'email' => $email, diff --git a/app/Traits/EnvironmentWriterTrait.php b/app/Traits/EnvironmentWriterTrait.php index 2011165716..cb5bef0476 100644 --- a/app/Traits/EnvironmentWriterTrait.php +++ b/app/Traits/EnvironmentWriterTrait.php @@ -37,10 +37,10 @@ public function writeToEnvironment(array $values = []): void $key = strtoupper($key); $saveValue = sprintf('%s=%s', $key, $this->escapeEnvironmentValue($value ?? '')); - if (preg_match_all('/^'.$key.'=(.*)$/m', $saveContents) < 1) { - $saveContents = $saveContents.PHP_EOL.$saveValue; + if (preg_match_all('/^' . $key . '=(.*)$/m', $saveContents) < 1) { + $saveContents = $saveContents . PHP_EOL . $saveValue; } else { - $saveContents = preg_replace('/^'.$key.'=(.*)$/m', $saveValue, $saveContents); + $saveContents = preg_replace('/^' . $key . '=(.*)$/m', $saveValue, $saveContents); } }); diff --git a/app/Transformers/Api/Client/ActivityLogTransformer.php b/app/Transformers/Api/Client/ActivityLogTransformer.php index 8ae8881426..e2f3650f48 100644 --- a/app/Transformers/Api/Client/ActivityLogTransformer.php +++ b/app/Transformers/Api/Client/ActivityLogTransformer.php @@ -62,7 +62,7 @@ protected function properties(ActivityLog $model): object if (!is_array($value)) { // Perform some directory normalization at this point. if ($key === 'directory') { - $value = str_replace('//', '/', '/'.trim($value, '/').'/'); + $value = str_replace('//', '/', '/' . trim($value, '/') . '/'); } return [$key => $value]; @@ -94,7 +94,7 @@ protected function hasAdditionalMetadata(ActivityLog $model): bool return false; } - $str = trans('activity.'.str_replace(':', '.', $model->event)); + $str = trans('activity.' . str_replace(':', '.', $model->event)); preg_match_all('/:(?[\w.-]+\w)(?:[^\w:]?|$)/', $str, $matches); $exclude = array_merge($matches['key'], ['ip', 'useragent', 'using_sftp']); diff --git a/app/Transformers/Api/Client/UserTransformer.php b/app/Transformers/Api/Client/UserTransformer.php index 06160a7225..f875463e56 100644 --- a/app/Transformers/Api/Client/UserTransformer.php +++ b/app/Transformers/Api/Client/UserTransformer.php @@ -28,7 +28,7 @@ public function transform(User $user): array 'first_name' => $user->name_first, 'last_name' => $user->name_last, 'language' => $user->language, - 'image' => 'https://gravatar.com/avatar/'.md5(Str::lower($user->email)), // deprecated + 'image' => 'https://gravatar.com/avatar/' . md5(Str::lower($user->email)), // deprecated 'admin' => $user->isRootAdmin(), // deprecated, use "root_admin" 'root_admin' => $user->isRootAdmin(), '2fa_enabled' => (bool) $user->use_totp, diff --git a/bootstrap/tests.php b/bootstrap/tests.php index 148613856d..a80e0b27f9 100644 --- a/bootstrap/tests.php +++ b/bootstrap/tests.php @@ -5,9 +5,9 @@ use Illuminate\Contracts\Console\Kernel; use Symfony\Component\Console\Output\ConsoleOutput; -require __DIR__.'/../vendor/autoload.php'; +require __DIR__ . '/../vendor/autoload.php'; -$app = require __DIR__.'/app.php'; +$app = require __DIR__ . '/app.php'; /** @var \App\Console\Kernel $kernel */ $kernel = $app->make(Kernel::class); @@ -23,10 +23,10 @@ $output = new ConsoleOutput(); -$prefix = 'database.connections.'.config('database.default'); +$prefix = 'database.connections.' . config('database.default'); if (!Str::contains(config("$prefix.database"), 'test')) { - $output->writeln(PHP_EOL.'Cannot run test process against non-testing database.'); - $output->writeln(PHP_EOL.'Environment is currently pointed at: "'.config("$prefix.database").'".'); + $output->writeln(PHP_EOL . 'Cannot run test process against non-testing database.'); + $output->writeln(PHP_EOL . 'Environment is currently pointed at: "' . config("$prefix.database") . '".'); exit(1); } @@ -35,11 +35,11 @@ * running the tests. */ if (!env('SKIP_MIGRATIONS')) { - $output->writeln(PHP_EOL.'Refreshing database for Integration tests...'); + $output->writeln(PHP_EOL . 'Refreshing database for Integration tests...'); $kernel->call('migrate:fresh'); - $output->writeln('Seeding database for Integration tests...'.PHP_EOL); + $output->writeln('Seeding database for Integration tests...' . PHP_EOL); $kernel->call('db:seed'); } else { - $output->writeln(PHP_EOL.'Skipping database migrations...'.PHP_EOL); + $output->writeln(PHP_EOL . 'Skipping database migrations...' . PHP_EOL); } diff --git a/database/Factories/NodeFactory.php b/database/Factories/NodeFactory.php index 7d0ac25a19..19a1fbf7b1 100644 --- a/database/Factories/NodeFactory.php +++ b/database/Factories/NodeFactory.php @@ -24,7 +24,7 @@ public function definition(): array return [ 'uuid' => Uuid::uuid4()->toString(), 'public' => true, - 'name' => 'FactoryNode_'.Str::random(10), + 'name' => 'FactoryNode_' . Str::random(10), 'fqdn' => $this->faker->unique()->ipv4(), 'scheme' => 'http', 'behind_proxy' => false, diff --git a/database/Factories/UserFactory.php b/database/Factories/UserFactory.php index 6284e7471b..3c6003cc24 100644 --- a/database/Factories/UserFactory.php +++ b/database/Factories/UserFactory.php @@ -27,8 +27,8 @@ public function definition(): array return [ 'external_id' => null, 'uuid' => Uuid::uuid4()->toString(), - 'username' => $this->faker->userName().'_'.Str::random(10), - 'email' => Str::random(32).'@example.com', + 'username' => $this->faker->userName() . '_' . Str::random(10), + 'email' => Str::random(32) . '@example.com', 'name_first' => $this->faker->firstName(), 'name_last' => $this->faker->lastName(), 'password' => $password ?: $password = bcrypt('password'), diff --git a/database/Seeders/EggSeeder.php b/database/Seeders/EggSeeder.php index 3053bfa76b..dcbc4f25c1 100644 --- a/database/Seeders/EggSeeder.php +++ b/database/Seeders/EggSeeder.php @@ -47,9 +47,9 @@ public function run() */ protected function parseEggFiles($name) { - $files = new \DirectoryIterator(database_path('Seeders/eggs/'.kebab_case($name))); + $files = new \DirectoryIterator(database_path('Seeders/eggs/' . kebab_case($name))); - $this->command->alert('Updating Eggs for: '.$name); + $this->command->alert('Updating Eggs for: ' . $name); /** @var \DirectoryIterator $file */ foreach ($files as $file) { if (!$file->isFile() || !$file->isReadable()) { @@ -71,10 +71,10 @@ protected function parseEggFiles($name) if ($egg instanceof Egg) { $this->importerService->fromFile($file, $egg); - $this->command->info('Updated '.$decoded['name']); + $this->command->info('Updated ' . $decoded['name']); } else { $this->importerService->fromFile($file); - $this->command->comment('Created '.$decoded['name']); + $this->command->comment('Created ' . $decoded['name']); } } diff --git a/database/migrations/2017_03_11_215455_ChangeServiceVariablesValidationRules.php b/database/migrations/2017_03_11_215455_ChangeServiceVariablesValidationRules.php index 5d8d38e6da..b96b2ba24a 100644 --- a/database/migrations/2017_03_11_215455_ChangeServiceVariablesValidationRules.php +++ b/database/migrations/2017_03_11_215455_ChangeServiceVariablesValidationRules.php @@ -17,7 +17,7 @@ public function up(): void DB::transaction(function () { foreach (DB::table('service_variables')->get() as $variable) { - $variable->rules = ($variable->required) ? 'required|regex:'.$variable->rules : 'regex:'.$variable->rules; + $variable->rules = ($variable->required) ? 'required|regex:' . $variable->rules : 'regex:' . $variable->rules; $variable->save(); } }); diff --git a/database/migrations/2017_09_13_211810_UpdateOldPermissionsToPointToNewScheduleSystem.php b/database/migrations/2017_09_13_211810_UpdateOldPermissionsToPointToNewScheduleSystem.php index 4e50c9a84d..aca8afb6c1 100644 --- a/database/migrations/2017_09_13_211810_UpdateOldPermissionsToPointToNewScheduleSystem.php +++ b/database/migrations/2017_09_13_211810_UpdateOldPermissionsToPointToNewScheduleSystem.php @@ -17,7 +17,7 @@ public function up(): void continue; } - $newPermission = $parts[0].'-'.str_replace('task', 'schedule', $parts[1]); + $newPermission = $parts[0] . '-' . str_replace('task', 'schedule', $parts[1]); DB::table('permissions')->where('id', '=', $record->id)->update(['permission' => $newPermission]); } @@ -35,7 +35,7 @@ public function down(): void continue; } - $newPermission = $parts[0].'-'.str_replace('schedule', 'task', $parts[1]); + $newPermission = $parts[0] . '-' . str_replace('schedule', 'task', $parts[1]); DB::table('permissions')->where('id', '=', $record->id)->update(['permission' => $newPermission]); } diff --git a/database/migrations/2017_09_23_173628_RemoveDaemonSecretFromServersTable.php b/database/migrations/2017_09_23_173628_RemoveDaemonSecretFromServersTable.php index e99078b667..ab2e8056e7 100644 --- a/database/migrations/2017_09_23_173628_RemoveDaemonSecretFromServersTable.php +++ b/database/migrations/2017_09_23_173628_RemoveDaemonSecretFromServersTable.php @@ -21,7 +21,7 @@ public function up(): void $inserts[] = [ 'user_id' => $server->owner_id, 'server_id' => $server->id, - 'secret' => DaemonKeyRepositoryInterface::INTERNAL_KEY_IDENTIFIER.str_random(40), + 'secret' => DaemonKeyRepositoryInterface::INTERNAL_KEY_IDENTIFIER . str_random(40), 'expires_at' => Carbon::now()->addMinutes(config('panel.api.key_expire_time', 720))->toDateTimeString(), 'created_at' => Carbon::now()->toDateTimeString(), 'updated_at' => Carbon::now()->toDateTimeString(), diff --git a/database/migrations/2017_09_23_185022_RemoveDaemonSecretFromSubusersTable.php b/database/migrations/2017_09_23_185022_RemoveDaemonSecretFromSubusersTable.php index 60b0d63582..9090be4072 100644 --- a/database/migrations/2017_09_23_185022_RemoveDaemonSecretFromSubusersTable.php +++ b/database/migrations/2017_09_23_185022_RemoveDaemonSecretFromSubusersTable.php @@ -19,7 +19,7 @@ public function up(): void $inserts[] = [ 'user_id' => $subuser->user_id, 'server_id' => $subuser->server_id, - 'secret' => DaemonKeyRepositoryInterface::INTERNAL_KEY_IDENTIFIER.str_random(40), + 'secret' => DaemonKeyRepositoryInterface::INTERNAL_KEY_IDENTIFIER . str_random(40), 'expires_at' => Carbon::now()->addMinutes(config('panel.api.key_expire_time', 720))->toDateTimeString(), 'created_at' => Carbon::now()->toDateTimeString(), 'updated_at' => Carbon::now()->toDateTimeString(), diff --git a/database/migrations/2020_03_22_163911_merge_permissions_table_into_subusers.php b/database/migrations/2020_03_22_163911_merge_permissions_table_into_subusers.php index 2a10ba96c8..6a9280b5f0 100644 --- a/database/migrations/2020_03_22_163911_merge_permissions_table_into_subusers.php +++ b/database/migrations/2020_03_22_163911_merge_permissions_table_into_subusers.php @@ -112,9 +112,9 @@ public function down(): void } if (!empty($values)) { - $string = 'VALUES '.implode(', ', array_fill(0, count($values) / 2, '(?, ?)')); + $string = 'VALUES ' . implode(', ', array_fill(0, count($values) / 2, '(?, ?)')); - DB::insert('INSERT INTO permissions(`subuser_id`, `permission`) '.$string, $values); + DB::insert('INSERT INTO permissions(`subuser_id`, `permission`) ' . $string, $values); } } diff --git a/database/migrations/2020_04_10_141024_store_node_tokens_as_encrypted_value.php b/database/migrations/2020_04_10_141024_store_node_tokens_as_encrypted_value.php index d98bbc3c8a..911461d709 100644 --- a/database/migrations/2020_04_10_141024_store_node_tokens_as_encrypted_value.php +++ b/database/migrations/2020_04_10_141024_store_node_tokens_as_encrypted_value.php @@ -53,7 +53,7 @@ public function down(): void DB::transaction(function () { foreach (DB::select('SELECT id, daemon_token_id, daemon_token FROM nodes') as $datum) { DB::update('UPDATE nodes SET daemon_token = ? WHERE id = ?', [ - $datum->daemon_token_id.decrypt($datum->daemon_token), + $datum->daemon_token_id . decrypt($datum->daemon_token), $datum->id, ]); } diff --git a/pint.json b/pint.json index 9427029f83..99fa80d3a1 100644 --- a/pint.json +++ b/pint.json @@ -1,6 +1,7 @@ { "preset": "laravel", "rules": { + "concat_space": false, "not_operator_with_successor_space": false, "ordered_imports": false } diff --git a/tests/Assertions/AssertsActivityLogged.php b/tests/Assertions/AssertsActivityLogged.php index ed33729e4d..23a3461b1f 100644 --- a/tests/Assertions/AssertsActivityLogged.php +++ b/tests/Assertions/AssertsActivityLogged.php @@ -35,7 +35,7 @@ public function assertActivityLogged(string $event): void public function assertActivitySubjects(string $event, Model|array $subjects): void { if (is_array($subjects)) { - \Webmozart\Assert\Assert::lessThanEq(count(func_get_args()), 2, 'Invalid call to '.__METHOD__.': cannot provide additional arguments if providing an array.'); + \Webmozart\Assert\Assert::lessThanEq(count(func_get_args()), 2, 'Invalid call to ' . __METHOD__ . ': cannot provide additional arguments if providing an array.'); } else { $subjects = array_slice(func_get_args(), 1); } diff --git a/tests/Assertions/MiddlewareAttributeAssertionsTrait.php b/tests/Assertions/MiddlewareAttributeAssertionsTrait.php index 4a8441abec..ab24f0311e 100644 --- a/tests/Assertions/MiddlewareAttributeAssertionsTrait.php +++ b/tests/Assertions/MiddlewareAttributeAssertionsTrait.php @@ -11,7 +11,7 @@ trait MiddlewareAttributeAssertionsTrait */ public function assertRequestHasAttribute(string $attribute): void { - Assert::assertTrue($this->request->attributes->has($attribute), 'Assert that request mock has '.$attribute.' attribute.'); + Assert::assertTrue($this->request->attributes->has($attribute), 'Assert that request mock has ' . $attribute . ' attribute.'); } /** @@ -19,7 +19,7 @@ public function assertRequestHasAttribute(string $attribute): void */ public function assertRequestMissingAttribute(string $attribute): void { - Assert::assertFalse($this->request->attributes->has($attribute), 'Assert that request mock does not have '.$attribute.' attribute.'); + Assert::assertFalse($this->request->attributes->has($attribute), 'Assert that request mock does not have ' . $attribute . ' attribute.'); } /** diff --git a/tests/Integration/Api/Application/ApplicationApiIntegrationTestCase.php b/tests/Integration/Api/Application/ApplicationApiIntegrationTestCase.php index 02b674a9ad..c104a3eae9 100644 --- a/tests/Integration/Api/Application/ApplicationApiIntegrationTestCase.php +++ b/tests/Integration/Api/Application/ApplicationApiIntegrationTestCase.php @@ -38,7 +38,7 @@ protected function setUp(): void $this ->withHeader('Accept', 'application/vnd.panel.v1+json') - ->withHeader('Authorization', 'Bearer '.$this->key->identifier.$this->key->token); + ->withHeader('Authorization', 'Bearer ' . $this->key->identifier . $this->key->token); } public function getApiUser(): User @@ -58,7 +58,7 @@ protected function createNewDefaultApiKey(User $user, array $permissions = []): { $this->key = $this->createApiKey($user, $permissions); - $this->withHeader('Authorization', 'Bearer '.$this->key->identifier.$this->key->token); + $this->withHeader('Authorization', 'Bearer ' . $this->key->identifier . $this->key->token); return $this->key; } diff --git a/tests/Integration/Api/Application/EggControllerTest.php b/tests/Integration/Api/Application/EggControllerTest.php index 62ab2422f9..14a41cd6af 100644 --- a/tests/Integration/Api/Application/EggControllerTest.php +++ b/tests/Integration/Api/Application/EggControllerTest.php @@ -48,7 +48,7 @@ public function testListAllEggs(): void $this->assertSame( $expected, $actual, - 'Unable to find JSON fragment: '.PHP_EOL.PHP_EOL."[$expected]".PHP_EOL.PHP_EOL.'within'.PHP_EOL.PHP_EOL."[$actual]." + 'Unable to find JSON fragment: ' . PHP_EOL . PHP_EOL . "[$expected]" . PHP_EOL . PHP_EOL . 'within' . PHP_EOL . PHP_EOL . "[$actual]." ); } } @@ -60,7 +60,7 @@ public function testReturnSingleEgg(): void { $egg = Egg::query()->findOrFail(1); - $response = $this->getJson('/api/application/eggs/'.$egg->id); + $response = $this->getJson('/api/application/eggs/' . $egg->id); $response->assertStatus(Response::HTTP_OK); $response->assertJsonStructure([ 'object', @@ -82,7 +82,7 @@ public function testReturnSingleEggWithRelationships(): void { $egg = Egg::query()->findOrFail(1); - $response = $this->getJson('/api/application/eggs/'.$egg->id.'?include=servers,variables'); + $response = $this->getJson('/api/application/eggs/' . $egg->id . '?include=servers,variables'); $response->assertStatus(Response::HTTP_OK); $response->assertJsonStructure([ 'object', diff --git a/tests/Integration/Api/Application/Users/ExternalUserControllerTest.php b/tests/Integration/Api/Application/Users/ExternalUserControllerTest.php index 4ef873c433..24f3996ebf 100644 --- a/tests/Integration/Api/Application/Users/ExternalUserControllerTest.php +++ b/tests/Integration/Api/Application/Users/ExternalUserControllerTest.php @@ -16,7 +16,7 @@ public function testGetRemoteUser(): void { $user = User::factory()->create(['external_id' => Str::random()]); - $response = $this->getJson('/api/application/users/external/'.$user->external_id); + $response = $this->getJson('/api/application/users/external/' . $user->external_id); $response->assertStatus(Response::HTTP_OK); $response->assertJsonCount(2); $response->assertJsonStructure([ @@ -64,7 +64,7 @@ public function testErrorReturnedIfNoPermission(): void $user = User::factory()->create(['external_id' => Str::random()]); $this->createNewDefaultApiKey($this->getApiUser(), ['r_users' => 0]); - $response = $this->getJson('/api/application/users/external/'.$user->external_id); + $response = $this->getJson('/api/application/users/external/' . $user->external_id); $this->assertAccessDeniedJson($response); } } diff --git a/tests/Integration/Api/Application/Users/UserControllerTest.php b/tests/Integration/Api/Application/Users/UserControllerTest.php index 04ba5c2e6e..6787ff1f4e 100644 --- a/tests/Integration/Api/Application/Users/UserControllerTest.php +++ b/tests/Integration/Api/Application/Users/UserControllerTest.php @@ -89,7 +89,7 @@ public function testGetSingleUser(): void { $user = User::factory()->create(); - $response = $this->getJson('/api/application/users/'.$user->id); + $response = $this->getJson('/api/application/users/' . $user->id); $response->assertStatus(Response::HTTP_OK); $response->assertJsonCount(2); $response->assertJsonStructure([ @@ -124,7 +124,7 @@ public function testRelationshipsCanBeLoaded(): void $user = User::factory()->create(); $server = $this->createServerModel(['user_id' => $user->id]); - $response = $this->getJson('/api/application/users/'.$user->id.'?include=servers'); + $response = $this->getJson('/api/application/users/' . $user->id . '?include=servers'); $response->assertStatus(Response::HTTP_OK); $response->assertJsonCount(2); $response->assertJsonStructure([ @@ -157,7 +157,7 @@ public function testKeyWithoutPermissionCannotLoadRelationship(): void $user = User::factory()->create(); $this->createServerModel(['user_id' => $user->id]); - $response = $this->getJson('/api/application/users/'.$user->id.'?include=servers'); + $response = $this->getJson('/api/application/users/' . $user->id . '?include=servers'); $response->assertStatus(Response::HTTP_OK); $response->assertJsonCount(2)->assertJsonCount(1, 'attributes.relationships'); $response->assertJsonStructure([ @@ -199,7 +199,7 @@ public function testErrorReturnedIfNoPermission(): void $user = User::factory()->create(); $this->createNewDefaultApiKey($this->getApiUser(), ['r_users' => 0]); - $response = $this->getJson('/api/application/users/'.$user->id); + $response = $this->getJson('/api/application/users/' . $user->id); $this->assertAccessDeniedJson($response); } @@ -242,7 +242,7 @@ public function testUpdateUser(): void { $user = User::factory()->create(); - $response = $this->patchJson('/api/application/users/'.$user->id, [ + $response = $this->patchJson('/api/application/users/' . $user->id, [ 'username' => 'new.test.name', 'email' => 'new@emailtest.com', 'first_name' => $user->name_first, @@ -272,7 +272,7 @@ public function testDeleteUser(): void $user = User::factory()->create(); $this->assertDatabaseHas('users', ['id' => $user->id]); - $response = $this->delete('/api/application/users/'.$user->id); + $response = $this->delete('/api/application/users/' . $user->id); $response->assertStatus(Response::HTTP_NO_CONTENT); $this->assertDatabaseMissing('users', ['id' => $user->id]); diff --git a/tests/Integration/Api/Client/AccountControllerTest.php b/tests/Integration/Api/Client/AccountControllerTest.php index 38ce80fa96..ccca6818d5 100644 --- a/tests/Integration/Api/Client/AccountControllerTest.php +++ b/tests/Integration/Api/Client/AccountControllerTest.php @@ -28,7 +28,7 @@ public function testAccountDetailsAreReturned(): void 'first_name' => $user->name_first, 'last_name' => $user->name_last, 'language' => 'en', - 'image' => 'https://gravatar.com/avatar/'.md5(Str::lower($user->email)), + 'image' => 'https://gravatar.com/avatar/' . md5(Str::lower($user->email)), 'admin' => false, 'root_admin' => false, '2fa_enabled' => false, @@ -47,7 +47,7 @@ public function testEmailIsUpdated(): void $user = User::factory()->create(); $response = $this->actingAs($user)->putJson('/api/client/account/email', [ - 'email' => $email = Str::random().'@example.com', + 'email' => $email = Str::random() . '@example.com', 'password' => 'password', ]); diff --git a/tests/Integration/Api/Client/ApiKeyControllerTest.php b/tests/Integration/Api/Client/ApiKeyControllerTest.php index 27662a1735..462875c59b 100644 --- a/tests/Integration/Api/Client/ApiKeyControllerTest.php +++ b/tests/Integration/Api/Client/ApiKeyControllerTest.php @@ -83,7 +83,7 @@ public function testApiKeyCannotSpecifyMoreThanFiftyIps(): void { $ips = []; for ($i = 0; $i < 100; $i++) { - $ips[] = '127.0.0.'.$i; + $ips[] = '127.0.0.' . $i; } $this->actingAs(User::factory()->create()) @@ -162,7 +162,7 @@ public function testApiKeyCanBeDeleted(): void 'key_type' => ApiKey::TYPE_ACCOUNT, ]); - $response = $this->actingAs($user)->delete('/api/client/account/api-keys/'.$key->identifier); + $response = $this->actingAs($user)->delete('/api/client/account/api-keys/' . $key->identifier); $response->assertStatus(Response::HTTP_NO_CONTENT); $this->assertDatabaseMissing('api_keys', ['id' => $key->id]); @@ -205,7 +205,7 @@ public function testApiKeyBelongingToAnotherUserCannotBeDeleted(): void ]); $this->actingAs($user) - ->deleteJson('/api/client/account/api-keys/'.$key->identifier) + ->deleteJson('/api/client/account/api-keys/' . $key->identifier) ->assertNotFound(); $this->assertDatabaseHas('api_keys', ['id' => $key->id]); @@ -226,7 +226,7 @@ public function testApplicationApiKeyCannotBeDeleted(): void ]); $this->actingAs($user) - ->deleteJson('/api/client/account/api-keys/'.$key->identifier) + ->deleteJson('/api/client/account/api-keys/' . $key->identifier) ->assertNotFound(); $this->assertDatabaseHas('api_keys', ['id' => $key->id]); diff --git a/tests/Integration/Api/Client/ClientApiIntegrationTestCase.php b/tests/Integration/Api/Client/ClientApiIntegrationTestCase.php index 86e9a202d1..70db04614e 100644 --- a/tests/Integration/Api/Client/ClientApiIntegrationTestCase.php +++ b/tests/Integration/Api/Client/ClientApiIntegrationTestCase.php @@ -69,7 +69,7 @@ protected function link(mixed $model, ?string $append = null): string throw new \InvalidArgumentException(sprintf('Cannot create link for Model of type %s', class_basename($model))); } - return $link.($append ? '/'.ltrim($append, '/') : ''); + return $link . ($append ? '/' . ltrim($append, '/') : ''); } /** diff --git a/tests/Integration/Api/Client/ClientControllerTest.php b/tests/Integration/Api/Client/ClientControllerTest.php index 4e5e26b272..e4059f6947 100644 --- a/tests/Integration/Api/Client/ClientControllerTest.php +++ b/tests/Integration/Api/Client/ClientControllerTest.php @@ -298,7 +298,7 @@ public function testNoServersAreReturnedIfAdminFilterIsPassedByRegularUser(strin $this->createServerModel(['user_id' => $users[1]->id]); $this->createServerModel(['user_id' => $users[2]->id]); - $response = $this->actingAs($users[0])->getJson('/api/client?type='.$type); + $response = $this->actingAs($users[0])->getJson('/api/client?type=' . $type); $response->assertOk(); $response->assertJsonCount(0, 'data'); diff --git a/tests/Integration/Api/Client/Server/Allocation/AllocationAuthorizationTest.php b/tests/Integration/Api/Client/Server/Allocation/AllocationAuthorizationTest.php index f1d93f8ad3..6cd798e165 100644 --- a/tests/Integration/Api/Client/Server/Allocation/AllocationAuthorizationTest.php +++ b/tests/Integration/Api/Client/Server/Allocation/AllocationAuthorizationTest.php @@ -30,20 +30,20 @@ public function testAccessToAServersAllocationsIsRestrictedProperly(string $meth // This is the only valid call for this test, accessing the allocation for the same // server that the API user is the owner of. - $response = $this->actingAs($user)->json($method, $this->link($server1, '/network/allocations/'.$allocation1->id.$endpoint)); + $response = $this->actingAs($user)->json($method, $this->link($server1, '/network/allocations/' . $allocation1->id . $endpoint)); $this->assertTrue($response->status() <= 204 || $response->status() === 400 || $response->status() === 422); // This request fails because the allocation is valid for that server but the user // making the request is not authorized to perform that action. - $this->actingAs($user)->json($method, $this->link($server2, '/network/allocations/'.$allocation2->id.$endpoint))->assertForbidden(); + $this->actingAs($user)->json($method, $this->link($server2, '/network/allocations/' . $allocation2->id . $endpoint))->assertForbidden(); // Both of these should report a 404 error due to the allocations being linked to // servers that are not the same as the server in the request, or are assigned // to a server for which the user making the request has no access to. - $this->actingAs($user)->json($method, $this->link($server1, '/network/allocations/'.$allocation2->id.$endpoint))->assertNotFound(); - $this->actingAs($user)->json($method, $this->link($server1, '/network/allocations/'.$allocation3->id.$endpoint))->assertNotFound(); - $this->actingAs($user)->json($method, $this->link($server2, '/network/allocations/'.$allocation3->id.$endpoint))->assertNotFound(); - $this->actingAs($user)->json($method, $this->link($server3, '/network/allocations/'.$allocation3->id.$endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server1, '/network/allocations/' . $allocation2->id . $endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server1, '/network/allocations/' . $allocation3->id . $endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server2, '/network/allocations/' . $allocation3->id . $endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server3, '/network/allocations/' . $allocation3->id . $endpoint))->assertNotFound(); } public static function methodDataProvider(): array diff --git a/tests/Integration/Api/Client/Server/Backup/BackupAuthorizationTest.php b/tests/Integration/Api/Client/Server/Backup/BackupAuthorizationTest.php index c91c2e3a10..472364d78e 100644 --- a/tests/Integration/Api/Client/Server/Backup/BackupAuthorizationTest.php +++ b/tests/Integration/Api/Client/Server/Backup/BackupAuthorizationTest.php @@ -38,20 +38,20 @@ public function testAccessToAServersBackupIsRestrictedProperly(string $method, s // This is the only valid call for this test, accessing the backup for the same // server that the API user is the owner of. - $this->actingAs($user)->json($method, $this->link($server1, '/backups/'.$backup1->uuid.$endpoint)) + $this->actingAs($user)->json($method, $this->link($server1, '/backups/' . $backup1->uuid . $endpoint)) ->assertStatus($method === 'DELETE' ? 204 : 200); // This request fails because the backup is valid for that server but the user // making the request is not authorized to perform that action. - $this->actingAs($user)->json($method, $this->link($server2, '/backups/'.$backup2->uuid.$endpoint))->assertForbidden(); + $this->actingAs($user)->json($method, $this->link($server2, '/backups/' . $backup2->uuid . $endpoint))->assertForbidden(); // Both of these should report a 404 error due to the backup being linked to // servers that are not the same as the server in the request, or are assigned // to a server for which the user making the request has no access to. - $this->actingAs($user)->json($method, $this->link($server1, '/backups/'.$backup2->uuid.$endpoint))->assertNotFound(); - $this->actingAs($user)->json($method, $this->link($server1, '/backups/'.$backup3->uuid.$endpoint))->assertNotFound(); - $this->actingAs($user)->json($method, $this->link($server2, '/backups/'.$backup3->uuid.$endpoint))->assertNotFound(); - $this->actingAs($user)->json($method, $this->link($server3, '/backups/'.$backup3->uuid.$endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server1, '/backups/' . $backup2->uuid . $endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server1, '/backups/' . $backup3->uuid . $endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server2, '/backups/' . $backup3->uuid . $endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server3, '/backups/' . $backup3->uuid . $endpoint))->assertNotFound(); } public static function methodDataProvider(): array diff --git a/tests/Integration/Api/Client/Server/Database/DatabaseAuthorizationTest.php b/tests/Integration/Api/Client/Server/Database/DatabaseAuthorizationTest.php index 2c8320812f..b95778104a 100644 --- a/tests/Integration/Api/Client/Server/Database/DatabaseAuthorizationTest.php +++ b/tests/Integration/Api/Client/Server/Database/DatabaseAuthorizationTest.php @@ -40,20 +40,20 @@ public function testAccessToAServersDatabasesIsRestrictedProperly(string $method // This is the only valid call for this test, accessing the database for the same // server that the API user is the owner of. - $this->actingAs($user)->json($method, $this->link($server1, '/databases/'.$database1->id.$endpoint)) + $this->actingAs($user)->json($method, $this->link($server1, '/databases/' . $database1->id . $endpoint)) ->assertStatus($method === 'DELETE' ? 204 : 200); // This request fails because the database is valid for that server but the user // making the request is not authorized to perform that action. - $this->actingAs($user)->json($method, $this->link($server2, '/databases/'.$database2->id.$endpoint))->assertForbidden(); + $this->actingAs($user)->json($method, $this->link($server2, '/databases/' . $database2->id . $endpoint))->assertForbidden(); // Both of these should report a 404 error due to the database being linked to // servers that are not the same as the server in the request, or are assigned // to a server for which the user making the request has no access to. - $this->actingAs($user)->json($method, $this->link($server1, '/databases/'.$database2->id.$endpoint))->assertNotFound(); - $this->actingAs($user)->json($method, $this->link($server1, '/databases/'.$database3->id.$endpoint))->assertNotFound(); - $this->actingAs($user)->json($method, $this->link($server2, '/databases/'.$database3->id.$endpoint))->assertNotFound(); - $this->actingAs($user)->json($method, $this->link($server3, '/databases/'.$database3->id.$endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server1, '/databases/' . $database2->id . $endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server1, '/databases/' . $database3->id . $endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server2, '/databases/' . $database3->id . $endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server3, '/databases/' . $database3->id . $endpoint))->assertNotFound(); } public static function methodDataProvider(): array diff --git a/tests/Integration/Api/Client/Server/Schedule/GetServerSchedulesTest.php b/tests/Integration/Api/Client/Server/Schedule/GetServerSchedulesTest.php index 5900e67f25..7d019178bf 100644 --- a/tests/Integration/Api/Client/Server/Schedule/GetServerSchedulesTest.php +++ b/tests/Integration/Api/Client/Server/Schedule/GetServerSchedulesTest.php @@ -47,13 +47,13 @@ public function testServerSchedulesAreReturned(array $permissions, bool $individ $response->assertJsonCount(1, 'data'); } - $response->assertJsonCount(1, $prefix.'attributes.relationships.tasks.data'); + $response->assertJsonCount(1, $prefix . 'attributes.relationships.tasks.data'); - $response->assertJsonPath($prefix.'object', Schedule::RESOURCE_NAME); - $response->assertJsonPath($prefix.'attributes.relationships.tasks.data.0.object', Task::RESOURCE_NAME); + $response->assertJsonPath($prefix . 'object', Schedule::RESOURCE_NAME); + $response->assertJsonPath($prefix . 'attributes.relationships.tasks.data.0.object', Task::RESOURCE_NAME); - $this->assertJsonTransformedWith($response->json($prefix.'attributes'), $schedule); - $this->assertJsonTransformedWith($response->json($prefix.'attributes.relationships.tasks.data.0.attributes'), $task); + $this->assertJsonTransformedWith($response->json($prefix . 'attributes'), $schedule); + $this->assertJsonTransformedWith($response->json($prefix . 'attributes.relationships.tasks.data.0.attributes'), $task); } /** diff --git a/tests/Integration/Api/Client/Server/Schedule/ScheduleAuthorizationTest.php b/tests/Integration/Api/Client/Server/Schedule/ScheduleAuthorizationTest.php index 011187e71d..b6777a7488 100644 --- a/tests/Integration/Api/Client/Server/Schedule/ScheduleAuthorizationTest.php +++ b/tests/Integration/Api/Client/Server/Schedule/ScheduleAuthorizationTest.php @@ -38,20 +38,20 @@ public function testAccessToAServersSchedulesIsRestrictedProperly(string $method // This is the only valid call for this test, accessing the schedule for the same // server that the API user is the owner of. - $response = $this->actingAs($user)->json($method, $this->link($server1, '/schedules/'.$schedule1->id.$endpoint)); + $response = $this->actingAs($user)->json($method, $this->link($server1, '/schedules/' . $schedule1->id . $endpoint)); $this->assertTrue($response->status() <= 204 || $response->status() === 400 || $response->status() === 422); // This request fails because the schedule is valid for that server but the user // making the request is not authorized to perform that action. - $this->actingAs($user)->json($method, $this->link($server2, '/schedules/'.$schedule2->id.$endpoint))->assertForbidden(); + $this->actingAs($user)->json($method, $this->link($server2, '/schedules/' . $schedule2->id . $endpoint))->assertForbidden(); // Both of these should report a 404 error due to the schedules being linked to // servers that are not the same as the server in the request, or are assigned // to a server for which the user making the request has no access to. - $this->actingAs($user)->json($method, $this->link($server1, '/schedules/'.$schedule2->id.$endpoint))->assertNotFound(); - $this->actingAs($user)->json($method, $this->link($server1, '/schedules/'.$schedule3->id.$endpoint))->assertNotFound(); - $this->actingAs($user)->json($method, $this->link($server2, '/schedules/'.$schedule3->id.$endpoint))->assertNotFound(); - $this->actingAs($user)->json($method, $this->link($server3, '/schedules/'.$schedule3->id.$endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server1, '/schedules/' . $schedule2->id . $endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server1, '/schedules/' . $schedule3->id . $endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server2, '/schedules/' . $schedule3->id . $endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server3, '/schedules/' . $schedule3->id . $endpoint))->assertNotFound(); } public static function methodDataProvider(): array diff --git a/tests/Integration/Api/Client/Server/Startup/GetStartupAndVariablesTest.php b/tests/Integration/Api/Client/Server/Startup/GetStartupAndVariablesTest.php index b11d06346c..88cc6ed6f2 100644 --- a/tests/Integration/Api/Client/Server/Startup/GetStartupAndVariablesTest.php +++ b/tests/Integration/Api/Client/Server/Startup/GetStartupAndVariablesTest.php @@ -33,7 +33,7 @@ public function testStartupVariablesAreReturnedForServer(array $permissions): vo ])->save(); $server = $server->refresh(); - $response = $this->actingAs($user)->getJson($this->link($server).'/startup'); + $response = $this->actingAs($user)->getJson($this->link($server) . '/startup'); $response->assertOk(); $response->assertJsonPath('meta.startup_command', 'java bungeecord.jar --version [hidden]'); @@ -52,10 +52,10 @@ public function testStartupVariablesAreReturnedForServer(array $permissions): vo public function testStartupDataIsNotReturnedWithoutPermission(): void { [$user, $server] = $this->generateTestAccount([Permission::ACTION_WEBSOCKET_CONNECT]); - $this->actingAs($user)->getJson($this->link($server).'/startup')->assertForbidden(); + $this->actingAs($user)->getJson($this->link($server) . '/startup')->assertForbidden(); $user2 = User::factory()->create(); - $this->actingAs($user2)->getJson($this->link($server).'/startup')->assertNotFound(); + $this->actingAs($user2)->getJson($this->link($server) . '/startup')->assertNotFound(); } public static function permissionsDataProvider(): array diff --git a/tests/Integration/Api/Client/Server/Startup/UpdateStartupVariableTest.php b/tests/Integration/Api/Client/Server/Startup/UpdateStartupVariableTest.php index c5471ec11f..e9c8af97ce 100644 --- a/tests/Integration/Api/Client/Server/Startup/UpdateStartupVariableTest.php +++ b/tests/Integration/Api/Client/Server/Startup/UpdateStartupVariableTest.php @@ -23,7 +23,7 @@ public function testStartupVariableCanBeUpdated(array $permissions): void 'startup' => 'java {{SERVER_JARFILE}} --version {{BUNGEE_VERSION}}', ])->save(); - $response = $this->actingAs($user)->putJson($this->link($server).'/startup/variable', [ + $response = $this->actingAs($user)->putJson($this->link($server) . '/startup/variable', [ 'key' => 'BUNGEE_VERSION', 'value' => '1.2.3', ]); @@ -32,7 +32,7 @@ public function testStartupVariableCanBeUpdated(array $permissions): void $response->assertJsonPath('errors.0.code', 'ValidationException'); $response->assertJsonPath('errors.0.detail', 'The value may only contain letters and numbers.'); - $response = $this->actingAs($user)->putJson($this->link($server).'/startup/variable', [ + $response = $this->actingAs($user)->putJson($this->link($server) . '/startup/variable', [ 'key' => 'BUNGEE_VERSION', 'value' => '123', ]); @@ -62,7 +62,7 @@ public function testStartupVariableCannotBeUpdatedIfNotUserViewableOrEditable(ar $server->fill(['egg_id' => $egg->id])->save(); $server->refresh(); - $response = $this->actingAs($user)->putJson($this->link($server).'/startup/variable', [ + $response = $this->actingAs($user)->putJson($this->link($server) . '/startup/variable', [ 'key' => 'BUNGEE_VERSION', 'value' => '123', ]); @@ -71,7 +71,7 @@ public function testStartupVariableCannotBeUpdatedIfNotUserViewableOrEditable(ar $response->assertJsonPath('errors.0.code', 'BadRequestHttpException'); $response->assertJsonPath('errors.0.detail', 'The environment variable you are trying to edit does not exist.'); - $response = $this->actingAs($user)->putJson($this->link($server).'/startup/variable', [ + $response = $this->actingAs($user)->putJson($this->link($server) . '/startup/variable', [ 'key' => 'SERVER_JARFILE', 'value' => 'server2.jar', ]); @@ -100,7 +100,7 @@ public function testHiddenVariablesAreNotReturnedInStartupCommandWhenUpdatingVar $server->refresh(); - $response = $this->actingAs($user)->putJson($this->link($server).'/startup/variable', [ + $response = $this->actingAs($user)->putJson($this->link($server) . '/startup/variable', [ 'key' => 'SERVER_JARFILE', 'value' => 'server2.jar', ]); @@ -125,7 +125,7 @@ public function testEggVariableWithNullableStringIsNotRequired(): void $server->fill(['egg_id' => $egg->id])->save(); $server->refresh(); - $response = $this->actingAs($user)->putJson($this->link($server).'/startup/variable', [ + $response = $this->actingAs($user)->putJson($this->link($server) . '/startup/variable', [ 'key' => 'BUNGEE_VERSION', 'value' => '', ]); @@ -141,10 +141,10 @@ public function testEggVariableWithNullableStringIsNotRequired(): void public function testStartupVariableCannotBeUpdatedIfNotUserViewable(): void { [$user, $server] = $this->generateTestAccount([Permission::ACTION_WEBSOCKET_CONNECT]); - $this->actingAs($user)->putJson($this->link($server).'/startup/variable')->assertForbidden(); + $this->actingAs($user)->putJson($this->link($server) . '/startup/variable')->assertForbidden(); $user2 = User::factory()->create(); - $this->actingAs($user2)->putJson($this->link($server).'/startup/variable')->assertNotFound(); + $this->actingAs($user2)->putJson($this->link($server) . '/startup/variable')->assertNotFound(); } public static function permissionsDataProvider(): array diff --git a/tests/Integration/Api/Client/Server/Subuser/CreateServerSubuserTest.php b/tests/Integration/Api/Client/Server/Subuser/CreateServerSubuserTest.php index f9c6595f40..7175a7cc73 100644 --- a/tests/Integration/Api/Client/Server/Subuser/CreateServerSubuserTest.php +++ b/tests/Integration/Api/Client/Server/Subuser/CreateServerSubuserTest.php @@ -23,7 +23,7 @@ public function testSubuserCanBeCreated(array $permissions): void { [$user, $server] = $this->generateTestAccount($permissions); - $response = $this->actingAs($user)->postJson($this->link($server).'/users', [ + $response = $this->actingAs($user)->postJson($this->link($server) . '/users', [ 'email' => $email = $this->faker->email(), 'permissions' => [ Permission::ACTION_USER_CREATE, @@ -60,7 +60,7 @@ public function testErrorIsReturnedIfAssigningPermissionsNotAssignedToSelf(): vo Permission::ACTION_CONTROL_CONSOLE, ]); - $response = $this->actingAs($user)->postJson($this->link($server).'/users', [ + $response = $this->actingAs($user)->postJson($this->link($server) . '/users', [ 'email' => $this->faker->email(), 'permissions' => [ Permission::ACTION_USER_CREATE, @@ -80,9 +80,9 @@ public function testSubuserWithExcessivelyLongEmailCannotBeCreated(): void { [$user, $server] = $this->generateTestAccount(); - $email = str_repeat(Str::random(35), 7).'@gmail.com'; // 255 is the hard limit for the column in MySQL. + $email = str_repeat(Str::random(35), 7) . '@gmail.com'; // 255 is the hard limit for the column in MySQL. - $response = $this->actingAs($user)->postJson($this->link($server).'/users', [ + $response = $this->actingAs($user)->postJson($this->link($server) . '/users', [ 'email' => $email, 'permissions' => [ Permission::ACTION_USER_CREATE, @@ -91,8 +91,8 @@ public function testSubuserWithExcessivelyLongEmailCannotBeCreated(): void $response->assertOk(); - $response = $this->actingAs($user)->postJson($this->link($server).'/users', [ - 'email' => $email.'.au', + $response = $this->actingAs($user)->postJson($this->link($server) . '/users', [ + 'email' => $email . '.au', 'permissions' => [ Permission::ACTION_USER_CREATE, ], @@ -114,7 +114,7 @@ public function testCreatingSubuserWithSameEmailAsExistingUserWorks(): void /** @var \App\Models\User $existing */ $existing = User::factory()->create(['email' => $this->faker->email()]); - $response = $this->actingAs($user)->postJson($this->link($server).'/users', [ + $response = $this->actingAs($user)->postJson($this->link($server) . '/users', [ 'email' => $existing->email, 'permissions' => [ Permission::ACTION_USER_CREATE, @@ -134,7 +134,7 @@ public function testAddingSubuserThatAlreadyIsAssignedReturnsError(): void { [$user, $server] = $this->generateTestAccount(); - $response = $this->actingAs($user)->postJson($this->link($server).'/users', [ + $response = $this->actingAs($user)->postJson($this->link($server) . '/users', [ 'email' => $email = $this->faker->email(), 'permissions' => [ Permission::ACTION_USER_CREATE, @@ -143,7 +143,7 @@ public function testAddingSubuserThatAlreadyIsAssignedReturnsError(): void $response->assertOk(); - $response = $this->actingAs($user)->postJson($this->link($server).'/users', [ + $response = $this->actingAs($user)->postJson($this->link($server) . '/users', [ 'email' => $email, 'permissions' => [ Permission::ACTION_USER_CREATE, diff --git a/tests/Integration/Api/Client/Server/Subuser/DeleteSubuserTest.php b/tests/Integration/Api/Client/Server/Subuser/DeleteSubuserTest.php index 21067ad1be..bbd97f4b3d 100644 --- a/tests/Integration/Api/Client/Server/Subuser/DeleteSubuserTest.php +++ b/tests/Integration/Api/Client/Server/Subuser/DeleteSubuserTest.php @@ -31,7 +31,7 @@ public function testCorrectSubuserIsDeletedFromServer(): void $real = Uuid::uuid4()->toString(); // Generate a UUID that lines up with a user in the database if it were to be cast to an int. - $uuid = $differentUser->id.substr($real, strlen((string) $differentUser->id)); + $uuid = $differentUser->id . substr($real, strlen((string) $differentUser->id)); /** @var \App\Models\User $subuser */ $subuser = User::factory()->create(['uuid' => $uuid]); @@ -44,11 +44,11 @@ public function testCorrectSubuserIsDeletedFromServer(): void $mock->expects('setServer->revokeUserJTI')->with($subuser->id)->andReturnUndefined(); - $this->actingAs($user)->deleteJson($this->link($server)."/users/$subuser->uuid")->assertNoContent(); + $this->actingAs($user)->deleteJson($this->link($server) . "/users/$subuser->uuid")->assertNoContent(); // Try the same test, but this time with a UUID that if cast to an int (shouldn't) line up with // anything in the database. - $uuid = '18180000'.substr(Uuid::uuid4()->toString(), 8); + $uuid = '18180000' . substr(Uuid::uuid4()->toString(), 8); /** @var \App\Models\User $subuser */ $subuser = User::factory()->create(['uuid' => $uuid]); @@ -60,6 +60,6 @@ public function testCorrectSubuserIsDeletedFromServer(): void $mock->expects('setServer->revokeUserJTI')->with($subuser->id)->andReturnUndefined(); - $this->actingAs($user)->deleteJson($this->link($server)."/users/$subuser->uuid")->assertNoContent(); + $this->actingAs($user)->deleteJson($this->link($server) . "/users/$subuser->uuid")->assertNoContent(); } } diff --git a/tests/Integration/Api/Client/Server/Subuser/SubuserAuthorizationTest.php b/tests/Integration/Api/Client/Server/Subuser/SubuserAuthorizationTest.php index 03bd42ee96..ab844d0b3b 100644 --- a/tests/Integration/Api/Client/Server/Subuser/SubuserAuthorizationTest.php +++ b/tests/Integration/Api/Client/Server/Subuser/SubuserAuthorizationTest.php @@ -41,12 +41,12 @@ public function testUserCannotAccessResourceBelongingToOtherServers(string $meth } // This route is acceptable since they're accessing a subuser on their own server. - $this->actingAs($user)->json($method, $this->link($server1, '/users/'.$internal->uuid))->assertStatus($method === 'POST' ? 422 : ($method === 'DELETE' ? 204 : 200)); + $this->actingAs($user)->json($method, $this->link($server1, '/users/' . $internal->uuid))->assertStatus($method === 'POST' ? 422 : ($method === 'DELETE' ? 204 : 200)); // This route can be revealed since the subuser belongs to the correct server, but // errors out with a 403 since $user does not have the right permissions for this. - $this->actingAs($user)->json($method, $this->link($server2, '/users/'.$internal->uuid))->assertForbidden(); - $this->actingAs($user)->json($method, $this->link($server3, '/users/'.$internal->uuid))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server2, '/users/' . $internal->uuid))->assertForbidden(); + $this->actingAs($user)->json($method, $this->link($server3, '/users/' . $internal->uuid))->assertNotFound(); } public static function methodDataProvider(): array diff --git a/tests/Integration/Api/Daemon/DaemonAuthenticateTest.php b/tests/Integration/Api/Daemon/DaemonAuthenticateTest.php index 1dde922845..b18b3e5e81 100644 --- a/tests/Integration/Api/Daemon/DaemonAuthenticateTest.php +++ b/tests/Integration/Api/Daemon/DaemonAuthenticateTest.php @@ -69,7 +69,7 @@ public function testResponseShouldFailIfTokenIsNotValid(): void $this->expectException(AccessDeniedHttpException::class); $this->request->expects('route->getName')->withNoArgs()->andReturn('random.route'); - $this->request->expects('bearerToken')->withNoArgs()->andReturn($node->daemon_token_id.'.random_string_123'); + $this->request->expects('bearerToken')->withNoArgs()->andReturn($node->daemon_token_id . '.random_string_123'); $this->getMiddleware()->handle($this->request, $this->getClosureAssertions()); } @@ -98,7 +98,7 @@ public function testSuccessfulMiddlewareProcess(): void $node->save(); $this->request->expects('route->getName')->withNoArgs()->andReturn('random.route'); - $this->request->expects('bearerToken')->withNoArgs()->andReturn($node->daemon_token_id.'.the_same'); + $this->request->expects('bearerToken')->withNoArgs()->andReturn($node->daemon_token_id . '.the_same'); $this->getMiddleware()->handle($this->request, $this->getClosureAssertions()); $this->assertRequestHasAttribute('node'); diff --git a/tests/Integration/Api/Remote/SftpAuthenticationControllerTest.php b/tests/Integration/Api/Remote/SftpAuthenticationControllerTest.php index da340cbb4f..3236266dcd 100644 --- a/tests/Integration/Api/Remote/SftpAuthenticationControllerTest.php +++ b/tests/Integration/Api/Remote/SftpAuthenticationControllerTest.php @@ -143,7 +143,7 @@ public function testRequestIsDeniedIfUserLacksSftpPermission(): void $this->setAuthorization($server->node); $this->postJson('/api/remote/sftp/auth', [ - 'username' => $user->username.'.'.$server->uuid_short, + 'username' => $user->username . '.' . $server->uuid_short, 'password' => 'foobar', ]) ->assertForbidden() @@ -173,7 +173,7 @@ public function testUserPermissionsAreReturnedCorrectly(): void $this->setAuthorization($server->node); $data = [ - 'username' => $user->username.'.'.$server->uuid_short, + 'username' => $user->username . '.' . $server->uuid_short, 'password' => 'foobar', ]; @@ -188,7 +188,7 @@ public function testUserPermissionsAreReturnedCorrectly(): void ->assertJsonPath('permissions.0', '*'); $this->setAuthorization(); - $data['username'] = $user->username.'.'.$this->server->uuid_short; + $data['username'] = $user->username . '.' . $this->server->uuid_short; $this->post('/api/remote/sftp/auth', $data) ->assertOk() @@ -220,7 +220,7 @@ public static function serverStateDataProvider(): array */ protected function getUsername(bool $long = false): string { - return $this->user->username.'.'.($long ? $this->server->uuid : $this->server->uuid_short); + return $this->user->username . '.' . ($long ? $this->server->uuid : $this->server->uuid_short); } /** @@ -230,6 +230,6 @@ protected function setAuthorization(?Node $node = null): void { $node = $node ?? $this->server->node; - $this->withHeader('Authorization', 'Bearer '.$node->daemon_token_id.'.'.$node->daemon_token); + $this->withHeader('Authorization', 'Bearer ' . $node->daemon_token_id . '.' . $node->daemon_token); } } diff --git a/tests/Integration/Http/Controllers/Admin/UserControllerTest.php b/tests/Integration/Http/Controllers/Admin/UserControllerTest.php index b82aa61aba..cbd263501e 100644 --- a/tests/Integration/Http/Controllers/Admin/UserControllerTest.php +++ b/tests/Integration/Http/Controllers/Admin/UserControllerTest.php @@ -21,8 +21,8 @@ public function testIndexReturnsExpectedData(): void { $unique = Str::random(); $users = [ - User::factory()->create(['username' => $unique.'_1']), - User::factory()->create(['username' => $unique.'_2']), + User::factory()->create(['username' => $unique . '_1']), + User::factory()->create(['username' => $unique . '_2']), ]; $servers = [ @@ -38,7 +38,7 @@ public function testIndexReturnsExpectedData(): void /** @var \App\Http\Controllers\Admin\UserController $controller */ $controller = $this->app->make(UserController::class); - $request = Request::create('/admin/users?filter[username]='.$unique); + $request = Request::create('/admin/users?filter[username]=' . $unique); $this->app->instance(Request::class, $request); $data = $controller->index($request)->getData(); diff --git a/tests/Integration/Services/Databases/DatabaseManagementServiceTest.php b/tests/Integration/Services/Databases/DatabaseManagementServiceTest.php index 1584c20006..060ed9f10f 100644 --- a/tests/Integration/Services/Databases/DatabaseManagementServiceTest.php +++ b/tests/Integration/Services/Databases/DatabaseManagementServiceTest.php @@ -29,7 +29,7 @@ public function testUniqueDatabaseNameIsGeneratedCorrectly(): void { $this->assertSame('s1_example', DatabaseManagementService::generateUniqueDatabaseName('example', 1)); $this->assertSame('s123_something_else', DatabaseManagementService::generateUniqueDatabaseName('something_else', 123)); - $this->assertSame('s123_'.str_repeat('a', 43), DatabaseManagementService::generateUniqueDatabaseName(str_repeat('a', 100), 123)); + $this->assertSame('s123_' . str_repeat('a', 43), DatabaseManagementService::generateUniqueDatabaseName(str_repeat('a', 100), 123)); } /** diff --git a/tests/Traits/Http/RequestMockHelpers.php b/tests/Traits/Http/RequestMockHelpers.php index d4da1bb238..46a71e26a7 100644 --- a/tests/Traits/Http/RequestMockHelpers.php +++ b/tests/Traits/Http/RequestMockHelpers.php @@ -68,7 +68,7 @@ protected function buildRequestMock(): void { $this->request = m::mock($this->requestMockClass); if (!$this->request instanceof Request) { - throw new \InvalidArgumentException('Request mock class must be an instance of '.Request::class.' when mocked.'); + throw new \InvalidArgumentException('Request mock class must be an instance of ' . Request::class . ' when mocked.'); } $this->request->attributes = new ParameterBag(); diff --git a/tests/Traits/MocksUuids.php b/tests/Traits/MocksUuids.php index 8b6d2b0a82..8cfa4b7ce4 100644 --- a/tests/Traits/MocksUuids.php +++ b/tests/Traits/MocksUuids.php @@ -19,7 +19,7 @@ trait MocksUuids public function setKnownUuidFactory(): void { $uuid = Uuid::fromString($this->getKnownUuid()); - $factoryMock = m::mock(UuidFactory::class.'[uuid4]', [ + $factoryMock = m::mock(UuidFactory::class . '[uuid4]', [ 'uuid4' => $uuid, ]); From 38be89a71e6b0251a34d536ea4bbaec025171dcd Mon Sep 17 00:00:00 2001 From: Lance Pioch Date: Sat, 19 Oct 2024 21:16:33 -0400 Subject: [PATCH 20/33] Pint --- .../Resources/DatabaseHostResource/Pages/EditDatabaseHost.php | 2 +- app/Filament/Resources/UserResource/Pages/EditProfile.php | 2 +- app/Http/Controllers/Auth/ForgotPasswordController.php | 2 -- app/Models/ActivityLogSubject.php | 1 - tests/Integration/IntegrationTestCase.php | 2 -- 5 files changed, 2 insertions(+), 7 deletions(-) diff --git a/app/Filament/Resources/DatabaseHostResource/Pages/EditDatabaseHost.php b/app/Filament/Resources/DatabaseHostResource/Pages/EditDatabaseHost.php index 8951cff8b7..52688b3891 100644 --- a/app/Filament/Resources/DatabaseHostResource/Pages/EditDatabaseHost.php +++ b/app/Filament/Resources/DatabaseHostResource/Pages/EditDatabaseHost.php @@ -101,7 +101,7 @@ public function getRelationManagers(): array protected function handleRecordUpdate(Model $record, array $data): Model { - if (! $record instanceof DatabaseHost) { + if (!$record instanceof DatabaseHost) { return $record; } diff --git a/app/Filament/Resources/UserResource/Pages/EditProfile.php b/app/Filament/Resources/UserResource/Pages/EditProfile.php index 9b22e88ee5..c7f5d6da6d 100644 --- a/app/Filament/Resources/UserResource/Pages/EditProfile.php +++ b/app/Filament/Resources/UserResource/Pages/EditProfile.php @@ -278,7 +278,7 @@ protected function getForms(): array protected function handleRecordUpdate(Model $record, array $data): Model { - if (! $record instanceof User) { + if (!$record instanceof User) { return $record; } diff --git a/app/Http/Controllers/Auth/ForgotPasswordController.php b/app/Http/Controllers/Auth/ForgotPasswordController.php index 32a7049fce..f58aded823 100644 --- a/app/Http/Controllers/Auth/ForgotPasswordController.php +++ b/app/Http/Controllers/Auth/ForgotPasswordController.php @@ -28,8 +28,6 @@ protected function sendResetLinkFailedResponse(Request $request, string $respons /** * Get the response for a successful password reset link. - * - * @param string $response */ protected function sendResetLinkResponse(Request $request, string $response): JsonResponse { diff --git a/app/Models/ActivityLogSubject.php b/app/Models/ActivityLogSubject.php index 9e4e2777b8..92aa3d4559 100644 --- a/app/Models/ActivityLogSubject.php +++ b/app/Models/ActivityLogSubject.php @@ -5,7 +5,6 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\MorphTo; use Illuminate\Database\Eloquent\Relations\Pivot; -use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletingScope; /** diff --git a/tests/Integration/IntegrationTestCase.php b/tests/Integration/IntegrationTestCase.php index c608e2a8ea..0a588e81e1 100644 --- a/tests/Integration/IntegrationTestCase.php +++ b/tests/Integration/IntegrationTestCase.php @@ -40,8 +40,6 @@ protected function formatTimestamp(string $timestamp): string /** * The database connections that should have transactions. - * - * @return array */ protected function connectionsToTransact(): array { From bb5955cff421d83bb5cdf3ff832f88c6a2ba3428 Mon Sep 17 00:00:00 2001 From: Lance Pioch Date: Sat, 19 Oct 2024 21:19:59 -0400 Subject: [PATCH 21/33] Have to make this match the trait --- tests/Integration/IntegrationTestCase.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/Integration/IntegrationTestCase.php b/tests/Integration/IntegrationTestCase.php index 0a588e81e1..b496eeaa0d 100644 --- a/tests/Integration/IntegrationTestCase.php +++ b/tests/Integration/IntegrationTestCase.php @@ -40,8 +40,10 @@ protected function formatTimestamp(string $timestamp): string /** * The database connections that should have transactions. + * + * @return array */ - protected function connectionsToTransact(): array + protected function connectionsToTransact() { return [DB::getDriverName()]; } From 71aed151d9715f55003227c25a675e74a7fba9b3 Mon Sep 17 00:00:00 2001 From: Lance Pioch Date: Sat, 19 Oct 2024 22:11:24 -0400 Subject: [PATCH 22/33] Redirect to configuration file tab after creating the node --- app/Filament/Resources/NodeResource/Pages/CreateNode.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Filament/Resources/NodeResource/Pages/CreateNode.php b/app/Filament/Resources/NodeResource/Pages/CreateNode.php index 10fc403280..c8d9bbc30a 100644 --- a/app/Filament/Resources/NodeResource/Pages/CreateNode.php +++ b/app/Filament/Resources/NodeResource/Pages/CreateNode.php @@ -398,7 +398,7 @@ public function form(Forms\Form $form): Forms\Form protected function getRedirectUrlParameters(): array { return [ - 'tab' => '-configuration-tab', + 'tab' => '-configuration-file-tab', ]; } From 6a8e630444d40d0d97dda9de58f87cd3b89625cc Mon Sep 17 00:00:00 2001 From: Lance Pioch Date: Sat, 19 Oct 2024 22:16:55 -0400 Subject: [PATCH 23/33] Redirect to Admin Panel Dashboard after installer finishes --- app/Filament/Pages/Installer/PanelInstaller.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Filament/Pages/Installer/PanelInstaller.php b/app/Filament/Pages/Installer/PanelInstaller.php index 55da7add71..e64d158a2a 100644 --- a/app/Filament/Pages/Installer/PanelInstaller.php +++ b/app/Filament/Pages/Installer/PanelInstaller.php @@ -2,6 +2,7 @@ namespace App\Filament\Pages\Installer; +use App\Filament\Pages\Dashboard; use App\Filament\Pages\Installer\Steps\AdminUserStep; use App\Filament\Pages\Installer\Steps\CompletedStep; use App\Filament\Pages\Installer\Steps\DatabaseStep; @@ -13,7 +14,6 @@ use App\Traits\CheckMigrationsTrait; use App\Traits\EnvironmentWriterTrait; use Exception; -use Filament\Facades\Filament; use Filament\Forms\Components\Actions\Action; use Filament\Forms\Components\Wizard; use Filament\Forms\Concerns\InteractsWithForms; @@ -103,7 +103,7 @@ public function submit() auth()->guard()->login($this->user, true); // Redirect to admin panel - return redirect(Filament::getPanel('admin')->getUrl()); + return redirect(Dashboard::getUrl()); } public function writeToEnv(string $key): void From e162374e156d5e77499aeeddcdaed0d73853edf1 Mon Sep 17 00:00:00 2001 From: Lance Pioch Date: Sun, 20 Oct 2024 11:41:46 -0400 Subject: [PATCH 24/33] Add return types --- .../Resources/DatabaseHostResource/Pages/CreateDatabaseHost.php | 2 +- .../Resources/DatabaseHostResource/Pages/EditDatabaseHost.php | 2 +- app/Filament/Resources/ServerResource/Pages/CreateServer.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Filament/Resources/DatabaseHostResource/Pages/CreateDatabaseHost.php b/app/Filament/Resources/DatabaseHostResource/Pages/CreateDatabaseHost.php index 682c96b1f5..606b9ca82b 100644 --- a/app/Filament/Resources/DatabaseHostResource/Pages/CreateDatabaseHost.php +++ b/app/Filament/Resources/DatabaseHostResource/Pages/CreateDatabaseHost.php @@ -28,7 +28,7 @@ class CreateDatabaseHost extends CreateRecord protected ?string $subheading = '(database servers that can have individual databases)'; - public function boot(HostCreationService $service) + public function boot(HostCreationService $service): void { $this->service = $service; } diff --git a/app/Filament/Resources/DatabaseHostResource/Pages/EditDatabaseHost.php b/app/Filament/Resources/DatabaseHostResource/Pages/EditDatabaseHost.php index 5ca3cb5c59..5d0176699a 100644 --- a/app/Filament/Resources/DatabaseHostResource/Pages/EditDatabaseHost.php +++ b/app/Filament/Resources/DatabaseHostResource/Pages/EditDatabaseHost.php @@ -25,7 +25,7 @@ class EditDatabaseHost extends EditRecord private HostUpdateService $hostUpdateService; - public function boot(HostUpdateService $hostUpdateService) + public function boot(HostUpdateService $hostUpdateService): void { $this->hostUpdateService = $hostUpdateService; } diff --git a/app/Filament/Resources/ServerResource/Pages/CreateServer.php b/app/Filament/Resources/ServerResource/Pages/CreateServer.php index c914f1201c..df9d3b0332 100644 --- a/app/Filament/Resources/ServerResource/Pages/CreateServer.php +++ b/app/Filament/Resources/ServerResource/Pages/CreateServer.php @@ -51,7 +51,7 @@ class CreateServer extends CreateRecord private ServerCreationService $serverCreationService; - public function boot(ServerCreationService $serverCreationService) + public function boot(ServerCreationService $serverCreationService): void { $this->serverCreationService = $serverCreationService; } From c621d2dad51f4c2051c83db25a71982de719c266 Mon Sep 17 00:00:00 2001 From: Lance Pioch Date: Sun, 20 Oct 2024 11:55:47 -0400 Subject: [PATCH 25/33] Remove superfluous doc block --- app/Http/Controllers/Auth/ForgotPasswordController.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/Http/Controllers/Auth/ForgotPasswordController.php b/app/Http/Controllers/Auth/ForgotPasswordController.php index 26f5376404..f58aded823 100644 --- a/app/Http/Controllers/Auth/ForgotPasswordController.php +++ b/app/Http/Controllers/Auth/ForgotPasswordController.php @@ -28,8 +28,6 @@ protected function sendResetLinkFailedResponse(Request $request, string $respons /** * Get the response for a successful password reset link. - * - * @param string $response */ protected function sendResetLinkResponse(Request $request, string $response): JsonResponse { From bcbacb47cdcc20ae6a77189882dc17b3744dd594 Mon Sep 17 00:00:00 2001 From: Lance Pioch Date: Sun, 20 Oct 2024 14:20:32 -0400 Subject: [PATCH 26/33] Fix #606 - Prevent database hosts bulk selection if host has any databases (#640) * Prevent hosts with databases from being selected for bulk actions * Add icons * Update input to select * Update app/Filament/Resources/DatabaseHostResource/Pages/ListDatabaseHosts.php * Add placeholder --- .../DatabaseHostResource/Pages/ListDatabaseHosts.php | 11 +++++++---- .../DatabaseResource/Pages/CreateDatabase.php | 9 ++++++--- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/app/Filament/Resources/DatabaseHostResource/Pages/ListDatabaseHosts.php b/app/Filament/Resources/DatabaseHostResource/Pages/ListDatabaseHosts.php index 384f9cda63..c5db9ea855 100644 --- a/app/Filament/Resources/DatabaseHostResource/Pages/ListDatabaseHosts.php +++ b/app/Filament/Resources/DatabaseHostResource/Pages/ListDatabaseHosts.php @@ -32,13 +32,16 @@ public function table(Table $table): Table ->sortable(), TextColumn::make('username') ->searchable(), - TextColumn::make('max_databases') - ->numeric() - ->sortable(), + TextColumn::make('databases_count') + ->counts('databases') + ->icon('tabler-database') + ->label('Databases'), TextColumn::make('node.name') - ->numeric() + ->icon('tabler-server-2') + ->placeholder('No Nodes') ->sortable(), ]) + ->checkIfRecordIsSelectableUsing(fn (DatabaseHost $databaseHost) => !$databaseHost->databases_count) ->actions([ EditAction::make(), ]) diff --git a/app/Filament/Resources/DatabaseResource/Pages/CreateDatabase.php b/app/Filament/Resources/DatabaseResource/Pages/CreateDatabase.php index 0e85e0a6a0..71d57d3611 100644 --- a/app/Filament/Resources/DatabaseResource/Pages/CreateDatabase.php +++ b/app/Filament/Resources/DatabaseResource/Pages/CreateDatabase.php @@ -21,9 +21,12 @@ public function form(Form $form): Form ->searchable() ->preload() ->required(), - TextInput::make('database_host_id') - ->required() - ->numeric(), + Select::make('database_host_id') + ->relationship('host', 'name') + ->searchable() + ->selectablePlaceholder(false) + ->preload() + ->required(), TextInput::make('database') ->required() ->maxLength(255), From de002324d72aad71f99de97cdbd70d11e1435146 Mon Sep 17 00:00:00 2001 From: Lance Pioch Date: Mon, 21 Oct 2024 12:27:23 -0400 Subject: [PATCH 27/33] Deselect all table records when switching primary allocation (#645) --- .../RelationManagers/AllocationsRelationManager.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Filament/Resources/ServerResource/RelationManagers/AllocationsRelationManager.php b/app/Filament/Resources/ServerResource/RelationManagers/AllocationsRelationManager.php index aa6658b4d3..c43132b585 100644 --- a/app/Filament/Resources/ServerResource/RelationManagers/AllocationsRelationManager.php +++ b/app/Filament/Resources/ServerResource/RelationManagers/AllocationsRelationManager.php @@ -57,13 +57,13 @@ public function table(Table $table): Table true => 'warning', default => 'gray', }) - ->action(fn (Allocation $allocation) => $this->getOwnerRecord()->update(['allocation_id' => $allocation->id])) + ->action(fn (Allocation $allocation) => $this->getOwnerRecord()->update(['allocation_id' => $allocation->id]) && $this->deselectAllTableRecords()) ->default(fn (Allocation $allocation) => $allocation->id === $this->getOwnerRecord()->allocation_id) ->label('Primary'), ]) ->actions([ Action::make('make-primary') - ->action(fn (Allocation $allocation) => $this->getOwnerRecord()->update(['allocation_id' => $allocation->id])) + ->action(fn (Allocation $allocation) => $this->getOwnerRecord()->update(['allocation_id' => $allocation->id]) && $this->deselectAllTableRecords()) ->label(fn (Allocation $allocation) => $allocation->id === $this->getOwnerRecord()->allocation_id ? '' : 'Make Primary'), ]) ->headerActions([ From 3d5c8d14bd28a95e9d438479d6e1cd8991eb8d8a Mon Sep 17 00:00:00 2001 From: Boy132 Date: Mon, 21 Oct 2024 18:43:05 +0200 Subject: [PATCH 28/33] Add back `trustedproxy` config (#651) --- config/trustedproxy.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 config/trustedproxy.php diff --git a/config/trustedproxy.php b/config/trustedproxy.php new file mode 100644 index 0000000000..7e0166af8e --- /dev/null +++ b/config/trustedproxy.php @@ -0,0 +1,28 @@ +getClientIp() + * always gets the originating client IP, no matter + * how many proxies that client's request has + * subsequently passed through. + */ + 'proxies' => in_array(env('TRUSTED_PROXIES', []), ['*', '**']) ? + env('TRUSTED_PROXIES') : explode(',', env('TRUSTED_PROXIES') ?? ''), +]; From a193b4f5ab2b8d2e0a53dcbf81e84368956f1309 Mon Sep 17 00:00:00 2001 From: Boy132 Date: Mon, 21 Oct 2024 18:43:16 +0200 Subject: [PATCH 29/33] Installer: fix argument types for `testConnection` & return type for `submit` (#650) * fix argument types for `testConnection` * fix return type of submit --- app/Filament/Pages/Installer/PanelInstaller.php | 3 ++- app/Filament/Pages/Installer/Steps/DatabaseStep.php | 2 +- app/Filament/Pages/Installer/Steps/RedisStep.php | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/Filament/Pages/Installer/PanelInstaller.php b/app/Filament/Pages/Installer/PanelInstaller.php index 10bb32ccf8..fba27eade8 100644 --- a/app/Filament/Pages/Installer/PanelInstaller.php +++ b/app/Filament/Pages/Installer/PanelInstaller.php @@ -25,6 +25,7 @@ use Filament\Support\Enums\MaxWidth; use Filament\Support\Exceptions\Halt; use Illuminate\Http\RedirectResponse; +use Illuminate\Routing\Redirector; use Illuminate\Support\Facades\Artisan; use Illuminate\Support\Facades\Blade; use Illuminate\Support\HtmlString; @@ -94,7 +95,7 @@ protected function getFormStatePath(): ?string return 'data'; } - public function submit(): RedirectResponse + public function submit(): Redirector|RedirectResponse { // Disable installer $this->writeToEnvironment(['APP_INSTALLED' => 'true']); diff --git a/app/Filament/Pages/Installer/Steps/DatabaseStep.php b/app/Filament/Pages/Installer/Steps/DatabaseStep.php index 04803352da..3a4449777e 100644 --- a/app/Filament/Pages/Installer/Steps/DatabaseStep.php +++ b/app/Filament/Pages/Installer/Steps/DatabaseStep.php @@ -72,7 +72,7 @@ public static function make(PanelInstaller $installer): Step }); } - private static function testConnection(string $driver, string $host, string $port, string $database, string $username, string $password): bool + private static function testConnection(string $driver, ?string $host, null|string|int $port, ?string $database, ?string $username, ?string $password): bool { if ($driver === 'sqlite') { return true; diff --git a/app/Filament/Pages/Installer/Steps/RedisStep.php b/app/Filament/Pages/Installer/Steps/RedisStep.php index d160e0b700..2f257c4016 100644 --- a/app/Filament/Pages/Installer/Steps/RedisStep.php +++ b/app/Filament/Pages/Installer/Steps/RedisStep.php @@ -56,7 +56,7 @@ public static function make(PanelInstaller $installer): Step }); } - private static function testConnection(string $host, string $port, string $username, string $password): bool + private static function testConnection(string $host, null|string|int $port, ?string $username, ?string $password): bool { try { config()->set('database.redis._panel_install_test', [ From 6655ccca6e8a17a068bca558127b971eeed506cd Mon Sep 17 00:00:00 2001 From: Fredrik Falk Date: Mon, 21 Oct 2024 18:46:42 +0200 Subject: [PATCH 30/33] Speed up docker start (#647) Starting the docker container is hampered due to setting `chown -R www-data:www-data /var/www/html/` on every start, causing it to traverse the entire directory which in our use case is very slow. This PR instead changes it to set permissions as part of the build process. Sidenote: Is `LE_EMAIL` supposed to be used in addition to `ADMIN_EMAIL`? --- .github/docker/entrypoint.sh | 2 +- Dockerfile | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/docker/entrypoint.sh b/.github/docker/entrypoint.sh index 9a801e2d94..ad1b359b64 100644 --- a/.github/docker/entrypoint.sh +++ b/.github/docker/entrypoint.sh @@ -58,7 +58,7 @@ else echo "Starting PHP-FPM only" fi -chown -R www-data:www-data . /pelican-data/.env /pelican-data/database +chown -R www-data:www-data /pelican-data/.env /pelican-data/database echo "Starting Supervisord" exec "$@" diff --git a/Dockerfile b/Dockerfile index c759649f16..3e2da64825 100644 --- a/Dockerfile +++ b/Dockerfile @@ -38,7 +38,8 @@ RUN touch .env RUN composer install --no-dev --optimize-autoloader # Set file permissions -RUN chmod -R 755 storage bootstrap/cache +RUN chmod -R 755 storage bootstrap/cache \ + && chown -R www-data:www-data ./ # Add scheduler to cron RUN echo "* * * * * php /var/www/html/artisan schedule:run >> /dev/null 2>&1" | crontab -u www-data - From 94420d06bebec1ae5ae7ccff138423fa9cff6e93 Mon Sep 17 00:00:00 2001 From: Boy132 Date: Tue, 22 Oct 2024 23:34:46 +0200 Subject: [PATCH 31/33] Add UI for cpu pinning (#652) * add ui for cpu pinning * create "advanced" section --- .../ServerResource/Pages/CreateServer.php | 42 ++++++++++++++++- .../ServerResource/Pages/EditServer.php | 46 ++++++++++++++++++- 2 files changed, 85 insertions(+), 3 deletions(-) diff --git a/app/Filament/Resources/ServerResource/Pages/CreateServer.php b/app/Filament/Resources/ServerResource/Pages/CreateServer.php index 99fd1d4337..6ad8c11c29 100644 --- a/app/Filament/Resources/ServerResource/Pages/CreateServer.php +++ b/app/Filament/Resources/ServerResource/Pages/CreateServer.php @@ -627,14 +627,24 @@ public function form(Form $form): Form ->minValue(0) ->helperText('100% equals one CPU core.'), ]), + ]), + Fieldset::make('Advanced Limits') + ->columnSpan(6) + ->columns([ + 'default' => 1, + 'sm' => 2, + 'md' => 3, + 'lg' => 3, + ]) + ->schema([ Grid::make() ->columns(4) ->columnSpanFull() ->schema([ ToggleButtons::make('swap_support') ->live() - ->label('Enable Swap Memory') + ->label('Swap Memory') ->inlineLabel() ->inline() ->columnSpan(2) @@ -681,6 +691,36 @@ public function form(Form $form): Form ->label('Block IO Proportion') ->default(500), + Grid::make() + ->columns(4) + ->columnSpanFull() + ->schema([ + ToggleButtons::make('cpu_pinning') + ->label('CPU Pinning')->inlineLabel()->inline() + ->default(false) + ->afterStateUpdated(fn (Set $set) => $set('threads', [])) + ->live() + ->options([ + false => 'Disabled', + true => 'Enabled', + ]) + ->colors([ + false => 'success', + true => 'warning', + ]) + ->columnSpan(2), + + TagsInput::make('threads') + ->dehydratedWhenHidden() + ->hidden(fn (Get $get) => !$get('cpu_pinning')) + ->label('Pinned Threads')->inlineLabel() + ->required() + ->columnSpan(2) + ->separator() + ->splitKeys([',']) + ->placeholder('Add pinned thread, e.g. 0 or 2-4'), + ]), + Grid::make() ->columns(4) ->columnSpanFull() diff --git a/app/Filament/Resources/ServerResource/Pages/EditServer.php b/app/Filament/Resources/ServerResource/Pages/EditServer.php index fe1be62764..8ce1c99804 100644 --- a/app/Filament/Resources/ServerResource/Pages/EditServer.php +++ b/app/Filament/Resources/ServerResource/Pages/EditServer.php @@ -24,10 +24,12 @@ use Filament\Forms\Components\CheckboxList; use Filament\Forms\Components\Fieldset; use Filament\Forms\Components\Grid; +use Filament\Forms\Components\Hidden; use Filament\Forms\Components\Repeater; use Filament\Forms\Components\Select; use Filament\Forms\Components\Tabs; use Filament\Forms\Components\Tabs\Tab; +use Filament\Forms\Components\TagsInput; use Filament\Forms\Components\Textarea; use Filament\Forms\Components\TextInput; use Filament\Forms\Components\ToggleButtons; @@ -263,14 +265,23 @@ public function form(Form $form): Form ->numeric() ->minValue(0), ]), + ]), + Fieldset::make('Advanced Limits') + ->columns([ + 'default' => 1, + 'sm' => 2, + 'md' => 3, + 'lg' => 3, + ]) + ->schema([ Grid::make() ->columns(4) ->columnSpanFull() ->schema([ ToggleButtons::make('swap_support') ->live() - ->label('Enable Swap Memory')->inlineLabel()->inline() + ->label('Swap Memory')->inlineLabel()->inline() ->columnSpan(2) ->afterStateUpdated(function ($state, Set $set) { $value = match ($state) { @@ -315,10 +326,41 @@ public function form(Form $form): Form ->integer(), ]), - Forms\Components\Hidden::make('io') + Hidden::make('io') ->helperText('The IO performance relative to other running containers') ->label('Block IO Proportion'), + Grid::make() + ->columns(4) + ->columnSpanFull() + ->schema([ + ToggleButtons::make('cpu_pinning') + ->label('CPU Pinning')->inlineLabel()->inline() + ->default(false) + ->afterStateUpdated(fn (Set $set) => $set('threads', [])) + ->formatStateUsing(fn (Get $get) => !empty($get('threads'))) + ->live() + ->options([ + false => 'Disabled', + true => 'Enabled', + ]) + ->colors([ + false => 'success', + true => 'warning', + ]) + ->columnSpan(2), + + TagsInput::make('threads') + ->dehydratedWhenHidden() + ->hidden(fn (Get $get) => !$get('cpu_pinning')) + ->label('Pinned Threads')->inlineLabel() + ->required() + ->columnSpan(2) + ->separator() + ->splitKeys([',']) + ->placeholder('Add pinned thread, e.g. 0 or 2-4'), + ]), + Grid::make() ->columns(4) ->columnSpanFull() From 60792c05c2b6c313dc36e7de3707919b2508fdff Mon Sep 17 00:00:00 2001 From: Boy132 Date: Wed, 23 Oct 2024 12:50:09 +0200 Subject: [PATCH 32/33] Fix `required` for pinned threads input (#656) --- app/Filament/Resources/ServerResource/Pages/CreateServer.php | 2 +- app/Filament/Resources/ServerResource/Pages/EditServer.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Filament/Resources/ServerResource/Pages/CreateServer.php b/app/Filament/Resources/ServerResource/Pages/CreateServer.php index 6ad8c11c29..c5a5997177 100644 --- a/app/Filament/Resources/ServerResource/Pages/CreateServer.php +++ b/app/Filament/Resources/ServerResource/Pages/CreateServer.php @@ -714,7 +714,7 @@ public function form(Form $form): Form ->dehydratedWhenHidden() ->hidden(fn (Get $get) => !$get('cpu_pinning')) ->label('Pinned Threads')->inlineLabel() - ->required() + ->required(fn (Get $get) => $get('cpu_pinning')) ->columnSpan(2) ->separator() ->splitKeys([',']) diff --git a/app/Filament/Resources/ServerResource/Pages/EditServer.php b/app/Filament/Resources/ServerResource/Pages/EditServer.php index 8ce1c99804..5c0ff49185 100644 --- a/app/Filament/Resources/ServerResource/Pages/EditServer.php +++ b/app/Filament/Resources/ServerResource/Pages/EditServer.php @@ -354,7 +354,7 @@ public function form(Form $form): Form ->dehydratedWhenHidden() ->hidden(fn (Get $get) => !$get('cpu_pinning')) ->label('Pinned Threads')->inlineLabel() - ->required() + ->required(fn (Get $get) => $get('cpu_pinning')) ->columnSpan(2) ->separator() ->splitKeys([',']) From c53ef78d89bba4373a8ae8f8d6a4445af001d545 Mon Sep 17 00:00:00 2001 From: Boy132 Date: Wed, 23 Oct 2024 21:59:13 +0200 Subject: [PATCH 33/33] Make sure schedules run with UTC (#657) * make sure schedules use UTC for `next_run_at` * use function from Utilities --- .../Commands/Schedule/ProcessRunnableCommand.php | 3 +-- app/Helpers/Utilities.php | 2 +- app/Models/Schedule.php | 11 +++-------- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/app/Console/Commands/Schedule/ProcessRunnableCommand.php b/app/Console/Commands/Schedule/ProcessRunnableCommand.php index c11ade6c35..d773cb2b2f 100644 --- a/app/Console/Commands/Schedule/ProcessRunnableCommand.php +++ b/app/Console/Commands/Schedule/ProcessRunnableCommand.php @@ -6,7 +6,6 @@ use App\Models\Schedule; use Illuminate\Database\Eloquent\Builder; use App\Services\Schedules\ProcessScheduleService; -use Carbon\Carbon; class ProcessRunnableCommand extends Command { @@ -24,7 +23,7 @@ public function handle(): int ->whereRelation('server', fn (Builder $builder) => $builder->whereNull('status')) ->where('is_active', true) ->where('is_processing', false) - ->where('next_run_at', '<=', Carbon::now()->toDateTimeString()) + ->where('next_run_at', '<=', now('UTC')->toDateTimeString()) ->get(); if ($schedules->count() < 1) { diff --git a/app/Helpers/Utilities.php b/app/Helpers/Utilities.php index e0c824d01a..c810788cc2 100644 --- a/app/Helpers/Utilities.php +++ b/app/Helpers/Utilities.php @@ -40,7 +40,7 @@ public static function getScheduleNextRunDate(string $minute, string $hour, stri { return Carbon::instance((new CronExpression( sprintf('%s %s %s %s %s', $minute, $hour, $dayOfMonth, $month, $dayOfWeek) - ))->getNextRunDate()); + ))->getNextRunDate(now('UTC'))); } public static function checked(string $name, mixed $default): string diff --git a/app/Models/Schedule.php b/app/Models/Schedule.php index ae7b9baecf..d6d19a8e14 100644 --- a/app/Models/Schedule.php +++ b/app/Models/Schedule.php @@ -2,8 +2,7 @@ namespace App\Models; -use Cron\CronExpression; -use Carbon\CarbonImmutable; +use App\Helpers\Utilities; use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\BelongsTo; @@ -112,13 +111,9 @@ public function getRouteKeyName(): string * * @throws \Exception */ - public function getNextRunDate(): CarbonImmutable + public function getNextRunDate(): string { - $formatted = sprintf('%s %s %s %s %s', $this->cron_minute, $this->cron_hour, $this->cron_day_of_month, $this->cron_month, $this->cron_day_of_week); - - return CarbonImmutable::createFromTimestamp( - (new CronExpression($formatted))->getNextRunDate()->getTimestamp() - ); + return Utilities::getScheduleNextRunDate($this->cron_minute, $this->cron_hour, $this->cron_day_of_month, $this->cron_month, $this->cron_day_of_week)->toDateTimeString(); } /**