diff --git a/app/Console/Commands/Environment/EmailSettingsCommand.php b/app/Console/Commands/Environment/EmailSettingsCommand.php index 87c8186c1..23061bf04 100644 --- a/app/Console/Commands/Environment/EmailSettingsCommand.php +++ b/app/Console/Commands/Environment/EmailSettingsCommand.php @@ -70,7 +70,7 @@ class EmailSettingsCommand extends Command /** * 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 @@ class EmailSettingsCommand extends Command /** * 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 @@ class EmailSettingsCommand extends Command /** * 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 @@ class EmailSettingsCommand extends Command /** * 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 d1d71ae02..c11ade6c3 100644 --- a/app/Console/Commands/Schedule/ProcessRunnableCommand.php +++ b/app/Console/Commands/Schedule/ProcessRunnableCommand.php @@ -51,7 +51,7 @@ class ProcessRunnableCommand extends Command * 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 75a3c185f..145e6e0c6 100644 --- a/app/Console/Commands/UpgradeCommand.php +++ b/app/Console/Commands/UpgradeCommand.php @@ -178,7 +178,7 @@ class UpgradeCommand extends Command $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 6c44c356c..5dfe42a4a 100644 --- a/app/Exceptions/DisplayException.php +++ b/app/Exceptions/DisplayException.php @@ -4,6 +4,8 @@ namespace App\Exceptions; 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 @@ class DisplayException extends PanelException implements HttpExceptionInterface * 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 @@ class DisplayException extends PanelException implements HttpExceptionInterface ->danger() ->send(); - return; + return false; } if ($request->expectsJson()) { @@ -73,10 +75,10 @@ class DisplayException extends PanelException implements HttpExceptionInterface * * @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 @@ class DisplayException extends PanelException implements HttpExceptionInterface 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 2badc3dcb..f6f55d8c8 100644 --- a/app/Extensions/Themes/Theme.php +++ b/app/Extensions/Themes/Theme.php @@ -4,17 +4,17 @@ namespace App\Extensions\Themes; 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 55da7add7..8a112a834 100644 --- a/app/Filament/Pages/Installer/PanelInstaller.php +++ b/app/Filament/Pages/Installer/PanelInstaller.php @@ -24,6 +24,7 @@ use Filament\Notifications\Notification; 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 @@ class PanelInstaller extends SimplePage implements HasForms return env('APP_INSTALLED', true); } - public function mount() + public function mount(): void { abort_if(self::isInstalled(), 404); @@ -93,7 +94,7 @@ class PanelInstaller extends SimplePage implements HasForms 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 5a0d6b736..04803352d 100644 --- a/app/Filament/Pages/Installer/Steps/DatabaseStep.php +++ b/app/Filament/Pages/Installer/Steps/DatabaseStep.php @@ -72,7 +72,7 @@ class DatabaseStep }); } - 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 00ecb18af..d160e0b70 100644 --- a/app/Filament/Pages/Installer/Steps/RedisStep.php +++ b/app/Filament/Pages/Installer/Steps/RedisStep.php @@ -56,7 +56,7 @@ class RedisStep }); } - 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 ba2a851ca..daefee22b 100644 --- a/app/Filament/Resources/ApiKeyResource.php +++ b/app/Filament/Resources/ApiKeyResource.php @@ -5,6 +5,7 @@ namespace App\Filament\Resources; 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 @@ class ApiKeyResource extends Resource 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 d3e07bcb9..e42e5e15e 100644 --- a/app/Filament/Resources/DatabaseHostResource/Pages/CreateDatabaseHost.php +++ b/app/Filament/Resources/DatabaseHostResource/Pages/CreateDatabaseHost.php @@ -4,6 +4,8 @@ namespace App\Filament\Resources\DatabaseHostResource\Pages; 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 @@ class CreateDatabaseHost extends CreateRecord 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 862c33b8c..8951cff8b 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; 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 @@ class EditDatabaseHost extends EditRecord ]; } - 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 4dfcdd955..bdd93d60d 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\Actions\Action; 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 @@ class DatabasesRelationManager extends RelationManager ]); } - 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 e2c5f2c32..10d5d1062 100644 --- a/app/Filament/Resources/NodeResource/Pages/EditNode.php +++ b/app/Filament/Resources/NodeResource/Pages/EditNode.php @@ -469,12 +469,12 @@ class EditNode extends EditRecord $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 51a59591d..be746d6c3 100644 --- a/app/Filament/Resources/ServerResource/Pages/EditServer.php +++ b/app/Filament/Resources/ServerResource/Pages/EditServer.php @@ -813,7 +813,7 @@ class EditServer extends EditRecord ->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 f5c5f5828..9b22e88ee 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\EccLevel; 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 @@ class EditProfile extends \Filament\Pages\Auth\EditProfile ]; } - 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 @@ class EditProfile extends \Filament\Pages\Auth\EditProfile 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 9ddd9c7e6..9c7836e39 100644 --- a/app/Http/Controllers/Admin/ServersController.php +++ b/app/Http/Controllers/Admin/ServersController.php @@ -70,7 +70,7 @@ class ServersController extends Controller * @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 @@ class ServersController extends Controller ->body(trans('admin/server.alerts.install_toggled')) ->success() ->send(); - - return null; } /** @@ -94,7 +92,7 @@ class ServersController extends Controller * @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 174e6243a..87c721a74 100644 --- a/app/Http/Controllers/Api/Application/ApplicationApiController.php +++ b/app/Http/Controllers/Api/Application/ApplicationApiController.php @@ -40,7 +40,7 @@ abstract class ApplicationApiController extends Controller * 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 e07584d23..3b6badaa5 100644 --- a/app/Http/Controllers/Api/Remote/ActivityProcessingController.php +++ b/app/Http/Controllers/Api/Remote/ActivityProcessingController.php @@ -14,7 +14,7 @@ use App\Http\Requests\Api\Remote\ActivityEventRequest; 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 e5b50d0ad..e62f9fab8 100644 --- a/app/Http/Controllers/Auth/AbstractLoginController.php +++ b/app/Http/Controllers/Auth/AbstractLoginController.php @@ -51,7 +51,7 @@ abstract class AbstractLoginController extends Controller * * @throws \App\Exceptions\DisplayException */ - protected function sendFailedLoginResponse(Request $request, Authenticatable $user = null, string $message = null) + protected function sendFailedLoginResponse(Request $request, Authenticatable $user = null, string $message = null): never { $this->incrementLoginAttempts($request); $this->fireFailedLoginEvent($user, [ @@ -99,7 +99,7 @@ abstract class AbstractLoginController extends Controller /** * 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 21ef4fee8..32a7049fc 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 @@ class ForgotPasswordController extends Controller * * @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 540aca5a0..8797f533b 100644 --- a/app/Http/Controllers/Auth/LoginCheckpointController.php +++ b/app/Http/Controllers/Auth/LoginCheckpointController.php @@ -72,7 +72,7 @@ class LoginCheckpointController extends AbstractLoginController } } - 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 28c3c4f5e..ea2a59594 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -4,11 +4,13 @@ namespace App\Http\Controllers\Auth; 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 b4c338ee9..11dcc0346 100644 --- a/app/Http/Controllers/Auth/ResetPasswordController.php +++ b/app/Http/Controllers/Auth/ResetPasswordController.php @@ -69,7 +69,7 @@ class ResetPasswordController extends Controller * * @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 66689fe11..35c1795cc 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 d1af8a085..aae5ae013 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 @@ class EggFormRequest extends AdminFormRequest 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 111560bbf..83c74ac3b 100644 --- a/app/Http/Requests/Api/Application/DatabaseHosts/UpdateDatabaseHostRequest.php +++ b/app/Http/Requests/Api/Application/DatabaseHosts/UpdateDatabaseHostRequest.php @@ -11,6 +11,6 @@ class UpdateDatabaseHostRequest extends StoreDatabaseHostRequest /** @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 7f76ec420..e111553d4 100644 --- a/app/Http/Requests/Api/Application/Mounts/UpdateMountRequest.php +++ b/app/Http/Requests/Api/Application/Mounts/UpdateMountRequest.php @@ -14,6 +14,6 @@ class UpdateMountRequest extends StoreMountRequest /** @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 ab636dff0..a59039d99 100644 --- a/app/Http/Requests/Api/Application/Nodes/UpdateNodeRequest.php +++ b/app/Http/Requests/Api/Application/Nodes/UpdateNodeRequest.php @@ -15,6 +15,6 @@ class UpdateNodeRequest extends StoreNodeRequest /** @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 ecccbdd5a..c7a919bee 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 bd68fb890..349db0616 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 @@ abstract class SubuserRequest extends ClientApiRequest * * @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 6a660e5c0..167980ac9 100644 --- a/app/Jobs/Schedule/RunTaskJob.php +++ b/app/Jobs/Schedule/RunTaskJob.php @@ -90,7 +90,7 @@ class RunTaskJob extends Job implements ShouldQueue /** * Handle a failure while sending the action to the daemon or otherwise processing the job. */ - public function failed(\Exception $exception = null) + public function failed(\Exception $exception = null): void { $this->markTaskNotQueued(); $this->markScheduleComplete(); @@ -99,7 +99,7 @@ class RunTaskJob extends Job implements ShouldQueue /** * 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 @@ class RunTaskJob extends Job implements ShouldQueue /** * 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 @@ class RunTaskJob extends Job implements ShouldQueue /** * 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 b29190251..54b4cd827 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 bb6149c14..20fb579e0 100644 --- a/app/Models/ActivityLog.php +++ b/app/Models/ActivityLog.php @@ -123,7 +123,7 @@ class ActivityLog extends Model * * @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 @@ class ActivityLog extends Model * 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 @@ class ActivityLog extends Model }); } - 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 037d344f0..9e4e2777b 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 @@ class ActivityLogSubject extends Pivot 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 d3c1eea60..bebde0ee9 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 da3f91f6d..4523825f4 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 536edf9b5..20bc2bf33 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 @@ abstract class Model extends IlluminateModel return 'uuid'; } - protected function asDateTime($value) + protected function asDateTime($value): Carbon { $timezone = auth()->user()?->timezone ?? config('app.timezone', 'UTC'); @@ -135,11 +135,9 @@ abstract class Model extends IlluminateModel * 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 223603805..60cb2b436 100644 --- a/app/Models/Mount.php +++ b/app/Models/Mount.php @@ -70,7 +70,7 @@ class Mount extends Model /** * Blacklisted source paths. */ - public static $invalidSourcePaths = [ + public static array $invalidSourcePaths = [ '/etc/pelican', '/var/lib/pelican/volumes', '/srv/daemon-data', @@ -79,7 +79,7 @@ class Mount extends Model /** * 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 0a9613196..366d63fb9 100644 --- a/app/Models/Node.php +++ b/app/Models/Node.php @@ -8,6 +8,7 @@ use Exception; 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 @@ class Node extends Model 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 @@ class Node extends Model 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 a0c341c6d..1ace74961 100644 --- a/app/Models/Server.php +++ b/app/Models/Server.php @@ -363,7 +363,7 @@ class Server extends Model * * @throws ServerStateConflictException */ - public function validateCurrentState() + public function validateCurrentState(): void { if ( $this->isSuspended() || @@ -382,7 +382,7 @@ class Server extends Model * 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 395f4994f..45f8ee87c 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -235,7 +235,7 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac * * @param string $token */ - public function sendPasswordResetNotification($token) + public function sendPasswordResetNotification($token): void { Activity::event('auth:reset-password') ->withRequestMetadata() @@ -248,7 +248,7 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac /** * 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 dbc2ae402..dfa72c9b9 100644 --- a/app/Policies/ServerPolicy.php +++ b/app/Policies/ServerPolicy.php @@ -41,7 +41,7 @@ class ServerPolicy * 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 7bae85856..f6b7c568b 100644 --- a/app/Providers/Filament/AdminPanelProvider.php +++ b/app/Providers/Filament/AdminPanelProvider.php @@ -22,7 +22,7 @@ use Illuminate\View\Middleware\ShareErrorsFromSession; 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 bbe852e80..ce9e394e5 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 @@ class DaemonBackupRepository extends DaemonRepository * * @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 @@ class DaemonBackupRepository extends DaemonRepository * * @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 @@ class DaemonBackupRepository extends DaemonRepository * * @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 52cda56dd..910e95e58 100644 --- a/app/Repositories/Daemon/DaemonConfigurationRepository.php +++ b/app/Repositories/Daemon/DaemonConfigurationRepository.php @@ -5,6 +5,7 @@ namespace App\Repositories\Daemon; 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 @@ class DaemonConfigurationRepository extends DaemonRepository * * @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 7667f482e..e97261eb1 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 @@ class DaemonFileRepository extends DaemonRepository * * @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 @@ class DaemonFileRepository extends DaemonRepository * * @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 @@ class DaemonFileRepository extends DaemonRepository * * @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 @@ class DaemonFileRepository extends DaemonRepository * * @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 @@ class DaemonFileRepository extends DaemonRepository * * @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 @@ class DaemonFileRepository extends DaemonRepository * * @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 @@ class DaemonFileRepository extends DaemonRepository * * @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 @@ class DaemonFileRepository extends DaemonRepository * * @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 ca3e03c44..3b701be34 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 37b7ae43b..514791218 100644 --- a/app/Services/Activity/ActivityLogService.php +++ b/app/Services/Activity/ActivityLogService.php @@ -168,7 +168,7 @@ class ActivityLogService * * @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 4cffc71d2..d95c08c64 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 aef02b7b2..4557fae3d 100644 --- a/app/Services/Servers/SuspensionService.php +++ b/app/Services/Servers/SuspensionService.php @@ -27,7 +27,7 @@ class SuspensionService * * @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 @@ class SuspensionService // 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 4312369dd..8a7bcd3ea 100644 --- a/app/Services/Servers/TransferServerService.php +++ b/app/Services/Servers/TransferServerService.php @@ -106,7 +106,7 @@ class TransferServerService /** * 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 4b5169296..e77686776 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 381b3102e..d70299787 100644 --- a/app/Transformers/Api/Application/EggVariableTransformer.php +++ b/app/Transformers/Api/Application/EggVariableTransformer.php @@ -15,7 +15,7 @@ class EggVariableTransformer extends BaseTransformer 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 c658f30fa..18dbe36dc 100644 --- a/app/Transformers/Api/Application/MountTransformer.php +++ b/app/Transformers/Api/Application/MountTransformer.php @@ -22,7 +22,7 @@ class MountTransformer extends BaseTransformer 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 90836cc24..b81baf279 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 58d5f13ae..7a60592ae 100644 --- a/app/Transformers/Api/Client/ActivityLogTransformer.php +++ b/app/Transformers/Api/Client/ActivityLogTransformer.php @@ -6,6 +6,7 @@ use Illuminate\Support\Str; 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 @@ class ActivityLogTransformer extends BaseClientTransformer ]; } - 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 2f7f6694e..b2e7c20e4 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 dcbc4f25c..d6a3743b7 100644 --- a/database/Seeders/EggSeeder.php +++ b/database/Seeders/EggSeeder.php @@ -34,7 +34,7 @@ class EggSeeder extends Seeder /** * Run the egg seeder. */ - public function run() + public function run(): void { foreach (static::$imports as $import) { /* @noinspection PhpParamsInspection */ @@ -45,7 +45,7 @@ class EggSeeder extends Seeder /** * 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 58b6c8e91..21d412e89 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 e909bb41e..4fb417408 100644 --- a/tests/Integration/Api/Client/ClientApiIntegrationTestCase.php +++ b/tests/Integration/Api/Client/ClientApiIntegrationTestCase.php @@ -76,7 +76,7 @@ abstract class ClientApiIntegrationTestCase extends IntegrationTestCase * 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 b496eeaa0..c608e2a8e 100644 --- a/tests/Integration/IntegrationTestCase.php +++ b/tests/Integration/IntegrationTestCase.php @@ -43,7 +43,7 @@ abstract class IntegrationTestCase extends TestCase * * @return array */ - protected function connectionsToTransact() + protected function connectionsToTransact(): array { return [DB::getDriverName()]; }