diff --git a/app/Exceptions/Http/HttpForbiddenException.php b/app/Exceptions/Http/HttpForbiddenException.php index b0536257e..318ab3b6c 100644 --- a/app/Exceptions/Http/HttpForbiddenException.php +++ b/app/Exceptions/Http/HttpForbiddenException.php @@ -10,7 +10,7 @@ class HttpForbiddenException extends HttpException /** * HttpForbiddenException constructor. */ - public function __construct(string $message = null, \Throwable $previous = null) + public function __construct(?string $message = null, ?\Throwable $previous = null) { parent::__construct(Response::HTTP_FORBIDDEN, $message, $previous); } diff --git a/app/Exceptions/Http/Server/ServerStateConflictException.php b/app/Exceptions/Http/Server/ServerStateConflictException.php index 1e20082a3..c5b53b4da 100644 --- a/app/Exceptions/Http/Server/ServerStateConflictException.php +++ b/app/Exceptions/Http/Server/ServerStateConflictException.php @@ -12,7 +12,7 @@ class ServerStateConflictException extends ConflictHttpException * Exception thrown when the server is in an unsupported state for API access or * certain operations within the codebase. */ - public function __construct(Server $server, \Throwable $previous = null) + public function __construct(Server $server, ?\Throwable $previous = null) { $message = 'This server is currently in an unsupported state, please try again later.'; if ($server->isSuspended()) { diff --git a/app/Exceptions/Http/TwoFactorAuthRequiredException.php b/app/Exceptions/Http/TwoFactorAuthRequiredException.php index 6b9804812..fb9c09ebc 100644 --- a/app/Exceptions/Http/TwoFactorAuthRequiredException.php +++ b/app/Exceptions/Http/TwoFactorAuthRequiredException.php @@ -11,7 +11,7 @@ class TwoFactorAuthRequiredException extends HttpException implements HttpExcept /** * TwoFactorAuthRequiredException constructor. */ - public function __construct(\Throwable $previous = null) + public function __construct(?\Throwable $previous = null) { parent::__construct(Response::HTTP_BAD_REQUEST, 'Two-factor authentication is required on this account in order to access this endpoint.', $previous); } diff --git a/app/Exceptions/Service/ServiceLimitExceededException.php b/app/Exceptions/Service/ServiceLimitExceededException.php index 3609be97d..2570197d6 100644 --- a/app/Exceptions/Service/ServiceLimitExceededException.php +++ b/app/Exceptions/Service/ServiceLimitExceededException.php @@ -10,7 +10,7 @@ class ServiceLimitExceededException extends DisplayException * Exception thrown when something goes over a defined limit, such as allocated * ports, tasks, databases, etc. */ - public function __construct(string $message, \Throwable $previous = null) + public function __construct(string $message, ?\Throwable $previous = null) { parent::__construct($message, $previous, self::LEVEL_WARNING); } diff --git a/app/Extensions/Backups/BackupManager.php b/app/Extensions/Backups/BackupManager.php index 8fcb1e198..b26f8f4c5 100644 --- a/app/Extensions/Backups/BackupManager.php +++ b/app/Extensions/Backups/BackupManager.php @@ -34,7 +34,7 @@ class BackupManager /** * Returns a backup adapter instance. */ - public function adapter(string $name = null): FilesystemAdapter + public function adapter(?string $name = null): FilesystemAdapter { return $this->get($name ?: $this->getDefaultAdapter()); } diff --git a/app/Http/Controllers/Admin/Eggs/EggController.php b/app/Http/Controllers/Admin/Eggs/EggController.php index 692ff7942..2f3de5ae1 100644 --- a/app/Http/Controllers/Admin/Eggs/EggController.php +++ b/app/Http/Controllers/Admin/Eggs/EggController.php @@ -127,7 +127,7 @@ class EggController extends Controller /** * Normalizes a string of docker image data into the expected egg format. */ - protected function normalizeDockerImages(string $input = null): array + protected function normalizeDockerImages(?string $input = null): array { $data = array_map(fn ($value) => trim($value), explode("\n", $input ?? '')); diff --git a/app/Http/Controllers/Auth/AbstractLoginController.php b/app/Http/Controllers/Auth/AbstractLoginController.php index e5b50d0ad..f72e7ba6c 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) { $this->incrementLoginAttempts($request); $this->fireFailedLoginEvent($user, [ @@ -91,7 +91,7 @@ abstract class AbstractLoginController extends Controller /** * Determine if the user is logging in using an email or username. */ - protected function getField(string $input = null): string + protected function getField(?string $input = null): string { return ($input && str_contains($input, '@')) ? 'email' : 'username'; } @@ -99,7 +99,7 @@ abstract class AbstractLoginController extends Controller /** * Fire a failed login event. */ - protected function fireFailedLoginEvent(Authenticatable $user = null, array $credentials = []) + 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 38af84f7e..f645f552e 100644 --- a/app/Http/Middleware/RedirectIfAuthenticated.php +++ b/app/Http/Middleware/RedirectIfAuthenticated.php @@ -17,7 +17,7 @@ class RedirectIfAuthenticated /** * Handle an incoming request. */ - public function handle(Request $request, \Closure $next, string $guard = null): mixed + public function handle(Request $request, \Closure $next, ?string $guard = null): mixed { if ($this->authManager->guard($guard)->check()) { return redirect()->route('index'); diff --git a/app/Http/Requests/Admin/AdminFormRequest.php b/app/Http/Requests/Admin/AdminFormRequest.php index 54e9f5e92..adfb97fb8 100644 --- a/app/Http/Requests/Admin/AdminFormRequest.php +++ b/app/Http/Requests/Admin/AdminFormRequest.php @@ -28,7 +28,7 @@ abstract class AdminFormRequest extends FormRequest * Return only the fields that we are interested in from the request. * This will include empty fields as a null value. */ - public function normalize(array $only = null): array + public function normalize(?array $only = null): array { return $this->only($only ?? array_keys($this->rules())); } diff --git a/app/Http/Requests/Admin/Settings/MailSettingsFormRequest.php b/app/Http/Requests/Admin/Settings/MailSettingsFormRequest.php index 9e62869d8..38fa792d5 100644 --- a/app/Http/Requests/Admin/Settings/MailSettingsFormRequest.php +++ b/app/Http/Requests/Admin/Settings/MailSettingsFormRequest.php @@ -27,7 +27,7 @@ class MailSettingsFormRequest extends AdminFormRequest * Override the default normalization function for this type of request * as we need to accept empty values on the keys. */ - public function normalize(array $only = null): array + public function normalize(?array $only = null): array { $keys = array_flip(array_keys($this->rules())); diff --git a/app/Http/Requests/Api/Application/DatabaseHosts/StoreDatabaseHostRequest.php b/app/Http/Requests/Api/Application/DatabaseHosts/StoreDatabaseHostRequest.php index aedd5109b..435a6d86b 100644 --- a/app/Http/Requests/Api/Application/DatabaseHosts/StoreDatabaseHostRequest.php +++ b/app/Http/Requests/Api/Application/DatabaseHosts/StoreDatabaseHostRequest.php @@ -12,7 +12,7 @@ class StoreDatabaseHostRequest extends ApplicationApiRequest protected int $permission = AdminAcl::WRITE; - public function rules(array $rules = null): array + public function rules(?array $rules = null): array { return $rules ?? DatabaseHost::getRules(); } diff --git a/app/Http/Requests/Api/Application/DatabaseHosts/UpdateDatabaseHostRequest.php b/app/Http/Requests/Api/Application/DatabaseHosts/UpdateDatabaseHostRequest.php index 111560bbf..95b006546 100644 --- a/app/Http/Requests/Api/Application/DatabaseHosts/UpdateDatabaseHostRequest.php +++ b/app/Http/Requests/Api/Application/DatabaseHosts/UpdateDatabaseHostRequest.php @@ -6,7 +6,7 @@ use App\Models\DatabaseHost; class UpdateDatabaseHostRequest extends StoreDatabaseHostRequest { - public function rules(array $rules = null): array + public function rules(?array $rules = null): array { /** @var DatabaseHost $databaseHost */ $databaseHost = $this->route()->parameter('database_host'); diff --git a/app/Http/Requests/Api/Application/Mounts/UpdateMountRequest.php b/app/Http/Requests/Api/Application/Mounts/UpdateMountRequest.php index 7f76ec420..e843f2c70 100644 --- a/app/Http/Requests/Api/Application/Mounts/UpdateMountRequest.php +++ b/app/Http/Requests/Api/Application/Mounts/UpdateMountRequest.php @@ -9,7 +9,7 @@ class UpdateMountRequest extends StoreMountRequest /** * Apply validation rules to this request. */ - public function rules(array $rules = null): array + public function rules(?array $rules = null): array { /** @var Mount $mount */ $mount = $this->route()->parameter('mount'); diff --git a/app/Http/Requests/Api/Application/Nodes/StoreNodeRequest.php b/app/Http/Requests/Api/Application/Nodes/StoreNodeRequest.php index 913204b83..eae324233 100644 --- a/app/Http/Requests/Api/Application/Nodes/StoreNodeRequest.php +++ b/app/Http/Requests/Api/Application/Nodes/StoreNodeRequest.php @@ -15,7 +15,7 @@ class StoreNodeRequest extends ApplicationApiRequest /** * Validation rules to apply to this request. */ - public function rules(array $rules = null): array + public function rules(?array $rules = null): array { return collect($rules ?? Node::getRules())->only([ 'public', diff --git a/app/Http/Requests/Api/Application/Nodes/UpdateNodeRequest.php b/app/Http/Requests/Api/Application/Nodes/UpdateNodeRequest.php index ab636dff0..388b2fd47 100644 --- a/app/Http/Requests/Api/Application/Nodes/UpdateNodeRequest.php +++ b/app/Http/Requests/Api/Application/Nodes/UpdateNodeRequest.php @@ -10,7 +10,7 @@ class UpdateNodeRequest extends StoreNodeRequest * Apply validation rules to this request. Uses the parent class rules() * function but passes in the rules for updating rather than creating. */ - public function rules(array $rules = null): array + public function rules(?array $rules = null): array { /** @var Node $node */ $node = $this->route()->parameter('node'); diff --git a/app/Http/Requests/Api/Application/Roles/StoreRoleRequest.php b/app/Http/Requests/Api/Application/Roles/StoreRoleRequest.php index 7968449a7..4cf01400e 100644 --- a/app/Http/Requests/Api/Application/Roles/StoreRoleRequest.php +++ b/app/Http/Requests/Api/Application/Roles/StoreRoleRequest.php @@ -11,7 +11,7 @@ class StoreRoleRequest extends ApplicationApiRequest protected int $permission = AdminAcl::WRITE; - public function rules(array $rules = null): array + public function rules(?array $rules = null): array { return [ 'name' => 'required|string', diff --git a/app/Http/Requests/Api/Application/Users/AssignUserRolesRequest.php b/app/Http/Requests/Api/Application/Users/AssignUserRolesRequest.php index c0af95102..61e191c20 100644 --- a/app/Http/Requests/Api/Application/Users/AssignUserRolesRequest.php +++ b/app/Http/Requests/Api/Application/Users/AssignUserRolesRequest.php @@ -7,7 +7,7 @@ class AssignUserRolesRequest extends StoreUserRequest /** * Return the validation rules for this request. */ - public function rules(array $rules = null): array + public function rules(?array $rules = null): array { return [ 'roles' => 'array', diff --git a/app/Http/Requests/Api/Application/Users/StoreUserRequest.php b/app/Http/Requests/Api/Application/Users/StoreUserRequest.php index 43603639c..cf1b6c244 100644 --- a/app/Http/Requests/Api/Application/Users/StoreUserRequest.php +++ b/app/Http/Requests/Api/Application/Users/StoreUserRequest.php @@ -15,7 +15,7 @@ class StoreUserRequest extends ApplicationApiRequest /** * Return the validation rules for this request. */ - public function rules(array $rules = null): array + public function rules(?array $rules = null): array { $rules = $rules ?? User::getRules(); diff --git a/app/Http/Requests/Api/Application/Users/UpdateUserRequest.php b/app/Http/Requests/Api/Application/Users/UpdateUserRequest.php index ecccbdd5a..2db4cd049 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 ea0c84486..d4b0cabce 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) { $this->markTaskNotQueued(); $this->markScheduleComplete(); diff --git a/app/Repositories/Daemon/DaemonBackupRepository.php b/app/Repositories/Daemon/DaemonBackupRepository.php index bbe852e80..9d9c4bafa 100644 --- a/app/Repositories/Daemon/DaemonBackupRepository.php +++ b/app/Repositories/Daemon/DaemonBackupRepository.php @@ -50,7 +50,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) { Assert::isInstanceOf($this->server, Server::class); diff --git a/app/Repositories/Daemon/DaemonFileRepository.php b/app/Repositories/Daemon/DaemonFileRepository.php index 7667f482e..ca6fc7399 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 37b7ae43b..170278558 100644 --- a/app/Services/Activity/ActivityLogService.php +++ b/app/Services/Activity/ActivityLogService.php @@ -130,7 +130,7 @@ class ActivityLogService * performing this action it will be logged to the disk but will not interrupt * the code flow. */ - public function log(string $description = null): ActivityLog + public function log(?string $description = null): ActivityLog { $activity = $this->getActivity(); diff --git a/app/Services/Allocations/AssignmentService.php b/app/Services/Allocations/AssignmentService.php index be4c04131..23f28e122 100644 --- a/app/Services/Allocations/AssignmentService.php +++ b/app/Services/Allocations/AssignmentService.php @@ -43,7 +43,7 @@ class AssignmentService * @throws \App\Exceptions\Service\Allocation\PortOutOfRangeException * @throws \App\Exceptions\Service\Allocation\TooManyPortsInRangeException */ - public function handle(Node $node, array $data, Server $server = null): array + public function handle(Node $node, array $data, ?Server $server = null): array { $explode = explode('/', $data['allocation_ip']); if (count($explode) !== 1) { diff --git a/app/Services/Backups/InitiateBackupService.php b/app/Services/Backups/InitiateBackupService.php index 447c57535..69807a942 100644 --- a/app/Services/Backups/InitiateBackupService.php +++ b/app/Services/Backups/InitiateBackupService.php @@ -70,7 +70,7 @@ class InitiateBackupService * @throws \App\Exceptions\Service\Backup\TooManyBackupsException * @throws \Symfony\Component\HttpKernel\Exception\TooManyRequestsHttpException */ - public function handle(Server $server, string $name = null, bool $override = false): Backup + public function handle(Server $server, ?string $name = null, bool $override = false): Backup { $limit = config('backups.throttles.limit'); $period = config('backups.throttles.period'); diff --git a/app/Services/Eggs/Sharing/EggImporterService.php b/app/Services/Eggs/Sharing/EggImporterService.php index dc54525a6..e539a7f28 100644 --- a/app/Services/Eggs/Sharing/EggImporterService.php +++ b/app/Services/Eggs/Sharing/EggImporterService.php @@ -34,7 +34,7 @@ class EggImporterService * * @throws \App\Exceptions\Service\InvalidFileUploadException|\Throwable */ - public function fromFile(UploadedFile $file, Egg $egg = null): Egg + public function fromFile(UploadedFile $file, ?Egg $egg = null): Egg { $parsed = $this->parseFile($file); @@ -75,7 +75,7 @@ class EggImporterService * * @throws \App\Exceptions\Service\InvalidFileUploadException|\Throwable */ - public function fromUrl(string $url, Egg $egg = null): Egg + public function fromUrl(string $url, ?Egg $egg = null): Egg { $info = pathinfo($url); $tmpDir = TemporaryDirectory::make()->deleteWhenDestroyed(); diff --git a/app/Services/Servers/ServerCreationService.php b/app/Services/Servers/ServerCreationService.php index 7fd3e8b67..18eb790e5 100644 --- a/app/Services/Servers/ServerCreationService.php +++ b/app/Services/Servers/ServerCreationService.php @@ -45,7 +45,7 @@ class ServerCreationService * @throws \Illuminate\Validation\ValidationException * @throws \App\Exceptions\Service\Deployment\NoViableAllocationException */ - public function handle(array $data, DeploymentObject $deployment = null): Server + public function handle(array $data, ?DeploymentObject $deployment = null): Server { if (!isset($data['oom_killer']) && isset($data['oom_disabled'])) { $data['oom_killer'] = !$data['oom_disabled']; diff --git a/app/Services/Users/ToggleTwoFactorService.php b/app/Services/Users/ToggleTwoFactorService.php index 64518e39b..ca5df2dcb 100644 --- a/app/Services/Users/ToggleTwoFactorService.php +++ b/app/Services/Users/ToggleTwoFactorService.php @@ -30,7 +30,7 @@ class ToggleTwoFactorService * @throws \PragmaRX\Google2FA\Exceptions\SecretKeyTooShortException * @throws \App\Exceptions\Service\User\TwoFactorAuthenticationTokenInvalid */ - public function handle(User $user, string $token, bool $toggleState = null): array + public function handle(User $user, string $token, ?bool $toggleState = null): array { $isValidToken = $this->google2FA->verifyKey($user->totp_secret, $token, config()->get('panel.auth.2fa.window')); diff --git a/app/Transformers/Api/Client/ActivityLogTransformer.php b/app/Transformers/Api/Client/ActivityLogTransformer.php index 1d38507ec..8ae888142 100644 --- a/app/Transformers/Api/Client/ActivityLogTransformer.php +++ b/app/Transformers/Api/Client/ActivityLogTransformer.php @@ -111,7 +111,7 @@ class ActivityLogTransformer extends BaseClientTransformer * Determines if the user can view the IP address in the output either because they are the * actor that performed the action, or because they are an administrator on the Panel. */ - protected function canViewIP(Model $actor = null): bool + protected function canViewIP(?Model $actor = null): bool { return $actor?->is($this->request->user()) || $this->request->user()->isRootAdmin(); } diff --git a/app/Transformers/Api/Client/BaseClientTransformer.php b/app/Transformers/Api/Client/BaseClientTransformer.php index c490d1bfd..9ee56cfaf 100644 --- a/app/Transformers/Api/Client/BaseClientTransformer.php +++ b/app/Transformers/Api/Client/BaseClientTransformer.php @@ -24,7 +24,7 @@ abstract class BaseClientTransformer extends BaseApplicationTransformer * * @noinspection PhpParameterNameChangedDuringInheritanceInspection */ - protected function authorize(string $ability, Server $server = null): bool + protected function authorize(string $ability, ?Server $server = null): bool { Assert::isInstanceOf($server, Server::class); diff --git a/pint.json b/pint.json index e6d2cafb8..606e3351a 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 44c06e570..86e9a202d 100644 --- a/tests/Integration/Api/Client/ClientApiIntegrationTestCase.php +++ b/tests/Integration/Api/Client/ClientApiIntegrationTestCase.php @@ -47,7 +47,7 @@ abstract class ClientApiIntegrationTestCase extends IntegrationTestCase /** * Returns a link to the specific resource using the client API. */ - protected function link(mixed $model, string $append = null): string + protected function link(mixed $model, ?string $append = null): string { switch (get_class($model)) { case Server::class: diff --git a/tests/Integration/Api/Remote/SftpAuthenticationControllerTest.php b/tests/Integration/Api/Remote/SftpAuthenticationControllerTest.php index 994a601a9..da340cbb4 100644 --- a/tests/Integration/Api/Remote/SftpAuthenticationControllerTest.php +++ b/tests/Integration/Api/Remote/SftpAuthenticationControllerTest.php @@ -226,7 +226,7 @@ class SftpAuthenticationControllerTest extends IntegrationTestCase /** * Sets the authorization header for the rest of the test. */ - protected function setAuthorization(Node $node = null): void + protected function setAuthorization(?Node $node = null): void { $node = $node ?? $this->server->node; diff --git a/tests/Traits/Http/RequestMockHelpers.php b/tests/Traits/Http/RequestMockHelpers.php index b2fa0e917..d4da1bb23 100644 --- a/tests/Traits/Http/RequestMockHelpers.php +++ b/tests/Traits/Http/RequestMockHelpers.php @@ -27,7 +27,7 @@ trait RequestMockHelpers /** * Configure the user model that the request mock should return with. */ - public function setRequestUserModel(User $user = null): void + public function setRequestUserModel(?User $user = null): void { $this->request->shouldReceive('user')->andReturn($user); } @@ -80,7 +80,7 @@ trait RequestMockHelpers * * @deprecated */ - protected function setRequestUser(User $user = null): User + protected function setRequestUser(?User $user = null): User { $user = $user instanceof User ? $user : User::factory()->make(); $this->request->shouldReceive('user')->withNoArgs()->andReturn($user);