mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-20 05:14:46 +02:00
Add nullable_type_declaration_for_default_null_value rule
This commit is contained in:
parent
96acd268be
commit
1bf6a880fb
@ -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);
|
||||
}
|
||||
|
@ -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()) {
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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());
|
||||
}
|
||||
|
@ -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 ?? ''));
|
||||
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -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');
|
||||
|
@ -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()));
|
||||
}
|
||||
|
@ -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()));
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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');
|
||||
|
@ -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');
|
||||
|
@ -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',
|
||||
|
@ -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');
|
||||
|
@ -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',
|
||||
|
@ -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',
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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');
|
||||
|
@ -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();
|
||||
|
@ -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'];
|
||||
|
@ -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'));
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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
|
||||
|
@ -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:
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user