Merge pull request #638 from pelican-dev/lance/pint-fixes

Reenable Disabled Pint Rules
This commit is contained in:
Lance Pioch 2024-10-20 11:59:20 -04:00 committed by GitHub
commit e9f6fbadd4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
87 changed files with 165 additions and 73 deletions

View File

@ -16,8 +16,11 @@ use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
class DisplayException extends PanelException implements HttpExceptionInterface
{
public const LEVEL_DEBUG = 'debug';
public const LEVEL_INFO = 'info';
public const LEVEL_WARNING = 'warning';
public const LEVEL_ERROR = 'error';
/**

View File

@ -114,7 +114,7 @@ class Handler extends ExceptionHandler
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Illuminate\Http\Request $request
*
* @throws \Throwable
*/
@ -140,7 +140,7 @@ class Handler extends ExceptionHandler
* Transform a validation exception into a consistent format to be returned for
* calls to the API.
*
* @param \Illuminate\Http\Request $request
* @param \Illuminate\Http\Request $request
*/
public function invalidJson($request, ValidationException $exception): JsonResponse
{
@ -236,7 +236,7 @@ class Handler extends ExceptionHandler
/**
* Convert an authentication exception into an unauthenticated response.
*
* @param \Illuminate\Http\Request $request
* @param \Illuminate\Http\Request $request
*/
protected function unauthenticated($request, AuthenticationException $exception): JsonResponse|RedirectResponse
{

View File

@ -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);
}

View File

@ -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()) {

View File

@ -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);
}

View File

@ -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);
}

View File

@ -7,6 +7,7 @@ use App\Exceptions\DisplayException;
class TwoFactorAuthenticationTokenInvalid extends DisplayException
{
public string $title = 'Invalid 2FA Code';
public string $icon = 'tabler-2fa';
public function __construct()

View File

@ -34,7 +34,7 @@ class BackupManager
/**
* Returns a backup adapter instance.
*/
public function adapter(string $name = null): FilesystemAdapter
public function adapter(?string $name = null): FilesystemAdapter
{
return $this->get($name ?: $this->getDefaultAdapter());
}
@ -145,7 +145,7 @@ class BackupManager
/**
* Unset the given adapter instances.
*
* @param string|string[] $adapter
* @param string|string[] $adapter
*/
public function forget(array|string $adapter): self
{

View File

@ -7,7 +7,9 @@ use App\Models\DatabaseHost;
class DynamicDatabaseConnection
{
public const DB_CHARSET = 'utf8';
public const DB_COLLATION = 'utf8_unicode_ci';
public const DB_DRIVER = 'mysql';
/**

View File

@ -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';

View File

@ -10,8 +10,11 @@ use Illuminate\Database\Eloquent\Model;
class ApiKeyResource extends Resource
{
protected static ?string $model = ApiKey::class;
protected static ?string $label = 'API Key';
protected static ?string $navigationIcon = 'tabler-key';
protected static ?string $navigationGroup = 'Advanced';
public static function getNavigationBadge(): ?string

View File

@ -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

View File

@ -41,6 +41,7 @@ class DatabasesRelationManager extends RelationManager
->formatStateUsing(fn (Get $get, Database $database) => 'jdbc:mysql://' . $get('username') . ':' . urlencode($database->password) . '@' . $database->host->host . ':' . $database->host->port . '/' . $get('database')),
]);
}
public function table(Table $table): Table
{
return $table

View File

@ -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

View File

@ -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

View File

@ -98,6 +98,7 @@ class ListEggs extends ListRecords
]),
]);
}
protected function getHeaderActions(): array
{
return [

View File

@ -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

View File

@ -96,6 +96,7 @@ class EditMount extends EditRecord
'lg' => 2,
]);
}
protected function getHeaderActions(): array
{
return [

View File

@ -17,6 +17,7 @@ use Filament\Tables\Table;
class ListMounts extends ListRecords
{
protected static string $resource = MountResource::class;
public function table(Table $table): Table
{
return $table
@ -56,6 +57,7 @@ class ListMounts extends ListRecords
->button(),
]);
}
protected function getHeaderActions(): array
{
return [

View File

@ -12,6 +12,7 @@ use Illuminate\Support\Number;
class NodeCpuChart extends ChartWidget
{
protected static ?string $pollingInterval = '5s';
protected static ?string $maxHeight = '300px';
public ?Model $record = null;

View File

@ -12,6 +12,7 @@ use Illuminate\Support\Number;
class NodeMemoryChart extends ChartWidget
{
protected static ?string $pollingInterval = '5s';
protected static ?string $maxHeight = '300px';
public ?Model $record = null;

View File

@ -9,7 +9,9 @@ use Illuminate\Database\Eloquent\Model;
class NodeStorageChart extends ChartWidget
{
protected static ?string $heading = 'Storage';
protected static ?string $pollingInterval = '60s';
protected static ?string $maxHeight = '300px';
public ?Model $record = null;

View File

@ -45,6 +45,7 @@ use LogicException;
class CreateServer extends CreateRecord
{
protected static string $resource = ServerResource::class;
protected static bool $canCreateAnother = false;
public ?Node $node = null;

View File

@ -741,6 +741,7 @@ class EditServer extends EditRecord
]);
}
protected function getHeaderActions(): array
{
return [
@ -763,6 +764,7 @@ class EditServer extends EditRecord
];
}
protected function getFormActions(): array
{
return [];

View File

@ -96,6 +96,7 @@ class ListServers extends ListRecords
->button(),
]);
}
protected function getHeaderActions(): array
{
return [

View File

@ -18,6 +18,7 @@ use Illuminate\Support\Facades\Hash;
class EditUser extends EditRecord
{
protected static string $resource = UserResource::class;
public function form(Form $form): Form
{
return $form
@ -46,6 +47,7 @@ class EditUser extends EditRecord
])->columns(),
]);
}
protected function getHeaderActions(): array
{
return [

View File

@ -78,6 +78,7 @@ class ListUsers extends ListRecords
]),
]);
}
protected function getHeaderActions(): array
{
return [

View File

@ -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 ?? ''));

View File

@ -15,6 +15,7 @@ class NodeViewController extends Controller
use JavascriptInjection;
public const THRESHOLD_PERCENTAGE_LOW = 75;
public const THRESHOLD_PERCENTAGE_MEDIUM = 90;
/**

View File

@ -51,8 +51,7 @@ abstract class ApplicationApiController extends Controller
*
* @template T of \App\Transformers\Api\Application\BaseTransformer
*
* @param class-string<T> $abstract
*
* @param class-string<T> $abstract
* @return T
*
* @noinspection PhpDocSignatureInspection

View File

@ -41,8 +41,7 @@ abstract class ClientApiController extends ApplicationApiController
*
* @template T of \App\Transformers\Api\Client\BaseClientTransformer
*
* @param class-string<T> $abstract
*
* @param class-string<T> $abstract
* @return T
*
* @noinspection PhpDocSignatureInspection

View File

@ -51,7 +51,7 @@ abstract class AbstractLoginController extends Controller
*
* @throws \App\Exceptions\DisplayException
*/
protected function sendFailedLoginResponse(Request $request, Authenticatable $user = null, string $message = null): never
protected function sendFailedLoginResponse(Request $request, ?Authenticatable $user = null, ?string $message = null): never
{
$this->incrementLoginAttempts($request);
$this->fireFailedLoginEvent($user, [
@ -91,7 +91,7 @@ abstract class AbstractLoginController extends Controller
/**
* Determine if the user is logging in using an email or username.
*/
protected function getField(string $input = null): string
protected function getField(?string $input = null): string
{
return ($input && str_contains($input, '@')) ? 'email' : 'username';
}
@ -99,7 +99,7 @@ abstract class AbstractLoginController extends Controller
/**
* Fire a failed login event.
*/
protected function fireFailedLoginEvent(Authenticatable $user = null, array $credentials = []): void
protected function fireFailedLoginEvent(?Authenticatable $user = null, array $credentials = []): void
{
Event::dispatch(new Failed('auth', $user, $credentials));
}

View File

@ -64,8 +64,8 @@ class ResetPasswordController extends Controller
* account do not automatically log them in. In those cases, send the user back to the login
* form with a note telling them their password was changed and to log back in.
*
* @param \Illuminate\Contracts\Auth\CanResetPassword|\App\Models\User $user
* @param string $password
* @param \Illuminate\Contracts\Auth\CanResetPassword|\App\Models\User $user
* @param string $password
*
* @throws \App\Exceptions\Model\DataValidationException
*/

View File

@ -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');

View File

@ -10,7 +10,9 @@ use App\Exceptions\Http\TwoFactorAuthRequiredException;
class RequireTwoFactorAuthentication
{
public const LEVEL_NONE = 0;
public const LEVEL_ADMIN = 1;
public const LEVEL_ALL = 2;
/**

View File

@ -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()));
}

View File

@ -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()));

View File

@ -74,8 +74,7 @@ abstract class ApplicationApiRequest extends FormRequest
*
* @template T of \Illuminate\Database\Eloquent\Model
*
* @param class-string<T> $expect
*
* @param class-string<T> $expect
* @return T
*
* @noinspection PhpDocSignatureInspection

View File

@ -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();
}

View File

@ -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');

View File

@ -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');

View File

@ -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',

View File

@ -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');

View File

@ -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',

View File

@ -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',

View File

@ -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();

View File

@ -9,7 +9,7 @@ class UpdateUserRequest extends StoreUserRequest
/**
* Return the validation rules for this request.
*/
public function rules(array $rules = null): array
public function rules(?array $rules = null): array
{
$user = $this->parameter('user', User::class);

View File

@ -42,5 +42,4 @@ class NodeStatistics implements ShouldQueue
}
}
}
}

View File

@ -90,7 +90,7 @@ class RunTaskJob extends Job implements ShouldQueue
/**
* Handle a failure while sending the action to the daemon or otherwise processing the job.
*/
public function failed(\Exception $exception = null): void
public function failed(?\Exception $exception = null): void
{
$this->markTaskNotQueued();
$this->markScheduleComplete();

View File

@ -9,6 +9,7 @@ use Livewire\Component;
class NodeSystemInformation extends Component
{
public Node $node;
public string $sizeClasses;
public function render(): View

View File

@ -26,6 +26,7 @@ use Illuminate\Database\Eloquent\SoftDeletingScope;
class ActivityLogSubject extends Pivot
{
public $incrementing = true;
public $timestamps = false;
protected $table = 'activity_log_subjects';

View File

@ -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.

View File

@ -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';

View File

@ -70,6 +70,7 @@ class Egg extends Model
* than leaving it null.
*/
public const FEATURE_EULA_POPUP = 'eula';
public const FEATURE_FASTDL = 'fastdl';
/**

View File

@ -11,7 +11,7 @@ class AdminServerFilter implements Filter
* A multi-column filter for the servers table that allows an administrative user to search
* across UUID, name, owner username, and owner email.
*
* @param string $value
* @param string $value
*/
public function __invoke(Builder $query, $value, string $property): void
{

View File

@ -19,7 +19,7 @@ class MultiFieldServerFilter implements Filter
* search across multiple columns. This allows us to provide a very generic search ability for
* the frontend.
*
* @param string $value
* @param string $value
*/
public function __invoke(Builder $query, $value, string $property): void
{

View File

@ -54,6 +54,7 @@ class Node extends Model
public const RESOURCE_NAME = 'node';
public const DAEMON_TOKEN_ID_LENGTH = 16;
public const DAEMON_TOKEN_LENGTH = 64;
/**
@ -136,7 +137,9 @@ class Node extends Model
}
public int $servers_sum_memory = 0;
public int $servers_sum_disk = 0;
public int $servers_sum_cpu = 0;
public function getRouteKeyName(): string

View File

@ -45,5 +45,4 @@ class DeploymentObject
return $this;
}
}

View File

@ -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';

View File

@ -71,6 +71,7 @@ use App\Exceptions\Http\Server\ServerStateConflictException;
* @property \App\Models\User $user
* @property \Illuminate\Database\Eloquent\Collection|\App\Models\EggVariable[] $variables
* @property int|null $variables_count
*
* @method static \Database\Factories\ServerFactory factory(...$parameters)
* @method static \Illuminate\Database\Eloquent\Builder|Server newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|Server newQuery()
@ -101,6 +102,7 @@ use App\Exceptions\Http\Server\ServerStateConflictException;
* @method static \Illuminate\Database\Eloquent\Builder|Server whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|Server whereUuid($value)
* @method static \Illuminate\Database\Eloquent\Builder|Server whereuuid_short($value)
*
* @property array|null $docker_labels
* @property string|null $ports
* @property-read mixed $condition
@ -108,10 +110,12 @@ use App\Exceptions\Http\Server\ServerStateConflictException;
* @property-read int|null $egg_variables_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\ServerVariable> $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

View File

@ -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';
/**

View File

@ -99,6 +99,7 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac
use Notifiable;
public const USER_LEVEL_USER = 0;
public const USER_LEVEL_ADMIN = 1;
/**
@ -233,7 +234,7 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac
/**
* Send the password reset notification.
*
* @param string $token
* @param string $token
*/
public function sendPasswordResetNotification($token): void
{

View File

@ -51,7 +51,7 @@ class DaemonBackupRepository extends DaemonRepository
*
* @throws \App\Exceptions\Http\Connection\DaemonConnectionException
*/
public function restore(Backup $backup, string $url = null, bool $truncate = false): Response
public function restore(Backup $backup, ?string $url = null, bool $truncate = false): Response
{
Assert::isInstanceOf($this->server, Server::class);

View File

@ -16,13 +16,13 @@ class DaemonFileRepository extends DaemonRepository
/**
* Return the contents of a given file.
*
* @param int|null $notLargerThan the maximum content length in bytes
* @param int|null $notLargerThan the maximum content length in bytes
*
* @throws \GuzzleHttp\Exception\TransferException
* @throws \App\Exceptions\Http\Server\FileSizeTooLargeException
* @throws \App\Exceptions\Http\Connection\DaemonConnectionException
*/
public function getContent(string $path, int $notLargerThan = null): string
public function getContent(string $path, ?int $notLargerThan = null): string
{
Assert::isInstanceOf($this->server, Server::class);

View File

@ -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
{

View File

@ -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';
/**

View File

@ -7,6 +7,7 @@ use Ramsey\Uuid\Uuid;
class ActivityLogBatchService
{
protected int $transaction = 0;
protected ?string $uuid = null;
/**

View File

@ -64,7 +64,7 @@ class ActivityLogService
*
* @template T extends \Illuminate\Database\Eloquent\Model|\Illuminate\Contracts\Auth\Authenticatable
*
* @param T|T[]|null $subjects
* @param T|T[]|null $subjects
*/
public function subject(...$subjects): self
{
@ -100,8 +100,8 @@ class ActivityLogService
/**
* Sets a custom property on the activity log instance.
*
* @param string|array $key
* @param mixed $value
* @param string|array $key
* @param mixed $value
*/
public function property($key, $value = null): self
{
@ -130,7 +130,7 @@ class ActivityLogService
* performing this action it will be logged to the disk but will not interrupt
* the code flow.
*/
public function log(string $description = null): ActivityLog
public function log(?string $description = null): ActivityLog
{
$activity = $this->getActivity();

View File

@ -16,10 +16,15 @@ use App\Exceptions\Service\Allocation\TooManyPortsInRangeException;
class AssignmentService
{
public const CIDR_MAX_BITS = 25;
public const CIDR_MIN_BITS = 32;
public const PORT_FLOOR = 1024;
public const PORT_CEIL = 65535;
public const PORT_RANGE_LIMIT = 1000;
public const PORT_RANGE_REGEX = '/^(\d{4,5})-(\d{4,5})$/';
/**
@ -38,7 +43,7 @@ class AssignmentService
* @throws \App\Exceptions\Service\Allocation\PortOutOfRangeException
* @throws \App\Exceptions\Service\Allocation\TooManyPortsInRangeException
*/
public function handle(Node $node, array $data, Server $server = null): array
public function handle(Node $node, array $data, ?Server $server = null): array
{
$explode = explode('/', $data['allocation_ip']);
if (count($explode) !== 1) {

View File

@ -43,7 +43,7 @@ class InitiateBackupService
/**
* Sets the files to be ignored by this backup.
*
* @param string[]|null $ignored
* @param string[]|null $ignored
*/
public function setIgnoredFiles(?array $ignored): self
{
@ -70,7 +70,7 @@ class InitiateBackupService
* @throws \App\Exceptions\Service\Backup\TooManyBackupsException
* @throws \Symfony\Component\HttpKernel\Exception\TooManyRequestsHttpException
*/
public function handle(Server $server, string $name = null, bool $override = false): Backup
public function handle(Server $server, ?string $name = null, bool $override = false): Backup
{
$limit = config('backups.throttles.limit');
$period = config('backups.throttles.period');

View File

@ -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();

View File

@ -19,6 +19,7 @@ class DeleteFilesService
/**
* Deletes the given files.
*
* @throws DaemonConnectionException
*/
public function handle(Server $server, array $files): void

View File

@ -93,5 +93,4 @@ class ServerConfigurationStructureService
return $response;
}
}

View File

@ -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'];

View File

@ -12,6 +12,7 @@ use Symfony\Component\HttpKernel\Exception\ConflictHttpException;
class SuspensionService
{
public const ACTION_SUSPEND = 'suspend';
public const ACTION_UNSUSPEND = 'unsuspend';
/**

View File

@ -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'));

View File

@ -22,6 +22,7 @@ trait EnvironmentWriterTrait
/**
* Update the .env file for the application using the passed in values.
*
* @throws Exception
*/
public function writeToEnvironment(array $values = []): void

View File

@ -90,8 +90,7 @@ abstract class BaseTransformer extends TransformerAbstract
*
* @template T of \App\Transformers\Api\Application\BaseTransformer
*
* @param class-string<T> $abstract
*
* @param class-string<T> $abstract
* @return T
*
* @throws \App\Exceptions\Transformer\InvalidTransformerLevelException

View File

@ -112,7 +112,7 @@ class ActivityLogTransformer extends BaseClientTransformer
* Determines if the user can view the IP address in the output either because they are the
* actor that performed the action, or because they are an administrator on the Panel.
*/
protected function canViewIP(Model $actor = null): bool
protected function canViewIP(?Model $actor = null): bool
{
return $actor?->is($this->request->user()) || $this->request->user()->isRootAdmin();
}

View File

@ -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);

View File

@ -1,12 +1,8 @@
{
"preset": "laravel",
"rules": {
"class_attributes_separation": false,
"concat_space": false,
"not_operator_with_successor_space": false,
"nullable_type_declaration_for_default_null_value": false,
"ordered_imports": false,
"phpdoc_align": false,
"phpdoc_separation": false
"ordered_imports": false
}
}

View File

@ -11,7 +11,7 @@ use App\Models\ActivityLogSubject;
trait AssertsActivityLogged
{
/**
* @param \Illuminate\Database\Eloquent\Model|array $subjects
* @param \Illuminate\Database\Eloquent\Model|array $subjects
*/
public function assertActivityFor(string $event, ?Model $actor, ...$subjects): void
{

View File

@ -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:

View File

@ -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
*/

View File

@ -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;

View File

@ -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);

View File

@ -65,8 +65,7 @@ trait CreatesTestModels
* Generates a user and a server for that user. If an array of permissions is passed it
* is assumed that the user is actually a subuser of the server.
*
* @param string[] $permissions
*
* @param string[] $permissions
* @return array{\App\Models\User, \App\Models\Server}
*/
public function generateTestAccount(array $permissions = []): array