From c0a41acf1f1c9f415afca82e8f9c317df32bd7c8 Mon Sep 17 00:00:00 2001 From: Lance Pioch Date: Sat, 19 Oct 2024 18:29:44 -0400 Subject: [PATCH 1/7] Add class_attributes_separation --- app/Exceptions/DisplayException.php | 3 ++ .../TwoFactorAuthenticationTokenInvalid.php | 1 + app/Extensions/DynamicDatabaseConnection.php | 2 ++ app/Filament/Pages/Settings.php | 1 + app/Filament/Resources/ApiKeyResource.php | 3 ++ .../Resources/DatabaseHostResource.php | 1 + .../DatabasesRelationManager.php | 1 + app/Filament/Resources/DatabaseResource.php | 1 + .../Resources/EggResource/Pages/CreateEgg.php | 1 + .../Resources/EggResource/Pages/ListEggs.php | 1 + app/Filament/Resources/MountResource.php | 1 + .../MountResource/Pages/EditMount.php | 1 + .../MountResource/Pages/ListMounts.php | 2 ++ .../NodeResource/Widgets/NodeCpuChart.php | 1 + .../NodeResource/Widgets/NodeMemoryChart.php | 1 + .../NodeResource/Widgets/NodeStorageChart.php | 2 ++ .../ServerResource/Pages/CreateServer.php | 1 + .../ServerResource/Pages/EditServer.php | 2 ++ .../ServerResource/Pages/ListServers.php | 1 + .../Resources/UserResource/Pages/EditUser.php | 2 ++ .../UserResource/Pages/ListUsers.php | 1 + .../Admin/Nodes/NodeViewController.php | 1 + .../RequireTwoFactorAuthentication.php | 2 ++ app/Jobs/NodeStatistics.php | 1 - app/Livewire/NodeSystemInformation.php | 1 + app/Models/ActivityLogSubject.php | 1 + app/Models/ApiKey.php | 7 +++++ app/Models/Backup.php | 1 + app/Models/Egg.php | 1 + app/Models/Node.php | 3 ++ app/Models/Objects/DeploymentObject.php | 1 - app/Models/Permission.php | 30 +++++++++++++++++++ app/Models/Task.php | 3 ++ app/Models/User.php | 1 + app/Services/Acl/Api/AdminAcl.php | 10 +++++++ .../Activity/ActivityLogBatchService.php | 1 + .../Allocations/AssignmentService.php | 5 ++++ .../ServerConfigurationStructureService.php | 1 - app/Services/Servers/SuspensionService.php | 1 + pint.json | 1 - 40 files changed, 98 insertions(+), 4 deletions(-) diff --git a/app/Exceptions/DisplayException.php b/app/Exceptions/DisplayException.php index 6c44c356c..025c45fe5 100644 --- a/app/Exceptions/DisplayException.php +++ b/app/Exceptions/DisplayException.php @@ -14,8 +14,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'; /** diff --git a/app/Exceptions/Service/User/TwoFactorAuthenticationTokenInvalid.php b/app/Exceptions/Service/User/TwoFactorAuthenticationTokenInvalid.php index d5f09884c..0c058d0d8 100644 --- a/app/Exceptions/Service/User/TwoFactorAuthenticationTokenInvalid.php +++ b/app/Exceptions/Service/User/TwoFactorAuthenticationTokenInvalid.php @@ -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() diff --git a/app/Extensions/DynamicDatabaseConnection.php b/app/Extensions/DynamicDatabaseConnection.php index d14407427..147f78064 100644 --- a/app/Extensions/DynamicDatabaseConnection.php +++ b/app/Extensions/DynamicDatabaseConnection.php @@ -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'; /** diff --git a/app/Filament/Pages/Settings.php b/app/Filament/Pages/Settings.php index f3ef2c2b9..f8d18a01c 100644 --- a/app/Filament/Pages/Settings.php +++ b/app/Filament/Pages/Settings.php @@ -38,6 +38,7 @@ class Settings extends Page implements HasForms use InteractsWithHeaderActions; protected static ?string $navigationIcon = 'tabler-settings'; + protected static ?string $navigationGroup = 'Advanced'; protected static string $view = 'filament.pages.settings'; diff --git a/app/Filament/Resources/ApiKeyResource.php b/app/Filament/Resources/ApiKeyResource.php index ba2a851ca..11ebc6813 100644 --- a/app/Filament/Resources/ApiKeyResource.php +++ b/app/Filament/Resources/ApiKeyResource.php @@ -9,8 +9,11 @@ use Filament\Resources\Resource; class ApiKeyResource extends Resource { protected static ?string $model = ApiKey::class; + protected static ?string $label = 'API Key'; + protected static ?string $navigationIcon = 'tabler-key'; + protected static ?string $navigationGroup = 'Advanced'; public static function getNavigationBadge(): ?string diff --git a/app/Filament/Resources/DatabaseHostResource.php b/app/Filament/Resources/DatabaseHostResource.php index 7576fbc3a..790895983 100644 --- a/app/Filament/Resources/DatabaseHostResource.php +++ b/app/Filament/Resources/DatabaseHostResource.php @@ -13,6 +13,7 @@ class DatabaseHostResource extends Resource protected static ?string $label = 'Database Host'; protected static ?string $navigationIcon = 'tabler-database'; + protected static ?string $navigationGroup = 'Advanced'; public static function getNavigationBadge(): ?string diff --git a/app/Filament/Resources/DatabaseHostResource/RelationManagers/DatabasesRelationManager.php b/app/Filament/Resources/DatabaseHostResource/RelationManagers/DatabasesRelationManager.php index 4dfcdd955..13b32602f 100644 --- a/app/Filament/Resources/DatabaseHostResource/RelationManagers/DatabasesRelationManager.php +++ b/app/Filament/Resources/DatabaseHostResource/RelationManagers/DatabasesRelationManager.php @@ -40,6 +40,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 diff --git a/app/Filament/Resources/DatabaseResource.php b/app/Filament/Resources/DatabaseResource.php index 92580dfdf..912f6fe93 100644 --- a/app/Filament/Resources/DatabaseResource.php +++ b/app/Filament/Resources/DatabaseResource.php @@ -13,6 +13,7 @@ class DatabaseResource extends Resource protected static ?string $navigationIcon = 'tabler-database'; protected static bool $shouldRegisterNavigation = false; + protected static ?string $navigationGroup = 'Advanced'; public static function getNavigationBadge(): ?string diff --git a/app/Filament/Resources/EggResource/Pages/CreateEgg.php b/app/Filament/Resources/EggResource/Pages/CreateEgg.php index a663540cb..4ec91ea24 100644 --- a/app/Filament/Resources/EggResource/Pages/CreateEgg.php +++ b/app/Filament/Resources/EggResource/Pages/CreateEgg.php @@ -27,6 +27,7 @@ class CreateEgg extends CreateRecord protected static string $resource = EggResource::class; protected static bool $canCreateAnother = false; + public function form(Form $form): Form { return $form diff --git a/app/Filament/Resources/EggResource/Pages/ListEggs.php b/app/Filament/Resources/EggResource/Pages/ListEggs.php index 792eaa162..a7f84b274 100644 --- a/app/Filament/Resources/EggResource/Pages/ListEggs.php +++ b/app/Filament/Resources/EggResource/Pages/ListEggs.php @@ -97,6 +97,7 @@ class ListEggs extends ListRecords ]), ]); } + protected function getHeaderActions(): array { return [ diff --git a/app/Filament/Resources/MountResource.php b/app/Filament/Resources/MountResource.php index a2d7a187e..a30f586e1 100644 --- a/app/Filament/Resources/MountResource.php +++ b/app/Filament/Resources/MountResource.php @@ -11,6 +11,7 @@ class MountResource extends Resource protected static ?string $model = Mount::class; protected static ?string $navigationIcon = 'tabler-layers-linked'; + protected static ?string $navigationGroup = 'Advanced'; public static function getNavigationBadge(): ?string diff --git a/app/Filament/Resources/MountResource/Pages/EditMount.php b/app/Filament/Resources/MountResource/Pages/EditMount.php index 71c6febb5..e44fb581b 100644 --- a/app/Filament/Resources/MountResource/Pages/EditMount.php +++ b/app/Filament/Resources/MountResource/Pages/EditMount.php @@ -96,6 +96,7 @@ class EditMount extends EditRecord 'lg' => 2, ]); } + protected function getHeaderActions(): array { return [ diff --git a/app/Filament/Resources/MountResource/Pages/ListMounts.php b/app/Filament/Resources/MountResource/Pages/ListMounts.php index d39c5d972..10bfbc6dd 100644 --- a/app/Filament/Resources/MountResource/Pages/ListMounts.php +++ b/app/Filament/Resources/MountResource/Pages/ListMounts.php @@ -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 [ diff --git a/app/Filament/Resources/NodeResource/Widgets/NodeCpuChart.php b/app/Filament/Resources/NodeResource/Widgets/NodeCpuChart.php index 476b8b533..89d1cb254 100644 --- a/app/Filament/Resources/NodeResource/Widgets/NodeCpuChart.php +++ b/app/Filament/Resources/NodeResource/Widgets/NodeCpuChart.php @@ -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; diff --git a/app/Filament/Resources/NodeResource/Widgets/NodeMemoryChart.php b/app/Filament/Resources/NodeResource/Widgets/NodeMemoryChart.php index 9d75fd116..0cabbed51 100644 --- a/app/Filament/Resources/NodeResource/Widgets/NodeMemoryChart.php +++ b/app/Filament/Resources/NodeResource/Widgets/NodeMemoryChart.php @@ -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; diff --git a/app/Filament/Resources/NodeResource/Widgets/NodeStorageChart.php b/app/Filament/Resources/NodeResource/Widgets/NodeStorageChart.php index b841d84ef..61db8c98d 100644 --- a/app/Filament/Resources/NodeResource/Widgets/NodeStorageChart.php +++ b/app/Filament/Resources/NodeResource/Widgets/NodeStorageChart.php @@ -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; diff --git a/app/Filament/Resources/ServerResource/Pages/CreateServer.php b/app/Filament/Resources/ServerResource/Pages/CreateServer.php index c1f6aa22e..b8ac8a520 100644 --- a/app/Filament/Resources/ServerResource/Pages/CreateServer.php +++ b/app/Filament/Resources/ServerResource/Pages/CreateServer.php @@ -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; diff --git a/app/Filament/Resources/ServerResource/Pages/EditServer.php b/app/Filament/Resources/ServerResource/Pages/EditServer.php index 51a59591d..267fd998f 100644 --- a/app/Filament/Resources/ServerResource/Pages/EditServer.php +++ b/app/Filament/Resources/ServerResource/Pages/EditServer.php @@ -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 []; diff --git a/app/Filament/Resources/ServerResource/Pages/ListServers.php b/app/Filament/Resources/ServerResource/Pages/ListServers.php index 326499898..dd6fc4a16 100644 --- a/app/Filament/Resources/ServerResource/Pages/ListServers.php +++ b/app/Filament/Resources/ServerResource/Pages/ListServers.php @@ -96,6 +96,7 @@ class ListServers extends ListRecords ->button(), ]); } + protected function getHeaderActions(): array { return [ diff --git a/app/Filament/Resources/UserResource/Pages/EditUser.php b/app/Filament/Resources/UserResource/Pages/EditUser.php index 777f20d73..3fa6a5571 100644 --- a/app/Filament/Resources/UserResource/Pages/EditUser.php +++ b/app/Filament/Resources/UserResource/Pages/EditUser.php @@ -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 [ diff --git a/app/Filament/Resources/UserResource/Pages/ListUsers.php b/app/Filament/Resources/UserResource/Pages/ListUsers.php index 3d9a1af18..c386d4ce6 100644 --- a/app/Filament/Resources/UserResource/Pages/ListUsers.php +++ b/app/Filament/Resources/UserResource/Pages/ListUsers.php @@ -78,6 +78,7 @@ class ListUsers extends ListRecords ]), ]); } + protected function getHeaderActions(): array { return [ diff --git a/app/Http/Controllers/Admin/Nodes/NodeViewController.php b/app/Http/Controllers/Admin/Nodes/NodeViewController.php index 95dc7ede0..115b7b6b1 100644 --- a/app/Http/Controllers/Admin/Nodes/NodeViewController.php +++ b/app/Http/Controllers/Admin/Nodes/NodeViewController.php @@ -15,6 +15,7 @@ class NodeViewController extends Controller use JavascriptInjection; public const THRESHOLD_PERCENTAGE_LOW = 75; + public const THRESHOLD_PERCENTAGE_MEDIUM = 90; /** diff --git a/app/Http/Middleware/RequireTwoFactorAuthentication.php b/app/Http/Middleware/RequireTwoFactorAuthentication.php index 470cc73b3..58ff1564d 100644 --- a/app/Http/Middleware/RequireTwoFactorAuthentication.php +++ b/app/Http/Middleware/RequireTwoFactorAuthentication.php @@ -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; /** diff --git a/app/Jobs/NodeStatistics.php b/app/Jobs/NodeStatistics.php index 19fae9b9d..9546f0ba0 100644 --- a/app/Jobs/NodeStatistics.php +++ b/app/Jobs/NodeStatistics.php @@ -42,5 +42,4 @@ class NodeStatistics implements ShouldQueue } } } - } diff --git a/app/Livewire/NodeSystemInformation.php b/app/Livewire/NodeSystemInformation.php index b29190251..4f2a5de0a 100644 --- a/app/Livewire/NodeSystemInformation.php +++ b/app/Livewire/NodeSystemInformation.php @@ -8,6 +8,7 @@ use Livewire\Component; class NodeSystemInformation extends Component { public Node $node; + public string $sizeClasses; public function render() diff --git a/app/Models/ActivityLogSubject.php b/app/Models/ActivityLogSubject.php index 037d344f0..b4b31e58f 100644 --- a/app/Models/ActivityLogSubject.php +++ b/app/Models/ActivityLogSubject.php @@ -25,6 +25,7 @@ use Illuminate\Database\Eloquent\SoftDeletes; class ActivityLogSubject extends Pivot { public $incrementing = true; + public $timestamps = false; protected $table = 'activity_log_subjects'; diff --git a/app/Models/ApiKey.php b/app/Models/ApiKey.php index 52d78a97b..96c714f24 100644 --- a/app/Models/ApiKey.php +++ b/app/Models/ApiKey.php @@ -63,21 +63,28 @@ class ApiKey extends Model * API representation using fractal. */ public const RESOURCE_NAME = 'api_key'; + /** * Different API keys that can exist on the system. */ public const TYPE_NONE = 0; + public const TYPE_ACCOUNT = 1; + /* @deprecated */ public const TYPE_APPLICATION = 2; + /* @deprecated */ public const TYPE_DAEMON_USER = 3; + /* @deprecated */ public const TYPE_DAEMON_APPLICATION = 4; + /** * The length of API key identifiers. */ public const IDENTIFIER_LENGTH = 16; + /** * The length of the actual API key that is encrypted and stored * in the database. diff --git a/app/Models/Backup.php b/app/Models/Backup.php index 3f2a931d1..d6e4be65a 100644 --- a/app/Models/Backup.php +++ b/app/Models/Backup.php @@ -32,6 +32,7 @@ class Backup extends Model public const RESOURCE_NAME = 'backup'; public const ADAPTER_DAEMON = 'wings'; + public const ADAPTER_AWS_S3 = 's3'; protected $table = 'backups'; diff --git a/app/Models/Egg.php b/app/Models/Egg.php index e8c672064..001be85e3 100644 --- a/app/Models/Egg.php +++ b/app/Models/Egg.php @@ -70,6 +70,7 @@ class Egg extends Model * than leaving it null. */ public const FEATURE_EULA_POPUP = 'eula'; + public const FEATURE_FASTDL = 'fastdl'; /** diff --git a/app/Models/Node.php b/app/Models/Node.php index 0a9613196..da5416091 100644 --- a/app/Models/Node.php +++ b/app/Models/Node.php @@ -53,6 +53,7 @@ class Node extends Model public const RESOURCE_NAME = 'node'; public const DAEMON_TOKEN_ID_LENGTH = 16; + public const DAEMON_TOKEN_LENGTH = 64; /** @@ -135,7 +136,9 @@ 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 diff --git a/app/Models/Objects/DeploymentObject.php b/app/Models/Objects/DeploymentObject.php index b7a4ebaf3..692ca7487 100644 --- a/app/Models/Objects/DeploymentObject.php +++ b/app/Models/Objects/DeploymentObject.php @@ -45,5 +45,4 @@ class DeploymentObject return $this; } - } diff --git a/app/Models/Permission.php b/app/Models/Permission.php index ab9fef260..29cbd826d 100644 --- a/app/Models/Permission.php +++ b/app/Models/Permission.php @@ -16,51 +16,81 @@ class Permission extends Model * Constants defining different permissions available. */ public const ACTION_WEBSOCKET_CONNECT = 'websocket.connect'; + public const ACTION_CONTROL_CONSOLE = 'control.console'; + public const ACTION_CONTROL_START = 'control.start'; + public const ACTION_CONTROL_STOP = 'control.stop'; + public const ACTION_CONTROL_RESTART = 'control.restart'; public const ACTION_DATABASE_READ = 'database.read'; + public const ACTION_DATABASE_CREATE = 'database.create'; + public const ACTION_DATABASE_UPDATE = 'database.update'; + public const ACTION_DATABASE_DELETE = 'database.delete'; + public const ACTION_DATABASE_VIEW_PASSWORD = 'database.view_password'; public const ACTION_SCHEDULE_READ = 'schedule.read'; + public const ACTION_SCHEDULE_CREATE = 'schedule.create'; + public const ACTION_SCHEDULE_UPDATE = 'schedule.update'; + public const ACTION_SCHEDULE_DELETE = 'schedule.delete'; public const ACTION_USER_READ = 'user.read'; + public const ACTION_USER_CREATE = 'user.create'; + public const ACTION_USER_UPDATE = 'user.update'; + public const ACTION_USER_DELETE = 'user.delete'; public const ACTION_BACKUP_READ = 'backup.read'; + public const ACTION_BACKUP_CREATE = 'backup.create'; + public const ACTION_BACKUP_DELETE = 'backup.delete'; + public const ACTION_BACKUP_DOWNLOAD = 'backup.download'; + public const ACTION_BACKUP_RESTORE = 'backup.restore'; public const ACTION_ALLOCATION_READ = 'allocation.read'; + public const ACTION_ALLOCATION_CREATE = 'allocation.create'; + public const ACTION_ALLOCATION_UPDATE = 'allocation.update'; + public const ACTION_ALLOCATION_DELETE = 'allocation.delete'; public const ACTION_FILE_READ = 'file.read'; + public const ACTION_FILE_READ_CONTENT = 'file.read-content'; + public const ACTION_FILE_CREATE = 'file.create'; + public const ACTION_FILE_UPDATE = 'file.update'; + public const ACTION_FILE_DELETE = 'file.delete'; + public const ACTION_FILE_ARCHIVE = 'file.archive'; + public const ACTION_FILE_SFTP = 'file.sftp'; public const ACTION_STARTUP_READ = 'startup.read'; + public const ACTION_STARTUP_UPDATE = 'startup.update'; + public const ACTION_STARTUP_DOCKER_IMAGE = 'startup.docker-image'; public const ACTION_SETTINGS_RENAME = 'settings.rename'; + public const ACTION_SETTINGS_REINSTALL = 'settings.reinstall'; public const ACTION_ACTIVITY_READ = 'activity.read'; diff --git a/app/Models/Task.php b/app/Models/Task.php index 254d38ece..202a3165a 100644 --- a/app/Models/Task.php +++ b/app/Models/Task.php @@ -31,8 +31,11 @@ class Task extends Model * The default actions that can exist for a task */ public const ACTION_POWER = 'power'; + public const ACTION_COMMAND = 'command'; + public const ACTION_BACKUP = 'backup'; + public const ACTION_DELETE_FILES = 'delete_files'; /** diff --git a/app/Models/User.php b/app/Models/User.php index 395f4994f..3b4eff193 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -99,6 +99,7 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac use Notifiable; public const USER_LEVEL_USER = 0; + public const USER_LEVEL_ADMIN = 1; /** diff --git a/app/Services/Acl/Api/AdminAcl.php b/app/Services/Acl/Api/AdminAcl.php index dd58e317c..90ec6480a 100644 --- a/app/Services/Acl/Api/AdminAcl.php +++ b/app/Services/Acl/Api/AdminAcl.php @@ -17,7 +17,9 @@ class AdminAcl * implements a read/write/none permissions scheme for all endpoints. */ public const NONE = 0; + public const READ = 1; + public const WRITE = 2; /** @@ -25,13 +27,21 @@ class AdminAcl * set for each key. These are stored in the database as r_{resource}. */ public const RESOURCE_SERVERS = 'servers'; + public const RESOURCE_NODES = 'nodes'; + public const RESOURCE_ALLOCATIONS = 'allocations'; + public const RESOURCE_USERS = 'users'; + public const RESOURCE_EGGS = 'eggs'; + public const RESOURCE_DATABASE_HOSTS = 'database_hosts'; + public const RESOURCE_SERVER_DATABASES = 'server_databases'; + public const RESOURCE_MOUNTS = 'mounts'; + public const RESOURCE_ROLES = 'roles'; /** diff --git a/app/Services/Activity/ActivityLogBatchService.php b/app/Services/Activity/ActivityLogBatchService.php index cb2e91b5c..df237286f 100644 --- a/app/Services/Activity/ActivityLogBatchService.php +++ b/app/Services/Activity/ActivityLogBatchService.php @@ -7,6 +7,7 @@ use Ramsey\Uuid\Uuid; class ActivityLogBatchService { protected int $transaction = 0; + protected ?string $uuid = null; /** diff --git a/app/Services/Allocations/AssignmentService.php b/app/Services/Allocations/AssignmentService.php index 33ed4aa74..be4c04131 100644 --- a/app/Services/Allocations/AssignmentService.php +++ b/app/Services/Allocations/AssignmentService.php @@ -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})$/'; /** diff --git a/app/Services/Servers/ServerConfigurationStructureService.php b/app/Services/Servers/ServerConfigurationStructureService.php index 43b8c9736..7ac714ed5 100644 --- a/app/Services/Servers/ServerConfigurationStructureService.php +++ b/app/Services/Servers/ServerConfigurationStructureService.php @@ -93,5 +93,4 @@ class ServerConfigurationStructureService return $response; } - } diff --git a/app/Services/Servers/SuspensionService.php b/app/Services/Servers/SuspensionService.php index aef02b7b2..b175bccb6 100644 --- a/app/Services/Servers/SuspensionService.php +++ b/app/Services/Servers/SuspensionService.php @@ -12,6 +12,7 @@ use Symfony\Component\HttpKernel\Exception\ConflictHttpException; class SuspensionService { public const ACTION_SUSPEND = 'suspend'; + public const ACTION_UNSUSPEND = 'unsuspend'; /** diff --git a/pint.json b/pint.json index 4d7ccf113..17de52db6 100644 --- a/pint.json +++ b/pint.json @@ -1,7 +1,6 @@ { "preset": "laravel", "rules": { - "class_attributes_separation": false, "concat_space": false, "not_operator_with_successor_space": false, "nullable_type_declaration_for_default_null_value": false, From 96acd268bee7005fe1691b572a4674575604d437 Mon Sep 17 00:00:00 2001 From: Lance Pioch Date: Sat, 19 Oct 2024 18:30:34 -0400 Subject: [PATCH 2/7] Add concat_space rule --- .../Environment/AppSettingsCommand.php | 2 +- .../Environment/EmailSettingsCommand.php | 2 +- .../Environment/QueueWorkerServiceCommand.php | 6 +-- .../Maintenance/PruneImagesCommand.php | 2 +- .../Schedule/ProcessRunnableCommand.php | 2 +- app/Console/Commands/UpgradeCommand.php | 8 +-- app/Console/Kernel.php | 2 +- app/Exceptions/Handler.php | 4 +- app/Extensions/Backups/BackupManager.php | 2 +- app/Extensions/DynamicDatabaseConnection.php | 2 +- app/Extensions/Themes/Theme.php | 6 +-- .../Pages/Installer/Steps/CompletedStep.php | 4 +- .../Installer/Steps/RequirementsStep.php | 8 +-- .../ApiKeyResource/Pages/ListApiKeys.php | 2 +- .../DatabasesRelationManager.php | 4 +- .../Resources/EggResource/Pages/EditEgg.php | 2 +- .../Resources/EggResource/Pages/ListEggs.php | 2 +- .../NodeResource/Widgets/NodeCpuChart.php | 4 +- .../NodeResource/Widgets/NodeMemoryChart.php | 10 ++-- app/Filament/Resources/RoleResource.php | 18 +++---- .../ServerResource/Pages/CreateServer.php | 16 +++--- .../ServerResource/Pages/EditServer.php | 14 +++--- .../UserResource/Pages/EditProfile.php | 2 +- .../UserResource/Pages/ListUsers.php | 4 +- .../Admin/Eggs/EggShareController.php | 2 +- .../Admin/NodeAutoDeployController.php | 2 +- .../Admin/Servers/CreateServerController.php | 2 +- .../Controllers/Admin/ServersController.php | 2 +- .../Api/Client/Servers/FileController.php | 2 +- .../Client/Servers/FileUploadController.php | 2 +- .../Client/Servers/WebsocketController.php | 4 +- .../Remote/Backups/BackupStatusController.php | 2 +- .../Remote/SftpAuthenticationController.php | 2 +- app/Http/Controllers/Auth/OAuthController.php | 2 +- .../Middleware/Api/AuthenticateIPAccess.php | 2 +- .../Client/Server/ResourceBelongsToServer.php | 2 +- app/Http/Middleware/Api/IsValidJson.php | 2 +- .../RequireTwoFactorAuthentication.php | 2 +- .../Api/StoreApplicationApiKeyRequest.php | 2 +- .../Admin/Egg/EggVariableFormRequest.php | 2 +- .../Api/Client/Account/StoreApiKeyRequest.php | 2 +- app/Jobs/Schedule/RunTaskJob.php | 2 +- app/Models/ApiKey.php | 50 +++++++++---------- app/Models/EggVariable.php | 2 +- app/Models/Filters/MultiFieldServerFilter.php | 2 +- app/Models/Node.php | 4 +- app/Models/User.php | 4 +- app/Notifications/AccountCreated.php | 10 ++-- app/Notifications/AddedToServer.php | 6 +-- app/Notifications/MailTested.php | 2 +- app/Notifications/RemovedFromServer.php | 4 +- app/Notifications/SendPasswordReset.php | 2 +- app/Notifications/ServerInstalled.php | 4 +- app/Policies/DefaultPolicies.php | 10 ++-- .../Daemon/DaemonConfigurationRepository.php | 2 +- .../Daemon/DaemonServerRepository.php | 4 +- app/Services/Acl/Api/AdminAcl.php | 2 +- app/Services/Backups/DownloadLinkService.php | 2 +- app/Services/Files/DeleteFilesService.php | 2 +- app/Services/Helpers/AssetHashService.php | 4 +- .../Helpers/SoftwareVersionService.php | 4 +- .../Servers/StartupCommandService.php | 2 +- .../Servers/TransferServerService.php | 4 +- .../Servers/VariableValidatorService.php | 4 +- .../Subusers/SubuserCreationService.php | 2 +- app/Traits/EnvironmentWriterTrait.php | 6 +-- .../Api/Client/ActivityLogTransformer.php | 4 +- .../Api/Client/UserTransformer.php | 2 +- bootstrap/tests.php | 16 +++--- database/Factories/NodeFactory.php | 2 +- database/Factories/UserFactory.php | 4 +- database/Seeders/EggSeeder.php | 8 +-- ..._ChangeServiceVariablesValidationRules.php | 2 +- ...dPermissionsToPointToNewScheduleSystem.php | 4 +- ...628_RemoveDaemonSecretFromServersTable.php | 2 +- ...22_RemoveDaemonSecretFromSubusersTable.php | 2 +- ..._merge_permissions_table_into_subusers.php | 4 +- ...4_store_node_tokens_as_encrypted_value.php | 2 +- pint.json | 1 - tests/Assertions/AssertsActivityLogged.php | 2 +- .../MiddlewareAttributeAssertionsTrait.php | 4 +- .../ApplicationApiIntegrationTestCase.php | 4 +- .../Api/Application/EggControllerTest.php | 6 +-- .../Users/ExternalUserControllerTest.php | 4 +- .../Application/Users/UserControllerTest.php | 12 ++--- .../Api/Client/AccountControllerTest.php | 4 +- .../Api/Client/ApiKeyControllerTest.php | 8 +-- .../Client/ClientApiIntegrationTestCase.php | 2 +- .../Api/Client/ClientControllerTest.php | 2 +- .../AllocationAuthorizationTest.php | 12 ++--- .../Server/Backup/BackupAuthorizationTest.php | 12 ++--- .../Database/DatabaseAuthorizationTest.php | 12 ++--- .../Schedule/GetServerSchedulesTest.php | 10 ++-- .../Schedule/ScheduleAuthorizationTest.php | 12 ++--- .../Startup/GetStartupAndVariablesTest.php | 6 +-- .../Startup/UpdateStartupVariableTest.php | 16 +++--- .../Subuser/CreateServerSubuserTest.php | 18 +++---- .../Server/Subuser/DeleteSubuserTest.php | 8 +-- .../Subuser/SubuserAuthorizationTest.php | 6 +-- .../Api/Daemon/DaemonAuthenticateTest.php | 4 +- .../SftpAuthenticationControllerTest.php | 10 ++-- .../Controllers/Admin/UserControllerTest.php | 6 +-- .../DatabaseManagementServiceTest.php | 2 +- tests/Traits/Http/RequestMockHelpers.php | 2 +- tests/Traits/MocksUuids.php | 2 +- 105 files changed, 271 insertions(+), 272 deletions(-) diff --git a/app/Console/Commands/Environment/AppSettingsCommand.php b/app/Console/Commands/Environment/AppSettingsCommand.php index a16f38176..d1ce5c00e 100644 --- a/app/Console/Commands/Environment/AppSettingsCommand.php +++ b/app/Console/Commands/Environment/AppSettingsCommand.php @@ -16,7 +16,7 @@ class AppSettingsCommand extends Command $path = base_path('.env'); if (!file_exists($path)) { $this->comment('Copying example .env file'); - copy($path . '.example', $path); + copy($path.'.example', $path); } if (!config('app.key')) { diff --git a/app/Console/Commands/Environment/EmailSettingsCommand.php b/app/Console/Commands/Environment/EmailSettingsCommand.php index 87c8186c1..a1ec5f7c2 100644 --- a/app/Console/Commands/Environment/EmailSettingsCommand.php +++ b/app/Console/Commands/Environment/EmailSettingsCommand.php @@ -44,7 +44,7 @@ class EmailSettingsCommand extends Command env('MAIL_MAILER', env('MAIL_DRIVER', 'smtp')), ); - $method = 'setup' . studly_case($this->variables['MAIL_MAILER']) . 'DriverVariables'; + $method = 'setup'.studly_case($this->variables['MAIL_MAILER']).'DriverVariables'; if (method_exists($this, $method)) { $this->{$method}(); } diff --git a/app/Console/Commands/Environment/QueueWorkerServiceCommand.php b/app/Console/Commands/Environment/QueueWorkerServiceCommand.php index dbf1aa735..83266155b 100644 --- a/app/Console/Commands/Environment/QueueWorkerServiceCommand.php +++ b/app/Console/Commands/Environment/QueueWorkerServiceCommand.php @@ -19,7 +19,7 @@ class QueueWorkerServiceCommand extends Command public function handle(): void { $serviceName = $this->option('service-name') ?? $this->ask('Queue worker service name', 'pelican-queue'); - $path = '/etc/systemd/system/' . $serviceName . '.service'; + $path = '/etc/systemd/system/'.$serviceName.'.service'; $fileExists = file_exists($path); if ($fileExists && !$this->option('overwrite') && !$this->confirm('The service file already exists. Do you want to overwrite it?')) { @@ -65,7 +65,7 @@ WantedBy=multi-user.target if ($fileExists) { $result = Process::run("systemctl restart $serviceName.service"); if ($result->failed()) { - $this->error('Error restarting service: ' . $result->errorOutput()); + $this->error('Error restarting service: '.$result->errorOutput()); return; } @@ -74,7 +74,7 @@ WantedBy=multi-user.target } else { $result = Process::run("systemctl enable --now $serviceName.service"); if ($result->failed()) { - $this->error('Error enabling service: ' . $result->errorOutput()); + $this->error('Error enabling service: '.$result->errorOutput()); return; } diff --git a/app/Console/Commands/Maintenance/PruneImagesCommand.php b/app/Console/Commands/Maintenance/PruneImagesCommand.php index 23f613fa3..a2f8c36ce 100644 --- a/app/Console/Commands/Maintenance/PruneImagesCommand.php +++ b/app/Console/Commands/Maintenance/PruneImagesCommand.php @@ -50,7 +50,7 @@ class PruneImagesCommand extends Command $count = count($response['ImagesDeleted']); $useBinaryPrefix = config('panel.use_binary_prefix'); - $space = round($useBinaryPrefix ? $response['SpaceReclaimed'] / 1024 / 1024 : $response['SpaceReclaimed'] / 1000 / 1000, 2) . ($useBinaryPrefix ? ' MiB' : ' MB'); + $space = round($useBinaryPrefix ? $response['SpaceReclaimed'] / 1024 / 1024 : $response['SpaceReclaimed'] / 1000 / 1000, 2).($useBinaryPrefix ? ' MiB' : ' MB'); $this->info("Node {$node->id}: Cleaned up {$count} dangling docker images. ({$space})"); } catch (Exception $exception) { diff --git a/app/Console/Commands/Schedule/ProcessRunnableCommand.php b/app/Console/Commands/Schedule/ProcessRunnableCommand.php index d1d71ae02..67ee89f3d 100644 --- a/app/Console/Commands/Schedule/ProcessRunnableCommand.php +++ b/app/Console/Commands/Schedule/ProcessRunnableCommand.php @@ -67,7 +67,7 @@ class ProcessRunnableCommand extends Command } catch (\Throwable|\Exception $exception) { logger()->error($exception, ['schedule_id' => $schedule->id]); - $this->error(__('commands.schedule.process.no_tasks') . " #$schedule->id: " . $exception->getMessage()); + $this->error(__('commands.schedule.process.no_tasks')." #$schedule->id: ".$exception->getMessage()); } } } diff --git a/app/Console/Commands/UpgradeCommand.php b/app/Console/Commands/UpgradeCommand.php index 75a3c185f..8f97d6dd3 100644 --- a/app/Console/Commands/UpgradeCommand.php +++ b/app/Console/Commands/UpgradeCommand.php @@ -40,7 +40,7 @@ class UpgradeCommand extends Command } if (version_compare(PHP_VERSION, '7.4.0') < 0) { - $this->error(__('commands.upgrade.php_version') . ' [' . PHP_VERSION . '].'); + $this->error(__('commands.upgrade.php_version').' ['.PHP_VERSION.'].'); } $user = 'www-data'; @@ -125,7 +125,7 @@ class UpgradeCommand extends Command $command[] = '--no-dev'; } - $this->line('$upgrader> ' . implode(' ', $command)); + $this->line('$upgrader> '.implode(' ', $command)); $process = new Process($command); $process->setTimeout(10 * 60); $process->run(function ($type, $buffer) { @@ -134,7 +134,7 @@ class UpgradeCommand extends Command }); /** @var \Illuminate\Foundation\Application $app */ - $app = require __DIR__ . '/../../../bootstrap/app.php'; + $app = require __DIR__.'/../../../bootstrap/app.php'; /** @var \App\Console\Kernel $kernel */ $kernel = $app->make(Kernel::class); $kernel->bootstrap(); @@ -192,6 +192,6 @@ class UpgradeCommand extends Command return $this->option('url'); } - return sprintf(self::DEFAULT_URL, $this->option('release') ? 'download/v' . $this->option('release') : 'latest/download'); + return sprintf(self::DEFAULT_URL, $this->option('release') ? 'download/v'.$this->option('release') : 'latest/download'); } } diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 3c2fc96fa..f4a17cefc 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -20,7 +20,7 @@ class Kernel extends ConsoleKernel */ protected function commands(): void { - $this->load(__DIR__ . '/Commands'); + $this->load(__DIR__.'/Commands'); } /** diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index d30475f66..a8cc206d9 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -108,7 +108,7 @@ class Handler extends ExceptionHandler $exception->getLine() ); - return $message . "\nStack trace:\n" . trim($cleanedStack); + return $message."\nStack trace:\n".trim($cleanedStack); } /** @@ -160,7 +160,7 @@ class Handler extends ExceptionHandler 'source_field' => $field, 'rule' => str_replace(self::PANEL_RULE_STRING, 'p_', Arr::get( $codes, - str_replace('.', '_', $field) . '.' . $key + str_replace('.', '_', $field).'.'.$key )), ]; diff --git a/app/Extensions/Backups/BackupManager.php b/app/Extensions/Backups/BackupManager.php index ad1cfdbbc..8fcb1e198 100644 --- a/app/Extensions/Backups/BackupManager.php +++ b/app/Extensions/Backups/BackupManager.php @@ -74,7 +74,7 @@ class BackupManager return $this->callCustomCreator($config); } - $adapterMethod = 'create' . Str::studly($adapter) . 'Adapter'; + $adapterMethod = 'create'.Str::studly($adapter).'Adapter'; if (method_exists($this, $adapterMethod)) { $instance = $this->{$adapterMethod}($config); diff --git a/app/Extensions/DynamicDatabaseConnection.php b/app/Extensions/DynamicDatabaseConnection.php index 147f78064..b4409ed4b 100644 --- a/app/Extensions/DynamicDatabaseConnection.php +++ b/app/Extensions/DynamicDatabaseConnection.php @@ -21,7 +21,7 @@ class DynamicDatabaseConnection $host = DatabaseHost::query()->findOrFail($host); } - config()->set('database.connections.' . $connection, [ + config()->set('database.connections.'.$connection, [ 'driver' => self::DB_DRIVER, 'host' => $host->host, 'port' => $host->port, diff --git a/app/Extensions/Themes/Theme.php b/app/Extensions/Themes/Theme.php index 2badc3dcb..92b587fb7 100644 --- a/app/Extensions/Themes/Theme.php +++ b/app/Extensions/Themes/Theme.php @@ -6,16 +6,16 @@ class Theme { public function js($path): string { - return sprintf('' . PHP_EOL, $this->getUrl($path)); + return sprintf(''.PHP_EOL, $this->getUrl($path)); } public function css($path): string { - return sprintf('' . PHP_EOL, $this->getUrl($path)); + return sprintf(''.PHP_EOL, $this->getUrl($path)); } protected function getUrl($path): string { - return '/themes/panel/' . ltrim($path, '/'); + return '/themes/panel/'.ltrim($path, '/'); } } diff --git a/app/Filament/Pages/Installer/Steps/CompletedStep.php b/app/Filament/Pages/Installer/Steps/CompletedStep.php index 50f9a780c..8b91c7686 100644 --- a/app/Filament/Pages/Installer/Steps/CompletedStep.php +++ b/app/Filament/Pages/Installer/Steps/CompletedStep.php @@ -21,12 +21,12 @@ class CompletedStep ->label(new HtmlString('Run the following command to setup your crontab. Note that www-data is your webserver user. On some systems this username might be different!')) ->disabled() ->hintAction(CopyAction::make()) - ->default('(crontab -l -u www-data 2>/dev/null; echo "* * * * * php ' . base_path() . '/artisan schedule:run >> /dev/null 2>&1") | crontab -u www-data -'), + ->default('(crontab -l -u www-data 2>/dev/null; echo "* * * * * php '.base_path().'/artisan schedule:run >> /dev/null 2>&1") | crontab -u www-data -'), TextInput::make('queueService') ->label(new HtmlString('To setup the queue worker service you simply have to run the following command.')) ->disabled() ->hintAction(CopyAction::make()) - ->default('sudo php ' . base_path() . '/artisan p:environment:queue-service'), + ->default('sudo php '.base_path().'/artisan p:environment:queue-service'), Placeholder::make('') ->content('After you finished these two last tasks you can click on "Finish" and use your new panel! Have fun!'), ]); diff --git a/app/Filament/Pages/Installer/Steps/RequirementsStep.php b/app/Filament/Pages/Installer/Steps/RequirementsStep.php index 5e6d6988d..d2afd4b37 100644 --- a/app/Filament/Pages/Installer/Steps/RequirementsStep.php +++ b/app/Filament/Pages/Installer/Steps/RequirementsStep.php @@ -18,12 +18,12 @@ class RequirementsStep $fields = [ Section::make('PHP Version') - ->description(self::MIN_PHP_VERSION . ' or newer') + ->description(self::MIN_PHP_VERSION.' or newer') ->icon($correctPhpVersion ? 'tabler-check' : 'tabler-x') ->iconColor($correctPhpVersion ? 'success' : 'danger') ->schema([ Placeholder::make('') - ->content('Your PHP Version is ' . PHP_VERSION . '.'), + ->content('Your PHP Version is '.PHP_VERSION.'.'), ]), ]; @@ -49,7 +49,7 @@ class RequirementsStep ->content('All needed PHP Extensions are installed.') ->visible($allExtensionsInstalled), Placeholder::make('') - ->content('The following PHP Extensions are missing: ' . implode(', ', array_keys($phpExtensions, false))) + ->content('The following PHP Extensions are missing: '.implode(', ', array_keys($phpExtensions, false))) ->visible(!$allExtensionsInstalled), ]); @@ -68,7 +68,7 @@ class RequirementsStep ->content('All Folders have the correct permissions.') ->visible($correctFolderPermissions), Placeholder::make('') - ->content('The following Folders have wrong permissions: ' . implode(', ', array_keys($folderPermissions, false))) + ->content('The following Folders have wrong permissions: '.implode(', ', array_keys($folderPermissions, false))) ->visible(!$correctFolderPermissions), ]); diff --git a/app/Filament/Resources/ApiKeyResource/Pages/ListApiKeys.php b/app/Filament/Resources/ApiKeyResource/Pages/ListApiKeys.php index aa0b9cdb5..8ef0cdd3c 100644 --- a/app/Filament/Resources/ApiKeyResource/Pages/ListApiKeys.php +++ b/app/Filament/Resources/ApiKeyResource/Pages/ListApiKeys.php @@ -24,7 +24,7 @@ class ListApiKeys extends ListRecords TextColumn::make('key') ->copyable() ->icon('tabler-clipboard-text') - ->state(fn (ApiKey $key) => $key->identifier . $key->token), + ->state(fn (ApiKey $key) => $key->identifier.$key->token), TextColumn::make('memo') ->label('Description') diff --git a/app/Filament/Resources/DatabaseHostResource/RelationManagers/DatabasesRelationManager.php b/app/Filament/Resources/DatabaseHostResource/RelationManagers/DatabasesRelationManager.php index 13b32602f..3b209d7f7 100644 --- a/app/Filament/Resources/DatabaseHostResource/RelationManagers/DatabasesRelationManager.php +++ b/app/Filament/Resources/DatabaseHostResource/RelationManagers/DatabasesRelationManager.php @@ -37,7 +37,7 @@ class DatabasesRelationManager extends RelationManager TextInput::make('JDBC') ->label('JDBC Connection String') ->columnSpanFull() - ->formatStateUsing(fn (Get $get, Database $database) => 'jdbc:mysql://' . $get('username') . ':' . urlencode($database->password) . '@' . $database->host->host . ':' . $database->host->port . '/' . $get('database')), + ->formatStateUsing(fn (Get $get, Database $database) => 'jdbc:mysql://'.$get('username').':'.urlencode($database->password).'@'.$database->host->host.':'.$database->host->port.'/'.$get('database')), ]); } @@ -64,7 +64,7 @@ class DatabasesRelationManager extends RelationManager protected function rotatePassword(DatabasePasswordService $service, Database $database, $set, $get): void { $newPassword = $service->handle($database); - $jdbcString = 'jdbc:mysql://' . $get('username') . ':' . urlencode($newPassword) . '@' . $database->host->host . ':' . $database->host->port . '/' . $get('database'); + $jdbcString = 'jdbc:mysql://'.$get('username').':'.urlencode($newPassword).'@'.$database->host->host.':'.$database->host->port.'/'.$get('database'); $set('password', $newPassword); $set('JDBC', $jdbcString); diff --git a/app/Filament/Resources/EggResource/Pages/EditEgg.php b/app/Filament/Resources/EggResource/Pages/EditEgg.php index d1d59c064..b9b839cb1 100644 --- a/app/Filament/Resources/EggResource/Pages/EditEgg.php +++ b/app/Filament/Resources/EggResource/Pages/EditEgg.php @@ -249,7 +249,7 @@ class EditEgg extends EditRecord ->color('primary') ->action(fn (EggExporterService $service, Egg $egg) => response()->streamDownload(function () use ($service, $egg) { echo $service->handle($egg->id); - }, 'egg-' . $egg->getKebabName() . '.json')) + }, 'egg-'.$egg->getKebabName().'.json')) ->authorize(fn () => auth()->user()->can('export egg')), Actions\Action::make('importEgg') ->label('Import') diff --git a/app/Filament/Resources/EggResource/Pages/ListEggs.php b/app/Filament/Resources/EggResource/Pages/ListEggs.php index a7f84b274..0903379e5 100644 --- a/app/Filament/Resources/EggResource/Pages/ListEggs.php +++ b/app/Filament/Resources/EggResource/Pages/ListEggs.php @@ -55,7 +55,7 @@ class ListEggs extends ListRecords ->color('primary') ->action(fn (EggExporterService $service, Egg $egg) => response()->streamDownload(function () use ($service, $egg) { echo $service->handle($egg->id); - }, 'egg-' . $egg->getKebabName() . '.json')) + }, 'egg-'.$egg->getKebabName().'.json')) ->authorize(fn () => auth()->user()->can('export egg')), Action::make('update') ->icon('tabler-cloud-download') diff --git a/app/Filament/Resources/NodeResource/Widgets/NodeCpuChart.php b/app/Filament/Resources/NodeResource/Widgets/NodeCpuChart.php index 89d1cb254..78119aaf5 100644 --- a/app/Filament/Resources/NodeResource/Widgets/NodeCpuChart.php +++ b/app/Filament/Resources/NodeResource/Widgets/NodeCpuChart.php @@ -76,8 +76,8 @@ class NodeCpuChart extends ChartWidget $threads = $node->systemInformation()['cpu_count'] ?? 0; $cpu = Number::format(collect(cache()->get("nodes.$node->id.cpu_percent"))->last() * $threads, maxPrecision: 2, locale: auth()->user()->language); - $max = Number::format($threads * 100, locale: auth()->user()->language) . '%'; + $max = Number::format($threads * 100, locale: auth()->user()->language).'%'; - return 'CPU - ' . $cpu . '% Of ' . $max; + return 'CPU - '.$cpu.'% Of '.$max; } } diff --git a/app/Filament/Resources/NodeResource/Widgets/NodeMemoryChart.php b/app/Filament/Resources/NodeResource/Widgets/NodeMemoryChart.php index 0cabbed51..e1c19099b 100644 --- a/app/Filament/Resources/NodeResource/Widgets/NodeMemoryChart.php +++ b/app/Filament/Resources/NodeResource/Widgets/NodeMemoryChart.php @@ -75,13 +75,13 @@ class NodeMemoryChart extends ChartWidget $totalMemory = collect(cache()->get("nodes.$node->id.memory_total"))->last(); $used = config('panel.use_binary_prefix') - ? Number::format($latestMemoryUsed / 1024 / 1024 / 1024, maxPrecision: 2, locale: auth()->user()->language) .' GiB' - : Number::format($latestMemoryUsed / 1000 / 1000 / 1000, maxPrecision: 2, locale: auth()->user()->language) . ' GB'; + ? Number::format($latestMemoryUsed / 1024 / 1024 / 1024, maxPrecision: 2, locale: auth()->user()->language).' GiB' + : Number::format($latestMemoryUsed / 1000 / 1000 / 1000, maxPrecision: 2, locale: auth()->user()->language).' GB'; $total = config('panel.use_binary_prefix') - ? Number::format($totalMemory / 1024 / 1024 / 1024, maxPrecision: 2, locale: auth()->user()->language) .' GiB' - : Number::format($totalMemory / 1000 / 1000 / 1000, maxPrecision: 2, locale: auth()->user()->language) . ' GB'; + ? Number::format($totalMemory / 1024 / 1024 / 1024, maxPrecision: 2, locale: auth()->user()->language).' GiB' + : Number::format($totalMemory / 1000 / 1000 / 1000, maxPrecision: 2, locale: auth()->user()->language).' GB'; - return 'Memory - ' . $used . ' Of ' . $total; + return 'Memory - '.$used.' Of '.$total; } } diff --git a/app/Filament/Resources/RoleResource.php b/app/Filament/Resources/RoleResource.php index 306c9676d..898090222 100644 --- a/app/Filament/Resources/RoleResource.php +++ b/app/Filament/Resources/RoleResource.php @@ -40,12 +40,12 @@ class RoleResource extends Resource $options = []; foreach (RolePermissionPrefixes::cases() as $prefix) { - $options[$prefix->value . ' ' . strtolower($model->value)] = Str::headline($prefix->value); + $options[$prefix->value.' '.strtolower($model->value)] = Str::headline($prefix->value); } if (array_key_exists($model->value, Role::MODEL_SPECIFIC_PERMISSIONS)) { foreach (Role::MODEL_SPECIFIC_PERMISSIONS[$model->value] as $permission) { - $options[$permission . ' ' . strtolower($model->value)] = Str::headline($permission); + $options[$permission.' '.strtolower($model->value)] = Str::headline($permission); } } @@ -56,7 +56,7 @@ class RoleResource extends Resource $options = []; foreach ($prefixes as $prefix) { - $options[$prefix . ' ' . strtolower($model)] = Str::headline($prefix); + $options[$prefix.' '.strtolower($model)] = Str::headline($prefix); } $permissions[] = self::makeSection($model, $options); @@ -88,10 +88,10 @@ class RoleResource extends Resource { $icon = null; - if (class_exists('\App\Filament\Resources\\' . $model . 'Resource')) { - $icon = ('\App\Filament\Resources\\' . $model . 'Resource')::getNavigationIcon(); - } elseif (class_exists('\App\Filament\Pages\\' . $model)) { - $icon = ('\App\Filament\Pages\\' . $model)::getNavigationIcon(); + if (class_exists('\App\Filament\Resources\\'.$model.'Resource')) { + $icon = ('\App\Filament\Resources\\'.$model.'Resource')::getNavigationIcon(); + } elseif (class_exists('\App\Filament\Pages\\'.$model)) { + $icon = ('\App\Filament\Pages\\'.$model)::getNavigationIcon(); } return Section::make(Str::headline(Str::plural($model))) @@ -101,11 +101,11 @@ class RoleResource extends Resource ->icon($icon) ->headerActions([ Action::make('count') - ->label(fn (Get $get) => count($get(strtolower($model) . '_list'))) + ->label(fn (Get $get) => count($get(strtolower($model).'_list'))) ->badge(), ]) ->schema([ - CheckboxList::make(strtolower($model) . '_list') + CheckboxList::make(strtolower($model).'_list') ->label('') ->options($options) ->columns() diff --git a/app/Filament/Resources/ServerResource/Pages/CreateServer.php b/app/Filament/Resources/ServerResource/Pages/CreateServer.php index b8ac8a520..61696804f 100644 --- a/app/Filament/Resources/ServerResource/Pages/CreateServer.php +++ b/app/Filament/Resources/ServerResource/Pages/CreateServer.php @@ -70,14 +70,14 @@ class CreateServer extends CreateRecord ->prefixIcon('tabler-server') ->label('Name') ->suffixAction(Forms\Components\Actions\Action::make('random') - ->icon('tabler-dice-' . random_int(1, 6)) + ->icon('tabler-dice-'.random_int(1, 6)) ->action(function (Set $set, Get $get) { $egg = Egg::find($get('egg_id')); - $prefix = $egg ? str($egg->name)->lower()->kebab() . '-' : ''; + $prefix = $egg ? str($egg->name)->lower()->kebab().'-' : ''; $word = (new RandomWordService())->word(); - $set('name', $prefix . $word); + $set('name', $prefix.$word); })) ->columnSpan([ 'default' => 2, @@ -101,7 +101,7 @@ class CreateServer extends CreateRecord ]) ->relationship('user', 'username') ->searchable(['username', 'email']) - ->getOptionLabelFromRecordUsing(fn (User $user) => "$user->email | $user->username " . ($user->isRootAdmin() ? '(admin)' : '')) + ->getOptionLabelFromRecordUsing(fn (User $user) => "$user->email | $user->username ".($user->isRootAdmin() ? '(admin)' : '')) ->createOptionForm([ TextInput::make('username') ->alphaNum() @@ -163,7 +163,7 @@ class CreateServer extends CreateRecord $set('allocation_additional.needstobeastringhere.extra_allocations', null); }) ->getOptionLabelFromRecordUsing( - fn (Allocation $allocation) => "$allocation->ip:$allocation->port" . + fn (Allocation $allocation) => "$allocation->ip:$allocation->port". ($allocation->ip_alias ? " ($allocation->ip_alias)" : '') ) ->placeholder(function (Get $get) { @@ -293,7 +293,7 @@ class CreateServer extends CreateRecord ->disabled(fn (Get $get) => $get('../../node_id') === null) ->searchable(['ip', 'port', 'ip_alias']) ->getOptionLabelFromRecordUsing( - fn (Allocation $allocation) => "$allocation->ip:$allocation->port" . + fn (Allocation $allocation) => "$allocation->ip:$allocation->port". ($allocation->ip_alias ? " ($allocation->ip_alias)" : '') ) ->placeholder('Select additional Allocations') @@ -498,7 +498,7 @@ class CreateServer extends CreateRecord ->hintIcon('tabler-code') ->label(fn (Get $get) => $get('name')) ->hintIconTooltip(fn (Get $get) => implode('|', $get('rules'))) - ->prefix(fn (Get $get) => '{{' . $get('env_variable') . '}}') + ->prefix(fn (Get $get) => '{{'.$get('env_variable').'}}') ->helperText(fn (Get $get) => empty($get('description')) ? '—' : $get('description')) ->afterStateUpdated(function (Set $set, Get $get, $state) { $environment = $get($envPath = '../../environment'); @@ -846,7 +846,7 @@ class CreateServer extends CreateRecord return !$containsRuleIn; } - throw new Exception('Component type not supported: ' . $component::class); + throw new Exception('Component type not supported: '.$component::class); } private function getSelectOptionsFromRules(Get $get): array diff --git a/app/Filament/Resources/ServerResource/Pages/EditServer.php b/app/Filament/Resources/ServerResource/Pages/EditServer.php index 267fd998f..33a90ace0 100644 --- a/app/Filament/Resources/ServerResource/Pages/EditServer.php +++ b/app/Filament/Resources/ServerResource/Pages/EditServer.php @@ -66,14 +66,14 @@ class EditServer extends EditRecord ->prefixIcon('tabler-server') ->label('Display Name') ->suffixAction(Action::make('random') - ->icon('tabler-dice-' . random_int(1, 6)) + ->icon('tabler-dice-'.random_int(1, 6)) ->action(function (Set $set, Get $get) { $egg = Egg::find($get('egg_id')); - $prefix = $egg ? str($egg->name)->lower()->kebab() . '-' : ''; + $prefix = $egg ? str($egg->name)->lower()->kebab().'-' : ''; $word = (new RandomWordService())->word(); - $set('name', $prefix . $word); + $set('name', $prefix.$word); })) ->columnSpan([ 'default' => 2, @@ -541,7 +541,7 @@ class EditServer extends EditRecord ->hintIcon('tabler-code') ->label(fn (ServerVariable $serverVariable) => $serverVariable->variable->name) ->hintIconTooltip(fn (ServerVariable $serverVariable) => implode('|', $serverVariable->variable->rules)) - ->prefix(fn (ServerVariable $serverVariable) => '{{' . $serverVariable->variable->env_variable . '}}') + ->prefix(fn (ServerVariable $serverVariable) => '{{'.$serverVariable->variable->env_variable.'}}') ->helperText(fn (ServerVariable $serverVariable) => empty($serverVariable->variable->description) ? '—' : $serverVariable->variable->description); } @@ -606,7 +606,7 @@ class EditServer extends EditRecord ->disabled() ->label('JDBC Connection String') ->columnSpan(2) - ->formatStateUsing(fn (Get $get, $record) => 'jdbc:mysql://' . $get('username') . ':' . urlencode($record->password) . '@' . $record->host->host . ':' . $record->host->port . '/' . $get('database')), + ->formatStateUsing(fn (Get $get, $record) => 'jdbc:mysql://'.$get('username').':'.urlencode($record->password).'@'.$record->host->host.':'.$record->host->port.'/'.$get('database')), ]) ->relationship('databases') ->deletable(false) @@ -800,7 +800,7 @@ class EditServer extends EditRecord return $containsRuleIn; } - throw new Exception('Component type not supported: ' . $component::class); + throw new Exception('Component type not supported: '.$component::class); } private function getSelectOptionsFromRules(ServerVariable $serverVariable): array @@ -818,7 +818,7 @@ class EditServer extends EditRecord protected function rotatePassword(DatabasePasswordService $service, $record, $set, $get): void { $newPassword = $service->handle($record); - $jdbcString = 'jdbc:mysql://' . $get('username') . ':' . urlencode($newPassword) . '@' . $record->host->host . ':' . $record->host->port . '/' . $get('database'); + $jdbcString = 'jdbc:mysql://'.$get('username').':'.urlencode($newPassword).'@'.$record->host->host.':'.$record->host->port.'/'.$get('database'); $set('password', $newPassword); $set('JDBC', $jdbcString); diff --git a/app/Filament/Resources/UserResource/Pages/EditProfile.php b/app/Filament/Resources/UserResource/Pages/EditProfile.php index f5c5f5828..20bd0f61f 100644 --- a/app/Filament/Resources/UserResource/Pages/EditProfile.php +++ b/app/Filament/Resources/UserResource/Pages/EditProfile.php @@ -178,7 +178,7 @@ class EditProfile extends \Filament\Pages\Auth\EditProfile ->content(fn () => new HtmlString("
$image
")) - ->helperText('Setup Key: '. $secret), + ->helperText('Setup Key: '.$secret), TextInput::make('2facode') ->label('Code') ->requiredWith('2fapassword') diff --git a/app/Filament/Resources/UserResource/Pages/ListUsers.php b/app/Filament/Resources/UserResource/Pages/ListUsers.php index c386d4ce6..03df51554 100644 --- a/app/Filament/Resources/UserResource/Pages/ListUsers.php +++ b/app/Filament/Resources/UserResource/Pages/ListUsers.php @@ -33,7 +33,7 @@ class ListUsers extends ListRecords ->visibleFrom('lg') ->label('') ->extraImgAttributes(['class' => 'rounded-full']) - ->defaultImageUrl(fn (User $user) => 'https://gravatar.com/avatar/' . md5(strtolower($user->email))), + ->defaultImageUrl(fn (User $user) => 'https://gravatar.com/avatar/'.md5(strtolower($user->email))), TextColumn::make('external_id') ->searchable() ->hidden(), @@ -55,7 +55,7 @@ class ListUsers extends ListRecords ->counts('roles') ->icon('tabler-users-group') ->label('Roles') - ->formatStateUsing(fn (User $user, $state) => $state . ($user->isRootAdmin() ? ' (Root Admin)' : '')), + ->formatStateUsing(fn (User $user, $state) => $state.($user->isRootAdmin() ? ' (Root Admin)' : '')), TextColumn::make('servers_count') ->counts('servers') ->icon('tabler-server') diff --git a/app/Http/Controllers/Admin/Eggs/EggShareController.php b/app/Http/Controllers/Admin/Eggs/EggShareController.php index 993064b65..56f38f4f7 100644 --- a/app/Http/Controllers/Admin/Eggs/EggShareController.php +++ b/app/Http/Controllers/Admin/Eggs/EggShareController.php @@ -30,7 +30,7 @@ class EggShareController extends Controller return response($this->exporterService->handle($egg->id), 200, [ 'Content-Transfer-Encoding' => 'binary', 'Content-Description' => 'File Transfer', - 'Content-Disposition' => 'attachment; filename=egg-' . $filename . '.json', + 'Content-Disposition' => 'attachment; filename=egg-'.$filename.'.json', 'Content-Type' => 'application/json', ]); } diff --git a/app/Http/Controllers/Admin/NodeAutoDeployController.php b/app/Http/Controllers/Admin/NodeAutoDeployController.php index 1029706c3..b61e41acb 100644 --- a/app/Http/Controllers/Admin/NodeAutoDeployController.php +++ b/app/Http/Controllers/Admin/NodeAutoDeployController.php @@ -56,7 +56,7 @@ class NodeAutoDeployController extends Controller return new JsonResponse([ 'node' => $node->id, - 'token' => $key->identifier . $key->token, + 'token' => $key->identifier.$key->token, ]); } } diff --git a/app/Http/Controllers/Admin/Servers/CreateServerController.php b/app/Http/Controllers/Admin/Servers/CreateServerController.php index c59e22fbe..7e7c19175 100644 --- a/app/Http/Controllers/Admin/Servers/CreateServerController.php +++ b/app/Http/Controllers/Admin/Servers/CreateServerController.php @@ -67,6 +67,6 @@ class CreateServerController extends Controller $this->alert->success(trans('admin/server.alerts.server_created'))->flash(); - return new RedirectResponse('/admin/servers/view/' . $server->id); + return new RedirectResponse('/admin/servers/view/'.$server->id); } } diff --git a/app/Http/Controllers/Admin/ServersController.php b/app/Http/Controllers/Admin/ServersController.php index 9ddd9c7e6..4cb398bbe 100644 --- a/app/Http/Controllers/Admin/ServersController.php +++ b/app/Http/Controllers/Admin/ServersController.php @@ -115,7 +115,7 @@ class ServersController extends Controller { $this->suspensionService->toggle($server, $request->input('action')); $this->alert->success(trans('admin/server.alerts.suspension_toggled', [ - 'status' => $request->input('action') . 'ed', + 'status' => $request->input('action').'ed', ]))->flash(); return redirect()->route('admin.servers.view.manage', $server->id); diff --git a/app/Http/Controllers/Api/Client/Servers/FileController.php b/app/Http/Controllers/Api/Client/Servers/FileController.php index 09d354a36..bd175aef5 100644 --- a/app/Http/Controllers/Api/Client/Servers/FileController.php +++ b/app/Http/Controllers/Api/Client/Servers/FileController.php @@ -83,7 +83,7 @@ class FileController extends ClientApiController 'file_path' => rawurldecode($request->get('file')), 'server_uuid' => $server->uuid, ]) - ->handle($server->node, $request->user()->id . $server->uuid); + ->handle($server->node, $request->user()->id.$server->uuid); Activity::event('server:file.download')->property('file', $request->get('file'))->log(); diff --git a/app/Http/Controllers/Api/Client/Servers/FileUploadController.php b/app/Http/Controllers/Api/Client/Servers/FileUploadController.php index e48dd75bd..9ee74fb44 100644 --- a/app/Http/Controllers/Api/Client/Servers/FileUploadController.php +++ b/app/Http/Controllers/Api/Client/Servers/FileUploadController.php @@ -43,7 +43,7 @@ class FileUploadController extends ClientApiController ->setExpiresAt(CarbonImmutable::now()->addMinutes(15)) ->setUser($user) ->setClaims(['server_uuid' => $server->uuid]) - ->handle($server->node, $user->id . $server->uuid); + ->handle($server->node, $user->id.$server->uuid); return sprintf( '%s/upload/file?token=%s', diff --git a/app/Http/Controllers/Api/Client/Servers/WebsocketController.php b/app/Http/Controllers/Api/Client/Servers/WebsocketController.php index 0fb062e96..8d636872d 100644 --- a/app/Http/Controllers/Api/Client/Servers/WebsocketController.php +++ b/app/Http/Controllers/Api/Client/Servers/WebsocketController.php @@ -59,14 +59,14 @@ class WebsocketController extends ClientApiController 'server_uuid' => $server->uuid, 'permissions' => $permissions, ]) - ->handle($node, $user->id . $server->uuid); + ->handle($node, $user->id.$server->uuid); $socket = str_replace(['https://', 'http://'], ['wss://', 'ws://'], $node->getConnectionAddress()); return new JsonResponse([ 'data' => [ 'token' => $token->toString(), - 'socket' => $socket . sprintf('/api/servers/%s/ws', $server->uuid), + 'socket' => $socket.sprintf('/api/servers/%s/ws', $server->uuid), ], ]); } diff --git a/app/Http/Controllers/Api/Remote/Backups/BackupStatusController.php b/app/Http/Controllers/Api/Remote/Backups/BackupStatusController.php index 4f32689ec..47350c69d 100644 --- a/app/Http/Controllers/Api/Remote/Backups/BackupStatusController.php +++ b/app/Http/Controllers/Api/Remote/Backups/BackupStatusController.php @@ -64,7 +64,7 @@ class BackupStatusController extends Controller // deleted easily. Also does not make sense to have a locked backup on the system // that is failed. 'is_locked' => $successful ? $model->is_locked : false, - 'checksum' => $successful ? ($request->input('checksum_type') . ':' . $request->input('checksum')) : null, + 'checksum' => $successful ? ($request->input('checksum_type').':'.$request->input('checksum')) : null, 'bytes' => $successful ? $request->input('size') : 0, 'completed_at' => CarbonImmutable::now(), ])->save(); diff --git a/app/Http/Controllers/Api/Remote/SftpAuthenticationController.php b/app/Http/Controllers/Api/Remote/SftpAuthenticationController.php index 9b59704f1..f9e63dfb5 100644 --- a/app/Http/Controllers/Api/Remote/SftpAuthenticationController.php +++ b/app/Http/Controllers/Api/Remote/SftpAuthenticationController.php @@ -160,6 +160,6 @@ class SftpAuthenticationController extends Controller { $username = explode('.', strrev($request->input('username', ''))); - return strtolower(strrev($username[0] ?? '') . '|' . $request->ip()); + return strtolower(strrev($username[0] ?? '').'|'.$request->ip()); } } diff --git a/app/Http/Controllers/Auth/OAuthController.php b/app/Http/Controllers/Auth/OAuthController.php index 2989761ef..34f0b3bbc 100644 --- a/app/Http/Controllers/Auth/OAuthController.php +++ b/app/Http/Controllers/Auth/OAuthController.php @@ -48,7 +48,7 @@ class OAuthController extends Controller } try { - $user = User::query()->whereJsonContains('oauth->'. $driver, $oauthUser->getId())->firstOrFail(); + $user = User::query()->whereJsonContains('oauth->'.$driver, $oauthUser->getId())->firstOrFail(); $this->auth->guard()->login($user, true); } catch (Exception $e) { diff --git a/app/Http/Middleware/Api/AuthenticateIPAccess.php b/app/Http/Middleware/Api/AuthenticateIPAccess.php index c9f3bf7dc..a1c6d4710 100644 --- a/app/Http/Middleware/Api/AuthenticateIPAccess.php +++ b/app/Http/Middleware/Api/AuthenticateIPAccess.php @@ -43,6 +43,6 @@ class AuthenticateIPAccess ->property('identifier', $token->identifier) ->log(); - throw new AccessDeniedHttpException('This IP address (' . $request->ip() . ') does not have permission to access the API using these credentials.'); + throw new AccessDeniedHttpException('This IP address ('.$request->ip().') does not have permission to access the API using these credentials.'); } } diff --git a/app/Http/Middleware/Api/Client/Server/ResourceBelongsToServer.php b/app/Http/Middleware/Api/Client/Server/ResourceBelongsToServer.php index 0ead01f1d..d7754d36e 100644 --- a/app/Http/Middleware/Api/Client/Server/ResourceBelongsToServer.php +++ b/app/Http/Middleware/Api/Client/Server/ResourceBelongsToServer.php @@ -80,7 +80,7 @@ class ResourceBelongsToServer default: // Don't return a 404 here since we want to make sure no one relies // on this middleware in a context in which it will not work. Fail safe. - throw new \InvalidArgumentException('There is no handler configured for a resource of this type: ' . get_class($model)); + throw new \InvalidArgumentException('There is no handler configured for a resource of this type: '.get_class($model)); } } diff --git a/app/Http/Middleware/Api/IsValidJson.php b/app/Http/Middleware/Api/IsValidJson.php index 86bb34ff2..77bd25fe8 100644 --- a/app/Http/Middleware/Api/IsValidJson.php +++ b/app/Http/Middleware/Api/IsValidJson.php @@ -18,7 +18,7 @@ class IsValidJson try { json_decode($request->getContent(), true, 512, JSON_THROW_ON_ERROR); } catch (\JsonException $exception) { - throw new BadRequestHttpException('The JSON data passed in the request appears to be malformed: ' . $exception->getMessage()); + throw new BadRequestHttpException('The JSON data passed in the request appears to be malformed: '.$exception->getMessage()); } } diff --git a/app/Http/Middleware/RequireTwoFactorAuthentication.php b/app/Http/Middleware/RequireTwoFactorAuthentication.php index 58ff1564d..bfbab4438 100644 --- a/app/Http/Middleware/RequireTwoFactorAuthentication.php +++ b/app/Http/Middleware/RequireTwoFactorAuthentication.php @@ -38,7 +38,7 @@ class RequireTwoFactorAuthentication public function handle(Request $request, \Closure $next): mixed { $user = $request->user(); - $uri = rtrim($request->getRequestUri(), '/') . '/'; + $uri = rtrim($request->getRequestUri(), '/').'/'; $current = $request->route()->getName(); if (!$user || Str::startsWith($uri, ['/auth/']) || Str::startsWith($current, ['auth.', 'account.'])) { diff --git a/app/Http/Requests/Admin/Api/StoreApplicationApiKeyRequest.php b/app/Http/Requests/Admin/Api/StoreApplicationApiKeyRequest.php index 83f80f267..b092ead91 100644 --- a/app/Http/Requests/Admin/Api/StoreApplicationApiKeyRequest.php +++ b/app/Http/Requests/Admin/Api/StoreApplicationApiKeyRequest.php @@ -17,7 +17,7 @@ class StoreApplicationApiKeyRequest extends AdminFormRequest $modelRules = ApiKey::getRules(); return collect(AdminAcl::getResourceList())->mapWithKeys(function ($resource) use ($modelRules) { - return [AdminAcl::COLUMN_IDENTIFIER . $resource => $modelRules['r_' . $resource]]; + return [AdminAcl::COLUMN_IDENTIFIER.$resource => $modelRules['r_'.$resource]]; })->merge(['memo' => $modelRules['memo']])->toArray(); } diff --git a/app/Http/Requests/Admin/Egg/EggVariableFormRequest.php b/app/Http/Requests/Admin/Egg/EggVariableFormRequest.php index c6720aa2c..b7e64daaa 100644 --- a/app/Http/Requests/Admin/Egg/EggVariableFormRequest.php +++ b/app/Http/Requests/Admin/Egg/EggVariableFormRequest.php @@ -15,7 +15,7 @@ class EggVariableFormRequest extends AdminFormRequest return [ 'name' => 'required|string|min:1|max:255', 'description' => 'sometimes|nullable|string', - 'env_variable' => 'required|regex:/^[\w]{1,255}$/|notIn:' . EggVariable::RESERVED_ENV_NAMES, + 'env_variable' => 'required|regex:/^[\w]{1,255}$/|notIn:'.EggVariable::RESERVED_ENV_NAMES, 'options' => 'sometimes|required|array', 'rules' => 'bail|required|string', 'default_value' => 'present', diff --git a/app/Http/Requests/Api/Client/Account/StoreApiKeyRequest.php b/app/Http/Requests/Api/Client/Account/StoreApiKeyRequest.php index e0034fcfe..866832214 100644 --- a/app/Http/Requests/Api/Client/Account/StoreApiKeyRequest.php +++ b/app/Http/Requests/Api/Client/Account/StoreApiKeyRequest.php @@ -39,7 +39,7 @@ class StoreApiKeyRequest extends ClientApiRequest throw $exception; } } finally { - $validator->errors()->addIf(!$valid, "allowed_ips.{$index}", '"' . $ip . '" is not a valid IP address or CIDR range.'); + $validator->errors()->addIf(!$valid, "allowed_ips.{$index}", '"'.$ip.'" is not a valid IP address or CIDR range.'); } } }); diff --git a/app/Jobs/Schedule/RunTaskJob.php b/app/Jobs/Schedule/RunTaskJob.php index 6a660e5c0..ea0c84486 100644 --- a/app/Jobs/Schedule/RunTaskJob.php +++ b/app/Jobs/Schedule/RunTaskJob.php @@ -73,7 +73,7 @@ class RunTaskJob extends Job implements ShouldQueue $deleteFilesService->handle($server, explode(PHP_EOL, $this->task->payload)); break; default: - throw new \InvalidArgumentException('Invalid task action provided: ' . $this->task->action); + throw new \InvalidArgumentException('Invalid task action provided: '.$this->task->action); } } catch (\Exception $exception) { // If this isn't a DaemonConnectionException on a task that allows for failures diff --git a/app/Models/ApiKey.php b/app/Models/ApiKey.php index 96c714f24..6593803e2 100644 --- a/app/Models/ApiKey.php +++ b/app/Models/ApiKey.php @@ -110,14 +110,14 @@ class ApiKey extends Model 'memo', 'last_used_at', 'expires_at', - 'r_' . AdminAcl::RESOURCE_USERS, - 'r_' . AdminAcl::RESOURCE_ALLOCATIONS, - 'r_' . AdminAcl::RESOURCE_DATABASE_HOSTS, - 'r_' . AdminAcl::RESOURCE_SERVER_DATABASES, - 'r_' . AdminAcl::RESOURCE_EGGS, - 'r_' . AdminAcl::RESOURCE_NODES, - 'r_' . AdminAcl::RESOURCE_SERVERS, - 'r_' . AdminAcl::RESOURCE_MOUNTS, + 'r_'.AdminAcl::RESOURCE_USERS, + 'r_'.AdminAcl::RESOURCE_ALLOCATIONS, + 'r_'.AdminAcl::RESOURCE_DATABASE_HOSTS, + 'r_'.AdminAcl::RESOURCE_SERVER_DATABASES, + 'r_'.AdminAcl::RESOURCE_EGGS, + 'r_'.AdminAcl::RESOURCE_NODES, + 'r_'.AdminAcl::RESOURCE_SERVERS, + 'r_'.AdminAcl::RESOURCE_MOUNTS, ]; /** @@ -146,14 +146,14 @@ class ApiKey extends Model 'allowed_ips.*' => 'string', 'last_used_at' => 'nullable|date', 'expires_at' => 'nullable|date', - 'r_' . AdminAcl::RESOURCE_USERS => 'integer|min:0|max:3', - 'r_' . AdminAcl::RESOURCE_ALLOCATIONS => 'integer|min:0|max:3', - 'r_' . AdminAcl::RESOURCE_DATABASE_HOSTS => 'integer|min:0|max:3', - 'r_' . AdminAcl::RESOURCE_SERVER_DATABASES => 'integer|min:0|max:3', - 'r_' . AdminAcl::RESOURCE_EGGS => 'integer|min:0|max:3', - 'r_' . AdminAcl::RESOURCE_NODES => 'integer|min:0|max:3', - 'r_' . AdminAcl::RESOURCE_SERVERS => 'integer|min:0|max:3', - 'r_' . AdminAcl::RESOURCE_MOUNTS => 'integer|min:0|max:3', + 'r_'.AdminAcl::RESOURCE_USERS => 'integer|min:0|max:3', + 'r_'.AdminAcl::RESOURCE_ALLOCATIONS => 'integer|min:0|max:3', + 'r_'.AdminAcl::RESOURCE_DATABASE_HOSTS => 'integer|min:0|max:3', + 'r_'.AdminAcl::RESOURCE_SERVER_DATABASES => 'integer|min:0|max:3', + 'r_'.AdminAcl::RESOURCE_EGGS => 'integer|min:0|max:3', + 'r_'.AdminAcl::RESOURCE_NODES => 'integer|min:0|max:3', + 'r_'.AdminAcl::RESOURCE_SERVERS => 'integer|min:0|max:3', + 'r_'.AdminAcl::RESOURCE_MOUNTS => 'integer|min:0|max:3', ]; protected function casts(): array @@ -166,14 +166,14 @@ class ApiKey extends Model 'token' => 'encrypted', self::CREATED_AT => 'datetime', self::UPDATED_AT => 'datetime', - 'r_' . AdminAcl::RESOURCE_USERS => 'int', - 'r_' . AdminAcl::RESOURCE_ALLOCATIONS => 'int', - 'r_' . AdminAcl::RESOURCE_DATABASE_HOSTS => 'int', - 'r_' . AdminAcl::RESOURCE_SERVER_DATABASES => 'int', - 'r_' . AdminAcl::RESOURCE_EGGS => 'int', - 'r_' . AdminAcl::RESOURCE_NODES => 'int', - 'r_' . AdminAcl::RESOURCE_SERVERS => 'int', - 'r_' . AdminAcl::RESOURCE_MOUNTS => 'int', + 'r_'.AdminAcl::RESOURCE_USERS => 'int', + 'r_'.AdminAcl::RESOURCE_ALLOCATIONS => 'int', + 'r_'.AdminAcl::RESOURCE_DATABASE_HOSTS => 'int', + 'r_'.AdminAcl::RESOURCE_SERVER_DATABASES => 'int', + 'r_'.AdminAcl::RESOURCE_EGGS => 'int', + 'r_'.AdminAcl::RESOURCE_NODES => 'int', + 'r_'.AdminAcl::RESOURCE_SERVERS => 'int', + 'r_'.AdminAcl::RESOURCE_MOUNTS => 'int', ]; } @@ -227,6 +227,6 @@ class ApiKey extends Model { $prefix = self::getPrefixForType($type); - return $prefix . Str::random(self::IDENTIFIER_LENGTH - strlen($prefix)); + return $prefix.Str::random(self::IDENTIFIER_LENGTH - strlen($prefix)); } } diff --git a/app/Models/EggVariable.php b/app/Models/EggVariable.php index 2d3a4fb2c..b56213c1a 100644 --- a/app/Models/EggVariable.php +++ b/app/Models/EggVariable.php @@ -54,7 +54,7 @@ class EggVariable extends Model 'sort' => 'nullable', 'name' => 'required|string|between:1,255', 'description' => 'string', - 'env_variable' => 'required|alphaDash|between:1,255|notIn:' . self::RESERVED_ENV_NAMES, + 'env_variable' => 'required|alphaDash|between:1,255|notIn:'.self::RESERVED_ENV_NAMES, 'default_value' => 'string', 'user_viewable' => 'boolean', 'user_editable' => 'boolean', diff --git a/app/Models/Filters/MultiFieldServerFilter.php b/app/Models/Filters/MultiFieldServerFilter.php index da3f91f6d..0ab266574 100644 --- a/app/Models/Filters/MultiFieldServerFilter.php +++ b/app/Models/Filters/MultiFieldServerFilter.php @@ -48,7 +48,7 @@ class MultiFieldServerFilter implements Filter }, // Otherwise, just try to search for that specific port in the allocations. function (Builder $builder) use ($value) { - $builder->orWhere('allocations.port', 'LIKE', substr($value, 1) . '%'); + $builder->orWhere('allocations.port', 'LIKE', substr($value, 1).'%'); } ); }) diff --git a/app/Models/Node.php b/app/Models/Node.php index da5416091..59a337f2b 100644 --- a/app/Models/Node.php +++ b/app/Models/Node.php @@ -184,8 +184,8 @@ class Node extends Model 'port' => $this->daemon_listen, 'ssl' => [ 'enabled' => (!$this->behind_proxy && $this->scheme === 'https'), - 'cert' => '/etc/letsencrypt/live/' . Str::lower($this->fqdn) . '/fullchain.pem', - 'key' => '/etc/letsencrypt/live/' . Str::lower($this->fqdn) . '/privkey.pem', + 'cert' => '/etc/letsencrypt/live/'.Str::lower($this->fqdn).'/fullchain.pem', + 'key' => '/etc/letsencrypt/live/'.Str::lower($this->fqdn).'/privkey.pem', ], 'upload_limit' => $this->upload_size, ], diff --git a/app/Models/User.php b/app/Models/User.php index 3b4eff193..5bc8fa632 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -259,7 +259,7 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac */ public function getNameAttribute(): string { - return trim($this->name_first . ' ' . $this->name_last); + return trim($this->name_first.' '.$this->name_last); } /** @@ -379,7 +379,7 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac public function getFilamentAvatarUrl(): ?string { - return 'https://gravatar.com/avatar/' . md5(strtolower($this->email)); + return 'https://gravatar.com/avatar/'.md5(strtolower($this->email)); } public function canTarget(IlluminateModel $user): bool diff --git a/app/Notifications/AccountCreated.php b/app/Notifications/AccountCreated.php index 0123435f7..0f7cb77a7 100644 --- a/app/Notifications/AccountCreated.php +++ b/app/Notifications/AccountCreated.php @@ -33,13 +33,13 @@ class AccountCreated extends Notification implements ShouldQueue public function toMail(): MailMessage { $message = (new MailMessage()) - ->greeting('Hello ' . $this->user->name . '!') - ->line('You are receiving this email because an account has been created for you on ' . config('app.name') . '.') - ->line('Username: ' . $this->user->username) - ->line('Email: ' . $this->user->email); + ->greeting('Hello '.$this->user->name.'!') + ->line('You are receiving this email because an account has been created for you on '.config('app.name').'.') + ->line('Username: '.$this->user->username) + ->line('Email: '.$this->user->email); if (!is_null($this->token)) { - return $message->action('Setup Your Account', url('/auth/password/reset/' . $this->token . '?email=' . urlencode($this->user->email))); + return $message->action('Setup Your Account', url('/auth/password/reset/'.$this->token.'?email='.urlencode($this->user->email))); } return $message; diff --git a/app/Notifications/AddedToServer.php b/app/Notifications/AddedToServer.php index 647c33822..56ddd4a40 100644 --- a/app/Notifications/AddedToServer.php +++ b/app/Notifications/AddedToServer.php @@ -35,9 +35,9 @@ class AddedToServer extends Notification implements ShouldQueue public function toMail(): MailMessage { return (new MailMessage()) - ->greeting('Hello ' . $this->server->user . '!') + ->greeting('Hello '.$this->server->user.'!') ->line('You have been added as a subuser for the following server, allowing you certain control over the server.') - ->line('Server Name: ' . $this->server->name) - ->action('Visit Server', url('/server/' . $this->server->uuid_short)); + ->line('Server Name: '.$this->server->name) + ->action('Visit Server', url('/server/'.$this->server->uuid_short)); } } diff --git a/app/Notifications/MailTested.php b/app/Notifications/MailTested.php index 3bb816bf7..0dcbb4e9c 100644 --- a/app/Notifications/MailTested.php +++ b/app/Notifications/MailTested.php @@ -21,7 +21,7 @@ class MailTested extends Notification { return (new MailMessage()) ->subject('Panel Test Message') - ->greeting('Hello ' . $this->user->name . '!') + ->greeting('Hello '.$this->user->name.'!') ->line('This is a test of the Panel mail system. You\'re good to go!'); } } diff --git a/app/Notifications/RemovedFromServer.php b/app/Notifications/RemovedFromServer.php index 668d8f28a..6c7899d6a 100644 --- a/app/Notifications/RemovedFromServer.php +++ b/app/Notifications/RemovedFromServer.php @@ -36,9 +36,9 @@ class RemovedFromServer extends Notification implements ShouldQueue { return (new MailMessage()) ->error() - ->greeting('Hello ' . $this->server->user . '.') + ->greeting('Hello '.$this->server->user.'.') ->line('You have been removed as a subuser for the following server.') - ->line('Server Name: ' . $this->server->name) + ->line('Server Name: '.$this->server->name) ->action('Visit Panel', route('index')); } } diff --git a/app/Notifications/SendPasswordReset.php b/app/Notifications/SendPasswordReset.php index 434d1dd48..381b731a7 100644 --- a/app/Notifications/SendPasswordReset.php +++ b/app/Notifications/SendPasswordReset.php @@ -34,7 +34,7 @@ class SendPasswordReset extends Notification implements ShouldQueue return (new MailMessage()) ->subject('Reset Password') ->line('You are receiving this email because we received a password reset request for your account.') - ->action('Reset Password', url('/auth/password/reset/' . $this->token . '?email=' . urlencode($notifiable->email))) + ->action('Reset Password', url('/auth/password/reset/'.$this->token.'?email='.urlencode($notifiable->email))) ->line('If you did not request a password reset, no further action is required.'); } } diff --git a/app/Notifications/ServerInstalled.php b/app/Notifications/ServerInstalled.php index fa6500afa..f23371bc3 100644 --- a/app/Notifications/ServerInstalled.php +++ b/app/Notifications/ServerInstalled.php @@ -51,9 +51,9 @@ class ServerInstalled extends Notification implements ShouldQueue public function toMail(): MailMessage { return (new MailMessage()) - ->greeting('Hello ' . $this->user->username . '.') + ->greeting('Hello '.$this->user->username.'.') ->line('Your server has finished installing and is now ready for you to use.') - ->line('Server Name: ' . $this->server->name) + ->line('Server Name: '.$this->server->name) ->action('Login and Begin Using', route('index')); } } diff --git a/app/Policies/DefaultPolicies.php b/app/Policies/DefaultPolicies.php index 3035cae19..e1d2890ab 100644 --- a/app/Policies/DefaultPolicies.php +++ b/app/Policies/DefaultPolicies.php @@ -12,7 +12,7 @@ trait DefaultPolicies */ public function viewAny(User $user): bool { - return $user->can('viewList ' . $this->modelName); + return $user->can('viewList '.$this->modelName); } /** @@ -20,7 +20,7 @@ trait DefaultPolicies */ public function view(User $user, Model $model): bool { - return $user->can('view ' . $this->modelName, $model); + return $user->can('view '.$this->modelName, $model); } /** @@ -28,7 +28,7 @@ trait DefaultPolicies */ public function create(User $user): bool { - return $user->can('create ' . $this->modelName); + return $user->can('create '.$this->modelName); } /** @@ -36,7 +36,7 @@ trait DefaultPolicies */ public function update(User $user, Model $model): bool { - return $user->can('update ' . $this->modelName, $model); + return $user->can('update '.$this->modelName, $model); } /** @@ -44,6 +44,6 @@ trait DefaultPolicies */ public function delete(User $user, Model $model): bool { - return $user->can('delete ' . $this->modelName, $model); + return $user->can('delete '.$this->modelName, $model); } } diff --git a/app/Repositories/Daemon/DaemonConfigurationRepository.php b/app/Repositories/Daemon/DaemonConfigurationRepository.php index 52cda56dd..86b8418ea 100644 --- a/app/Repositories/Daemon/DaemonConfigurationRepository.php +++ b/app/Repositories/Daemon/DaemonConfigurationRepository.php @@ -19,7 +19,7 @@ class DaemonConfigurationRepository extends DaemonRepository $response = $this ->getHttpClient() ->connectTimeout($connectTimeout) - ->get('/api/system' . (!is_null($version) ? '?v=' . $version : '')); + ->get('/api/system'.(!is_null($version) ? '?v='.$version : '')); } catch (TransferException $exception) { throw new DaemonConnectionException($exception); } diff --git a/app/Repositories/Daemon/DaemonServerRepository.php b/app/Repositories/Daemon/DaemonServerRepository.php index ce91ece2b..8656adc74 100644 --- a/app/Repositories/Daemon/DaemonServerRepository.php +++ b/app/Repositories/Daemon/DaemonServerRepository.php @@ -96,7 +96,7 @@ class DaemonServerRepository extends DaemonRepository Assert::isInstanceOf($this->server, Server::class); try { - $this->getHttpClient()->delete('/api/servers/' . $this->server->uuid); + $this->getHttpClient()->delete('/api/servers/'.$this->server->uuid); } catch (TransferException $exception) { throw new DaemonConnectionException($exception); } @@ -192,7 +192,7 @@ class DaemonServerRepository extends DaemonRepository { Assert::isInstanceOf($this->server, Server::class); - $this->revokeJTIs([md5($id . $this->server->uuid)]); + $this->revokeJTIs([md5($id.$this->server->uuid)]); } /** diff --git a/app/Services/Acl/Api/AdminAcl.php b/app/Services/Acl/Api/AdminAcl.php index 90ec6480a..fc7b176ca 100644 --- a/app/Services/Acl/Api/AdminAcl.php +++ b/app/Services/Acl/Api/AdminAcl.php @@ -62,7 +62,7 @@ class AdminAcl */ public static function check(ApiKey $key, string $resource, int $action = self::READ): bool { - return self::can(data_get($key, self::COLUMN_IDENTIFIER . $resource, self::NONE), $action); + return self::can(data_get($key, self::COLUMN_IDENTIFIER.$resource, self::NONE), $action); } /** diff --git a/app/Services/Backups/DownloadLinkService.php b/app/Services/Backups/DownloadLinkService.php index a167a1bb2..ed3867266 100644 --- a/app/Services/Backups/DownloadLinkService.php +++ b/app/Services/Backups/DownloadLinkService.php @@ -34,7 +34,7 @@ class DownloadLinkService 'backup_uuid' => $backup->uuid, 'server_uuid' => $backup->server->uuid, ]) - ->handle($backup->server->node, $user->id . $backup->server->uuid); + ->handle($backup->server->node, $user->id.$backup->server->uuid); return sprintf('%s/download/backup?token=%s', $backup->server->node->getConnectionAddress(), $token->toString()); } diff --git a/app/Services/Files/DeleteFilesService.php b/app/Services/Files/DeleteFilesService.php index 2b1be5fda..907c12c31 100644 --- a/app/Services/Files/DeleteFilesService.php +++ b/app/Services/Files/DeleteFilesService.php @@ -29,7 +29,7 @@ class DeleteFilesService $pattern = basename($line); collect($this->daemonFileRepository->setServer($server)->getDirectory($path))->each(function ($item) use ($path, $pattern, $filesToDelete) { if (Str::is($pattern, $item['name'])) { - $filesToDelete->push($path . '/' . $item['name']); + $filesToDelete->push($path.'/'.$item['name']); } }); } diff --git a/app/Services/Helpers/AssetHashService.php b/app/Services/Helpers/AssetHashService.php index f94c32f3b..304dabdfc 100644 --- a/app/Services/Helpers/AssetHashService.php +++ b/app/Services/Helpers/AssetHashService.php @@ -70,7 +70,7 @@ class AssetHashService $output .= " $key=\"$value\""; } - return $output . '>'; + return $output.'>'; } /** @@ -92,7 +92,7 @@ class AssetHashService $output .= " $key=\"$value\""; } - return $output . '>'; + return $output.'>'; } /** diff --git a/app/Services/Helpers/SoftwareVersionService.php b/app/Services/Helpers/SoftwareVersionService.php index 7d50203bf..18c212d99 100644 --- a/app/Services/Helpers/SoftwareVersionService.php +++ b/app/Services/Helpers/SoftwareVersionService.php @@ -127,13 +127,13 @@ class SoftwareVersionService $head = explode(' ', file_get_contents(base_path('.git/HEAD'))); if (array_key_exists(1, $head)) { - $path = base_path('.git/' . trim($head[1])); + $path = base_path('.git/'.trim($head[1])); } } if (isset($path) && file_exists($path)) { return [ - 'version' => 'canary (' . substr(file_get_contents($path), 0, 8) . ')', + 'version' => 'canary ('.substr(file_get_contents($path), 0, 8).')', 'is_git' => true, ]; } diff --git a/app/Services/Servers/StartupCommandService.php b/app/Services/Servers/StartupCommandService.php index 4703eb075..1c6ff1be2 100644 --- a/app/Services/Servers/StartupCommandService.php +++ b/app/Services/Servers/StartupCommandService.php @@ -15,7 +15,7 @@ class StartupCommandService $replace = [$server->memory, $server->allocation->ip, $server->allocation->port]; foreach ($server->variables as $variable) { - $find[] = '{{' . $variable->env_variable . '}}'; + $find[] = '{{'.$variable->env_variable.'}}'; $replace[] = ($variable->user_viewable && !$hideAllValues) ? ($variable->server_value ?? $variable->default_value) : '[hidden]'; } diff --git a/app/Services/Servers/TransferServerService.php b/app/Services/Servers/TransferServerService.php index 4312369dd..070f84f32 100644 --- a/app/Services/Servers/TransferServerService.php +++ b/app/Services/Servers/TransferServerService.php @@ -31,8 +31,8 @@ class TransferServerService Http::daemon($server->node)->post('/api/transfer', [ 'json' => [ 'server_id' => $server->uuid, - 'url' => $server->node->getConnectionAddress() . "/api/servers/$server->uuid/archive", - 'token' => 'Bearer ' . $token->toString(), + 'url' => $server->node->getConnectionAddress()."/api/servers/$server->uuid/archive", + 'token' => 'Bearer '.$token->toString(), 'server' => [ 'uuid' => $server->uuid, 'start_on_completion' => false, diff --git a/app/Services/Servers/VariableValidatorService.php b/app/Services/Servers/VariableValidatorService.php index 75f4a59b1..904e494d9 100644 --- a/app/Services/Servers/VariableValidatorService.php +++ b/app/Services/Servers/VariableValidatorService.php @@ -40,8 +40,8 @@ class VariableValidatorService $data = $rules = $customAttributes = []; foreach ($variables as $variable) { $data['environment'][$variable->env_variable] = array_get($fields, $variable->env_variable); - $rules['environment.' . $variable->env_variable] = $variable->rules; - $customAttributes['environment.' . $variable->env_variable] = trans('validation.internal.variable_value', ['env' => $variable->name]); + $rules['environment.'.$variable->env_variable] = $variable->rules; + $customAttributes['environment.'.$variable->env_variable] = trans('validation.internal.variable_value', ['env' => $variable->name]); } $validator = $this->validator->make($data, $rules, [], $customAttributes); diff --git a/app/Services/Subusers/SubuserCreationService.php b/app/Services/Subusers/SubuserCreationService.php index 0f9508ba7..0439afd52 100644 --- a/app/Services/Subusers/SubuserCreationService.php +++ b/app/Services/Subusers/SubuserCreationService.php @@ -39,7 +39,7 @@ class SubuserCreationService if (!$user) { // Just cap the username generated at 64 characters at most and then append a random string // to the end to make it "unique"... - $username = substr(preg_replace('/([^\w\.-]+)/', '', strtok($email, '@')), 0, 64) . Str::random(3); + $username = substr(preg_replace('/([^\w\.-]+)/', '', strtok($email, '@')), 0, 64).Str::random(3); $user = $this->userCreationService->handle([ 'email' => $email, diff --git a/app/Traits/EnvironmentWriterTrait.php b/app/Traits/EnvironmentWriterTrait.php index 460d8000e..2eaca0e6f 100644 --- a/app/Traits/EnvironmentWriterTrait.php +++ b/app/Traits/EnvironmentWriterTrait.php @@ -36,10 +36,10 @@ trait EnvironmentWriterTrait $key = strtoupper($key); $saveValue = sprintf('%s=%s', $key, $this->escapeEnvironmentValue($value ?? '')); - if (preg_match_all('/^' . $key . '=(.*)$/m', $saveContents) < 1) { - $saveContents = $saveContents . PHP_EOL . $saveValue; + if (preg_match_all('/^'.$key.'=(.*)$/m', $saveContents) < 1) { + $saveContents = $saveContents.PHP_EOL.$saveValue; } else { - $saveContents = preg_replace('/^' . $key . '=(.*)$/m', $saveValue, $saveContents); + $saveContents = preg_replace('/^'.$key.'=(.*)$/m', $saveValue, $saveContents); } }); diff --git a/app/Transformers/Api/Client/ActivityLogTransformer.php b/app/Transformers/Api/Client/ActivityLogTransformer.php index 58d5f13ae..1d38507ec 100644 --- a/app/Transformers/Api/Client/ActivityLogTransformer.php +++ b/app/Transformers/Api/Client/ActivityLogTransformer.php @@ -62,7 +62,7 @@ class ActivityLogTransformer extends BaseClientTransformer if (!is_array($value)) { // Perform some directory normalization at this point. if ($key === 'directory') { - $value = str_replace('//', '/', '/' . trim($value, '/') . '/'); + $value = str_replace('//', '/', '/'.trim($value, '/').'/'); } return [$key => $value]; @@ -94,7 +94,7 @@ class ActivityLogTransformer extends BaseClientTransformer return false; } - $str = trans('activity.' . str_replace(':', '.', $model->event)); + $str = trans('activity.'.str_replace(':', '.', $model->event)); preg_match_all('/:(?[\w.-]+\w)(?:[^\w:]?|$)/', $str, $matches); $exclude = array_merge($matches['key'], ['ip', 'useragent', 'using_sftp']); diff --git a/app/Transformers/Api/Client/UserTransformer.php b/app/Transformers/Api/Client/UserTransformer.php index f875463e5..06160a722 100644 --- a/app/Transformers/Api/Client/UserTransformer.php +++ b/app/Transformers/Api/Client/UserTransformer.php @@ -28,7 +28,7 @@ class UserTransformer extends BaseClientTransformer 'first_name' => $user->name_first, 'last_name' => $user->name_last, 'language' => $user->language, - 'image' => 'https://gravatar.com/avatar/' . md5(Str::lower($user->email)), // deprecated + 'image' => 'https://gravatar.com/avatar/'.md5(Str::lower($user->email)), // deprecated 'admin' => $user->isRootAdmin(), // deprecated, use "root_admin" 'root_admin' => $user->isRootAdmin(), '2fa_enabled' => (bool) $user->use_totp, diff --git a/bootstrap/tests.php b/bootstrap/tests.php index a80e0b27f..148613856 100644 --- a/bootstrap/tests.php +++ b/bootstrap/tests.php @@ -5,9 +5,9 @@ use NunoMaduro\Collision\Provider; use Illuminate\Contracts\Console\Kernel; use Symfony\Component\Console\Output\ConsoleOutput; -require __DIR__ . '/../vendor/autoload.php'; +require __DIR__.'/../vendor/autoload.php'; -$app = require __DIR__ . '/app.php'; +$app = require __DIR__.'/app.php'; /** @var \App\Console\Kernel $kernel */ $kernel = $app->make(Kernel::class); @@ -23,10 +23,10 @@ $kernel->bootstrap(); $output = new ConsoleOutput(); -$prefix = 'database.connections.' . config('database.default'); +$prefix = 'database.connections.'.config('database.default'); if (!Str::contains(config("$prefix.database"), 'test')) { - $output->writeln(PHP_EOL . 'Cannot run test process against non-testing database.'); - $output->writeln(PHP_EOL . 'Environment is currently pointed at: "' . config("$prefix.database") . '".'); + $output->writeln(PHP_EOL.'Cannot run test process against non-testing database.'); + $output->writeln(PHP_EOL.'Environment is currently pointed at: "'.config("$prefix.database").'".'); exit(1); } @@ -35,11 +35,11 @@ if (!Str::contains(config("$prefix.database"), 'test')) { * running the tests. */ if (!env('SKIP_MIGRATIONS')) { - $output->writeln(PHP_EOL . 'Refreshing database for Integration tests...'); + $output->writeln(PHP_EOL.'Refreshing database for Integration tests...'); $kernel->call('migrate:fresh'); - $output->writeln('Seeding database for Integration tests...' . PHP_EOL); + $output->writeln('Seeding database for Integration tests...'.PHP_EOL); $kernel->call('db:seed'); } else { - $output->writeln(PHP_EOL . 'Skipping database migrations...' . PHP_EOL); + $output->writeln(PHP_EOL.'Skipping database migrations...'.PHP_EOL); } diff --git a/database/Factories/NodeFactory.php b/database/Factories/NodeFactory.php index 19a1fbf7b..7d0ac25a1 100644 --- a/database/Factories/NodeFactory.php +++ b/database/Factories/NodeFactory.php @@ -24,7 +24,7 @@ class NodeFactory extends Factory return [ 'uuid' => Uuid::uuid4()->toString(), 'public' => true, - 'name' => 'FactoryNode_' . Str::random(10), + 'name' => 'FactoryNode_'.Str::random(10), 'fqdn' => $this->faker->unique()->ipv4(), 'scheme' => 'http', 'behind_proxy' => false, diff --git a/database/Factories/UserFactory.php b/database/Factories/UserFactory.php index 3c6003cc2..6284e7471 100644 --- a/database/Factories/UserFactory.php +++ b/database/Factories/UserFactory.php @@ -27,8 +27,8 @@ class UserFactory extends Factory return [ 'external_id' => null, 'uuid' => Uuid::uuid4()->toString(), - 'username' => $this->faker->userName() . '_' . Str::random(10), - 'email' => Str::random(32) . '@example.com', + 'username' => $this->faker->userName().'_'.Str::random(10), + 'email' => Str::random(32).'@example.com', 'name_first' => $this->faker->firstName(), 'name_last' => $this->faker->lastName(), 'password' => $password ?: $password = bcrypt('password'), diff --git a/database/Seeders/EggSeeder.php b/database/Seeders/EggSeeder.php index dcbc4f25c..3053bfa76 100644 --- a/database/Seeders/EggSeeder.php +++ b/database/Seeders/EggSeeder.php @@ -47,9 +47,9 @@ class EggSeeder extends Seeder */ protected function parseEggFiles($name) { - $files = new \DirectoryIterator(database_path('Seeders/eggs/' . kebab_case($name))); + $files = new \DirectoryIterator(database_path('Seeders/eggs/'.kebab_case($name))); - $this->command->alert('Updating Eggs for: ' . $name); + $this->command->alert('Updating Eggs for: '.$name); /** @var \DirectoryIterator $file */ foreach ($files as $file) { if (!$file->isFile() || !$file->isReadable()) { @@ -71,10 +71,10 @@ class EggSeeder extends Seeder if ($egg instanceof Egg) { $this->importerService->fromFile($file, $egg); - $this->command->info('Updated ' . $decoded['name']); + $this->command->info('Updated '.$decoded['name']); } else { $this->importerService->fromFile($file); - $this->command->comment('Created ' . $decoded['name']); + $this->command->comment('Created '.$decoded['name']); } } diff --git a/database/migrations/2017_03_11_215455_ChangeServiceVariablesValidationRules.php b/database/migrations/2017_03_11_215455_ChangeServiceVariablesValidationRules.php index b96b2ba24..5d8d38e6d 100644 --- a/database/migrations/2017_03_11_215455_ChangeServiceVariablesValidationRules.php +++ b/database/migrations/2017_03_11_215455_ChangeServiceVariablesValidationRules.php @@ -17,7 +17,7 @@ return new class extends Migration DB::transaction(function () { foreach (DB::table('service_variables')->get() as $variable) { - $variable->rules = ($variable->required) ? 'required|regex:' . $variable->rules : 'regex:' . $variable->rules; + $variable->rules = ($variable->required) ? 'required|regex:'.$variable->rules : 'regex:'.$variable->rules; $variable->save(); } }); diff --git a/database/migrations/2017_09_13_211810_UpdateOldPermissionsToPointToNewScheduleSystem.php b/database/migrations/2017_09_13_211810_UpdateOldPermissionsToPointToNewScheduleSystem.php index aca8afb6c..4e50c9a84 100644 --- a/database/migrations/2017_09_13_211810_UpdateOldPermissionsToPointToNewScheduleSystem.php +++ b/database/migrations/2017_09_13_211810_UpdateOldPermissionsToPointToNewScheduleSystem.php @@ -17,7 +17,7 @@ return new class extends Migration continue; } - $newPermission = $parts[0] . '-' . str_replace('task', 'schedule', $parts[1]); + $newPermission = $parts[0].'-'.str_replace('task', 'schedule', $parts[1]); DB::table('permissions')->where('id', '=', $record->id)->update(['permission' => $newPermission]); } @@ -35,7 +35,7 @@ return new class extends Migration continue; } - $newPermission = $parts[0] . '-' . str_replace('schedule', 'task', $parts[1]); + $newPermission = $parts[0].'-'.str_replace('schedule', 'task', $parts[1]); DB::table('permissions')->where('id', '=', $record->id)->update(['permission' => $newPermission]); } diff --git a/database/migrations/2017_09_23_173628_RemoveDaemonSecretFromServersTable.php b/database/migrations/2017_09_23_173628_RemoveDaemonSecretFromServersTable.php index ab2e8056e..e99078b66 100644 --- a/database/migrations/2017_09_23_173628_RemoveDaemonSecretFromServersTable.php +++ b/database/migrations/2017_09_23_173628_RemoveDaemonSecretFromServersTable.php @@ -21,7 +21,7 @@ return new class extends Migration $inserts[] = [ 'user_id' => $server->owner_id, 'server_id' => $server->id, - 'secret' => DaemonKeyRepositoryInterface::INTERNAL_KEY_IDENTIFIER . str_random(40), + 'secret' => DaemonKeyRepositoryInterface::INTERNAL_KEY_IDENTIFIER.str_random(40), 'expires_at' => Carbon::now()->addMinutes(config('panel.api.key_expire_time', 720))->toDateTimeString(), 'created_at' => Carbon::now()->toDateTimeString(), 'updated_at' => Carbon::now()->toDateTimeString(), diff --git a/database/migrations/2017_09_23_185022_RemoveDaemonSecretFromSubusersTable.php b/database/migrations/2017_09_23_185022_RemoveDaemonSecretFromSubusersTable.php index 9090be407..60b0d6358 100644 --- a/database/migrations/2017_09_23_185022_RemoveDaemonSecretFromSubusersTable.php +++ b/database/migrations/2017_09_23_185022_RemoveDaemonSecretFromSubusersTable.php @@ -19,7 +19,7 @@ return new class extends Migration $inserts[] = [ 'user_id' => $subuser->user_id, 'server_id' => $subuser->server_id, - 'secret' => DaemonKeyRepositoryInterface::INTERNAL_KEY_IDENTIFIER . str_random(40), + 'secret' => DaemonKeyRepositoryInterface::INTERNAL_KEY_IDENTIFIER.str_random(40), 'expires_at' => Carbon::now()->addMinutes(config('panel.api.key_expire_time', 720))->toDateTimeString(), 'created_at' => Carbon::now()->toDateTimeString(), 'updated_at' => Carbon::now()->toDateTimeString(), diff --git a/database/migrations/2020_03_22_163911_merge_permissions_table_into_subusers.php b/database/migrations/2020_03_22_163911_merge_permissions_table_into_subusers.php index 6a9280b5f..2a10ba96c 100644 --- a/database/migrations/2020_03_22_163911_merge_permissions_table_into_subusers.php +++ b/database/migrations/2020_03_22_163911_merge_permissions_table_into_subusers.php @@ -112,9 +112,9 @@ return new class extends Migration } if (!empty($values)) { - $string = 'VALUES ' . implode(', ', array_fill(0, count($values) / 2, '(?, ?)')); + $string = 'VALUES '.implode(', ', array_fill(0, count($values) / 2, '(?, ?)')); - DB::insert('INSERT INTO permissions(`subuser_id`, `permission`) ' . $string, $values); + DB::insert('INSERT INTO permissions(`subuser_id`, `permission`) '.$string, $values); } } diff --git a/database/migrations/2020_04_10_141024_store_node_tokens_as_encrypted_value.php b/database/migrations/2020_04_10_141024_store_node_tokens_as_encrypted_value.php index 911461d70..d98bbc3c8 100644 --- a/database/migrations/2020_04_10_141024_store_node_tokens_as_encrypted_value.php +++ b/database/migrations/2020_04_10_141024_store_node_tokens_as_encrypted_value.php @@ -53,7 +53,7 @@ return new class extends Migration DB::transaction(function () { foreach (DB::select('SELECT id, daemon_token_id, daemon_token FROM nodes') as $datum) { DB::update('UPDATE nodes SET daemon_token = ? WHERE id = ?', [ - $datum->daemon_token_id . decrypt($datum->daemon_token), + $datum->daemon_token_id.decrypt($datum->daemon_token), $datum->id, ]); } diff --git a/pint.json b/pint.json index 17de52db6..e6d2cafb8 100644 --- a/pint.json +++ b/pint.json @@ -1,7 +1,6 @@ { "preset": "laravel", "rules": { - "concat_space": false, "not_operator_with_successor_space": false, "nullable_type_declaration_for_default_null_value": false, "ordered_imports": false, diff --git a/tests/Assertions/AssertsActivityLogged.php b/tests/Assertions/AssertsActivityLogged.php index db352bc97..ecc33a833 100644 --- a/tests/Assertions/AssertsActivityLogged.php +++ b/tests/Assertions/AssertsActivityLogged.php @@ -35,7 +35,7 @@ trait AssertsActivityLogged public function assertActivitySubjects(string $event, Model|array $subjects): void { if (is_array($subjects)) { - \Webmozart\Assert\Assert::lessThanEq(count(func_get_args()), 2, 'Invalid call to ' . __METHOD__ . ': cannot provide additional arguments if providing an array.'); + \Webmozart\Assert\Assert::lessThanEq(count(func_get_args()), 2, 'Invalid call to '.__METHOD__.': cannot provide additional arguments if providing an array.'); } else { $subjects = array_slice(func_get_args(), 1); } diff --git a/tests/Assertions/MiddlewareAttributeAssertionsTrait.php b/tests/Assertions/MiddlewareAttributeAssertionsTrait.php index ab24f0311..4a8441abe 100644 --- a/tests/Assertions/MiddlewareAttributeAssertionsTrait.php +++ b/tests/Assertions/MiddlewareAttributeAssertionsTrait.php @@ -11,7 +11,7 @@ trait MiddlewareAttributeAssertionsTrait */ public function assertRequestHasAttribute(string $attribute): void { - Assert::assertTrue($this->request->attributes->has($attribute), 'Assert that request mock has ' . $attribute . ' attribute.'); + Assert::assertTrue($this->request->attributes->has($attribute), 'Assert that request mock has '.$attribute.' attribute.'); } /** @@ -19,7 +19,7 @@ trait MiddlewareAttributeAssertionsTrait */ public function assertRequestMissingAttribute(string $attribute): void { - Assert::assertFalse($this->request->attributes->has($attribute), 'Assert that request mock does not have ' . $attribute . ' attribute.'); + Assert::assertFalse($this->request->attributes->has($attribute), 'Assert that request mock does not have '.$attribute.' attribute.'); } /** diff --git a/tests/Integration/Api/Application/ApplicationApiIntegrationTestCase.php b/tests/Integration/Api/Application/ApplicationApiIntegrationTestCase.php index c104a3eae..02b674a9a 100644 --- a/tests/Integration/Api/Application/ApplicationApiIntegrationTestCase.php +++ b/tests/Integration/Api/Application/ApplicationApiIntegrationTestCase.php @@ -38,7 +38,7 @@ abstract class ApplicationApiIntegrationTestCase extends IntegrationTestCase $this ->withHeader('Accept', 'application/vnd.panel.v1+json') - ->withHeader('Authorization', 'Bearer ' . $this->key->identifier . $this->key->token); + ->withHeader('Authorization', 'Bearer '.$this->key->identifier.$this->key->token); } public function getApiUser(): User @@ -58,7 +58,7 @@ abstract class ApplicationApiIntegrationTestCase extends IntegrationTestCase { $this->key = $this->createApiKey($user, $permissions); - $this->withHeader('Authorization', 'Bearer ' . $this->key->identifier . $this->key->token); + $this->withHeader('Authorization', 'Bearer '.$this->key->identifier.$this->key->token); return $this->key; } diff --git a/tests/Integration/Api/Application/EggControllerTest.php b/tests/Integration/Api/Application/EggControllerTest.php index 14a41cd6a..62ab2422f 100644 --- a/tests/Integration/Api/Application/EggControllerTest.php +++ b/tests/Integration/Api/Application/EggControllerTest.php @@ -48,7 +48,7 @@ class EggControllerTest extends ApplicationApiIntegrationTestCase $this->assertSame( $expected, $actual, - 'Unable to find JSON fragment: ' . PHP_EOL . PHP_EOL . "[$expected]" . PHP_EOL . PHP_EOL . 'within' . PHP_EOL . PHP_EOL . "[$actual]." + 'Unable to find JSON fragment: '.PHP_EOL.PHP_EOL."[$expected]".PHP_EOL.PHP_EOL.'within'.PHP_EOL.PHP_EOL."[$actual]." ); } } @@ -60,7 +60,7 @@ class EggControllerTest extends ApplicationApiIntegrationTestCase { $egg = Egg::query()->findOrFail(1); - $response = $this->getJson('/api/application/eggs/' . $egg->id); + $response = $this->getJson('/api/application/eggs/'.$egg->id); $response->assertStatus(Response::HTTP_OK); $response->assertJsonStructure([ 'object', @@ -82,7 +82,7 @@ class EggControllerTest extends ApplicationApiIntegrationTestCase { $egg = Egg::query()->findOrFail(1); - $response = $this->getJson('/api/application/eggs/' . $egg->id . '?include=servers,variables'); + $response = $this->getJson('/api/application/eggs/'.$egg->id.'?include=servers,variables'); $response->assertStatus(Response::HTTP_OK); $response->assertJsonStructure([ 'object', diff --git a/tests/Integration/Api/Application/Users/ExternalUserControllerTest.php b/tests/Integration/Api/Application/Users/ExternalUserControllerTest.php index 24f3996eb..4ef873c43 100644 --- a/tests/Integration/Api/Application/Users/ExternalUserControllerTest.php +++ b/tests/Integration/Api/Application/Users/ExternalUserControllerTest.php @@ -16,7 +16,7 @@ class ExternalUserControllerTest extends ApplicationApiIntegrationTestCase { $user = User::factory()->create(['external_id' => Str::random()]); - $response = $this->getJson('/api/application/users/external/' . $user->external_id); + $response = $this->getJson('/api/application/users/external/'.$user->external_id); $response->assertStatus(Response::HTTP_OK); $response->assertJsonCount(2); $response->assertJsonStructure([ @@ -64,7 +64,7 @@ class ExternalUserControllerTest extends ApplicationApiIntegrationTestCase $user = User::factory()->create(['external_id' => Str::random()]); $this->createNewDefaultApiKey($this->getApiUser(), ['r_users' => 0]); - $response = $this->getJson('/api/application/users/external/' . $user->external_id); + $response = $this->getJson('/api/application/users/external/'.$user->external_id); $this->assertAccessDeniedJson($response); } } diff --git a/tests/Integration/Api/Application/Users/UserControllerTest.php b/tests/Integration/Api/Application/Users/UserControllerTest.php index 6787ff1f4..04ba5c2e6 100644 --- a/tests/Integration/Api/Application/Users/UserControllerTest.php +++ b/tests/Integration/Api/Application/Users/UserControllerTest.php @@ -89,7 +89,7 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase { $user = User::factory()->create(); - $response = $this->getJson('/api/application/users/' . $user->id); + $response = $this->getJson('/api/application/users/'.$user->id); $response->assertStatus(Response::HTTP_OK); $response->assertJsonCount(2); $response->assertJsonStructure([ @@ -124,7 +124,7 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase $user = User::factory()->create(); $server = $this->createServerModel(['user_id' => $user->id]); - $response = $this->getJson('/api/application/users/' . $user->id . '?include=servers'); + $response = $this->getJson('/api/application/users/'.$user->id.'?include=servers'); $response->assertStatus(Response::HTTP_OK); $response->assertJsonCount(2); $response->assertJsonStructure([ @@ -157,7 +157,7 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase $user = User::factory()->create(); $this->createServerModel(['user_id' => $user->id]); - $response = $this->getJson('/api/application/users/' . $user->id . '?include=servers'); + $response = $this->getJson('/api/application/users/'.$user->id.'?include=servers'); $response->assertStatus(Response::HTTP_OK); $response->assertJsonCount(2)->assertJsonCount(1, 'attributes.relationships'); $response->assertJsonStructure([ @@ -199,7 +199,7 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase $user = User::factory()->create(); $this->createNewDefaultApiKey($this->getApiUser(), ['r_users' => 0]); - $response = $this->getJson('/api/application/users/' . $user->id); + $response = $this->getJson('/api/application/users/'.$user->id); $this->assertAccessDeniedJson($response); } @@ -242,7 +242,7 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase { $user = User::factory()->create(); - $response = $this->patchJson('/api/application/users/' . $user->id, [ + $response = $this->patchJson('/api/application/users/'.$user->id, [ 'username' => 'new.test.name', 'email' => 'new@emailtest.com', 'first_name' => $user->name_first, @@ -272,7 +272,7 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase $user = User::factory()->create(); $this->assertDatabaseHas('users', ['id' => $user->id]); - $response = $this->delete('/api/application/users/' . $user->id); + $response = $this->delete('/api/application/users/'.$user->id); $response->assertStatus(Response::HTTP_NO_CONTENT); $this->assertDatabaseMissing('users', ['id' => $user->id]); diff --git a/tests/Integration/Api/Client/AccountControllerTest.php b/tests/Integration/Api/Client/AccountControllerTest.php index ccca6818d..38ce80fa9 100644 --- a/tests/Integration/Api/Client/AccountControllerTest.php +++ b/tests/Integration/Api/Client/AccountControllerTest.php @@ -28,7 +28,7 @@ class AccountControllerTest extends ClientApiIntegrationTestCase 'first_name' => $user->name_first, 'last_name' => $user->name_last, 'language' => 'en', - 'image' => 'https://gravatar.com/avatar/' . md5(Str::lower($user->email)), + 'image' => 'https://gravatar.com/avatar/'.md5(Str::lower($user->email)), 'admin' => false, 'root_admin' => false, '2fa_enabled' => false, @@ -47,7 +47,7 @@ class AccountControllerTest extends ClientApiIntegrationTestCase $user = User::factory()->create(); $response = $this->actingAs($user)->putJson('/api/client/account/email', [ - 'email' => $email = Str::random() . '@example.com', + 'email' => $email = Str::random().'@example.com', 'password' => 'password', ]); diff --git a/tests/Integration/Api/Client/ApiKeyControllerTest.php b/tests/Integration/Api/Client/ApiKeyControllerTest.php index 462875c59..27662a173 100644 --- a/tests/Integration/Api/Client/ApiKeyControllerTest.php +++ b/tests/Integration/Api/Client/ApiKeyControllerTest.php @@ -83,7 +83,7 @@ class ApiKeyControllerTest extends ClientApiIntegrationTestCase { $ips = []; for ($i = 0; $i < 100; $i++) { - $ips[] = '127.0.0.' . $i; + $ips[] = '127.0.0.'.$i; } $this->actingAs(User::factory()->create()) @@ -162,7 +162,7 @@ class ApiKeyControllerTest extends ClientApiIntegrationTestCase 'key_type' => ApiKey::TYPE_ACCOUNT, ]); - $response = $this->actingAs($user)->delete('/api/client/account/api-keys/' . $key->identifier); + $response = $this->actingAs($user)->delete('/api/client/account/api-keys/'.$key->identifier); $response->assertStatus(Response::HTTP_NO_CONTENT); $this->assertDatabaseMissing('api_keys', ['id' => $key->id]); @@ -205,7 +205,7 @@ class ApiKeyControllerTest extends ClientApiIntegrationTestCase ]); $this->actingAs($user) - ->deleteJson('/api/client/account/api-keys/' . $key->identifier) + ->deleteJson('/api/client/account/api-keys/'.$key->identifier) ->assertNotFound(); $this->assertDatabaseHas('api_keys', ['id' => $key->id]); @@ -226,7 +226,7 @@ class ApiKeyControllerTest extends ClientApiIntegrationTestCase ]); $this->actingAs($user) - ->deleteJson('/api/client/account/api-keys/' . $key->identifier) + ->deleteJson('/api/client/account/api-keys/'.$key->identifier) ->assertNotFound(); $this->assertDatabaseHas('api_keys', ['id' => $key->id]); diff --git a/tests/Integration/Api/Client/ClientApiIntegrationTestCase.php b/tests/Integration/Api/Client/ClientApiIntegrationTestCase.php index e909bb41e..44c06e570 100644 --- a/tests/Integration/Api/Client/ClientApiIntegrationTestCase.php +++ b/tests/Integration/Api/Client/ClientApiIntegrationTestCase.php @@ -69,7 +69,7 @@ abstract class ClientApiIntegrationTestCase extends IntegrationTestCase throw new \InvalidArgumentException(sprintf('Cannot create link for Model of type %s', class_basename($model))); } - return $link . ($append ? '/' . ltrim($append, '/') : ''); + return $link.($append ? '/'.ltrim($append, '/') : ''); } /** diff --git a/tests/Integration/Api/Client/ClientControllerTest.php b/tests/Integration/Api/Client/ClientControllerTest.php index e4059f694..4e5e26b27 100644 --- a/tests/Integration/Api/Client/ClientControllerTest.php +++ b/tests/Integration/Api/Client/ClientControllerTest.php @@ -298,7 +298,7 @@ class ClientControllerTest extends ClientApiIntegrationTestCase $this->createServerModel(['user_id' => $users[1]->id]); $this->createServerModel(['user_id' => $users[2]->id]); - $response = $this->actingAs($users[0])->getJson('/api/client?type=' . $type); + $response = $this->actingAs($users[0])->getJson('/api/client?type='.$type); $response->assertOk(); $response->assertJsonCount(0, 'data'); diff --git a/tests/Integration/Api/Client/Server/Allocation/AllocationAuthorizationTest.php b/tests/Integration/Api/Client/Server/Allocation/AllocationAuthorizationTest.php index 6cd798e16..f1d93f8ad 100644 --- a/tests/Integration/Api/Client/Server/Allocation/AllocationAuthorizationTest.php +++ b/tests/Integration/Api/Client/Server/Allocation/AllocationAuthorizationTest.php @@ -30,20 +30,20 @@ class AllocationAuthorizationTest extends ClientApiIntegrationTestCase // This is the only valid call for this test, accessing the allocation for the same // server that the API user is the owner of. - $response = $this->actingAs($user)->json($method, $this->link($server1, '/network/allocations/' . $allocation1->id . $endpoint)); + $response = $this->actingAs($user)->json($method, $this->link($server1, '/network/allocations/'.$allocation1->id.$endpoint)); $this->assertTrue($response->status() <= 204 || $response->status() === 400 || $response->status() === 422); // This request fails because the allocation is valid for that server but the user // making the request is not authorized to perform that action. - $this->actingAs($user)->json($method, $this->link($server2, '/network/allocations/' . $allocation2->id . $endpoint))->assertForbidden(); + $this->actingAs($user)->json($method, $this->link($server2, '/network/allocations/'.$allocation2->id.$endpoint))->assertForbidden(); // Both of these should report a 404 error due to the allocations being linked to // servers that are not the same as the server in the request, or are assigned // to a server for which the user making the request has no access to. - $this->actingAs($user)->json($method, $this->link($server1, '/network/allocations/' . $allocation2->id . $endpoint))->assertNotFound(); - $this->actingAs($user)->json($method, $this->link($server1, '/network/allocations/' . $allocation3->id . $endpoint))->assertNotFound(); - $this->actingAs($user)->json($method, $this->link($server2, '/network/allocations/' . $allocation3->id . $endpoint))->assertNotFound(); - $this->actingAs($user)->json($method, $this->link($server3, '/network/allocations/' . $allocation3->id . $endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server1, '/network/allocations/'.$allocation2->id.$endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server1, '/network/allocations/'.$allocation3->id.$endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server2, '/network/allocations/'.$allocation3->id.$endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server3, '/network/allocations/'.$allocation3->id.$endpoint))->assertNotFound(); } public static function methodDataProvider(): array diff --git a/tests/Integration/Api/Client/Server/Backup/BackupAuthorizationTest.php b/tests/Integration/Api/Client/Server/Backup/BackupAuthorizationTest.php index 472364d78..c91c2e3a1 100644 --- a/tests/Integration/Api/Client/Server/Backup/BackupAuthorizationTest.php +++ b/tests/Integration/Api/Client/Server/Backup/BackupAuthorizationTest.php @@ -38,20 +38,20 @@ class BackupAuthorizationTest extends ClientApiIntegrationTestCase // This is the only valid call for this test, accessing the backup for the same // server that the API user is the owner of. - $this->actingAs($user)->json($method, $this->link($server1, '/backups/' . $backup1->uuid . $endpoint)) + $this->actingAs($user)->json($method, $this->link($server1, '/backups/'.$backup1->uuid.$endpoint)) ->assertStatus($method === 'DELETE' ? 204 : 200); // This request fails because the backup is valid for that server but the user // making the request is not authorized to perform that action. - $this->actingAs($user)->json($method, $this->link($server2, '/backups/' . $backup2->uuid . $endpoint))->assertForbidden(); + $this->actingAs($user)->json($method, $this->link($server2, '/backups/'.$backup2->uuid.$endpoint))->assertForbidden(); // Both of these should report a 404 error due to the backup being linked to // servers that are not the same as the server in the request, or are assigned // to a server for which the user making the request has no access to. - $this->actingAs($user)->json($method, $this->link($server1, '/backups/' . $backup2->uuid . $endpoint))->assertNotFound(); - $this->actingAs($user)->json($method, $this->link($server1, '/backups/' . $backup3->uuid . $endpoint))->assertNotFound(); - $this->actingAs($user)->json($method, $this->link($server2, '/backups/' . $backup3->uuid . $endpoint))->assertNotFound(); - $this->actingAs($user)->json($method, $this->link($server3, '/backups/' . $backup3->uuid . $endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server1, '/backups/'.$backup2->uuid.$endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server1, '/backups/'.$backup3->uuid.$endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server2, '/backups/'.$backup3->uuid.$endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server3, '/backups/'.$backup3->uuid.$endpoint))->assertNotFound(); } public static function methodDataProvider(): array diff --git a/tests/Integration/Api/Client/Server/Database/DatabaseAuthorizationTest.php b/tests/Integration/Api/Client/Server/Database/DatabaseAuthorizationTest.php index b95778104..2c8320812 100644 --- a/tests/Integration/Api/Client/Server/Database/DatabaseAuthorizationTest.php +++ b/tests/Integration/Api/Client/Server/Database/DatabaseAuthorizationTest.php @@ -40,20 +40,20 @@ class DatabaseAuthorizationTest extends ClientApiIntegrationTestCase // This is the only valid call for this test, accessing the database for the same // server that the API user is the owner of. - $this->actingAs($user)->json($method, $this->link($server1, '/databases/' . $database1->id . $endpoint)) + $this->actingAs($user)->json($method, $this->link($server1, '/databases/'.$database1->id.$endpoint)) ->assertStatus($method === 'DELETE' ? 204 : 200); // This request fails because the database is valid for that server but the user // making the request is not authorized to perform that action. - $this->actingAs($user)->json($method, $this->link($server2, '/databases/' . $database2->id . $endpoint))->assertForbidden(); + $this->actingAs($user)->json($method, $this->link($server2, '/databases/'.$database2->id.$endpoint))->assertForbidden(); // Both of these should report a 404 error due to the database being linked to // servers that are not the same as the server in the request, or are assigned // to a server for which the user making the request has no access to. - $this->actingAs($user)->json($method, $this->link($server1, '/databases/' . $database2->id . $endpoint))->assertNotFound(); - $this->actingAs($user)->json($method, $this->link($server1, '/databases/' . $database3->id . $endpoint))->assertNotFound(); - $this->actingAs($user)->json($method, $this->link($server2, '/databases/' . $database3->id . $endpoint))->assertNotFound(); - $this->actingAs($user)->json($method, $this->link($server3, '/databases/' . $database3->id . $endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server1, '/databases/'.$database2->id.$endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server1, '/databases/'.$database3->id.$endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server2, '/databases/'.$database3->id.$endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server3, '/databases/'.$database3->id.$endpoint))->assertNotFound(); } public static function methodDataProvider(): array diff --git a/tests/Integration/Api/Client/Server/Schedule/GetServerSchedulesTest.php b/tests/Integration/Api/Client/Server/Schedule/GetServerSchedulesTest.php index 7d019178b..5900e67f2 100644 --- a/tests/Integration/Api/Client/Server/Schedule/GetServerSchedulesTest.php +++ b/tests/Integration/Api/Client/Server/Schedule/GetServerSchedulesTest.php @@ -47,13 +47,13 @@ class GetServerSchedulesTest extends ClientApiIntegrationTestCase $response->assertJsonCount(1, 'data'); } - $response->assertJsonCount(1, $prefix . 'attributes.relationships.tasks.data'); + $response->assertJsonCount(1, $prefix.'attributes.relationships.tasks.data'); - $response->assertJsonPath($prefix . 'object', Schedule::RESOURCE_NAME); - $response->assertJsonPath($prefix . 'attributes.relationships.tasks.data.0.object', Task::RESOURCE_NAME); + $response->assertJsonPath($prefix.'object', Schedule::RESOURCE_NAME); + $response->assertJsonPath($prefix.'attributes.relationships.tasks.data.0.object', Task::RESOURCE_NAME); - $this->assertJsonTransformedWith($response->json($prefix . 'attributes'), $schedule); - $this->assertJsonTransformedWith($response->json($prefix . 'attributes.relationships.tasks.data.0.attributes'), $task); + $this->assertJsonTransformedWith($response->json($prefix.'attributes'), $schedule); + $this->assertJsonTransformedWith($response->json($prefix.'attributes.relationships.tasks.data.0.attributes'), $task); } /** diff --git a/tests/Integration/Api/Client/Server/Schedule/ScheduleAuthorizationTest.php b/tests/Integration/Api/Client/Server/Schedule/ScheduleAuthorizationTest.php index b6777a748..011187e71 100644 --- a/tests/Integration/Api/Client/Server/Schedule/ScheduleAuthorizationTest.php +++ b/tests/Integration/Api/Client/Server/Schedule/ScheduleAuthorizationTest.php @@ -38,20 +38,20 @@ class ScheduleAuthorizationTest extends ClientApiIntegrationTestCase // This is the only valid call for this test, accessing the schedule for the same // server that the API user is the owner of. - $response = $this->actingAs($user)->json($method, $this->link($server1, '/schedules/' . $schedule1->id . $endpoint)); + $response = $this->actingAs($user)->json($method, $this->link($server1, '/schedules/'.$schedule1->id.$endpoint)); $this->assertTrue($response->status() <= 204 || $response->status() === 400 || $response->status() === 422); // This request fails because the schedule is valid for that server but the user // making the request is not authorized to perform that action. - $this->actingAs($user)->json($method, $this->link($server2, '/schedules/' . $schedule2->id . $endpoint))->assertForbidden(); + $this->actingAs($user)->json($method, $this->link($server2, '/schedules/'.$schedule2->id.$endpoint))->assertForbidden(); // Both of these should report a 404 error due to the schedules being linked to // servers that are not the same as the server in the request, or are assigned // to a server for which the user making the request has no access to. - $this->actingAs($user)->json($method, $this->link($server1, '/schedules/' . $schedule2->id . $endpoint))->assertNotFound(); - $this->actingAs($user)->json($method, $this->link($server1, '/schedules/' . $schedule3->id . $endpoint))->assertNotFound(); - $this->actingAs($user)->json($method, $this->link($server2, '/schedules/' . $schedule3->id . $endpoint))->assertNotFound(); - $this->actingAs($user)->json($method, $this->link($server3, '/schedules/' . $schedule3->id . $endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server1, '/schedules/'.$schedule2->id.$endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server1, '/schedules/'.$schedule3->id.$endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server2, '/schedules/'.$schedule3->id.$endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server3, '/schedules/'.$schedule3->id.$endpoint))->assertNotFound(); } public static function methodDataProvider(): array diff --git a/tests/Integration/Api/Client/Server/Startup/GetStartupAndVariablesTest.php b/tests/Integration/Api/Client/Server/Startup/GetStartupAndVariablesTest.php index 88cc6ed6f..b11d06346 100644 --- a/tests/Integration/Api/Client/Server/Startup/GetStartupAndVariablesTest.php +++ b/tests/Integration/Api/Client/Server/Startup/GetStartupAndVariablesTest.php @@ -33,7 +33,7 @@ class GetStartupAndVariablesTest extends ClientApiIntegrationTestCase ])->save(); $server = $server->refresh(); - $response = $this->actingAs($user)->getJson($this->link($server) . '/startup'); + $response = $this->actingAs($user)->getJson($this->link($server).'/startup'); $response->assertOk(); $response->assertJsonPath('meta.startup_command', 'java bungeecord.jar --version [hidden]'); @@ -52,10 +52,10 @@ class GetStartupAndVariablesTest extends ClientApiIntegrationTestCase public function testStartupDataIsNotReturnedWithoutPermission(): void { [$user, $server] = $this->generateTestAccount([Permission::ACTION_WEBSOCKET_CONNECT]); - $this->actingAs($user)->getJson($this->link($server) . '/startup')->assertForbidden(); + $this->actingAs($user)->getJson($this->link($server).'/startup')->assertForbidden(); $user2 = User::factory()->create(); - $this->actingAs($user2)->getJson($this->link($server) . '/startup')->assertNotFound(); + $this->actingAs($user2)->getJson($this->link($server).'/startup')->assertNotFound(); } public static function permissionsDataProvider(): array diff --git a/tests/Integration/Api/Client/Server/Startup/UpdateStartupVariableTest.php b/tests/Integration/Api/Client/Server/Startup/UpdateStartupVariableTest.php index e9c8af97c..c5471ec11 100644 --- a/tests/Integration/Api/Client/Server/Startup/UpdateStartupVariableTest.php +++ b/tests/Integration/Api/Client/Server/Startup/UpdateStartupVariableTest.php @@ -23,7 +23,7 @@ class UpdateStartupVariableTest extends ClientApiIntegrationTestCase 'startup' => 'java {{SERVER_JARFILE}} --version {{BUNGEE_VERSION}}', ])->save(); - $response = $this->actingAs($user)->putJson($this->link($server) . '/startup/variable', [ + $response = $this->actingAs($user)->putJson($this->link($server).'/startup/variable', [ 'key' => 'BUNGEE_VERSION', 'value' => '1.2.3', ]); @@ -32,7 +32,7 @@ class UpdateStartupVariableTest extends ClientApiIntegrationTestCase $response->assertJsonPath('errors.0.code', 'ValidationException'); $response->assertJsonPath('errors.0.detail', 'The value may only contain letters and numbers.'); - $response = $this->actingAs($user)->putJson($this->link($server) . '/startup/variable', [ + $response = $this->actingAs($user)->putJson($this->link($server).'/startup/variable', [ 'key' => 'BUNGEE_VERSION', 'value' => '123', ]); @@ -62,7 +62,7 @@ class UpdateStartupVariableTest extends ClientApiIntegrationTestCase $server->fill(['egg_id' => $egg->id])->save(); $server->refresh(); - $response = $this->actingAs($user)->putJson($this->link($server) . '/startup/variable', [ + $response = $this->actingAs($user)->putJson($this->link($server).'/startup/variable', [ 'key' => 'BUNGEE_VERSION', 'value' => '123', ]); @@ -71,7 +71,7 @@ class UpdateStartupVariableTest extends ClientApiIntegrationTestCase $response->assertJsonPath('errors.0.code', 'BadRequestHttpException'); $response->assertJsonPath('errors.0.detail', 'The environment variable you are trying to edit does not exist.'); - $response = $this->actingAs($user)->putJson($this->link($server) . '/startup/variable', [ + $response = $this->actingAs($user)->putJson($this->link($server).'/startup/variable', [ 'key' => 'SERVER_JARFILE', 'value' => 'server2.jar', ]); @@ -100,7 +100,7 @@ class UpdateStartupVariableTest extends ClientApiIntegrationTestCase $server->refresh(); - $response = $this->actingAs($user)->putJson($this->link($server) . '/startup/variable', [ + $response = $this->actingAs($user)->putJson($this->link($server).'/startup/variable', [ 'key' => 'SERVER_JARFILE', 'value' => 'server2.jar', ]); @@ -125,7 +125,7 @@ class UpdateStartupVariableTest extends ClientApiIntegrationTestCase $server->fill(['egg_id' => $egg->id])->save(); $server->refresh(); - $response = $this->actingAs($user)->putJson($this->link($server) . '/startup/variable', [ + $response = $this->actingAs($user)->putJson($this->link($server).'/startup/variable', [ 'key' => 'BUNGEE_VERSION', 'value' => '', ]); @@ -141,10 +141,10 @@ class UpdateStartupVariableTest extends ClientApiIntegrationTestCase public function testStartupVariableCannotBeUpdatedIfNotUserViewable(): void { [$user, $server] = $this->generateTestAccount([Permission::ACTION_WEBSOCKET_CONNECT]); - $this->actingAs($user)->putJson($this->link($server) . '/startup/variable')->assertForbidden(); + $this->actingAs($user)->putJson($this->link($server).'/startup/variable')->assertForbidden(); $user2 = User::factory()->create(); - $this->actingAs($user2)->putJson($this->link($server) . '/startup/variable')->assertNotFound(); + $this->actingAs($user2)->putJson($this->link($server).'/startup/variable')->assertNotFound(); } public static function permissionsDataProvider(): array diff --git a/tests/Integration/Api/Client/Server/Subuser/CreateServerSubuserTest.php b/tests/Integration/Api/Client/Server/Subuser/CreateServerSubuserTest.php index 7175a7cc7..f9c6595f4 100644 --- a/tests/Integration/Api/Client/Server/Subuser/CreateServerSubuserTest.php +++ b/tests/Integration/Api/Client/Server/Subuser/CreateServerSubuserTest.php @@ -23,7 +23,7 @@ class CreateServerSubuserTest extends ClientApiIntegrationTestCase { [$user, $server] = $this->generateTestAccount($permissions); - $response = $this->actingAs($user)->postJson($this->link($server) . '/users', [ + $response = $this->actingAs($user)->postJson($this->link($server).'/users', [ 'email' => $email = $this->faker->email(), 'permissions' => [ Permission::ACTION_USER_CREATE, @@ -60,7 +60,7 @@ class CreateServerSubuserTest extends ClientApiIntegrationTestCase Permission::ACTION_CONTROL_CONSOLE, ]); - $response = $this->actingAs($user)->postJson($this->link($server) . '/users', [ + $response = $this->actingAs($user)->postJson($this->link($server).'/users', [ 'email' => $this->faker->email(), 'permissions' => [ Permission::ACTION_USER_CREATE, @@ -80,9 +80,9 @@ class CreateServerSubuserTest extends ClientApiIntegrationTestCase { [$user, $server] = $this->generateTestAccount(); - $email = str_repeat(Str::random(35), 7) . '@gmail.com'; // 255 is the hard limit for the column in MySQL. + $email = str_repeat(Str::random(35), 7).'@gmail.com'; // 255 is the hard limit for the column in MySQL. - $response = $this->actingAs($user)->postJson($this->link($server) . '/users', [ + $response = $this->actingAs($user)->postJson($this->link($server).'/users', [ 'email' => $email, 'permissions' => [ Permission::ACTION_USER_CREATE, @@ -91,8 +91,8 @@ class CreateServerSubuserTest extends ClientApiIntegrationTestCase $response->assertOk(); - $response = $this->actingAs($user)->postJson($this->link($server) . '/users', [ - 'email' => $email . '.au', + $response = $this->actingAs($user)->postJson($this->link($server).'/users', [ + 'email' => $email.'.au', 'permissions' => [ Permission::ACTION_USER_CREATE, ], @@ -114,7 +114,7 @@ class CreateServerSubuserTest extends ClientApiIntegrationTestCase /** @var \App\Models\User $existing */ $existing = User::factory()->create(['email' => $this->faker->email()]); - $response = $this->actingAs($user)->postJson($this->link($server) . '/users', [ + $response = $this->actingAs($user)->postJson($this->link($server).'/users', [ 'email' => $existing->email, 'permissions' => [ Permission::ACTION_USER_CREATE, @@ -134,7 +134,7 @@ class CreateServerSubuserTest extends ClientApiIntegrationTestCase { [$user, $server] = $this->generateTestAccount(); - $response = $this->actingAs($user)->postJson($this->link($server) . '/users', [ + $response = $this->actingAs($user)->postJson($this->link($server).'/users', [ 'email' => $email = $this->faker->email(), 'permissions' => [ Permission::ACTION_USER_CREATE, @@ -143,7 +143,7 @@ class CreateServerSubuserTest extends ClientApiIntegrationTestCase $response->assertOk(); - $response = $this->actingAs($user)->postJson($this->link($server) . '/users', [ + $response = $this->actingAs($user)->postJson($this->link($server).'/users', [ 'email' => $email, 'permissions' => [ Permission::ACTION_USER_CREATE, diff --git a/tests/Integration/Api/Client/Server/Subuser/DeleteSubuserTest.php b/tests/Integration/Api/Client/Server/Subuser/DeleteSubuserTest.php index bbd97f4b3..21067ad1b 100644 --- a/tests/Integration/Api/Client/Server/Subuser/DeleteSubuserTest.php +++ b/tests/Integration/Api/Client/Server/Subuser/DeleteSubuserTest.php @@ -31,7 +31,7 @@ class DeleteSubuserTest extends ClientApiIntegrationTestCase $real = Uuid::uuid4()->toString(); // Generate a UUID that lines up with a user in the database if it were to be cast to an int. - $uuid = $differentUser->id . substr($real, strlen((string) $differentUser->id)); + $uuid = $differentUser->id.substr($real, strlen((string) $differentUser->id)); /** @var \App\Models\User $subuser */ $subuser = User::factory()->create(['uuid' => $uuid]); @@ -44,11 +44,11 @@ class DeleteSubuserTest extends ClientApiIntegrationTestCase $mock->expects('setServer->revokeUserJTI')->with($subuser->id)->andReturnUndefined(); - $this->actingAs($user)->deleteJson($this->link($server) . "/users/$subuser->uuid")->assertNoContent(); + $this->actingAs($user)->deleteJson($this->link($server)."/users/$subuser->uuid")->assertNoContent(); // Try the same test, but this time with a UUID that if cast to an int (shouldn't) line up with // anything in the database. - $uuid = '18180000' . substr(Uuid::uuid4()->toString(), 8); + $uuid = '18180000'.substr(Uuid::uuid4()->toString(), 8); /** @var \App\Models\User $subuser */ $subuser = User::factory()->create(['uuid' => $uuid]); @@ -60,6 +60,6 @@ class DeleteSubuserTest extends ClientApiIntegrationTestCase $mock->expects('setServer->revokeUserJTI')->with($subuser->id)->andReturnUndefined(); - $this->actingAs($user)->deleteJson($this->link($server) . "/users/$subuser->uuid")->assertNoContent(); + $this->actingAs($user)->deleteJson($this->link($server)."/users/$subuser->uuid")->assertNoContent(); } } diff --git a/tests/Integration/Api/Client/Server/Subuser/SubuserAuthorizationTest.php b/tests/Integration/Api/Client/Server/Subuser/SubuserAuthorizationTest.php index ab844d0b3..03bd42ee9 100644 --- a/tests/Integration/Api/Client/Server/Subuser/SubuserAuthorizationTest.php +++ b/tests/Integration/Api/Client/Server/Subuser/SubuserAuthorizationTest.php @@ -41,12 +41,12 @@ class SubuserAuthorizationTest extends ClientApiIntegrationTestCase } // This route is acceptable since they're accessing a subuser on their own server. - $this->actingAs($user)->json($method, $this->link($server1, '/users/' . $internal->uuid))->assertStatus($method === 'POST' ? 422 : ($method === 'DELETE' ? 204 : 200)); + $this->actingAs($user)->json($method, $this->link($server1, '/users/'.$internal->uuid))->assertStatus($method === 'POST' ? 422 : ($method === 'DELETE' ? 204 : 200)); // This route can be revealed since the subuser belongs to the correct server, but // errors out with a 403 since $user does not have the right permissions for this. - $this->actingAs($user)->json($method, $this->link($server2, '/users/' . $internal->uuid))->assertForbidden(); - $this->actingAs($user)->json($method, $this->link($server3, '/users/' . $internal->uuid))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server2, '/users/'.$internal->uuid))->assertForbidden(); + $this->actingAs($user)->json($method, $this->link($server3, '/users/'.$internal->uuid))->assertNotFound(); } public static function methodDataProvider(): array diff --git a/tests/Integration/Api/Daemon/DaemonAuthenticateTest.php b/tests/Integration/Api/Daemon/DaemonAuthenticateTest.php index b18b3e5e8..1dde92284 100644 --- a/tests/Integration/Api/Daemon/DaemonAuthenticateTest.php +++ b/tests/Integration/Api/Daemon/DaemonAuthenticateTest.php @@ -69,7 +69,7 @@ class DaemonAuthenticateTest extends MiddlewareTestCase $this->expectException(AccessDeniedHttpException::class); $this->request->expects('route->getName')->withNoArgs()->andReturn('random.route'); - $this->request->expects('bearerToken')->withNoArgs()->andReturn($node->daemon_token_id . '.random_string_123'); + $this->request->expects('bearerToken')->withNoArgs()->andReturn($node->daemon_token_id.'.random_string_123'); $this->getMiddleware()->handle($this->request, $this->getClosureAssertions()); } @@ -98,7 +98,7 @@ class DaemonAuthenticateTest extends MiddlewareTestCase $node->save(); $this->request->expects('route->getName')->withNoArgs()->andReturn('random.route'); - $this->request->expects('bearerToken')->withNoArgs()->andReturn($node->daemon_token_id . '.the_same'); + $this->request->expects('bearerToken')->withNoArgs()->andReturn($node->daemon_token_id.'.the_same'); $this->getMiddleware()->handle($this->request, $this->getClosureAssertions()); $this->assertRequestHasAttribute('node'); diff --git a/tests/Integration/Api/Remote/SftpAuthenticationControllerTest.php b/tests/Integration/Api/Remote/SftpAuthenticationControllerTest.php index 031eedce7..994a601a9 100644 --- a/tests/Integration/Api/Remote/SftpAuthenticationControllerTest.php +++ b/tests/Integration/Api/Remote/SftpAuthenticationControllerTest.php @@ -143,7 +143,7 @@ class SftpAuthenticationControllerTest extends IntegrationTestCase $this->setAuthorization($server->node); $this->postJson('/api/remote/sftp/auth', [ - 'username' => $user->username . '.' . $server->uuid_short, + 'username' => $user->username.'.'.$server->uuid_short, 'password' => 'foobar', ]) ->assertForbidden() @@ -173,7 +173,7 @@ class SftpAuthenticationControllerTest extends IntegrationTestCase $this->setAuthorization($server->node); $data = [ - 'username' => $user->username . '.' . $server->uuid_short, + 'username' => $user->username.'.'.$server->uuid_short, 'password' => 'foobar', ]; @@ -188,7 +188,7 @@ class SftpAuthenticationControllerTest extends IntegrationTestCase ->assertJsonPath('permissions.0', '*'); $this->setAuthorization(); - $data['username'] = $user->username . '.' . $this->server->uuid_short; + $data['username'] = $user->username.'.'.$this->server->uuid_short; $this->post('/api/remote/sftp/auth', $data) ->assertOk() @@ -220,7 +220,7 @@ class SftpAuthenticationControllerTest extends IntegrationTestCase */ protected function getUsername(bool $long = false): string { - return $this->user->username . '.' . ($long ? $this->server->uuid : $this->server->uuid_short); + return $this->user->username.'.'.($long ? $this->server->uuid : $this->server->uuid_short); } /** @@ -230,6 +230,6 @@ class SftpAuthenticationControllerTest extends IntegrationTestCase { $node = $node ?? $this->server->node; - $this->withHeader('Authorization', 'Bearer ' . $node->daemon_token_id . '.' . $node->daemon_token); + $this->withHeader('Authorization', 'Bearer '.$node->daemon_token_id.'.'.$node->daemon_token); } } diff --git a/tests/Integration/Http/Controllers/Admin/UserControllerTest.php b/tests/Integration/Http/Controllers/Admin/UserControllerTest.php index cbd263501..b82aa61ab 100644 --- a/tests/Integration/Http/Controllers/Admin/UserControllerTest.php +++ b/tests/Integration/Http/Controllers/Admin/UserControllerTest.php @@ -21,8 +21,8 @@ class UserControllerTest extends IntegrationTestCase { $unique = Str::random(); $users = [ - User::factory()->create(['username' => $unique . '_1']), - User::factory()->create(['username' => $unique . '_2']), + User::factory()->create(['username' => $unique.'_1']), + User::factory()->create(['username' => $unique.'_2']), ]; $servers = [ @@ -38,7 +38,7 @@ class UserControllerTest extends IntegrationTestCase /** @var \App\Http\Controllers\Admin\UserController $controller */ $controller = $this->app->make(UserController::class); - $request = Request::create('/admin/users?filter[username]=' . $unique); + $request = Request::create('/admin/users?filter[username]='.$unique); $this->app->instance(Request::class, $request); $data = $controller->index($request)->getData(); diff --git a/tests/Integration/Services/Databases/DatabaseManagementServiceTest.php b/tests/Integration/Services/Databases/DatabaseManagementServiceTest.php index 060ed9f10..1584c2000 100644 --- a/tests/Integration/Services/Databases/DatabaseManagementServiceTest.php +++ b/tests/Integration/Services/Databases/DatabaseManagementServiceTest.php @@ -29,7 +29,7 @@ class DatabaseManagementServiceTest extends IntegrationTestCase { $this->assertSame('s1_example', DatabaseManagementService::generateUniqueDatabaseName('example', 1)); $this->assertSame('s123_something_else', DatabaseManagementService::generateUniqueDatabaseName('something_else', 123)); - $this->assertSame('s123_' . str_repeat('a', 43), DatabaseManagementService::generateUniqueDatabaseName(str_repeat('a', 100), 123)); + $this->assertSame('s123_'.str_repeat('a', 43), DatabaseManagementService::generateUniqueDatabaseName(str_repeat('a', 100), 123)); } /** diff --git a/tests/Traits/Http/RequestMockHelpers.php b/tests/Traits/Http/RequestMockHelpers.php index 22f60e74f..b2fa0e917 100644 --- a/tests/Traits/Http/RequestMockHelpers.php +++ b/tests/Traits/Http/RequestMockHelpers.php @@ -68,7 +68,7 @@ trait RequestMockHelpers { $this->request = m::mock($this->requestMockClass); if (!$this->request instanceof Request) { - throw new \InvalidArgumentException('Request mock class must be an instance of ' . Request::class . ' when mocked.'); + throw new \InvalidArgumentException('Request mock class must be an instance of '.Request::class.' when mocked.'); } $this->request->attributes = new ParameterBag(); diff --git a/tests/Traits/MocksUuids.php b/tests/Traits/MocksUuids.php index 8cfa4b7ce..8b6d2b0a8 100644 --- a/tests/Traits/MocksUuids.php +++ b/tests/Traits/MocksUuids.php @@ -19,7 +19,7 @@ trait MocksUuids public function setKnownUuidFactory(): void { $uuid = Uuid::fromString($this->getKnownUuid()); - $factoryMock = m::mock(UuidFactory::class . '[uuid4]', [ + $factoryMock = m::mock(UuidFactory::class.'[uuid4]', [ 'uuid4' => $uuid, ]); From 1bf6a880fbb0f51a3f0019e5b45522ac36a7b0cd Mon Sep 17 00:00:00 2001 From: Lance Pioch Date: Sat, 19 Oct 2024 18:41:08 -0400 Subject: [PATCH 3/7] Add nullable_type_declaration_for_default_null_value rule --- app/Exceptions/Http/HttpForbiddenException.php | 2 +- app/Exceptions/Http/Server/ServerStateConflictException.php | 2 +- app/Exceptions/Http/TwoFactorAuthRequiredException.php | 2 +- app/Exceptions/Service/ServiceLimitExceededException.php | 2 +- app/Extensions/Backups/BackupManager.php | 2 +- app/Http/Controllers/Admin/Eggs/EggController.php | 2 +- app/Http/Controllers/Auth/AbstractLoginController.php | 6 +++--- app/Http/Middleware/RedirectIfAuthenticated.php | 2 +- app/Http/Requests/Admin/AdminFormRequest.php | 2 +- .../Requests/Admin/Settings/MailSettingsFormRequest.php | 2 +- .../Application/DatabaseHosts/StoreDatabaseHostRequest.php | 2 +- .../Application/DatabaseHosts/UpdateDatabaseHostRequest.php | 2 +- .../Requests/Api/Application/Mounts/UpdateMountRequest.php | 2 +- .../Requests/Api/Application/Nodes/StoreNodeRequest.php | 2 +- .../Requests/Api/Application/Nodes/UpdateNodeRequest.php | 2 +- .../Requests/Api/Application/Roles/StoreRoleRequest.php | 2 +- .../Api/Application/Users/AssignUserRolesRequest.php | 2 +- .../Requests/Api/Application/Users/StoreUserRequest.php | 2 +- .../Requests/Api/Application/Users/UpdateUserRequest.php | 2 +- app/Jobs/Schedule/RunTaskJob.php | 2 +- app/Repositories/Daemon/DaemonBackupRepository.php | 2 +- app/Repositories/Daemon/DaemonFileRepository.php | 2 +- app/Services/Activity/ActivityLogService.php | 2 +- app/Services/Allocations/AssignmentService.php | 2 +- app/Services/Backups/InitiateBackupService.php | 2 +- app/Services/Eggs/Sharing/EggImporterService.php | 4 ++-- app/Services/Servers/ServerCreationService.php | 2 +- app/Services/Users/ToggleTwoFactorService.php | 2 +- app/Transformers/Api/Client/ActivityLogTransformer.php | 2 +- app/Transformers/Api/Client/BaseClientTransformer.php | 2 +- pint.json | 1 - .../Integration/Api/Client/ClientApiIntegrationTestCase.php | 2 +- .../Api/Remote/SftpAuthenticationControllerTest.php | 2 +- tests/Traits/Http/RequestMockHelpers.php | 4 ++-- 34 files changed, 37 insertions(+), 38 deletions(-) diff --git a/app/Exceptions/Http/HttpForbiddenException.php b/app/Exceptions/Http/HttpForbiddenException.php index 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); From d21740d4589218dc8a7176edd665a1419a24373a Mon Sep 17 00:00:00 2001 From: Lance Pioch Date: Sat, 19 Oct 2024 18:42:23 -0400 Subject: [PATCH 4/7] Add phpdoc_align rule --- app/Exceptions/Handler.php | 6 +++--- app/Extensions/Backups/BackupManager.php | 2 +- .../Api/Application/ApplicationApiController.php | 2 +- app/Http/Controllers/Api/Client/ClientApiController.php | 2 +- app/Http/Controllers/Auth/ForgotPasswordController.php | 2 +- app/Http/Controllers/Auth/ResetPasswordController.php | 4 ++-- app/Http/Requests/Api/Application/ApplicationApiRequest.php | 2 +- app/Models/Filters/AdminServerFilter.php | 2 +- app/Models/Filters/MultiFieldServerFilter.php | 2 +- app/Models/User.php | 2 +- app/Repositories/Daemon/DaemonFileRepository.php | 2 +- app/Rules/Username.php | 4 ++-- app/Services/Activity/ActivityLogService.php | 6 +++--- app/Services/Backups/InitiateBackupService.php | 2 +- app/Transformers/Api/Application/BaseTransformer.php | 2 +- pint.json | 1 - tests/Assertions/AssertsActivityLogged.php | 2 +- tests/Integration/Api/Client/Server/PowerControllerTest.php | 2 +- tests/Traits/Integration/CreatesTestModels.php | 2 +- 19 files changed, 24 insertions(+), 25 deletions(-) diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index a8cc206d9..f3bc40cd3 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -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 { diff --git a/app/Extensions/Backups/BackupManager.php b/app/Extensions/Backups/BackupManager.php index b26f8f4c5..16c704b97 100644 --- a/app/Extensions/Backups/BackupManager.php +++ b/app/Extensions/Backups/BackupManager.php @@ -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 { diff --git a/app/Http/Controllers/Api/Application/ApplicationApiController.php b/app/Http/Controllers/Api/Application/ApplicationApiController.php index 174e6243a..e94de9889 100644 --- a/app/Http/Controllers/Api/Application/ApplicationApiController.php +++ b/app/Http/Controllers/Api/Application/ApplicationApiController.php @@ -51,7 +51,7 @@ abstract class ApplicationApiController extends Controller * * @template T of \App\Transformers\Api\Application\BaseTransformer * - * @param class-string $abstract + * @param class-string $abstract * * @return T * diff --git a/app/Http/Controllers/Api/Client/ClientApiController.php b/app/Http/Controllers/Api/Client/ClientApiController.php index 4cf081fec..a78e75487 100644 --- a/app/Http/Controllers/Api/Client/ClientApiController.php +++ b/app/Http/Controllers/Api/Client/ClientApiController.php @@ -41,7 +41,7 @@ abstract class ClientApiController extends ApplicationApiController * * @template T of \App\Transformers\Api\Client\BaseClientTransformer * - * @param class-string $abstract + * @param class-string $abstract * * @return T * diff --git a/app/Http/Controllers/Auth/ForgotPasswordController.php b/app/Http/Controllers/Auth/ForgotPasswordController.php index 21ef4fee8..5c8d3d5d4 100644 --- a/app/Http/Controllers/Auth/ForgotPasswordController.php +++ b/app/Http/Controllers/Auth/ForgotPasswordController.php @@ -29,7 +29,7 @@ class ForgotPasswordController extends Controller /** * Get the response for a successful password reset link. * - * @param string $response + * @param string $response */ protected function sendResetLinkResponse(Request $request, $response): JsonResponse { diff --git a/app/Http/Controllers/Auth/ResetPasswordController.php b/app/Http/Controllers/Auth/ResetPasswordController.php index b4c338ee9..c8dbd898e 100644 --- a/app/Http/Controllers/Auth/ResetPasswordController.php +++ b/app/Http/Controllers/Auth/ResetPasswordController.php @@ -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 */ diff --git a/app/Http/Requests/Api/Application/ApplicationApiRequest.php b/app/Http/Requests/Api/Application/ApplicationApiRequest.php index a0e17c15d..33c9581b1 100644 --- a/app/Http/Requests/Api/Application/ApplicationApiRequest.php +++ b/app/Http/Requests/Api/Application/ApplicationApiRequest.php @@ -74,7 +74,7 @@ abstract class ApplicationApiRequest extends FormRequest * * @template T of \Illuminate\Database\Eloquent\Model * - * @param class-string $expect + * @param class-string $expect * * @return T * diff --git a/app/Models/Filters/AdminServerFilter.php b/app/Models/Filters/AdminServerFilter.php index d3c1eea60..bca17499f 100644 --- a/app/Models/Filters/AdminServerFilter.php +++ b/app/Models/Filters/AdminServerFilter.php @@ -11,7 +11,7 @@ class AdminServerFilter implements Filter * A multi-column filter for the servers table that allows an administrative user to search * across UUID, name, owner username, and owner email. * - * @param string $value + * @param string $value */ public function __invoke(Builder $query, $value, string $property) { diff --git a/app/Models/Filters/MultiFieldServerFilter.php b/app/Models/Filters/MultiFieldServerFilter.php index 0ab266574..6039c450b 100644 --- a/app/Models/Filters/MultiFieldServerFilter.php +++ b/app/Models/Filters/MultiFieldServerFilter.php @@ -19,7 +19,7 @@ class MultiFieldServerFilter implements Filter * search across multiple columns. This allows us to provide a very generic search ability for * the frontend. * - * @param string $value + * @param string $value */ public function __invoke(Builder $query, $value, string $property) { diff --git a/app/Models/User.php b/app/Models/User.php index 5bc8fa632..04ecbb0c4 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -234,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) { diff --git a/app/Repositories/Daemon/DaemonFileRepository.php b/app/Repositories/Daemon/DaemonFileRepository.php index ca6fc7399..a414b8db7 100644 --- a/app/Repositories/Daemon/DaemonFileRepository.php +++ b/app/Repositories/Daemon/DaemonFileRepository.php @@ -15,7 +15,7 @@ class DaemonFileRepository extends DaemonRepository /** * Return the contents of a given file. * - * @param int|null $notLargerThan the maximum content length in bytes + * @param int|null $notLargerThan the maximum content length in bytes * * @throws \GuzzleHttp\Exception\TransferException * @throws \App\Exceptions\Http\Server\FileSizeTooLargeException diff --git a/app/Rules/Username.php b/app/Rules/Username.php index 591df389c..f888da103 100644 --- a/app/Rules/Username.php +++ b/app/Rules/Username.php @@ -17,8 +17,8 @@ class Username implements Rule * * Allowed characters: a-z0-9_-. * - * @param string $attribute - * @param mixed $value + * @param string $attribute + * @param mixed $value */ public function passes($attribute, $value): bool { diff --git a/app/Services/Activity/ActivityLogService.php b/app/Services/Activity/ActivityLogService.php index 170278558..38f742b72 100644 --- a/app/Services/Activity/ActivityLogService.php +++ b/app/Services/Activity/ActivityLogService.php @@ -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 { diff --git a/app/Services/Backups/InitiateBackupService.php b/app/Services/Backups/InitiateBackupService.php index 69807a942..fa15db88a 100644 --- a/app/Services/Backups/InitiateBackupService.php +++ b/app/Services/Backups/InitiateBackupService.php @@ -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 { diff --git a/app/Transformers/Api/Application/BaseTransformer.php b/app/Transformers/Api/Application/BaseTransformer.php index 62ee4ceeb..2fb5917c0 100644 --- a/app/Transformers/Api/Application/BaseTransformer.php +++ b/app/Transformers/Api/Application/BaseTransformer.php @@ -89,7 +89,7 @@ abstract class BaseTransformer extends TransformerAbstract * * @template T of \App\Transformers\Api\Application\BaseTransformer * - * @param class-string $abstract + * @param class-string $abstract * * @return T * diff --git a/pint.json b/pint.json index 606e3351a..aa20e37a0 100644 --- a/pint.json +++ b/pint.json @@ -3,7 +3,6 @@ "rules": { "not_operator_with_successor_space": false, "ordered_imports": false, - "phpdoc_align": false, "phpdoc_separation": false } } diff --git a/tests/Assertions/AssertsActivityLogged.php b/tests/Assertions/AssertsActivityLogged.php index ecc33a833..ed33729e4 100644 --- a/tests/Assertions/AssertsActivityLogged.php +++ b/tests/Assertions/AssertsActivityLogged.php @@ -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 { diff --git a/tests/Integration/Api/Client/Server/PowerControllerTest.php b/tests/Integration/Api/Client/Server/PowerControllerTest.php index 5cadb3772..94d3e7326 100644 --- a/tests/Integration/Api/Client/Server/PowerControllerTest.php +++ b/tests/Integration/Api/Client/Server/PowerControllerTest.php @@ -14,7 +14,7 @@ class PowerControllerTest extends ClientApiIntegrationTestCase * an error in response. This checks against the specific permission needed to send * the command to the server. * - * @param string[] $permissions + * @param string[] $permissions * * @dataProvider invalidPermissionDataProvider */ diff --git a/tests/Traits/Integration/CreatesTestModels.php b/tests/Traits/Integration/CreatesTestModels.php index 12d645934..3bede405e 100644 --- a/tests/Traits/Integration/CreatesTestModels.php +++ b/tests/Traits/Integration/CreatesTestModels.php @@ -65,7 +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} */ From 466f9f7edcc225fee30c47ea4b5b61f43437268d Mon Sep 17 00:00:00 2001 From: Lance Pioch Date: Sat, 19 Oct 2024 18:46:05 -0400 Subject: [PATCH 5/7] Add phpdoc_separation rule --- .../Controllers/Api/Application/ApplicationApiController.php | 1 - app/Http/Controllers/Api/Client/ClientApiController.php | 1 - app/Http/Requests/Api/Application/ApplicationApiRequest.php | 1 - app/Models/Server.php | 4 ++++ app/Services/Files/DeleteFilesService.php | 1 + app/Traits/EnvironmentWriterTrait.php | 1 + app/Transformers/Api/Application/BaseTransformer.php | 1 - pint.json | 3 +-- tests/Traits/Integration/CreatesTestModels.php | 1 - 9 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/Http/Controllers/Api/Application/ApplicationApiController.php b/app/Http/Controllers/Api/Application/ApplicationApiController.php index e94de9889..6e1b4112c 100644 --- a/app/Http/Controllers/Api/Application/ApplicationApiController.php +++ b/app/Http/Controllers/Api/Application/ApplicationApiController.php @@ -52,7 +52,6 @@ abstract class ApplicationApiController extends Controller * @template T of \App\Transformers\Api\Application\BaseTransformer * * @param class-string $abstract - * * @return T * * @noinspection PhpDocSignatureInspection diff --git a/app/Http/Controllers/Api/Client/ClientApiController.php b/app/Http/Controllers/Api/Client/ClientApiController.php index a78e75487..8d409a754 100644 --- a/app/Http/Controllers/Api/Client/ClientApiController.php +++ b/app/Http/Controllers/Api/Client/ClientApiController.php @@ -42,7 +42,6 @@ abstract class ClientApiController extends ApplicationApiController * @template T of \App\Transformers\Api\Client\BaseClientTransformer * * @param class-string $abstract - * * @return T * * @noinspection PhpDocSignatureInspection diff --git a/app/Http/Requests/Api/Application/ApplicationApiRequest.php b/app/Http/Requests/Api/Application/ApplicationApiRequest.php index 33c9581b1..b8feb094d 100644 --- a/app/Http/Requests/Api/Application/ApplicationApiRequest.php +++ b/app/Http/Requests/Api/Application/ApplicationApiRequest.php @@ -75,7 +75,6 @@ abstract class ApplicationApiRequest extends FormRequest * @template T of \Illuminate\Database\Eloquent\Model * * @param class-string $expect - * * @return T * * @noinspection PhpDocSignatureInspection diff --git a/app/Models/Server.php b/app/Models/Server.php index a0c341c6d..7cbc633d6 100644 --- a/app/Models/Server.php +++ b/app/Models/Server.php @@ -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 $serverVariables * @property-read int|null $server_variables_count + * * @method static \Illuminate\Database\Eloquent\Builder|Server whereDockerLabels($value) * @method static \Illuminate\Database\Eloquent\Builder|Server whereInstalledAt($value) * @method static \Illuminate\Database\Eloquent\Builder|Server wherePorts($value) * @method static \Illuminate\Database\Eloquent\Builder|Server whereUuidShort($value) + * * @mixin \Eloquent */ class Server extends Model diff --git a/app/Services/Files/DeleteFilesService.php b/app/Services/Files/DeleteFilesService.php index 907c12c31..f0a4f202c 100644 --- a/app/Services/Files/DeleteFilesService.php +++ b/app/Services/Files/DeleteFilesService.php @@ -19,6 +19,7 @@ class DeleteFilesService /** * Deletes the given files. + * * @throws DaemonConnectionException */ public function handle(Server $server, array $files): void diff --git a/app/Traits/EnvironmentWriterTrait.php b/app/Traits/EnvironmentWriterTrait.php index 2eaca0e6f..201116571 100644 --- a/app/Traits/EnvironmentWriterTrait.php +++ b/app/Traits/EnvironmentWriterTrait.php @@ -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 diff --git a/app/Transformers/Api/Application/BaseTransformer.php b/app/Transformers/Api/Application/BaseTransformer.php index 2fb5917c0..748b8a1d9 100644 --- a/app/Transformers/Api/Application/BaseTransformer.php +++ b/app/Transformers/Api/Application/BaseTransformer.php @@ -90,7 +90,6 @@ abstract class BaseTransformer extends TransformerAbstract * @template T of \App\Transformers\Api\Application\BaseTransformer * * @param class-string $abstract - * * @return T * * @throws \App\Exceptions\Transformer\InvalidTransformerLevelException diff --git a/pint.json b/pint.json index aa20e37a0..9427029f8 100644 --- a/pint.json +++ b/pint.json @@ -2,7 +2,6 @@ "preset": "laravel", "rules": { "not_operator_with_successor_space": false, - "ordered_imports": false, - "phpdoc_separation": false + "ordered_imports": false } } diff --git a/tests/Traits/Integration/CreatesTestModels.php b/tests/Traits/Integration/CreatesTestModels.php index 3bede405e..0e28cb40e 100644 --- a/tests/Traits/Integration/CreatesTestModels.php +++ b/tests/Traits/Integration/CreatesTestModels.php @@ -66,7 +66,6 @@ trait CreatesTestModels * is assumed that the user is actually a subuser of the server. * * @param string[] $permissions - * * @return array{\App\Models\User, \App\Models\Server} */ public function generateTestAccount(array $permissions = []): array From deb660384039275610f389302942774f65d35c10 Mon Sep 17 00:00:00 2001 From: Lance Pioch Date: Sat, 19 Oct 2024 21:14:41 -0400 Subject: [PATCH 6/7] Revert "Add concat_space rule" This reverts commit 96acd268bee7005fe1691b572a4674575604d437. --- .../Environment/AppSettingsCommand.php | 2 +- .../Environment/EmailSettingsCommand.php | 2 +- .../Environment/QueueWorkerServiceCommand.php | 6 +-- .../Maintenance/PruneImagesCommand.php | 2 +- .../Schedule/ProcessRunnableCommand.php | 2 +- app/Console/Commands/UpgradeCommand.php | 8 +-- app/Console/Kernel.php | 2 +- app/Exceptions/Handler.php | 4 +- app/Extensions/Backups/BackupManager.php | 2 +- app/Extensions/DynamicDatabaseConnection.php | 2 +- app/Extensions/Themes/Theme.php | 6 +-- .../Pages/Installer/Steps/CompletedStep.php | 4 +- .../Installer/Steps/RequirementsStep.php | 8 +-- .../ApiKeyResource/Pages/ListApiKeys.php | 2 +- .../DatabasesRelationManager.php | 4 +- .../Resources/EggResource/Pages/EditEgg.php | 2 +- .../Resources/EggResource/Pages/ListEggs.php | 2 +- .../NodeResource/Widgets/NodeCpuChart.php | 4 +- .../NodeResource/Widgets/NodeMemoryChart.php | 10 ++-- app/Filament/Resources/RoleResource.php | 18 +++---- .../ServerResource/Pages/CreateServer.php | 16 +++--- .../ServerResource/Pages/EditServer.php | 14 +++--- .../UserResource/Pages/EditProfile.php | 2 +- .../UserResource/Pages/ListUsers.php | 4 +- .../Admin/Eggs/EggShareController.php | 2 +- .../Admin/NodeAutoDeployController.php | 2 +- .../Admin/Servers/CreateServerController.php | 2 +- .../Controllers/Admin/ServersController.php | 2 +- .../Api/Client/Servers/FileController.php | 2 +- .../Client/Servers/FileUploadController.php | 2 +- .../Client/Servers/WebsocketController.php | 4 +- .../Remote/Backups/BackupStatusController.php | 2 +- .../Remote/SftpAuthenticationController.php | 2 +- app/Http/Controllers/Auth/OAuthController.php | 2 +- .../Middleware/Api/AuthenticateIPAccess.php | 2 +- .../Client/Server/ResourceBelongsToServer.php | 2 +- app/Http/Middleware/Api/IsValidJson.php | 2 +- .../RequireTwoFactorAuthentication.php | 2 +- .../Api/StoreApplicationApiKeyRequest.php | 2 +- .../Admin/Egg/EggVariableFormRequest.php | 2 +- .../Api/Client/Account/StoreApiKeyRequest.php | 2 +- app/Jobs/Schedule/RunTaskJob.php | 2 +- app/Models/ApiKey.php | 50 +++++++++---------- app/Models/EggVariable.php | 2 +- app/Models/Filters/MultiFieldServerFilter.php | 2 +- app/Models/Node.php | 4 +- app/Models/User.php | 4 +- app/Notifications/AccountCreated.php | 10 ++-- app/Notifications/AddedToServer.php | 6 +-- app/Notifications/MailTested.php | 2 +- app/Notifications/RemovedFromServer.php | 4 +- app/Notifications/SendPasswordReset.php | 2 +- app/Notifications/ServerInstalled.php | 4 +- app/Policies/DefaultPolicies.php | 10 ++-- .../Daemon/DaemonConfigurationRepository.php | 2 +- .../Daemon/DaemonServerRepository.php | 4 +- app/Services/Acl/Api/AdminAcl.php | 2 +- app/Services/Backups/DownloadLinkService.php | 2 +- app/Services/Files/DeleteFilesService.php | 2 +- app/Services/Helpers/AssetHashService.php | 4 +- .../Helpers/SoftwareVersionService.php | 4 +- .../Servers/StartupCommandService.php | 2 +- .../Servers/TransferServerService.php | 4 +- .../Servers/VariableValidatorService.php | 4 +- .../Subusers/SubuserCreationService.php | 2 +- app/Traits/EnvironmentWriterTrait.php | 6 +-- .../Api/Client/ActivityLogTransformer.php | 4 +- .../Api/Client/UserTransformer.php | 2 +- bootstrap/tests.php | 16 +++--- database/Factories/NodeFactory.php | 2 +- database/Factories/UserFactory.php | 4 +- database/Seeders/EggSeeder.php | 8 +-- ..._ChangeServiceVariablesValidationRules.php | 2 +- ...dPermissionsToPointToNewScheduleSystem.php | 4 +- ...628_RemoveDaemonSecretFromServersTable.php | 2 +- ...22_RemoveDaemonSecretFromSubusersTable.php | 2 +- ..._merge_permissions_table_into_subusers.php | 4 +- ...4_store_node_tokens_as_encrypted_value.php | 2 +- pint.json | 1 + tests/Assertions/AssertsActivityLogged.php | 2 +- .../MiddlewareAttributeAssertionsTrait.php | 4 +- .../ApplicationApiIntegrationTestCase.php | 4 +- .../Api/Application/EggControllerTest.php | 6 +-- .../Users/ExternalUserControllerTest.php | 4 +- .../Application/Users/UserControllerTest.php | 12 ++--- .../Api/Client/AccountControllerTest.php | 4 +- .../Api/Client/ApiKeyControllerTest.php | 8 +-- .../Client/ClientApiIntegrationTestCase.php | 2 +- .../Api/Client/ClientControllerTest.php | 2 +- .../AllocationAuthorizationTest.php | 12 ++--- .../Server/Backup/BackupAuthorizationTest.php | 12 ++--- .../Database/DatabaseAuthorizationTest.php | 12 ++--- .../Schedule/GetServerSchedulesTest.php | 10 ++-- .../Schedule/ScheduleAuthorizationTest.php | 12 ++--- .../Startup/GetStartupAndVariablesTest.php | 6 +-- .../Startup/UpdateStartupVariableTest.php | 16 +++--- .../Subuser/CreateServerSubuserTest.php | 18 +++---- .../Server/Subuser/DeleteSubuserTest.php | 8 +-- .../Subuser/SubuserAuthorizationTest.php | 6 +-- .../Api/Daemon/DaemonAuthenticateTest.php | 4 +- .../SftpAuthenticationControllerTest.php | 10 ++-- .../Controllers/Admin/UserControllerTest.php | 6 +-- .../DatabaseManagementServiceTest.php | 2 +- tests/Traits/Http/RequestMockHelpers.php | 2 +- tests/Traits/MocksUuids.php | 2 +- 105 files changed, 272 insertions(+), 271 deletions(-) diff --git a/app/Console/Commands/Environment/AppSettingsCommand.php b/app/Console/Commands/Environment/AppSettingsCommand.php index d1ce5c00e..a16f38176 100644 --- a/app/Console/Commands/Environment/AppSettingsCommand.php +++ b/app/Console/Commands/Environment/AppSettingsCommand.php @@ -16,7 +16,7 @@ class AppSettingsCommand extends Command $path = base_path('.env'); if (!file_exists($path)) { $this->comment('Copying example .env file'); - copy($path.'.example', $path); + copy($path . '.example', $path); } if (!config('app.key')) { diff --git a/app/Console/Commands/Environment/EmailSettingsCommand.php b/app/Console/Commands/Environment/EmailSettingsCommand.php index a1ec5f7c2..87c8186c1 100644 --- a/app/Console/Commands/Environment/EmailSettingsCommand.php +++ b/app/Console/Commands/Environment/EmailSettingsCommand.php @@ -44,7 +44,7 @@ class EmailSettingsCommand extends Command env('MAIL_MAILER', env('MAIL_DRIVER', 'smtp')), ); - $method = 'setup'.studly_case($this->variables['MAIL_MAILER']).'DriverVariables'; + $method = 'setup' . studly_case($this->variables['MAIL_MAILER']) . 'DriverVariables'; if (method_exists($this, $method)) { $this->{$method}(); } diff --git a/app/Console/Commands/Environment/QueueWorkerServiceCommand.php b/app/Console/Commands/Environment/QueueWorkerServiceCommand.php index 83266155b..dbf1aa735 100644 --- a/app/Console/Commands/Environment/QueueWorkerServiceCommand.php +++ b/app/Console/Commands/Environment/QueueWorkerServiceCommand.php @@ -19,7 +19,7 @@ class QueueWorkerServiceCommand extends Command public function handle(): void { $serviceName = $this->option('service-name') ?? $this->ask('Queue worker service name', 'pelican-queue'); - $path = '/etc/systemd/system/'.$serviceName.'.service'; + $path = '/etc/systemd/system/' . $serviceName . '.service'; $fileExists = file_exists($path); if ($fileExists && !$this->option('overwrite') && !$this->confirm('The service file already exists. Do you want to overwrite it?')) { @@ -65,7 +65,7 @@ WantedBy=multi-user.target if ($fileExists) { $result = Process::run("systemctl restart $serviceName.service"); if ($result->failed()) { - $this->error('Error restarting service: '.$result->errorOutput()); + $this->error('Error restarting service: ' . $result->errorOutput()); return; } @@ -74,7 +74,7 @@ WantedBy=multi-user.target } else { $result = Process::run("systemctl enable --now $serviceName.service"); if ($result->failed()) { - $this->error('Error enabling service: '.$result->errorOutput()); + $this->error('Error enabling service: ' . $result->errorOutput()); return; } diff --git a/app/Console/Commands/Maintenance/PruneImagesCommand.php b/app/Console/Commands/Maintenance/PruneImagesCommand.php index a2f8c36ce..23f613fa3 100644 --- a/app/Console/Commands/Maintenance/PruneImagesCommand.php +++ b/app/Console/Commands/Maintenance/PruneImagesCommand.php @@ -50,7 +50,7 @@ class PruneImagesCommand extends Command $count = count($response['ImagesDeleted']); $useBinaryPrefix = config('panel.use_binary_prefix'); - $space = round($useBinaryPrefix ? $response['SpaceReclaimed'] / 1024 / 1024 : $response['SpaceReclaimed'] / 1000 / 1000, 2).($useBinaryPrefix ? ' MiB' : ' MB'); + $space = round($useBinaryPrefix ? $response['SpaceReclaimed'] / 1024 / 1024 : $response['SpaceReclaimed'] / 1000 / 1000, 2) . ($useBinaryPrefix ? ' MiB' : ' MB'); $this->info("Node {$node->id}: Cleaned up {$count} dangling docker images. ({$space})"); } catch (Exception $exception) { diff --git a/app/Console/Commands/Schedule/ProcessRunnableCommand.php b/app/Console/Commands/Schedule/ProcessRunnableCommand.php index 67ee89f3d..d1d71ae02 100644 --- a/app/Console/Commands/Schedule/ProcessRunnableCommand.php +++ b/app/Console/Commands/Schedule/ProcessRunnableCommand.php @@ -67,7 +67,7 @@ class ProcessRunnableCommand extends Command } catch (\Throwable|\Exception $exception) { logger()->error($exception, ['schedule_id' => $schedule->id]); - $this->error(__('commands.schedule.process.no_tasks')." #$schedule->id: ".$exception->getMessage()); + $this->error(__('commands.schedule.process.no_tasks') . " #$schedule->id: " . $exception->getMessage()); } } } diff --git a/app/Console/Commands/UpgradeCommand.php b/app/Console/Commands/UpgradeCommand.php index 8f97d6dd3..75a3c185f 100644 --- a/app/Console/Commands/UpgradeCommand.php +++ b/app/Console/Commands/UpgradeCommand.php @@ -40,7 +40,7 @@ class UpgradeCommand extends Command } if (version_compare(PHP_VERSION, '7.4.0') < 0) { - $this->error(__('commands.upgrade.php_version').' ['.PHP_VERSION.'].'); + $this->error(__('commands.upgrade.php_version') . ' [' . PHP_VERSION . '].'); } $user = 'www-data'; @@ -125,7 +125,7 @@ class UpgradeCommand extends Command $command[] = '--no-dev'; } - $this->line('$upgrader> '.implode(' ', $command)); + $this->line('$upgrader> ' . implode(' ', $command)); $process = new Process($command); $process->setTimeout(10 * 60); $process->run(function ($type, $buffer) { @@ -134,7 +134,7 @@ class UpgradeCommand extends Command }); /** @var \Illuminate\Foundation\Application $app */ - $app = require __DIR__.'/../../../bootstrap/app.php'; + $app = require __DIR__ . '/../../../bootstrap/app.php'; /** @var \App\Console\Kernel $kernel */ $kernel = $app->make(Kernel::class); $kernel->bootstrap(); @@ -192,6 +192,6 @@ class UpgradeCommand extends Command return $this->option('url'); } - return sprintf(self::DEFAULT_URL, $this->option('release') ? 'download/v'.$this->option('release') : 'latest/download'); + return sprintf(self::DEFAULT_URL, $this->option('release') ? 'download/v' . $this->option('release') : 'latest/download'); } } diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index f4a17cefc..3c2fc96fa 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -20,7 +20,7 @@ class Kernel extends ConsoleKernel */ protected function commands(): void { - $this->load(__DIR__.'/Commands'); + $this->load(__DIR__ . '/Commands'); } /** diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index f3bc40cd3..6327a214c 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -108,7 +108,7 @@ class Handler extends ExceptionHandler $exception->getLine() ); - return $message."\nStack trace:\n".trim($cleanedStack); + return $message . "\nStack trace:\n" . trim($cleanedStack); } /** @@ -160,7 +160,7 @@ class Handler extends ExceptionHandler 'source_field' => $field, 'rule' => str_replace(self::PANEL_RULE_STRING, 'p_', Arr::get( $codes, - str_replace('.', '_', $field).'.'.$key + str_replace('.', '_', $field) . '.' . $key )), ]; diff --git a/app/Extensions/Backups/BackupManager.php b/app/Extensions/Backups/BackupManager.php index 16c704b97..9922a55c6 100644 --- a/app/Extensions/Backups/BackupManager.php +++ b/app/Extensions/Backups/BackupManager.php @@ -74,7 +74,7 @@ class BackupManager return $this->callCustomCreator($config); } - $adapterMethod = 'create'.Str::studly($adapter).'Adapter'; + $adapterMethod = 'create' . Str::studly($adapter) . 'Adapter'; if (method_exists($this, $adapterMethod)) { $instance = $this->{$adapterMethod}($config); diff --git a/app/Extensions/DynamicDatabaseConnection.php b/app/Extensions/DynamicDatabaseConnection.php index b4409ed4b..147f78064 100644 --- a/app/Extensions/DynamicDatabaseConnection.php +++ b/app/Extensions/DynamicDatabaseConnection.php @@ -21,7 +21,7 @@ class DynamicDatabaseConnection $host = DatabaseHost::query()->findOrFail($host); } - config()->set('database.connections.'.$connection, [ + config()->set('database.connections.' . $connection, [ 'driver' => self::DB_DRIVER, 'host' => $host->host, 'port' => $host->port, diff --git a/app/Extensions/Themes/Theme.php b/app/Extensions/Themes/Theme.php index 92b587fb7..2badc3dcb 100644 --- a/app/Extensions/Themes/Theme.php +++ b/app/Extensions/Themes/Theme.php @@ -6,16 +6,16 @@ class Theme { public function js($path): string { - return sprintf(''.PHP_EOL, $this->getUrl($path)); + return sprintf('' . PHP_EOL, $this->getUrl($path)); } public function css($path): string { - return sprintf(''.PHP_EOL, $this->getUrl($path)); + return sprintf('' . PHP_EOL, $this->getUrl($path)); } protected function getUrl($path): string { - return '/themes/panel/'.ltrim($path, '/'); + return '/themes/panel/' . ltrim($path, '/'); } } diff --git a/app/Filament/Pages/Installer/Steps/CompletedStep.php b/app/Filament/Pages/Installer/Steps/CompletedStep.php index 8b91c7686..50f9a780c 100644 --- a/app/Filament/Pages/Installer/Steps/CompletedStep.php +++ b/app/Filament/Pages/Installer/Steps/CompletedStep.php @@ -21,12 +21,12 @@ class CompletedStep ->label(new HtmlString('Run the following command to setup your crontab. Note that www-data is your webserver user. On some systems this username might be different!')) ->disabled() ->hintAction(CopyAction::make()) - ->default('(crontab -l -u www-data 2>/dev/null; echo "* * * * * php '.base_path().'/artisan schedule:run >> /dev/null 2>&1") | crontab -u www-data -'), + ->default('(crontab -l -u www-data 2>/dev/null; echo "* * * * * php ' . base_path() . '/artisan schedule:run >> /dev/null 2>&1") | crontab -u www-data -'), TextInput::make('queueService') ->label(new HtmlString('To setup the queue worker service you simply have to run the following command.')) ->disabled() ->hintAction(CopyAction::make()) - ->default('sudo php '.base_path().'/artisan p:environment:queue-service'), + ->default('sudo php ' . base_path() . '/artisan p:environment:queue-service'), Placeholder::make('') ->content('After you finished these two last tasks you can click on "Finish" and use your new panel! Have fun!'), ]); diff --git a/app/Filament/Pages/Installer/Steps/RequirementsStep.php b/app/Filament/Pages/Installer/Steps/RequirementsStep.php index d2afd4b37..5e6d6988d 100644 --- a/app/Filament/Pages/Installer/Steps/RequirementsStep.php +++ b/app/Filament/Pages/Installer/Steps/RequirementsStep.php @@ -18,12 +18,12 @@ class RequirementsStep $fields = [ Section::make('PHP Version') - ->description(self::MIN_PHP_VERSION.' or newer') + ->description(self::MIN_PHP_VERSION . ' or newer') ->icon($correctPhpVersion ? 'tabler-check' : 'tabler-x') ->iconColor($correctPhpVersion ? 'success' : 'danger') ->schema([ Placeholder::make('') - ->content('Your PHP Version is '.PHP_VERSION.'.'), + ->content('Your PHP Version is ' . PHP_VERSION . '.'), ]), ]; @@ -49,7 +49,7 @@ class RequirementsStep ->content('All needed PHP Extensions are installed.') ->visible($allExtensionsInstalled), Placeholder::make('') - ->content('The following PHP Extensions are missing: '.implode(', ', array_keys($phpExtensions, false))) + ->content('The following PHP Extensions are missing: ' . implode(', ', array_keys($phpExtensions, false))) ->visible(!$allExtensionsInstalled), ]); @@ -68,7 +68,7 @@ class RequirementsStep ->content('All Folders have the correct permissions.') ->visible($correctFolderPermissions), Placeholder::make('') - ->content('The following Folders have wrong permissions: '.implode(', ', array_keys($folderPermissions, false))) + ->content('The following Folders have wrong permissions: ' . implode(', ', array_keys($folderPermissions, false))) ->visible(!$correctFolderPermissions), ]); diff --git a/app/Filament/Resources/ApiKeyResource/Pages/ListApiKeys.php b/app/Filament/Resources/ApiKeyResource/Pages/ListApiKeys.php index 8ef0cdd3c..aa0b9cdb5 100644 --- a/app/Filament/Resources/ApiKeyResource/Pages/ListApiKeys.php +++ b/app/Filament/Resources/ApiKeyResource/Pages/ListApiKeys.php @@ -24,7 +24,7 @@ class ListApiKeys extends ListRecords TextColumn::make('key') ->copyable() ->icon('tabler-clipboard-text') - ->state(fn (ApiKey $key) => $key->identifier.$key->token), + ->state(fn (ApiKey $key) => $key->identifier . $key->token), TextColumn::make('memo') ->label('Description') diff --git a/app/Filament/Resources/DatabaseHostResource/RelationManagers/DatabasesRelationManager.php b/app/Filament/Resources/DatabaseHostResource/RelationManagers/DatabasesRelationManager.php index 3b209d7f7..13b32602f 100644 --- a/app/Filament/Resources/DatabaseHostResource/RelationManagers/DatabasesRelationManager.php +++ b/app/Filament/Resources/DatabaseHostResource/RelationManagers/DatabasesRelationManager.php @@ -37,7 +37,7 @@ class DatabasesRelationManager extends RelationManager TextInput::make('JDBC') ->label('JDBC Connection String') ->columnSpanFull() - ->formatStateUsing(fn (Get $get, Database $database) => 'jdbc:mysql://'.$get('username').':'.urlencode($database->password).'@'.$database->host->host.':'.$database->host->port.'/'.$get('database')), + ->formatStateUsing(fn (Get $get, Database $database) => 'jdbc:mysql://' . $get('username') . ':' . urlencode($database->password) . '@' . $database->host->host . ':' . $database->host->port . '/' . $get('database')), ]); } @@ -64,7 +64,7 @@ class DatabasesRelationManager extends RelationManager protected function rotatePassword(DatabasePasswordService $service, Database $database, $set, $get): void { $newPassword = $service->handle($database); - $jdbcString = 'jdbc:mysql://'.$get('username').':'.urlencode($newPassword).'@'.$database->host->host.':'.$database->host->port.'/'.$get('database'); + $jdbcString = 'jdbc:mysql://' . $get('username') . ':' . urlencode($newPassword) . '@' . $database->host->host . ':' . $database->host->port . '/' . $get('database'); $set('password', $newPassword); $set('JDBC', $jdbcString); diff --git a/app/Filament/Resources/EggResource/Pages/EditEgg.php b/app/Filament/Resources/EggResource/Pages/EditEgg.php index b9b839cb1..d1d59c064 100644 --- a/app/Filament/Resources/EggResource/Pages/EditEgg.php +++ b/app/Filament/Resources/EggResource/Pages/EditEgg.php @@ -249,7 +249,7 @@ class EditEgg extends EditRecord ->color('primary') ->action(fn (EggExporterService $service, Egg $egg) => response()->streamDownload(function () use ($service, $egg) { echo $service->handle($egg->id); - }, 'egg-'.$egg->getKebabName().'.json')) + }, 'egg-' . $egg->getKebabName() . '.json')) ->authorize(fn () => auth()->user()->can('export egg')), Actions\Action::make('importEgg') ->label('Import') diff --git a/app/Filament/Resources/EggResource/Pages/ListEggs.php b/app/Filament/Resources/EggResource/Pages/ListEggs.php index 0903379e5..a7f84b274 100644 --- a/app/Filament/Resources/EggResource/Pages/ListEggs.php +++ b/app/Filament/Resources/EggResource/Pages/ListEggs.php @@ -55,7 +55,7 @@ class ListEggs extends ListRecords ->color('primary') ->action(fn (EggExporterService $service, Egg $egg) => response()->streamDownload(function () use ($service, $egg) { echo $service->handle($egg->id); - }, 'egg-'.$egg->getKebabName().'.json')) + }, 'egg-' . $egg->getKebabName() . '.json')) ->authorize(fn () => auth()->user()->can('export egg')), Action::make('update') ->icon('tabler-cloud-download') diff --git a/app/Filament/Resources/NodeResource/Widgets/NodeCpuChart.php b/app/Filament/Resources/NodeResource/Widgets/NodeCpuChart.php index 78119aaf5..89d1cb254 100644 --- a/app/Filament/Resources/NodeResource/Widgets/NodeCpuChart.php +++ b/app/Filament/Resources/NodeResource/Widgets/NodeCpuChart.php @@ -76,8 +76,8 @@ class NodeCpuChart extends ChartWidget $threads = $node->systemInformation()['cpu_count'] ?? 0; $cpu = Number::format(collect(cache()->get("nodes.$node->id.cpu_percent"))->last() * $threads, maxPrecision: 2, locale: auth()->user()->language); - $max = Number::format($threads * 100, locale: auth()->user()->language).'%'; + $max = Number::format($threads * 100, locale: auth()->user()->language) . '%'; - return 'CPU - '.$cpu.'% Of '.$max; + return 'CPU - ' . $cpu . '% Of ' . $max; } } diff --git a/app/Filament/Resources/NodeResource/Widgets/NodeMemoryChart.php b/app/Filament/Resources/NodeResource/Widgets/NodeMemoryChart.php index e1c19099b..0cabbed51 100644 --- a/app/Filament/Resources/NodeResource/Widgets/NodeMemoryChart.php +++ b/app/Filament/Resources/NodeResource/Widgets/NodeMemoryChart.php @@ -75,13 +75,13 @@ class NodeMemoryChart extends ChartWidget $totalMemory = collect(cache()->get("nodes.$node->id.memory_total"))->last(); $used = config('panel.use_binary_prefix') - ? Number::format($latestMemoryUsed / 1024 / 1024 / 1024, maxPrecision: 2, locale: auth()->user()->language).' GiB' - : Number::format($latestMemoryUsed / 1000 / 1000 / 1000, maxPrecision: 2, locale: auth()->user()->language).' GB'; + ? Number::format($latestMemoryUsed / 1024 / 1024 / 1024, maxPrecision: 2, locale: auth()->user()->language) .' GiB' + : Number::format($latestMemoryUsed / 1000 / 1000 / 1000, maxPrecision: 2, locale: auth()->user()->language) . ' GB'; $total = config('panel.use_binary_prefix') - ? Number::format($totalMemory / 1024 / 1024 / 1024, maxPrecision: 2, locale: auth()->user()->language).' GiB' - : Number::format($totalMemory / 1000 / 1000 / 1000, maxPrecision: 2, locale: auth()->user()->language).' GB'; + ? Number::format($totalMemory / 1024 / 1024 / 1024, maxPrecision: 2, locale: auth()->user()->language) .' GiB' + : Number::format($totalMemory / 1000 / 1000 / 1000, maxPrecision: 2, locale: auth()->user()->language) . ' GB'; - return 'Memory - '.$used.' Of '.$total; + return 'Memory - ' . $used . ' Of ' . $total; } } diff --git a/app/Filament/Resources/RoleResource.php b/app/Filament/Resources/RoleResource.php index 898090222..306c9676d 100644 --- a/app/Filament/Resources/RoleResource.php +++ b/app/Filament/Resources/RoleResource.php @@ -40,12 +40,12 @@ class RoleResource extends Resource $options = []; foreach (RolePermissionPrefixes::cases() as $prefix) { - $options[$prefix->value.' '.strtolower($model->value)] = Str::headline($prefix->value); + $options[$prefix->value . ' ' . strtolower($model->value)] = Str::headline($prefix->value); } if (array_key_exists($model->value, Role::MODEL_SPECIFIC_PERMISSIONS)) { foreach (Role::MODEL_SPECIFIC_PERMISSIONS[$model->value] as $permission) { - $options[$permission.' '.strtolower($model->value)] = Str::headline($permission); + $options[$permission . ' ' . strtolower($model->value)] = Str::headline($permission); } } @@ -56,7 +56,7 @@ class RoleResource extends Resource $options = []; foreach ($prefixes as $prefix) { - $options[$prefix.' '.strtolower($model)] = Str::headline($prefix); + $options[$prefix . ' ' . strtolower($model)] = Str::headline($prefix); } $permissions[] = self::makeSection($model, $options); @@ -88,10 +88,10 @@ class RoleResource extends Resource { $icon = null; - if (class_exists('\App\Filament\Resources\\'.$model.'Resource')) { - $icon = ('\App\Filament\Resources\\'.$model.'Resource')::getNavigationIcon(); - } elseif (class_exists('\App\Filament\Pages\\'.$model)) { - $icon = ('\App\Filament\Pages\\'.$model)::getNavigationIcon(); + if (class_exists('\App\Filament\Resources\\' . $model . 'Resource')) { + $icon = ('\App\Filament\Resources\\' . $model . 'Resource')::getNavigationIcon(); + } elseif (class_exists('\App\Filament\Pages\\' . $model)) { + $icon = ('\App\Filament\Pages\\' . $model)::getNavigationIcon(); } return Section::make(Str::headline(Str::plural($model))) @@ -101,11 +101,11 @@ class RoleResource extends Resource ->icon($icon) ->headerActions([ Action::make('count') - ->label(fn (Get $get) => count($get(strtolower($model).'_list'))) + ->label(fn (Get $get) => count($get(strtolower($model) . '_list'))) ->badge(), ]) ->schema([ - CheckboxList::make(strtolower($model).'_list') + CheckboxList::make(strtolower($model) . '_list') ->label('') ->options($options) ->columns() diff --git a/app/Filament/Resources/ServerResource/Pages/CreateServer.php b/app/Filament/Resources/ServerResource/Pages/CreateServer.php index 61696804f..b8ac8a520 100644 --- a/app/Filament/Resources/ServerResource/Pages/CreateServer.php +++ b/app/Filament/Resources/ServerResource/Pages/CreateServer.php @@ -70,14 +70,14 @@ class CreateServer extends CreateRecord ->prefixIcon('tabler-server') ->label('Name') ->suffixAction(Forms\Components\Actions\Action::make('random') - ->icon('tabler-dice-'.random_int(1, 6)) + ->icon('tabler-dice-' . random_int(1, 6)) ->action(function (Set $set, Get $get) { $egg = Egg::find($get('egg_id')); - $prefix = $egg ? str($egg->name)->lower()->kebab().'-' : ''; + $prefix = $egg ? str($egg->name)->lower()->kebab() . '-' : ''; $word = (new RandomWordService())->word(); - $set('name', $prefix.$word); + $set('name', $prefix . $word); })) ->columnSpan([ 'default' => 2, @@ -101,7 +101,7 @@ class CreateServer extends CreateRecord ]) ->relationship('user', 'username') ->searchable(['username', 'email']) - ->getOptionLabelFromRecordUsing(fn (User $user) => "$user->email | $user->username ".($user->isRootAdmin() ? '(admin)' : '')) + ->getOptionLabelFromRecordUsing(fn (User $user) => "$user->email | $user->username " . ($user->isRootAdmin() ? '(admin)' : '')) ->createOptionForm([ TextInput::make('username') ->alphaNum() @@ -163,7 +163,7 @@ class CreateServer extends CreateRecord $set('allocation_additional.needstobeastringhere.extra_allocations', null); }) ->getOptionLabelFromRecordUsing( - fn (Allocation $allocation) => "$allocation->ip:$allocation->port". + fn (Allocation $allocation) => "$allocation->ip:$allocation->port" . ($allocation->ip_alias ? " ($allocation->ip_alias)" : '') ) ->placeholder(function (Get $get) { @@ -293,7 +293,7 @@ class CreateServer extends CreateRecord ->disabled(fn (Get $get) => $get('../../node_id') === null) ->searchable(['ip', 'port', 'ip_alias']) ->getOptionLabelFromRecordUsing( - fn (Allocation $allocation) => "$allocation->ip:$allocation->port". + fn (Allocation $allocation) => "$allocation->ip:$allocation->port" . ($allocation->ip_alias ? " ($allocation->ip_alias)" : '') ) ->placeholder('Select additional Allocations') @@ -498,7 +498,7 @@ class CreateServer extends CreateRecord ->hintIcon('tabler-code') ->label(fn (Get $get) => $get('name')) ->hintIconTooltip(fn (Get $get) => implode('|', $get('rules'))) - ->prefix(fn (Get $get) => '{{'.$get('env_variable').'}}') + ->prefix(fn (Get $get) => '{{' . $get('env_variable') . '}}') ->helperText(fn (Get $get) => empty($get('description')) ? '—' : $get('description')) ->afterStateUpdated(function (Set $set, Get $get, $state) { $environment = $get($envPath = '../../environment'); @@ -846,7 +846,7 @@ class CreateServer extends CreateRecord return !$containsRuleIn; } - throw new Exception('Component type not supported: '.$component::class); + throw new Exception('Component type not supported: ' . $component::class); } private function getSelectOptionsFromRules(Get $get): array diff --git a/app/Filament/Resources/ServerResource/Pages/EditServer.php b/app/Filament/Resources/ServerResource/Pages/EditServer.php index 33a90ace0..267fd998f 100644 --- a/app/Filament/Resources/ServerResource/Pages/EditServer.php +++ b/app/Filament/Resources/ServerResource/Pages/EditServer.php @@ -66,14 +66,14 @@ class EditServer extends EditRecord ->prefixIcon('tabler-server') ->label('Display Name') ->suffixAction(Action::make('random') - ->icon('tabler-dice-'.random_int(1, 6)) + ->icon('tabler-dice-' . random_int(1, 6)) ->action(function (Set $set, Get $get) { $egg = Egg::find($get('egg_id')); - $prefix = $egg ? str($egg->name)->lower()->kebab().'-' : ''; + $prefix = $egg ? str($egg->name)->lower()->kebab() . '-' : ''; $word = (new RandomWordService())->word(); - $set('name', $prefix.$word); + $set('name', $prefix . $word); })) ->columnSpan([ 'default' => 2, @@ -541,7 +541,7 @@ class EditServer extends EditRecord ->hintIcon('tabler-code') ->label(fn (ServerVariable $serverVariable) => $serverVariable->variable->name) ->hintIconTooltip(fn (ServerVariable $serverVariable) => implode('|', $serverVariable->variable->rules)) - ->prefix(fn (ServerVariable $serverVariable) => '{{'.$serverVariable->variable->env_variable.'}}') + ->prefix(fn (ServerVariable $serverVariable) => '{{' . $serverVariable->variable->env_variable . '}}') ->helperText(fn (ServerVariable $serverVariable) => empty($serverVariable->variable->description) ? '—' : $serverVariable->variable->description); } @@ -606,7 +606,7 @@ class EditServer extends EditRecord ->disabled() ->label('JDBC Connection String') ->columnSpan(2) - ->formatStateUsing(fn (Get $get, $record) => 'jdbc:mysql://'.$get('username').':'.urlencode($record->password).'@'.$record->host->host.':'.$record->host->port.'/'.$get('database')), + ->formatStateUsing(fn (Get $get, $record) => 'jdbc:mysql://' . $get('username') . ':' . urlencode($record->password) . '@' . $record->host->host . ':' . $record->host->port . '/' . $get('database')), ]) ->relationship('databases') ->deletable(false) @@ -800,7 +800,7 @@ class EditServer extends EditRecord return $containsRuleIn; } - throw new Exception('Component type not supported: '.$component::class); + throw new Exception('Component type not supported: ' . $component::class); } private function getSelectOptionsFromRules(ServerVariable $serverVariable): array @@ -818,7 +818,7 @@ class EditServer extends EditRecord protected function rotatePassword(DatabasePasswordService $service, $record, $set, $get): void { $newPassword = $service->handle($record); - $jdbcString = 'jdbc:mysql://'.$get('username').':'.urlencode($newPassword).'@'.$record->host->host.':'.$record->host->port.'/'.$get('database'); + $jdbcString = 'jdbc:mysql://' . $get('username') . ':' . urlencode($newPassword) . '@' . $record->host->host . ':' . $record->host->port . '/' . $get('database'); $set('password', $newPassword); $set('JDBC', $jdbcString); diff --git a/app/Filament/Resources/UserResource/Pages/EditProfile.php b/app/Filament/Resources/UserResource/Pages/EditProfile.php index 20bd0f61f..f5c5f5828 100644 --- a/app/Filament/Resources/UserResource/Pages/EditProfile.php +++ b/app/Filament/Resources/UserResource/Pages/EditProfile.php @@ -178,7 +178,7 @@ class EditProfile extends \Filament\Pages\Auth\EditProfile ->content(fn () => new HtmlString("
$image
")) - ->helperText('Setup Key: '.$secret), + ->helperText('Setup Key: '. $secret), TextInput::make('2facode') ->label('Code') ->requiredWith('2fapassword') diff --git a/app/Filament/Resources/UserResource/Pages/ListUsers.php b/app/Filament/Resources/UserResource/Pages/ListUsers.php index 03df51554..c386d4ce6 100644 --- a/app/Filament/Resources/UserResource/Pages/ListUsers.php +++ b/app/Filament/Resources/UserResource/Pages/ListUsers.php @@ -33,7 +33,7 @@ class ListUsers extends ListRecords ->visibleFrom('lg') ->label('') ->extraImgAttributes(['class' => 'rounded-full']) - ->defaultImageUrl(fn (User $user) => 'https://gravatar.com/avatar/'.md5(strtolower($user->email))), + ->defaultImageUrl(fn (User $user) => 'https://gravatar.com/avatar/' . md5(strtolower($user->email))), TextColumn::make('external_id') ->searchable() ->hidden(), @@ -55,7 +55,7 @@ class ListUsers extends ListRecords ->counts('roles') ->icon('tabler-users-group') ->label('Roles') - ->formatStateUsing(fn (User $user, $state) => $state.($user->isRootAdmin() ? ' (Root Admin)' : '')), + ->formatStateUsing(fn (User $user, $state) => $state . ($user->isRootAdmin() ? ' (Root Admin)' : '')), TextColumn::make('servers_count') ->counts('servers') ->icon('tabler-server') diff --git a/app/Http/Controllers/Admin/Eggs/EggShareController.php b/app/Http/Controllers/Admin/Eggs/EggShareController.php index 56f38f4f7..993064b65 100644 --- a/app/Http/Controllers/Admin/Eggs/EggShareController.php +++ b/app/Http/Controllers/Admin/Eggs/EggShareController.php @@ -30,7 +30,7 @@ class EggShareController extends Controller return response($this->exporterService->handle($egg->id), 200, [ 'Content-Transfer-Encoding' => 'binary', 'Content-Description' => 'File Transfer', - 'Content-Disposition' => 'attachment; filename=egg-'.$filename.'.json', + 'Content-Disposition' => 'attachment; filename=egg-' . $filename . '.json', 'Content-Type' => 'application/json', ]); } diff --git a/app/Http/Controllers/Admin/NodeAutoDeployController.php b/app/Http/Controllers/Admin/NodeAutoDeployController.php index b61e41acb..1029706c3 100644 --- a/app/Http/Controllers/Admin/NodeAutoDeployController.php +++ b/app/Http/Controllers/Admin/NodeAutoDeployController.php @@ -56,7 +56,7 @@ class NodeAutoDeployController extends Controller return new JsonResponse([ 'node' => $node->id, - 'token' => $key->identifier.$key->token, + 'token' => $key->identifier . $key->token, ]); } } diff --git a/app/Http/Controllers/Admin/Servers/CreateServerController.php b/app/Http/Controllers/Admin/Servers/CreateServerController.php index 7e7c19175..c59e22fbe 100644 --- a/app/Http/Controllers/Admin/Servers/CreateServerController.php +++ b/app/Http/Controllers/Admin/Servers/CreateServerController.php @@ -67,6 +67,6 @@ class CreateServerController extends Controller $this->alert->success(trans('admin/server.alerts.server_created'))->flash(); - return new RedirectResponse('/admin/servers/view/'.$server->id); + return new RedirectResponse('/admin/servers/view/' . $server->id); } } diff --git a/app/Http/Controllers/Admin/ServersController.php b/app/Http/Controllers/Admin/ServersController.php index 4cb398bbe..9ddd9c7e6 100644 --- a/app/Http/Controllers/Admin/ServersController.php +++ b/app/Http/Controllers/Admin/ServersController.php @@ -115,7 +115,7 @@ class ServersController extends Controller { $this->suspensionService->toggle($server, $request->input('action')); $this->alert->success(trans('admin/server.alerts.suspension_toggled', [ - 'status' => $request->input('action').'ed', + 'status' => $request->input('action') . 'ed', ]))->flash(); return redirect()->route('admin.servers.view.manage', $server->id); diff --git a/app/Http/Controllers/Api/Client/Servers/FileController.php b/app/Http/Controllers/Api/Client/Servers/FileController.php index bd175aef5..09d354a36 100644 --- a/app/Http/Controllers/Api/Client/Servers/FileController.php +++ b/app/Http/Controllers/Api/Client/Servers/FileController.php @@ -83,7 +83,7 @@ class FileController extends ClientApiController 'file_path' => rawurldecode($request->get('file')), 'server_uuid' => $server->uuid, ]) - ->handle($server->node, $request->user()->id.$server->uuid); + ->handle($server->node, $request->user()->id . $server->uuid); Activity::event('server:file.download')->property('file', $request->get('file'))->log(); diff --git a/app/Http/Controllers/Api/Client/Servers/FileUploadController.php b/app/Http/Controllers/Api/Client/Servers/FileUploadController.php index 9ee74fb44..e48dd75bd 100644 --- a/app/Http/Controllers/Api/Client/Servers/FileUploadController.php +++ b/app/Http/Controllers/Api/Client/Servers/FileUploadController.php @@ -43,7 +43,7 @@ class FileUploadController extends ClientApiController ->setExpiresAt(CarbonImmutable::now()->addMinutes(15)) ->setUser($user) ->setClaims(['server_uuid' => $server->uuid]) - ->handle($server->node, $user->id.$server->uuid); + ->handle($server->node, $user->id . $server->uuid); return sprintf( '%s/upload/file?token=%s', diff --git a/app/Http/Controllers/Api/Client/Servers/WebsocketController.php b/app/Http/Controllers/Api/Client/Servers/WebsocketController.php index 8d636872d..0fb062e96 100644 --- a/app/Http/Controllers/Api/Client/Servers/WebsocketController.php +++ b/app/Http/Controllers/Api/Client/Servers/WebsocketController.php @@ -59,14 +59,14 @@ class WebsocketController extends ClientApiController 'server_uuid' => $server->uuid, 'permissions' => $permissions, ]) - ->handle($node, $user->id.$server->uuid); + ->handle($node, $user->id . $server->uuid); $socket = str_replace(['https://', 'http://'], ['wss://', 'ws://'], $node->getConnectionAddress()); return new JsonResponse([ 'data' => [ 'token' => $token->toString(), - 'socket' => $socket.sprintf('/api/servers/%s/ws', $server->uuid), + 'socket' => $socket . sprintf('/api/servers/%s/ws', $server->uuid), ], ]); } diff --git a/app/Http/Controllers/Api/Remote/Backups/BackupStatusController.php b/app/Http/Controllers/Api/Remote/Backups/BackupStatusController.php index 47350c69d..4f32689ec 100644 --- a/app/Http/Controllers/Api/Remote/Backups/BackupStatusController.php +++ b/app/Http/Controllers/Api/Remote/Backups/BackupStatusController.php @@ -64,7 +64,7 @@ class BackupStatusController extends Controller // deleted easily. Also does not make sense to have a locked backup on the system // that is failed. 'is_locked' => $successful ? $model->is_locked : false, - 'checksum' => $successful ? ($request->input('checksum_type').':'.$request->input('checksum')) : null, + 'checksum' => $successful ? ($request->input('checksum_type') . ':' . $request->input('checksum')) : null, 'bytes' => $successful ? $request->input('size') : 0, 'completed_at' => CarbonImmutable::now(), ])->save(); diff --git a/app/Http/Controllers/Api/Remote/SftpAuthenticationController.php b/app/Http/Controllers/Api/Remote/SftpAuthenticationController.php index f9e63dfb5..9b59704f1 100644 --- a/app/Http/Controllers/Api/Remote/SftpAuthenticationController.php +++ b/app/Http/Controllers/Api/Remote/SftpAuthenticationController.php @@ -160,6 +160,6 @@ class SftpAuthenticationController extends Controller { $username = explode('.', strrev($request->input('username', ''))); - return strtolower(strrev($username[0] ?? '').'|'.$request->ip()); + return strtolower(strrev($username[0] ?? '') . '|' . $request->ip()); } } diff --git a/app/Http/Controllers/Auth/OAuthController.php b/app/Http/Controllers/Auth/OAuthController.php index 34f0b3bbc..2989761ef 100644 --- a/app/Http/Controllers/Auth/OAuthController.php +++ b/app/Http/Controllers/Auth/OAuthController.php @@ -48,7 +48,7 @@ class OAuthController extends Controller } try { - $user = User::query()->whereJsonContains('oauth->'.$driver, $oauthUser->getId())->firstOrFail(); + $user = User::query()->whereJsonContains('oauth->'. $driver, $oauthUser->getId())->firstOrFail(); $this->auth->guard()->login($user, true); } catch (Exception $e) { diff --git a/app/Http/Middleware/Api/AuthenticateIPAccess.php b/app/Http/Middleware/Api/AuthenticateIPAccess.php index a1c6d4710..c9f3bf7dc 100644 --- a/app/Http/Middleware/Api/AuthenticateIPAccess.php +++ b/app/Http/Middleware/Api/AuthenticateIPAccess.php @@ -43,6 +43,6 @@ class AuthenticateIPAccess ->property('identifier', $token->identifier) ->log(); - throw new AccessDeniedHttpException('This IP address ('.$request->ip().') does not have permission to access the API using these credentials.'); + throw new AccessDeniedHttpException('This IP address (' . $request->ip() . ') does not have permission to access the API using these credentials.'); } } diff --git a/app/Http/Middleware/Api/Client/Server/ResourceBelongsToServer.php b/app/Http/Middleware/Api/Client/Server/ResourceBelongsToServer.php index d7754d36e..0ead01f1d 100644 --- a/app/Http/Middleware/Api/Client/Server/ResourceBelongsToServer.php +++ b/app/Http/Middleware/Api/Client/Server/ResourceBelongsToServer.php @@ -80,7 +80,7 @@ class ResourceBelongsToServer default: // Don't return a 404 here since we want to make sure no one relies // on this middleware in a context in which it will not work. Fail safe. - throw new \InvalidArgumentException('There is no handler configured for a resource of this type: '.get_class($model)); + throw new \InvalidArgumentException('There is no handler configured for a resource of this type: ' . get_class($model)); } } diff --git a/app/Http/Middleware/Api/IsValidJson.php b/app/Http/Middleware/Api/IsValidJson.php index 77bd25fe8..86bb34ff2 100644 --- a/app/Http/Middleware/Api/IsValidJson.php +++ b/app/Http/Middleware/Api/IsValidJson.php @@ -18,7 +18,7 @@ class IsValidJson try { json_decode($request->getContent(), true, 512, JSON_THROW_ON_ERROR); } catch (\JsonException $exception) { - throw new BadRequestHttpException('The JSON data passed in the request appears to be malformed: '.$exception->getMessage()); + throw new BadRequestHttpException('The JSON data passed in the request appears to be malformed: ' . $exception->getMessage()); } } diff --git a/app/Http/Middleware/RequireTwoFactorAuthentication.php b/app/Http/Middleware/RequireTwoFactorAuthentication.php index bfbab4438..58ff1564d 100644 --- a/app/Http/Middleware/RequireTwoFactorAuthentication.php +++ b/app/Http/Middleware/RequireTwoFactorAuthentication.php @@ -38,7 +38,7 @@ class RequireTwoFactorAuthentication public function handle(Request $request, \Closure $next): mixed { $user = $request->user(); - $uri = rtrim($request->getRequestUri(), '/').'/'; + $uri = rtrim($request->getRequestUri(), '/') . '/'; $current = $request->route()->getName(); if (!$user || Str::startsWith($uri, ['/auth/']) || Str::startsWith($current, ['auth.', 'account.'])) { diff --git a/app/Http/Requests/Admin/Api/StoreApplicationApiKeyRequest.php b/app/Http/Requests/Admin/Api/StoreApplicationApiKeyRequest.php index b092ead91..83f80f267 100644 --- a/app/Http/Requests/Admin/Api/StoreApplicationApiKeyRequest.php +++ b/app/Http/Requests/Admin/Api/StoreApplicationApiKeyRequest.php @@ -17,7 +17,7 @@ class StoreApplicationApiKeyRequest extends AdminFormRequest $modelRules = ApiKey::getRules(); return collect(AdminAcl::getResourceList())->mapWithKeys(function ($resource) use ($modelRules) { - return [AdminAcl::COLUMN_IDENTIFIER.$resource => $modelRules['r_'.$resource]]; + return [AdminAcl::COLUMN_IDENTIFIER . $resource => $modelRules['r_' . $resource]]; })->merge(['memo' => $modelRules['memo']])->toArray(); } diff --git a/app/Http/Requests/Admin/Egg/EggVariableFormRequest.php b/app/Http/Requests/Admin/Egg/EggVariableFormRequest.php index b7e64daaa..c6720aa2c 100644 --- a/app/Http/Requests/Admin/Egg/EggVariableFormRequest.php +++ b/app/Http/Requests/Admin/Egg/EggVariableFormRequest.php @@ -15,7 +15,7 @@ class EggVariableFormRequest extends AdminFormRequest return [ 'name' => 'required|string|min:1|max:255', 'description' => 'sometimes|nullable|string', - 'env_variable' => 'required|regex:/^[\w]{1,255}$/|notIn:'.EggVariable::RESERVED_ENV_NAMES, + 'env_variable' => 'required|regex:/^[\w]{1,255}$/|notIn:' . EggVariable::RESERVED_ENV_NAMES, 'options' => 'sometimes|required|array', 'rules' => 'bail|required|string', 'default_value' => 'present', diff --git a/app/Http/Requests/Api/Client/Account/StoreApiKeyRequest.php b/app/Http/Requests/Api/Client/Account/StoreApiKeyRequest.php index 866832214..e0034fcfe 100644 --- a/app/Http/Requests/Api/Client/Account/StoreApiKeyRequest.php +++ b/app/Http/Requests/Api/Client/Account/StoreApiKeyRequest.php @@ -39,7 +39,7 @@ class StoreApiKeyRequest extends ClientApiRequest throw $exception; } } finally { - $validator->errors()->addIf(!$valid, "allowed_ips.{$index}", '"'.$ip.'" is not a valid IP address or CIDR range.'); + $validator->errors()->addIf(!$valid, "allowed_ips.{$index}", '"' . $ip . '" is not a valid IP address or CIDR range.'); } } }); diff --git a/app/Jobs/Schedule/RunTaskJob.php b/app/Jobs/Schedule/RunTaskJob.php index d4b0cabce..e4a47ada7 100644 --- a/app/Jobs/Schedule/RunTaskJob.php +++ b/app/Jobs/Schedule/RunTaskJob.php @@ -73,7 +73,7 @@ class RunTaskJob extends Job implements ShouldQueue $deleteFilesService->handle($server, explode(PHP_EOL, $this->task->payload)); break; default: - throw new \InvalidArgumentException('Invalid task action provided: '.$this->task->action); + throw new \InvalidArgumentException('Invalid task action provided: ' . $this->task->action); } } catch (\Exception $exception) { // If this isn't a DaemonConnectionException on a task that allows for failures diff --git a/app/Models/ApiKey.php b/app/Models/ApiKey.php index 6593803e2..96c714f24 100644 --- a/app/Models/ApiKey.php +++ b/app/Models/ApiKey.php @@ -110,14 +110,14 @@ class ApiKey extends Model 'memo', 'last_used_at', 'expires_at', - 'r_'.AdminAcl::RESOURCE_USERS, - 'r_'.AdminAcl::RESOURCE_ALLOCATIONS, - 'r_'.AdminAcl::RESOURCE_DATABASE_HOSTS, - 'r_'.AdminAcl::RESOURCE_SERVER_DATABASES, - 'r_'.AdminAcl::RESOURCE_EGGS, - 'r_'.AdminAcl::RESOURCE_NODES, - 'r_'.AdminAcl::RESOURCE_SERVERS, - 'r_'.AdminAcl::RESOURCE_MOUNTS, + 'r_' . AdminAcl::RESOURCE_USERS, + 'r_' . AdminAcl::RESOURCE_ALLOCATIONS, + 'r_' . AdminAcl::RESOURCE_DATABASE_HOSTS, + 'r_' . AdminAcl::RESOURCE_SERVER_DATABASES, + 'r_' . AdminAcl::RESOURCE_EGGS, + 'r_' . AdminAcl::RESOURCE_NODES, + 'r_' . AdminAcl::RESOURCE_SERVERS, + 'r_' . AdminAcl::RESOURCE_MOUNTS, ]; /** @@ -146,14 +146,14 @@ class ApiKey extends Model 'allowed_ips.*' => 'string', 'last_used_at' => 'nullable|date', 'expires_at' => 'nullable|date', - 'r_'.AdminAcl::RESOURCE_USERS => 'integer|min:0|max:3', - 'r_'.AdminAcl::RESOURCE_ALLOCATIONS => 'integer|min:0|max:3', - 'r_'.AdminAcl::RESOURCE_DATABASE_HOSTS => 'integer|min:0|max:3', - 'r_'.AdminAcl::RESOURCE_SERVER_DATABASES => 'integer|min:0|max:3', - 'r_'.AdminAcl::RESOURCE_EGGS => 'integer|min:0|max:3', - 'r_'.AdminAcl::RESOURCE_NODES => 'integer|min:0|max:3', - 'r_'.AdminAcl::RESOURCE_SERVERS => 'integer|min:0|max:3', - 'r_'.AdminAcl::RESOURCE_MOUNTS => 'integer|min:0|max:3', + 'r_' . AdminAcl::RESOURCE_USERS => 'integer|min:0|max:3', + 'r_' . AdminAcl::RESOURCE_ALLOCATIONS => 'integer|min:0|max:3', + 'r_' . AdminAcl::RESOURCE_DATABASE_HOSTS => 'integer|min:0|max:3', + 'r_' . AdminAcl::RESOURCE_SERVER_DATABASES => 'integer|min:0|max:3', + 'r_' . AdminAcl::RESOURCE_EGGS => 'integer|min:0|max:3', + 'r_' . AdminAcl::RESOURCE_NODES => 'integer|min:0|max:3', + 'r_' . AdminAcl::RESOURCE_SERVERS => 'integer|min:0|max:3', + 'r_' . AdminAcl::RESOURCE_MOUNTS => 'integer|min:0|max:3', ]; protected function casts(): array @@ -166,14 +166,14 @@ class ApiKey extends Model 'token' => 'encrypted', self::CREATED_AT => 'datetime', self::UPDATED_AT => 'datetime', - 'r_'.AdminAcl::RESOURCE_USERS => 'int', - 'r_'.AdminAcl::RESOURCE_ALLOCATIONS => 'int', - 'r_'.AdminAcl::RESOURCE_DATABASE_HOSTS => 'int', - 'r_'.AdminAcl::RESOURCE_SERVER_DATABASES => 'int', - 'r_'.AdminAcl::RESOURCE_EGGS => 'int', - 'r_'.AdminAcl::RESOURCE_NODES => 'int', - 'r_'.AdminAcl::RESOURCE_SERVERS => 'int', - 'r_'.AdminAcl::RESOURCE_MOUNTS => 'int', + 'r_' . AdminAcl::RESOURCE_USERS => 'int', + 'r_' . AdminAcl::RESOURCE_ALLOCATIONS => 'int', + 'r_' . AdminAcl::RESOURCE_DATABASE_HOSTS => 'int', + 'r_' . AdminAcl::RESOURCE_SERVER_DATABASES => 'int', + 'r_' . AdminAcl::RESOURCE_EGGS => 'int', + 'r_' . AdminAcl::RESOURCE_NODES => 'int', + 'r_' . AdminAcl::RESOURCE_SERVERS => 'int', + 'r_' . AdminAcl::RESOURCE_MOUNTS => 'int', ]; } @@ -227,6 +227,6 @@ class ApiKey extends Model { $prefix = self::getPrefixForType($type); - return $prefix.Str::random(self::IDENTIFIER_LENGTH - strlen($prefix)); + return $prefix . Str::random(self::IDENTIFIER_LENGTH - strlen($prefix)); } } diff --git a/app/Models/EggVariable.php b/app/Models/EggVariable.php index b56213c1a..2d3a4fb2c 100644 --- a/app/Models/EggVariable.php +++ b/app/Models/EggVariable.php @@ -54,7 +54,7 @@ class EggVariable extends Model 'sort' => 'nullable', 'name' => 'required|string|between:1,255', 'description' => 'string', - 'env_variable' => 'required|alphaDash|between:1,255|notIn:'.self::RESERVED_ENV_NAMES, + 'env_variable' => 'required|alphaDash|between:1,255|notIn:' . self::RESERVED_ENV_NAMES, 'default_value' => 'string', 'user_viewable' => 'boolean', 'user_editable' => 'boolean', diff --git a/app/Models/Filters/MultiFieldServerFilter.php b/app/Models/Filters/MultiFieldServerFilter.php index 6039c450b..d2c552321 100644 --- a/app/Models/Filters/MultiFieldServerFilter.php +++ b/app/Models/Filters/MultiFieldServerFilter.php @@ -48,7 +48,7 @@ class MultiFieldServerFilter implements Filter }, // Otherwise, just try to search for that specific port in the allocations. function (Builder $builder) use ($value) { - $builder->orWhere('allocations.port', 'LIKE', substr($value, 1).'%'); + $builder->orWhere('allocations.port', 'LIKE', substr($value, 1) . '%'); } ); }) diff --git a/app/Models/Node.php b/app/Models/Node.php index 59a337f2b..da5416091 100644 --- a/app/Models/Node.php +++ b/app/Models/Node.php @@ -184,8 +184,8 @@ class Node extends Model 'port' => $this->daemon_listen, 'ssl' => [ 'enabled' => (!$this->behind_proxy && $this->scheme === 'https'), - 'cert' => '/etc/letsencrypt/live/'.Str::lower($this->fqdn).'/fullchain.pem', - 'key' => '/etc/letsencrypt/live/'.Str::lower($this->fqdn).'/privkey.pem', + 'cert' => '/etc/letsencrypt/live/' . Str::lower($this->fqdn) . '/fullchain.pem', + 'key' => '/etc/letsencrypt/live/' . Str::lower($this->fqdn) . '/privkey.pem', ], 'upload_limit' => $this->upload_size, ], diff --git a/app/Models/User.php b/app/Models/User.php index 04ecbb0c4..3ccafe404 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -259,7 +259,7 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac */ public function getNameAttribute(): string { - return trim($this->name_first.' '.$this->name_last); + return trim($this->name_first . ' ' . $this->name_last); } /** @@ -379,7 +379,7 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac public function getFilamentAvatarUrl(): ?string { - return 'https://gravatar.com/avatar/'.md5(strtolower($this->email)); + return 'https://gravatar.com/avatar/' . md5(strtolower($this->email)); } public function canTarget(IlluminateModel $user): bool diff --git a/app/Notifications/AccountCreated.php b/app/Notifications/AccountCreated.php index 0f7cb77a7..0123435f7 100644 --- a/app/Notifications/AccountCreated.php +++ b/app/Notifications/AccountCreated.php @@ -33,13 +33,13 @@ class AccountCreated extends Notification implements ShouldQueue public function toMail(): MailMessage { $message = (new MailMessage()) - ->greeting('Hello '.$this->user->name.'!') - ->line('You are receiving this email because an account has been created for you on '.config('app.name').'.') - ->line('Username: '.$this->user->username) - ->line('Email: '.$this->user->email); + ->greeting('Hello ' . $this->user->name . '!') + ->line('You are receiving this email because an account has been created for you on ' . config('app.name') . '.') + ->line('Username: ' . $this->user->username) + ->line('Email: ' . $this->user->email); if (!is_null($this->token)) { - return $message->action('Setup Your Account', url('/auth/password/reset/'.$this->token.'?email='.urlencode($this->user->email))); + return $message->action('Setup Your Account', url('/auth/password/reset/' . $this->token . '?email=' . urlencode($this->user->email))); } return $message; diff --git a/app/Notifications/AddedToServer.php b/app/Notifications/AddedToServer.php index 56ddd4a40..647c33822 100644 --- a/app/Notifications/AddedToServer.php +++ b/app/Notifications/AddedToServer.php @@ -35,9 +35,9 @@ class AddedToServer extends Notification implements ShouldQueue public function toMail(): MailMessage { return (new MailMessage()) - ->greeting('Hello '.$this->server->user.'!') + ->greeting('Hello ' . $this->server->user . '!') ->line('You have been added as a subuser for the following server, allowing you certain control over the server.') - ->line('Server Name: '.$this->server->name) - ->action('Visit Server', url('/server/'.$this->server->uuid_short)); + ->line('Server Name: ' . $this->server->name) + ->action('Visit Server', url('/server/' . $this->server->uuid_short)); } } diff --git a/app/Notifications/MailTested.php b/app/Notifications/MailTested.php index 0dcbb4e9c..3bb816bf7 100644 --- a/app/Notifications/MailTested.php +++ b/app/Notifications/MailTested.php @@ -21,7 +21,7 @@ class MailTested extends Notification { return (new MailMessage()) ->subject('Panel Test Message') - ->greeting('Hello '.$this->user->name.'!') + ->greeting('Hello ' . $this->user->name . '!') ->line('This is a test of the Panel mail system. You\'re good to go!'); } } diff --git a/app/Notifications/RemovedFromServer.php b/app/Notifications/RemovedFromServer.php index 6c7899d6a..668d8f28a 100644 --- a/app/Notifications/RemovedFromServer.php +++ b/app/Notifications/RemovedFromServer.php @@ -36,9 +36,9 @@ class RemovedFromServer extends Notification implements ShouldQueue { return (new MailMessage()) ->error() - ->greeting('Hello '.$this->server->user.'.') + ->greeting('Hello ' . $this->server->user . '.') ->line('You have been removed as a subuser for the following server.') - ->line('Server Name: '.$this->server->name) + ->line('Server Name: ' . $this->server->name) ->action('Visit Panel', route('index')); } } diff --git a/app/Notifications/SendPasswordReset.php b/app/Notifications/SendPasswordReset.php index 381b731a7..434d1dd48 100644 --- a/app/Notifications/SendPasswordReset.php +++ b/app/Notifications/SendPasswordReset.php @@ -34,7 +34,7 @@ class SendPasswordReset extends Notification implements ShouldQueue return (new MailMessage()) ->subject('Reset Password') ->line('You are receiving this email because we received a password reset request for your account.') - ->action('Reset Password', url('/auth/password/reset/'.$this->token.'?email='.urlencode($notifiable->email))) + ->action('Reset Password', url('/auth/password/reset/' . $this->token . '?email=' . urlencode($notifiable->email))) ->line('If you did not request a password reset, no further action is required.'); } } diff --git a/app/Notifications/ServerInstalled.php b/app/Notifications/ServerInstalled.php index f23371bc3..fa6500afa 100644 --- a/app/Notifications/ServerInstalled.php +++ b/app/Notifications/ServerInstalled.php @@ -51,9 +51,9 @@ class ServerInstalled extends Notification implements ShouldQueue public function toMail(): MailMessage { return (new MailMessage()) - ->greeting('Hello '.$this->user->username.'.') + ->greeting('Hello ' . $this->user->username . '.') ->line('Your server has finished installing and is now ready for you to use.') - ->line('Server Name: '.$this->server->name) + ->line('Server Name: ' . $this->server->name) ->action('Login and Begin Using', route('index')); } } diff --git a/app/Policies/DefaultPolicies.php b/app/Policies/DefaultPolicies.php index e1d2890ab..3035cae19 100644 --- a/app/Policies/DefaultPolicies.php +++ b/app/Policies/DefaultPolicies.php @@ -12,7 +12,7 @@ trait DefaultPolicies */ public function viewAny(User $user): bool { - return $user->can('viewList '.$this->modelName); + return $user->can('viewList ' . $this->modelName); } /** @@ -20,7 +20,7 @@ trait DefaultPolicies */ public function view(User $user, Model $model): bool { - return $user->can('view '.$this->modelName, $model); + return $user->can('view ' . $this->modelName, $model); } /** @@ -28,7 +28,7 @@ trait DefaultPolicies */ public function create(User $user): bool { - return $user->can('create '.$this->modelName); + return $user->can('create ' . $this->modelName); } /** @@ -36,7 +36,7 @@ trait DefaultPolicies */ public function update(User $user, Model $model): bool { - return $user->can('update '.$this->modelName, $model); + return $user->can('update ' . $this->modelName, $model); } /** @@ -44,6 +44,6 @@ trait DefaultPolicies */ public function delete(User $user, Model $model): bool { - return $user->can('delete '.$this->modelName, $model); + return $user->can('delete ' . $this->modelName, $model); } } diff --git a/app/Repositories/Daemon/DaemonConfigurationRepository.php b/app/Repositories/Daemon/DaemonConfigurationRepository.php index 86b8418ea..52cda56dd 100644 --- a/app/Repositories/Daemon/DaemonConfigurationRepository.php +++ b/app/Repositories/Daemon/DaemonConfigurationRepository.php @@ -19,7 +19,7 @@ class DaemonConfigurationRepository extends DaemonRepository $response = $this ->getHttpClient() ->connectTimeout($connectTimeout) - ->get('/api/system'.(!is_null($version) ? '?v='.$version : '')); + ->get('/api/system' . (!is_null($version) ? '?v=' . $version : '')); } catch (TransferException $exception) { throw new DaemonConnectionException($exception); } diff --git a/app/Repositories/Daemon/DaemonServerRepository.php b/app/Repositories/Daemon/DaemonServerRepository.php index 8656adc74..ce91ece2b 100644 --- a/app/Repositories/Daemon/DaemonServerRepository.php +++ b/app/Repositories/Daemon/DaemonServerRepository.php @@ -96,7 +96,7 @@ class DaemonServerRepository extends DaemonRepository Assert::isInstanceOf($this->server, Server::class); try { - $this->getHttpClient()->delete('/api/servers/'.$this->server->uuid); + $this->getHttpClient()->delete('/api/servers/' . $this->server->uuid); } catch (TransferException $exception) { throw new DaemonConnectionException($exception); } @@ -192,7 +192,7 @@ class DaemonServerRepository extends DaemonRepository { Assert::isInstanceOf($this->server, Server::class); - $this->revokeJTIs([md5($id.$this->server->uuid)]); + $this->revokeJTIs([md5($id . $this->server->uuid)]); } /** diff --git a/app/Services/Acl/Api/AdminAcl.php b/app/Services/Acl/Api/AdminAcl.php index fc7b176ca..90ec6480a 100644 --- a/app/Services/Acl/Api/AdminAcl.php +++ b/app/Services/Acl/Api/AdminAcl.php @@ -62,7 +62,7 @@ class AdminAcl */ public static function check(ApiKey $key, string $resource, int $action = self::READ): bool { - return self::can(data_get($key, self::COLUMN_IDENTIFIER.$resource, self::NONE), $action); + return self::can(data_get($key, self::COLUMN_IDENTIFIER . $resource, self::NONE), $action); } /** diff --git a/app/Services/Backups/DownloadLinkService.php b/app/Services/Backups/DownloadLinkService.php index ed3867266..a167a1bb2 100644 --- a/app/Services/Backups/DownloadLinkService.php +++ b/app/Services/Backups/DownloadLinkService.php @@ -34,7 +34,7 @@ class DownloadLinkService 'backup_uuid' => $backup->uuid, 'server_uuid' => $backup->server->uuid, ]) - ->handle($backup->server->node, $user->id.$backup->server->uuid); + ->handle($backup->server->node, $user->id . $backup->server->uuid); return sprintf('%s/download/backup?token=%s', $backup->server->node->getConnectionAddress(), $token->toString()); } diff --git a/app/Services/Files/DeleteFilesService.php b/app/Services/Files/DeleteFilesService.php index f0a4f202c..1692923ed 100644 --- a/app/Services/Files/DeleteFilesService.php +++ b/app/Services/Files/DeleteFilesService.php @@ -30,7 +30,7 @@ class DeleteFilesService $pattern = basename($line); collect($this->daemonFileRepository->setServer($server)->getDirectory($path))->each(function ($item) use ($path, $pattern, $filesToDelete) { if (Str::is($pattern, $item['name'])) { - $filesToDelete->push($path.'/'.$item['name']); + $filesToDelete->push($path . '/' . $item['name']); } }); } diff --git a/app/Services/Helpers/AssetHashService.php b/app/Services/Helpers/AssetHashService.php index 304dabdfc..f94c32f3b 100644 --- a/app/Services/Helpers/AssetHashService.php +++ b/app/Services/Helpers/AssetHashService.php @@ -70,7 +70,7 @@ class AssetHashService $output .= " $key=\"$value\""; } - return $output.'>'; + return $output . '>'; } /** @@ -92,7 +92,7 @@ class AssetHashService $output .= " $key=\"$value\""; } - return $output.'>'; + return $output . '>'; } /** diff --git a/app/Services/Helpers/SoftwareVersionService.php b/app/Services/Helpers/SoftwareVersionService.php index 18c212d99..7d50203bf 100644 --- a/app/Services/Helpers/SoftwareVersionService.php +++ b/app/Services/Helpers/SoftwareVersionService.php @@ -127,13 +127,13 @@ class SoftwareVersionService $head = explode(' ', file_get_contents(base_path('.git/HEAD'))); if (array_key_exists(1, $head)) { - $path = base_path('.git/'.trim($head[1])); + $path = base_path('.git/' . trim($head[1])); } } if (isset($path) && file_exists($path)) { return [ - 'version' => 'canary ('.substr(file_get_contents($path), 0, 8).')', + 'version' => 'canary (' . substr(file_get_contents($path), 0, 8) . ')', 'is_git' => true, ]; } diff --git a/app/Services/Servers/StartupCommandService.php b/app/Services/Servers/StartupCommandService.php index 1c6ff1be2..4703eb075 100644 --- a/app/Services/Servers/StartupCommandService.php +++ b/app/Services/Servers/StartupCommandService.php @@ -15,7 +15,7 @@ class StartupCommandService $replace = [$server->memory, $server->allocation->ip, $server->allocation->port]; foreach ($server->variables as $variable) { - $find[] = '{{'.$variable->env_variable.'}}'; + $find[] = '{{' . $variable->env_variable . '}}'; $replace[] = ($variable->user_viewable && !$hideAllValues) ? ($variable->server_value ?? $variable->default_value) : '[hidden]'; } diff --git a/app/Services/Servers/TransferServerService.php b/app/Services/Servers/TransferServerService.php index 070f84f32..4312369dd 100644 --- a/app/Services/Servers/TransferServerService.php +++ b/app/Services/Servers/TransferServerService.php @@ -31,8 +31,8 @@ class TransferServerService Http::daemon($server->node)->post('/api/transfer', [ 'json' => [ 'server_id' => $server->uuid, - 'url' => $server->node->getConnectionAddress()."/api/servers/$server->uuid/archive", - 'token' => 'Bearer '.$token->toString(), + 'url' => $server->node->getConnectionAddress() . "/api/servers/$server->uuid/archive", + 'token' => 'Bearer ' . $token->toString(), 'server' => [ 'uuid' => $server->uuid, 'start_on_completion' => false, diff --git a/app/Services/Servers/VariableValidatorService.php b/app/Services/Servers/VariableValidatorService.php index 904e494d9..75f4a59b1 100644 --- a/app/Services/Servers/VariableValidatorService.php +++ b/app/Services/Servers/VariableValidatorService.php @@ -40,8 +40,8 @@ class VariableValidatorService $data = $rules = $customAttributes = []; foreach ($variables as $variable) { $data['environment'][$variable->env_variable] = array_get($fields, $variable->env_variable); - $rules['environment.'.$variable->env_variable] = $variable->rules; - $customAttributes['environment.'.$variable->env_variable] = trans('validation.internal.variable_value', ['env' => $variable->name]); + $rules['environment.' . $variable->env_variable] = $variable->rules; + $customAttributes['environment.' . $variable->env_variable] = trans('validation.internal.variable_value', ['env' => $variable->name]); } $validator = $this->validator->make($data, $rules, [], $customAttributes); diff --git a/app/Services/Subusers/SubuserCreationService.php b/app/Services/Subusers/SubuserCreationService.php index 0439afd52..0f9508ba7 100644 --- a/app/Services/Subusers/SubuserCreationService.php +++ b/app/Services/Subusers/SubuserCreationService.php @@ -39,7 +39,7 @@ class SubuserCreationService if (!$user) { // Just cap the username generated at 64 characters at most and then append a random string // to the end to make it "unique"... - $username = substr(preg_replace('/([^\w\.-]+)/', '', strtok($email, '@')), 0, 64).Str::random(3); + $username = substr(preg_replace('/([^\w\.-]+)/', '', strtok($email, '@')), 0, 64) . Str::random(3); $user = $this->userCreationService->handle([ 'email' => $email, diff --git a/app/Traits/EnvironmentWriterTrait.php b/app/Traits/EnvironmentWriterTrait.php index 201116571..cb5bef047 100644 --- a/app/Traits/EnvironmentWriterTrait.php +++ b/app/Traits/EnvironmentWriterTrait.php @@ -37,10 +37,10 @@ trait EnvironmentWriterTrait $key = strtoupper($key); $saveValue = sprintf('%s=%s', $key, $this->escapeEnvironmentValue($value ?? '')); - if (preg_match_all('/^'.$key.'=(.*)$/m', $saveContents) < 1) { - $saveContents = $saveContents.PHP_EOL.$saveValue; + if (preg_match_all('/^' . $key . '=(.*)$/m', $saveContents) < 1) { + $saveContents = $saveContents . PHP_EOL . $saveValue; } else { - $saveContents = preg_replace('/^'.$key.'=(.*)$/m', $saveValue, $saveContents); + $saveContents = preg_replace('/^' . $key . '=(.*)$/m', $saveValue, $saveContents); } }); diff --git a/app/Transformers/Api/Client/ActivityLogTransformer.php b/app/Transformers/Api/Client/ActivityLogTransformer.php index 8ae888142..e2f3650f4 100644 --- a/app/Transformers/Api/Client/ActivityLogTransformer.php +++ b/app/Transformers/Api/Client/ActivityLogTransformer.php @@ -62,7 +62,7 @@ class ActivityLogTransformer extends BaseClientTransformer if (!is_array($value)) { // Perform some directory normalization at this point. if ($key === 'directory') { - $value = str_replace('//', '/', '/'.trim($value, '/').'/'); + $value = str_replace('//', '/', '/' . trim($value, '/') . '/'); } return [$key => $value]; @@ -94,7 +94,7 @@ class ActivityLogTransformer extends BaseClientTransformer return false; } - $str = trans('activity.'.str_replace(':', '.', $model->event)); + $str = trans('activity.' . str_replace(':', '.', $model->event)); preg_match_all('/:(?[\w.-]+\w)(?:[^\w:]?|$)/', $str, $matches); $exclude = array_merge($matches['key'], ['ip', 'useragent', 'using_sftp']); diff --git a/app/Transformers/Api/Client/UserTransformer.php b/app/Transformers/Api/Client/UserTransformer.php index 06160a722..f875463e5 100644 --- a/app/Transformers/Api/Client/UserTransformer.php +++ b/app/Transformers/Api/Client/UserTransformer.php @@ -28,7 +28,7 @@ class UserTransformer extends BaseClientTransformer 'first_name' => $user->name_first, 'last_name' => $user->name_last, 'language' => $user->language, - 'image' => 'https://gravatar.com/avatar/'.md5(Str::lower($user->email)), // deprecated + 'image' => 'https://gravatar.com/avatar/' . md5(Str::lower($user->email)), // deprecated 'admin' => $user->isRootAdmin(), // deprecated, use "root_admin" 'root_admin' => $user->isRootAdmin(), '2fa_enabled' => (bool) $user->use_totp, diff --git a/bootstrap/tests.php b/bootstrap/tests.php index 148613856..a80e0b27f 100644 --- a/bootstrap/tests.php +++ b/bootstrap/tests.php @@ -5,9 +5,9 @@ use NunoMaduro\Collision\Provider; use Illuminate\Contracts\Console\Kernel; use Symfony\Component\Console\Output\ConsoleOutput; -require __DIR__.'/../vendor/autoload.php'; +require __DIR__ . '/../vendor/autoload.php'; -$app = require __DIR__.'/app.php'; +$app = require __DIR__ . '/app.php'; /** @var \App\Console\Kernel $kernel */ $kernel = $app->make(Kernel::class); @@ -23,10 +23,10 @@ $kernel->bootstrap(); $output = new ConsoleOutput(); -$prefix = 'database.connections.'.config('database.default'); +$prefix = 'database.connections.' . config('database.default'); if (!Str::contains(config("$prefix.database"), 'test')) { - $output->writeln(PHP_EOL.'Cannot run test process against non-testing database.'); - $output->writeln(PHP_EOL.'Environment is currently pointed at: "'.config("$prefix.database").'".'); + $output->writeln(PHP_EOL . 'Cannot run test process against non-testing database.'); + $output->writeln(PHP_EOL . 'Environment is currently pointed at: "' . config("$prefix.database") . '".'); exit(1); } @@ -35,11 +35,11 @@ if (!Str::contains(config("$prefix.database"), 'test')) { * running the tests. */ if (!env('SKIP_MIGRATIONS')) { - $output->writeln(PHP_EOL.'Refreshing database for Integration tests...'); + $output->writeln(PHP_EOL . 'Refreshing database for Integration tests...'); $kernel->call('migrate:fresh'); - $output->writeln('Seeding database for Integration tests...'.PHP_EOL); + $output->writeln('Seeding database for Integration tests...' . PHP_EOL); $kernel->call('db:seed'); } else { - $output->writeln(PHP_EOL.'Skipping database migrations...'.PHP_EOL); + $output->writeln(PHP_EOL . 'Skipping database migrations...' . PHP_EOL); } diff --git a/database/Factories/NodeFactory.php b/database/Factories/NodeFactory.php index 7d0ac25a1..19a1fbf7b 100644 --- a/database/Factories/NodeFactory.php +++ b/database/Factories/NodeFactory.php @@ -24,7 +24,7 @@ class NodeFactory extends Factory return [ 'uuid' => Uuid::uuid4()->toString(), 'public' => true, - 'name' => 'FactoryNode_'.Str::random(10), + 'name' => 'FactoryNode_' . Str::random(10), 'fqdn' => $this->faker->unique()->ipv4(), 'scheme' => 'http', 'behind_proxy' => false, diff --git a/database/Factories/UserFactory.php b/database/Factories/UserFactory.php index 6284e7471..3c6003cc2 100644 --- a/database/Factories/UserFactory.php +++ b/database/Factories/UserFactory.php @@ -27,8 +27,8 @@ class UserFactory extends Factory return [ 'external_id' => null, 'uuid' => Uuid::uuid4()->toString(), - 'username' => $this->faker->userName().'_'.Str::random(10), - 'email' => Str::random(32).'@example.com', + 'username' => $this->faker->userName() . '_' . Str::random(10), + 'email' => Str::random(32) . '@example.com', 'name_first' => $this->faker->firstName(), 'name_last' => $this->faker->lastName(), 'password' => $password ?: $password = bcrypt('password'), diff --git a/database/Seeders/EggSeeder.php b/database/Seeders/EggSeeder.php index 3053bfa76..dcbc4f25c 100644 --- a/database/Seeders/EggSeeder.php +++ b/database/Seeders/EggSeeder.php @@ -47,9 +47,9 @@ class EggSeeder extends Seeder */ protected function parseEggFiles($name) { - $files = new \DirectoryIterator(database_path('Seeders/eggs/'.kebab_case($name))); + $files = new \DirectoryIterator(database_path('Seeders/eggs/' . kebab_case($name))); - $this->command->alert('Updating Eggs for: '.$name); + $this->command->alert('Updating Eggs for: ' . $name); /** @var \DirectoryIterator $file */ foreach ($files as $file) { if (!$file->isFile() || !$file->isReadable()) { @@ -71,10 +71,10 @@ class EggSeeder extends Seeder if ($egg instanceof Egg) { $this->importerService->fromFile($file, $egg); - $this->command->info('Updated '.$decoded['name']); + $this->command->info('Updated ' . $decoded['name']); } else { $this->importerService->fromFile($file); - $this->command->comment('Created '.$decoded['name']); + $this->command->comment('Created ' . $decoded['name']); } } diff --git a/database/migrations/2017_03_11_215455_ChangeServiceVariablesValidationRules.php b/database/migrations/2017_03_11_215455_ChangeServiceVariablesValidationRules.php index 5d8d38e6d..b96b2ba24 100644 --- a/database/migrations/2017_03_11_215455_ChangeServiceVariablesValidationRules.php +++ b/database/migrations/2017_03_11_215455_ChangeServiceVariablesValidationRules.php @@ -17,7 +17,7 @@ return new class extends Migration DB::transaction(function () { foreach (DB::table('service_variables')->get() as $variable) { - $variable->rules = ($variable->required) ? 'required|regex:'.$variable->rules : 'regex:'.$variable->rules; + $variable->rules = ($variable->required) ? 'required|regex:' . $variable->rules : 'regex:' . $variable->rules; $variable->save(); } }); diff --git a/database/migrations/2017_09_13_211810_UpdateOldPermissionsToPointToNewScheduleSystem.php b/database/migrations/2017_09_13_211810_UpdateOldPermissionsToPointToNewScheduleSystem.php index 4e50c9a84..aca8afb6c 100644 --- a/database/migrations/2017_09_13_211810_UpdateOldPermissionsToPointToNewScheduleSystem.php +++ b/database/migrations/2017_09_13_211810_UpdateOldPermissionsToPointToNewScheduleSystem.php @@ -17,7 +17,7 @@ return new class extends Migration continue; } - $newPermission = $parts[0].'-'.str_replace('task', 'schedule', $parts[1]); + $newPermission = $parts[0] . '-' . str_replace('task', 'schedule', $parts[1]); DB::table('permissions')->where('id', '=', $record->id)->update(['permission' => $newPermission]); } @@ -35,7 +35,7 @@ return new class extends Migration continue; } - $newPermission = $parts[0].'-'.str_replace('schedule', 'task', $parts[1]); + $newPermission = $parts[0] . '-' . str_replace('schedule', 'task', $parts[1]); DB::table('permissions')->where('id', '=', $record->id)->update(['permission' => $newPermission]); } diff --git a/database/migrations/2017_09_23_173628_RemoveDaemonSecretFromServersTable.php b/database/migrations/2017_09_23_173628_RemoveDaemonSecretFromServersTable.php index e99078b66..ab2e8056e 100644 --- a/database/migrations/2017_09_23_173628_RemoveDaemonSecretFromServersTable.php +++ b/database/migrations/2017_09_23_173628_RemoveDaemonSecretFromServersTable.php @@ -21,7 +21,7 @@ return new class extends Migration $inserts[] = [ 'user_id' => $server->owner_id, 'server_id' => $server->id, - 'secret' => DaemonKeyRepositoryInterface::INTERNAL_KEY_IDENTIFIER.str_random(40), + 'secret' => DaemonKeyRepositoryInterface::INTERNAL_KEY_IDENTIFIER . str_random(40), 'expires_at' => Carbon::now()->addMinutes(config('panel.api.key_expire_time', 720))->toDateTimeString(), 'created_at' => Carbon::now()->toDateTimeString(), 'updated_at' => Carbon::now()->toDateTimeString(), diff --git a/database/migrations/2017_09_23_185022_RemoveDaemonSecretFromSubusersTable.php b/database/migrations/2017_09_23_185022_RemoveDaemonSecretFromSubusersTable.php index 60b0d6358..9090be407 100644 --- a/database/migrations/2017_09_23_185022_RemoveDaemonSecretFromSubusersTable.php +++ b/database/migrations/2017_09_23_185022_RemoveDaemonSecretFromSubusersTable.php @@ -19,7 +19,7 @@ return new class extends Migration $inserts[] = [ 'user_id' => $subuser->user_id, 'server_id' => $subuser->server_id, - 'secret' => DaemonKeyRepositoryInterface::INTERNAL_KEY_IDENTIFIER.str_random(40), + 'secret' => DaemonKeyRepositoryInterface::INTERNAL_KEY_IDENTIFIER . str_random(40), 'expires_at' => Carbon::now()->addMinutes(config('panel.api.key_expire_time', 720))->toDateTimeString(), 'created_at' => Carbon::now()->toDateTimeString(), 'updated_at' => Carbon::now()->toDateTimeString(), diff --git a/database/migrations/2020_03_22_163911_merge_permissions_table_into_subusers.php b/database/migrations/2020_03_22_163911_merge_permissions_table_into_subusers.php index 2a10ba96c..6a9280b5f 100644 --- a/database/migrations/2020_03_22_163911_merge_permissions_table_into_subusers.php +++ b/database/migrations/2020_03_22_163911_merge_permissions_table_into_subusers.php @@ -112,9 +112,9 @@ return new class extends Migration } if (!empty($values)) { - $string = 'VALUES '.implode(', ', array_fill(0, count($values) / 2, '(?, ?)')); + $string = 'VALUES ' . implode(', ', array_fill(0, count($values) / 2, '(?, ?)')); - DB::insert('INSERT INTO permissions(`subuser_id`, `permission`) '.$string, $values); + DB::insert('INSERT INTO permissions(`subuser_id`, `permission`) ' . $string, $values); } } diff --git a/database/migrations/2020_04_10_141024_store_node_tokens_as_encrypted_value.php b/database/migrations/2020_04_10_141024_store_node_tokens_as_encrypted_value.php index d98bbc3c8..911461d70 100644 --- a/database/migrations/2020_04_10_141024_store_node_tokens_as_encrypted_value.php +++ b/database/migrations/2020_04_10_141024_store_node_tokens_as_encrypted_value.php @@ -53,7 +53,7 @@ return new class extends Migration DB::transaction(function () { foreach (DB::select('SELECT id, daemon_token_id, daemon_token FROM nodes') as $datum) { DB::update('UPDATE nodes SET daemon_token = ? WHERE id = ?', [ - $datum->daemon_token_id.decrypt($datum->daemon_token), + $datum->daemon_token_id . decrypt($datum->daemon_token), $datum->id, ]); } diff --git a/pint.json b/pint.json index 9427029f8..99fa80d3a 100644 --- a/pint.json +++ b/pint.json @@ -1,6 +1,7 @@ { "preset": "laravel", "rules": { + "concat_space": false, "not_operator_with_successor_space": false, "ordered_imports": false } diff --git a/tests/Assertions/AssertsActivityLogged.php b/tests/Assertions/AssertsActivityLogged.php index ed33729e4..23a3461b1 100644 --- a/tests/Assertions/AssertsActivityLogged.php +++ b/tests/Assertions/AssertsActivityLogged.php @@ -35,7 +35,7 @@ trait AssertsActivityLogged public function assertActivitySubjects(string $event, Model|array $subjects): void { if (is_array($subjects)) { - \Webmozart\Assert\Assert::lessThanEq(count(func_get_args()), 2, 'Invalid call to '.__METHOD__.': cannot provide additional arguments if providing an array.'); + \Webmozart\Assert\Assert::lessThanEq(count(func_get_args()), 2, 'Invalid call to ' . __METHOD__ . ': cannot provide additional arguments if providing an array.'); } else { $subjects = array_slice(func_get_args(), 1); } diff --git a/tests/Assertions/MiddlewareAttributeAssertionsTrait.php b/tests/Assertions/MiddlewareAttributeAssertionsTrait.php index 4a8441abe..ab24f0311 100644 --- a/tests/Assertions/MiddlewareAttributeAssertionsTrait.php +++ b/tests/Assertions/MiddlewareAttributeAssertionsTrait.php @@ -11,7 +11,7 @@ trait MiddlewareAttributeAssertionsTrait */ public function assertRequestHasAttribute(string $attribute): void { - Assert::assertTrue($this->request->attributes->has($attribute), 'Assert that request mock has '.$attribute.' attribute.'); + Assert::assertTrue($this->request->attributes->has($attribute), 'Assert that request mock has ' . $attribute . ' attribute.'); } /** @@ -19,7 +19,7 @@ trait MiddlewareAttributeAssertionsTrait */ public function assertRequestMissingAttribute(string $attribute): void { - Assert::assertFalse($this->request->attributes->has($attribute), 'Assert that request mock does not have '.$attribute.' attribute.'); + Assert::assertFalse($this->request->attributes->has($attribute), 'Assert that request mock does not have ' . $attribute . ' attribute.'); } /** diff --git a/tests/Integration/Api/Application/ApplicationApiIntegrationTestCase.php b/tests/Integration/Api/Application/ApplicationApiIntegrationTestCase.php index 02b674a9a..c104a3eae 100644 --- a/tests/Integration/Api/Application/ApplicationApiIntegrationTestCase.php +++ b/tests/Integration/Api/Application/ApplicationApiIntegrationTestCase.php @@ -38,7 +38,7 @@ abstract class ApplicationApiIntegrationTestCase extends IntegrationTestCase $this ->withHeader('Accept', 'application/vnd.panel.v1+json') - ->withHeader('Authorization', 'Bearer '.$this->key->identifier.$this->key->token); + ->withHeader('Authorization', 'Bearer ' . $this->key->identifier . $this->key->token); } public function getApiUser(): User @@ -58,7 +58,7 @@ abstract class ApplicationApiIntegrationTestCase extends IntegrationTestCase { $this->key = $this->createApiKey($user, $permissions); - $this->withHeader('Authorization', 'Bearer '.$this->key->identifier.$this->key->token); + $this->withHeader('Authorization', 'Bearer ' . $this->key->identifier . $this->key->token); return $this->key; } diff --git a/tests/Integration/Api/Application/EggControllerTest.php b/tests/Integration/Api/Application/EggControllerTest.php index 62ab2422f..14a41cd6a 100644 --- a/tests/Integration/Api/Application/EggControllerTest.php +++ b/tests/Integration/Api/Application/EggControllerTest.php @@ -48,7 +48,7 @@ class EggControllerTest extends ApplicationApiIntegrationTestCase $this->assertSame( $expected, $actual, - 'Unable to find JSON fragment: '.PHP_EOL.PHP_EOL."[$expected]".PHP_EOL.PHP_EOL.'within'.PHP_EOL.PHP_EOL."[$actual]." + 'Unable to find JSON fragment: ' . PHP_EOL . PHP_EOL . "[$expected]" . PHP_EOL . PHP_EOL . 'within' . PHP_EOL . PHP_EOL . "[$actual]." ); } } @@ -60,7 +60,7 @@ class EggControllerTest extends ApplicationApiIntegrationTestCase { $egg = Egg::query()->findOrFail(1); - $response = $this->getJson('/api/application/eggs/'.$egg->id); + $response = $this->getJson('/api/application/eggs/' . $egg->id); $response->assertStatus(Response::HTTP_OK); $response->assertJsonStructure([ 'object', @@ -82,7 +82,7 @@ class EggControllerTest extends ApplicationApiIntegrationTestCase { $egg = Egg::query()->findOrFail(1); - $response = $this->getJson('/api/application/eggs/'.$egg->id.'?include=servers,variables'); + $response = $this->getJson('/api/application/eggs/' . $egg->id . '?include=servers,variables'); $response->assertStatus(Response::HTTP_OK); $response->assertJsonStructure([ 'object', diff --git a/tests/Integration/Api/Application/Users/ExternalUserControllerTest.php b/tests/Integration/Api/Application/Users/ExternalUserControllerTest.php index 4ef873c43..24f3996eb 100644 --- a/tests/Integration/Api/Application/Users/ExternalUserControllerTest.php +++ b/tests/Integration/Api/Application/Users/ExternalUserControllerTest.php @@ -16,7 +16,7 @@ class ExternalUserControllerTest extends ApplicationApiIntegrationTestCase { $user = User::factory()->create(['external_id' => Str::random()]); - $response = $this->getJson('/api/application/users/external/'.$user->external_id); + $response = $this->getJson('/api/application/users/external/' . $user->external_id); $response->assertStatus(Response::HTTP_OK); $response->assertJsonCount(2); $response->assertJsonStructure([ @@ -64,7 +64,7 @@ class ExternalUserControllerTest extends ApplicationApiIntegrationTestCase $user = User::factory()->create(['external_id' => Str::random()]); $this->createNewDefaultApiKey($this->getApiUser(), ['r_users' => 0]); - $response = $this->getJson('/api/application/users/external/'.$user->external_id); + $response = $this->getJson('/api/application/users/external/' . $user->external_id); $this->assertAccessDeniedJson($response); } } diff --git a/tests/Integration/Api/Application/Users/UserControllerTest.php b/tests/Integration/Api/Application/Users/UserControllerTest.php index 04ba5c2e6..6787ff1f4 100644 --- a/tests/Integration/Api/Application/Users/UserControllerTest.php +++ b/tests/Integration/Api/Application/Users/UserControllerTest.php @@ -89,7 +89,7 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase { $user = User::factory()->create(); - $response = $this->getJson('/api/application/users/'.$user->id); + $response = $this->getJson('/api/application/users/' . $user->id); $response->assertStatus(Response::HTTP_OK); $response->assertJsonCount(2); $response->assertJsonStructure([ @@ -124,7 +124,7 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase $user = User::factory()->create(); $server = $this->createServerModel(['user_id' => $user->id]); - $response = $this->getJson('/api/application/users/'.$user->id.'?include=servers'); + $response = $this->getJson('/api/application/users/' . $user->id . '?include=servers'); $response->assertStatus(Response::HTTP_OK); $response->assertJsonCount(2); $response->assertJsonStructure([ @@ -157,7 +157,7 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase $user = User::factory()->create(); $this->createServerModel(['user_id' => $user->id]); - $response = $this->getJson('/api/application/users/'.$user->id.'?include=servers'); + $response = $this->getJson('/api/application/users/' . $user->id . '?include=servers'); $response->assertStatus(Response::HTTP_OK); $response->assertJsonCount(2)->assertJsonCount(1, 'attributes.relationships'); $response->assertJsonStructure([ @@ -199,7 +199,7 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase $user = User::factory()->create(); $this->createNewDefaultApiKey($this->getApiUser(), ['r_users' => 0]); - $response = $this->getJson('/api/application/users/'.$user->id); + $response = $this->getJson('/api/application/users/' . $user->id); $this->assertAccessDeniedJson($response); } @@ -242,7 +242,7 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase { $user = User::factory()->create(); - $response = $this->patchJson('/api/application/users/'.$user->id, [ + $response = $this->patchJson('/api/application/users/' . $user->id, [ 'username' => 'new.test.name', 'email' => 'new@emailtest.com', 'first_name' => $user->name_first, @@ -272,7 +272,7 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase $user = User::factory()->create(); $this->assertDatabaseHas('users', ['id' => $user->id]); - $response = $this->delete('/api/application/users/'.$user->id); + $response = $this->delete('/api/application/users/' . $user->id); $response->assertStatus(Response::HTTP_NO_CONTENT); $this->assertDatabaseMissing('users', ['id' => $user->id]); diff --git a/tests/Integration/Api/Client/AccountControllerTest.php b/tests/Integration/Api/Client/AccountControllerTest.php index 38ce80fa9..ccca6818d 100644 --- a/tests/Integration/Api/Client/AccountControllerTest.php +++ b/tests/Integration/Api/Client/AccountControllerTest.php @@ -28,7 +28,7 @@ class AccountControllerTest extends ClientApiIntegrationTestCase 'first_name' => $user->name_first, 'last_name' => $user->name_last, 'language' => 'en', - 'image' => 'https://gravatar.com/avatar/'.md5(Str::lower($user->email)), + 'image' => 'https://gravatar.com/avatar/' . md5(Str::lower($user->email)), 'admin' => false, 'root_admin' => false, '2fa_enabled' => false, @@ -47,7 +47,7 @@ class AccountControllerTest extends ClientApiIntegrationTestCase $user = User::factory()->create(); $response = $this->actingAs($user)->putJson('/api/client/account/email', [ - 'email' => $email = Str::random().'@example.com', + 'email' => $email = Str::random() . '@example.com', 'password' => 'password', ]); diff --git a/tests/Integration/Api/Client/ApiKeyControllerTest.php b/tests/Integration/Api/Client/ApiKeyControllerTest.php index 27662a173..462875c59 100644 --- a/tests/Integration/Api/Client/ApiKeyControllerTest.php +++ b/tests/Integration/Api/Client/ApiKeyControllerTest.php @@ -83,7 +83,7 @@ class ApiKeyControllerTest extends ClientApiIntegrationTestCase { $ips = []; for ($i = 0; $i < 100; $i++) { - $ips[] = '127.0.0.'.$i; + $ips[] = '127.0.0.' . $i; } $this->actingAs(User::factory()->create()) @@ -162,7 +162,7 @@ class ApiKeyControllerTest extends ClientApiIntegrationTestCase 'key_type' => ApiKey::TYPE_ACCOUNT, ]); - $response = $this->actingAs($user)->delete('/api/client/account/api-keys/'.$key->identifier); + $response = $this->actingAs($user)->delete('/api/client/account/api-keys/' . $key->identifier); $response->assertStatus(Response::HTTP_NO_CONTENT); $this->assertDatabaseMissing('api_keys', ['id' => $key->id]); @@ -205,7 +205,7 @@ class ApiKeyControllerTest extends ClientApiIntegrationTestCase ]); $this->actingAs($user) - ->deleteJson('/api/client/account/api-keys/'.$key->identifier) + ->deleteJson('/api/client/account/api-keys/' . $key->identifier) ->assertNotFound(); $this->assertDatabaseHas('api_keys', ['id' => $key->id]); @@ -226,7 +226,7 @@ class ApiKeyControllerTest extends ClientApiIntegrationTestCase ]); $this->actingAs($user) - ->deleteJson('/api/client/account/api-keys/'.$key->identifier) + ->deleteJson('/api/client/account/api-keys/' . $key->identifier) ->assertNotFound(); $this->assertDatabaseHas('api_keys', ['id' => $key->id]); diff --git a/tests/Integration/Api/Client/ClientApiIntegrationTestCase.php b/tests/Integration/Api/Client/ClientApiIntegrationTestCase.php index 86e9a202d..70db04614 100644 --- a/tests/Integration/Api/Client/ClientApiIntegrationTestCase.php +++ b/tests/Integration/Api/Client/ClientApiIntegrationTestCase.php @@ -69,7 +69,7 @@ abstract class ClientApiIntegrationTestCase extends IntegrationTestCase throw new \InvalidArgumentException(sprintf('Cannot create link for Model of type %s', class_basename($model))); } - return $link.($append ? '/'.ltrim($append, '/') : ''); + return $link . ($append ? '/' . ltrim($append, '/') : ''); } /** diff --git a/tests/Integration/Api/Client/ClientControllerTest.php b/tests/Integration/Api/Client/ClientControllerTest.php index 4e5e26b27..e4059f694 100644 --- a/tests/Integration/Api/Client/ClientControllerTest.php +++ b/tests/Integration/Api/Client/ClientControllerTest.php @@ -298,7 +298,7 @@ class ClientControllerTest extends ClientApiIntegrationTestCase $this->createServerModel(['user_id' => $users[1]->id]); $this->createServerModel(['user_id' => $users[2]->id]); - $response = $this->actingAs($users[0])->getJson('/api/client?type='.$type); + $response = $this->actingAs($users[0])->getJson('/api/client?type=' . $type); $response->assertOk(); $response->assertJsonCount(0, 'data'); diff --git a/tests/Integration/Api/Client/Server/Allocation/AllocationAuthorizationTest.php b/tests/Integration/Api/Client/Server/Allocation/AllocationAuthorizationTest.php index f1d93f8ad..6cd798e16 100644 --- a/tests/Integration/Api/Client/Server/Allocation/AllocationAuthorizationTest.php +++ b/tests/Integration/Api/Client/Server/Allocation/AllocationAuthorizationTest.php @@ -30,20 +30,20 @@ class AllocationAuthorizationTest extends ClientApiIntegrationTestCase // This is the only valid call for this test, accessing the allocation for the same // server that the API user is the owner of. - $response = $this->actingAs($user)->json($method, $this->link($server1, '/network/allocations/'.$allocation1->id.$endpoint)); + $response = $this->actingAs($user)->json($method, $this->link($server1, '/network/allocations/' . $allocation1->id . $endpoint)); $this->assertTrue($response->status() <= 204 || $response->status() === 400 || $response->status() === 422); // This request fails because the allocation is valid for that server but the user // making the request is not authorized to perform that action. - $this->actingAs($user)->json($method, $this->link($server2, '/network/allocations/'.$allocation2->id.$endpoint))->assertForbidden(); + $this->actingAs($user)->json($method, $this->link($server2, '/network/allocations/' . $allocation2->id . $endpoint))->assertForbidden(); // Both of these should report a 404 error due to the allocations being linked to // servers that are not the same as the server in the request, or are assigned // to a server for which the user making the request has no access to. - $this->actingAs($user)->json($method, $this->link($server1, '/network/allocations/'.$allocation2->id.$endpoint))->assertNotFound(); - $this->actingAs($user)->json($method, $this->link($server1, '/network/allocations/'.$allocation3->id.$endpoint))->assertNotFound(); - $this->actingAs($user)->json($method, $this->link($server2, '/network/allocations/'.$allocation3->id.$endpoint))->assertNotFound(); - $this->actingAs($user)->json($method, $this->link($server3, '/network/allocations/'.$allocation3->id.$endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server1, '/network/allocations/' . $allocation2->id . $endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server1, '/network/allocations/' . $allocation3->id . $endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server2, '/network/allocations/' . $allocation3->id . $endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server3, '/network/allocations/' . $allocation3->id . $endpoint))->assertNotFound(); } public static function methodDataProvider(): array diff --git a/tests/Integration/Api/Client/Server/Backup/BackupAuthorizationTest.php b/tests/Integration/Api/Client/Server/Backup/BackupAuthorizationTest.php index c91c2e3a1..472364d78 100644 --- a/tests/Integration/Api/Client/Server/Backup/BackupAuthorizationTest.php +++ b/tests/Integration/Api/Client/Server/Backup/BackupAuthorizationTest.php @@ -38,20 +38,20 @@ class BackupAuthorizationTest extends ClientApiIntegrationTestCase // This is the only valid call for this test, accessing the backup for the same // server that the API user is the owner of. - $this->actingAs($user)->json($method, $this->link($server1, '/backups/'.$backup1->uuid.$endpoint)) + $this->actingAs($user)->json($method, $this->link($server1, '/backups/' . $backup1->uuid . $endpoint)) ->assertStatus($method === 'DELETE' ? 204 : 200); // This request fails because the backup is valid for that server but the user // making the request is not authorized to perform that action. - $this->actingAs($user)->json($method, $this->link($server2, '/backups/'.$backup2->uuid.$endpoint))->assertForbidden(); + $this->actingAs($user)->json($method, $this->link($server2, '/backups/' . $backup2->uuid . $endpoint))->assertForbidden(); // Both of these should report a 404 error due to the backup being linked to // servers that are not the same as the server in the request, or are assigned // to a server for which the user making the request has no access to. - $this->actingAs($user)->json($method, $this->link($server1, '/backups/'.$backup2->uuid.$endpoint))->assertNotFound(); - $this->actingAs($user)->json($method, $this->link($server1, '/backups/'.$backup3->uuid.$endpoint))->assertNotFound(); - $this->actingAs($user)->json($method, $this->link($server2, '/backups/'.$backup3->uuid.$endpoint))->assertNotFound(); - $this->actingAs($user)->json($method, $this->link($server3, '/backups/'.$backup3->uuid.$endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server1, '/backups/' . $backup2->uuid . $endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server1, '/backups/' . $backup3->uuid . $endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server2, '/backups/' . $backup3->uuid . $endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server3, '/backups/' . $backup3->uuid . $endpoint))->assertNotFound(); } public static function methodDataProvider(): array diff --git a/tests/Integration/Api/Client/Server/Database/DatabaseAuthorizationTest.php b/tests/Integration/Api/Client/Server/Database/DatabaseAuthorizationTest.php index 2c8320812..b95778104 100644 --- a/tests/Integration/Api/Client/Server/Database/DatabaseAuthorizationTest.php +++ b/tests/Integration/Api/Client/Server/Database/DatabaseAuthorizationTest.php @@ -40,20 +40,20 @@ class DatabaseAuthorizationTest extends ClientApiIntegrationTestCase // This is the only valid call for this test, accessing the database for the same // server that the API user is the owner of. - $this->actingAs($user)->json($method, $this->link($server1, '/databases/'.$database1->id.$endpoint)) + $this->actingAs($user)->json($method, $this->link($server1, '/databases/' . $database1->id . $endpoint)) ->assertStatus($method === 'DELETE' ? 204 : 200); // This request fails because the database is valid for that server but the user // making the request is not authorized to perform that action. - $this->actingAs($user)->json($method, $this->link($server2, '/databases/'.$database2->id.$endpoint))->assertForbidden(); + $this->actingAs($user)->json($method, $this->link($server2, '/databases/' . $database2->id . $endpoint))->assertForbidden(); // Both of these should report a 404 error due to the database being linked to // servers that are not the same as the server in the request, or are assigned // to a server for which the user making the request has no access to. - $this->actingAs($user)->json($method, $this->link($server1, '/databases/'.$database2->id.$endpoint))->assertNotFound(); - $this->actingAs($user)->json($method, $this->link($server1, '/databases/'.$database3->id.$endpoint))->assertNotFound(); - $this->actingAs($user)->json($method, $this->link($server2, '/databases/'.$database3->id.$endpoint))->assertNotFound(); - $this->actingAs($user)->json($method, $this->link($server3, '/databases/'.$database3->id.$endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server1, '/databases/' . $database2->id . $endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server1, '/databases/' . $database3->id . $endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server2, '/databases/' . $database3->id . $endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server3, '/databases/' . $database3->id . $endpoint))->assertNotFound(); } public static function methodDataProvider(): array diff --git a/tests/Integration/Api/Client/Server/Schedule/GetServerSchedulesTest.php b/tests/Integration/Api/Client/Server/Schedule/GetServerSchedulesTest.php index 5900e67f2..7d019178b 100644 --- a/tests/Integration/Api/Client/Server/Schedule/GetServerSchedulesTest.php +++ b/tests/Integration/Api/Client/Server/Schedule/GetServerSchedulesTest.php @@ -47,13 +47,13 @@ class GetServerSchedulesTest extends ClientApiIntegrationTestCase $response->assertJsonCount(1, 'data'); } - $response->assertJsonCount(1, $prefix.'attributes.relationships.tasks.data'); + $response->assertJsonCount(1, $prefix . 'attributes.relationships.tasks.data'); - $response->assertJsonPath($prefix.'object', Schedule::RESOURCE_NAME); - $response->assertJsonPath($prefix.'attributes.relationships.tasks.data.0.object', Task::RESOURCE_NAME); + $response->assertJsonPath($prefix . 'object', Schedule::RESOURCE_NAME); + $response->assertJsonPath($prefix . 'attributes.relationships.tasks.data.0.object', Task::RESOURCE_NAME); - $this->assertJsonTransformedWith($response->json($prefix.'attributes'), $schedule); - $this->assertJsonTransformedWith($response->json($prefix.'attributes.relationships.tasks.data.0.attributes'), $task); + $this->assertJsonTransformedWith($response->json($prefix . 'attributes'), $schedule); + $this->assertJsonTransformedWith($response->json($prefix . 'attributes.relationships.tasks.data.0.attributes'), $task); } /** diff --git a/tests/Integration/Api/Client/Server/Schedule/ScheduleAuthorizationTest.php b/tests/Integration/Api/Client/Server/Schedule/ScheduleAuthorizationTest.php index 011187e71..b6777a748 100644 --- a/tests/Integration/Api/Client/Server/Schedule/ScheduleAuthorizationTest.php +++ b/tests/Integration/Api/Client/Server/Schedule/ScheduleAuthorizationTest.php @@ -38,20 +38,20 @@ class ScheduleAuthorizationTest extends ClientApiIntegrationTestCase // This is the only valid call for this test, accessing the schedule for the same // server that the API user is the owner of. - $response = $this->actingAs($user)->json($method, $this->link($server1, '/schedules/'.$schedule1->id.$endpoint)); + $response = $this->actingAs($user)->json($method, $this->link($server1, '/schedules/' . $schedule1->id . $endpoint)); $this->assertTrue($response->status() <= 204 || $response->status() === 400 || $response->status() === 422); // This request fails because the schedule is valid for that server but the user // making the request is not authorized to perform that action. - $this->actingAs($user)->json($method, $this->link($server2, '/schedules/'.$schedule2->id.$endpoint))->assertForbidden(); + $this->actingAs($user)->json($method, $this->link($server2, '/schedules/' . $schedule2->id . $endpoint))->assertForbidden(); // Both of these should report a 404 error due to the schedules being linked to // servers that are not the same as the server in the request, or are assigned // to a server for which the user making the request has no access to. - $this->actingAs($user)->json($method, $this->link($server1, '/schedules/'.$schedule2->id.$endpoint))->assertNotFound(); - $this->actingAs($user)->json($method, $this->link($server1, '/schedules/'.$schedule3->id.$endpoint))->assertNotFound(); - $this->actingAs($user)->json($method, $this->link($server2, '/schedules/'.$schedule3->id.$endpoint))->assertNotFound(); - $this->actingAs($user)->json($method, $this->link($server3, '/schedules/'.$schedule3->id.$endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server1, '/schedules/' . $schedule2->id . $endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server1, '/schedules/' . $schedule3->id . $endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server2, '/schedules/' . $schedule3->id . $endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server3, '/schedules/' . $schedule3->id . $endpoint))->assertNotFound(); } public static function methodDataProvider(): array diff --git a/tests/Integration/Api/Client/Server/Startup/GetStartupAndVariablesTest.php b/tests/Integration/Api/Client/Server/Startup/GetStartupAndVariablesTest.php index b11d06346..88cc6ed6f 100644 --- a/tests/Integration/Api/Client/Server/Startup/GetStartupAndVariablesTest.php +++ b/tests/Integration/Api/Client/Server/Startup/GetStartupAndVariablesTest.php @@ -33,7 +33,7 @@ class GetStartupAndVariablesTest extends ClientApiIntegrationTestCase ])->save(); $server = $server->refresh(); - $response = $this->actingAs($user)->getJson($this->link($server).'/startup'); + $response = $this->actingAs($user)->getJson($this->link($server) . '/startup'); $response->assertOk(); $response->assertJsonPath('meta.startup_command', 'java bungeecord.jar --version [hidden]'); @@ -52,10 +52,10 @@ class GetStartupAndVariablesTest extends ClientApiIntegrationTestCase public function testStartupDataIsNotReturnedWithoutPermission(): void { [$user, $server] = $this->generateTestAccount([Permission::ACTION_WEBSOCKET_CONNECT]); - $this->actingAs($user)->getJson($this->link($server).'/startup')->assertForbidden(); + $this->actingAs($user)->getJson($this->link($server) . '/startup')->assertForbidden(); $user2 = User::factory()->create(); - $this->actingAs($user2)->getJson($this->link($server).'/startup')->assertNotFound(); + $this->actingAs($user2)->getJson($this->link($server) . '/startup')->assertNotFound(); } public static function permissionsDataProvider(): array diff --git a/tests/Integration/Api/Client/Server/Startup/UpdateStartupVariableTest.php b/tests/Integration/Api/Client/Server/Startup/UpdateStartupVariableTest.php index c5471ec11..e9c8af97c 100644 --- a/tests/Integration/Api/Client/Server/Startup/UpdateStartupVariableTest.php +++ b/tests/Integration/Api/Client/Server/Startup/UpdateStartupVariableTest.php @@ -23,7 +23,7 @@ class UpdateStartupVariableTest extends ClientApiIntegrationTestCase 'startup' => 'java {{SERVER_JARFILE}} --version {{BUNGEE_VERSION}}', ])->save(); - $response = $this->actingAs($user)->putJson($this->link($server).'/startup/variable', [ + $response = $this->actingAs($user)->putJson($this->link($server) . '/startup/variable', [ 'key' => 'BUNGEE_VERSION', 'value' => '1.2.3', ]); @@ -32,7 +32,7 @@ class UpdateStartupVariableTest extends ClientApiIntegrationTestCase $response->assertJsonPath('errors.0.code', 'ValidationException'); $response->assertJsonPath('errors.0.detail', 'The value may only contain letters and numbers.'); - $response = $this->actingAs($user)->putJson($this->link($server).'/startup/variable', [ + $response = $this->actingAs($user)->putJson($this->link($server) . '/startup/variable', [ 'key' => 'BUNGEE_VERSION', 'value' => '123', ]); @@ -62,7 +62,7 @@ class UpdateStartupVariableTest extends ClientApiIntegrationTestCase $server->fill(['egg_id' => $egg->id])->save(); $server->refresh(); - $response = $this->actingAs($user)->putJson($this->link($server).'/startup/variable', [ + $response = $this->actingAs($user)->putJson($this->link($server) . '/startup/variable', [ 'key' => 'BUNGEE_VERSION', 'value' => '123', ]); @@ -71,7 +71,7 @@ class UpdateStartupVariableTest extends ClientApiIntegrationTestCase $response->assertJsonPath('errors.0.code', 'BadRequestHttpException'); $response->assertJsonPath('errors.0.detail', 'The environment variable you are trying to edit does not exist.'); - $response = $this->actingAs($user)->putJson($this->link($server).'/startup/variable', [ + $response = $this->actingAs($user)->putJson($this->link($server) . '/startup/variable', [ 'key' => 'SERVER_JARFILE', 'value' => 'server2.jar', ]); @@ -100,7 +100,7 @@ class UpdateStartupVariableTest extends ClientApiIntegrationTestCase $server->refresh(); - $response = $this->actingAs($user)->putJson($this->link($server).'/startup/variable', [ + $response = $this->actingAs($user)->putJson($this->link($server) . '/startup/variable', [ 'key' => 'SERVER_JARFILE', 'value' => 'server2.jar', ]); @@ -125,7 +125,7 @@ class UpdateStartupVariableTest extends ClientApiIntegrationTestCase $server->fill(['egg_id' => $egg->id])->save(); $server->refresh(); - $response = $this->actingAs($user)->putJson($this->link($server).'/startup/variable', [ + $response = $this->actingAs($user)->putJson($this->link($server) . '/startup/variable', [ 'key' => 'BUNGEE_VERSION', 'value' => '', ]); @@ -141,10 +141,10 @@ class UpdateStartupVariableTest extends ClientApiIntegrationTestCase public function testStartupVariableCannotBeUpdatedIfNotUserViewable(): void { [$user, $server] = $this->generateTestAccount([Permission::ACTION_WEBSOCKET_CONNECT]); - $this->actingAs($user)->putJson($this->link($server).'/startup/variable')->assertForbidden(); + $this->actingAs($user)->putJson($this->link($server) . '/startup/variable')->assertForbidden(); $user2 = User::factory()->create(); - $this->actingAs($user2)->putJson($this->link($server).'/startup/variable')->assertNotFound(); + $this->actingAs($user2)->putJson($this->link($server) . '/startup/variable')->assertNotFound(); } public static function permissionsDataProvider(): array diff --git a/tests/Integration/Api/Client/Server/Subuser/CreateServerSubuserTest.php b/tests/Integration/Api/Client/Server/Subuser/CreateServerSubuserTest.php index f9c6595f4..7175a7cc7 100644 --- a/tests/Integration/Api/Client/Server/Subuser/CreateServerSubuserTest.php +++ b/tests/Integration/Api/Client/Server/Subuser/CreateServerSubuserTest.php @@ -23,7 +23,7 @@ class CreateServerSubuserTest extends ClientApiIntegrationTestCase { [$user, $server] = $this->generateTestAccount($permissions); - $response = $this->actingAs($user)->postJson($this->link($server).'/users', [ + $response = $this->actingAs($user)->postJson($this->link($server) . '/users', [ 'email' => $email = $this->faker->email(), 'permissions' => [ Permission::ACTION_USER_CREATE, @@ -60,7 +60,7 @@ class CreateServerSubuserTest extends ClientApiIntegrationTestCase Permission::ACTION_CONTROL_CONSOLE, ]); - $response = $this->actingAs($user)->postJson($this->link($server).'/users', [ + $response = $this->actingAs($user)->postJson($this->link($server) . '/users', [ 'email' => $this->faker->email(), 'permissions' => [ Permission::ACTION_USER_CREATE, @@ -80,9 +80,9 @@ class CreateServerSubuserTest extends ClientApiIntegrationTestCase { [$user, $server] = $this->generateTestAccount(); - $email = str_repeat(Str::random(35), 7).'@gmail.com'; // 255 is the hard limit for the column in MySQL. + $email = str_repeat(Str::random(35), 7) . '@gmail.com'; // 255 is the hard limit for the column in MySQL. - $response = $this->actingAs($user)->postJson($this->link($server).'/users', [ + $response = $this->actingAs($user)->postJson($this->link($server) . '/users', [ 'email' => $email, 'permissions' => [ Permission::ACTION_USER_CREATE, @@ -91,8 +91,8 @@ class CreateServerSubuserTest extends ClientApiIntegrationTestCase $response->assertOk(); - $response = $this->actingAs($user)->postJson($this->link($server).'/users', [ - 'email' => $email.'.au', + $response = $this->actingAs($user)->postJson($this->link($server) . '/users', [ + 'email' => $email . '.au', 'permissions' => [ Permission::ACTION_USER_CREATE, ], @@ -114,7 +114,7 @@ class CreateServerSubuserTest extends ClientApiIntegrationTestCase /** @var \App\Models\User $existing */ $existing = User::factory()->create(['email' => $this->faker->email()]); - $response = $this->actingAs($user)->postJson($this->link($server).'/users', [ + $response = $this->actingAs($user)->postJson($this->link($server) . '/users', [ 'email' => $existing->email, 'permissions' => [ Permission::ACTION_USER_CREATE, @@ -134,7 +134,7 @@ class CreateServerSubuserTest extends ClientApiIntegrationTestCase { [$user, $server] = $this->generateTestAccount(); - $response = $this->actingAs($user)->postJson($this->link($server).'/users', [ + $response = $this->actingAs($user)->postJson($this->link($server) . '/users', [ 'email' => $email = $this->faker->email(), 'permissions' => [ Permission::ACTION_USER_CREATE, @@ -143,7 +143,7 @@ class CreateServerSubuserTest extends ClientApiIntegrationTestCase $response->assertOk(); - $response = $this->actingAs($user)->postJson($this->link($server).'/users', [ + $response = $this->actingAs($user)->postJson($this->link($server) . '/users', [ 'email' => $email, 'permissions' => [ Permission::ACTION_USER_CREATE, diff --git a/tests/Integration/Api/Client/Server/Subuser/DeleteSubuserTest.php b/tests/Integration/Api/Client/Server/Subuser/DeleteSubuserTest.php index 21067ad1b..bbd97f4b3 100644 --- a/tests/Integration/Api/Client/Server/Subuser/DeleteSubuserTest.php +++ b/tests/Integration/Api/Client/Server/Subuser/DeleteSubuserTest.php @@ -31,7 +31,7 @@ class DeleteSubuserTest extends ClientApiIntegrationTestCase $real = Uuid::uuid4()->toString(); // Generate a UUID that lines up with a user in the database if it were to be cast to an int. - $uuid = $differentUser->id.substr($real, strlen((string) $differentUser->id)); + $uuid = $differentUser->id . substr($real, strlen((string) $differentUser->id)); /** @var \App\Models\User $subuser */ $subuser = User::factory()->create(['uuid' => $uuid]); @@ -44,11 +44,11 @@ class DeleteSubuserTest extends ClientApiIntegrationTestCase $mock->expects('setServer->revokeUserJTI')->with($subuser->id)->andReturnUndefined(); - $this->actingAs($user)->deleteJson($this->link($server)."/users/$subuser->uuid")->assertNoContent(); + $this->actingAs($user)->deleteJson($this->link($server) . "/users/$subuser->uuid")->assertNoContent(); // Try the same test, but this time with a UUID that if cast to an int (shouldn't) line up with // anything in the database. - $uuid = '18180000'.substr(Uuid::uuid4()->toString(), 8); + $uuid = '18180000' . substr(Uuid::uuid4()->toString(), 8); /** @var \App\Models\User $subuser */ $subuser = User::factory()->create(['uuid' => $uuid]); @@ -60,6 +60,6 @@ class DeleteSubuserTest extends ClientApiIntegrationTestCase $mock->expects('setServer->revokeUserJTI')->with($subuser->id)->andReturnUndefined(); - $this->actingAs($user)->deleteJson($this->link($server)."/users/$subuser->uuid")->assertNoContent(); + $this->actingAs($user)->deleteJson($this->link($server) . "/users/$subuser->uuid")->assertNoContent(); } } diff --git a/tests/Integration/Api/Client/Server/Subuser/SubuserAuthorizationTest.php b/tests/Integration/Api/Client/Server/Subuser/SubuserAuthorizationTest.php index 03bd42ee9..ab844d0b3 100644 --- a/tests/Integration/Api/Client/Server/Subuser/SubuserAuthorizationTest.php +++ b/tests/Integration/Api/Client/Server/Subuser/SubuserAuthorizationTest.php @@ -41,12 +41,12 @@ class SubuserAuthorizationTest extends ClientApiIntegrationTestCase } // This route is acceptable since they're accessing a subuser on their own server. - $this->actingAs($user)->json($method, $this->link($server1, '/users/'.$internal->uuid))->assertStatus($method === 'POST' ? 422 : ($method === 'DELETE' ? 204 : 200)); + $this->actingAs($user)->json($method, $this->link($server1, '/users/' . $internal->uuid))->assertStatus($method === 'POST' ? 422 : ($method === 'DELETE' ? 204 : 200)); // This route can be revealed since the subuser belongs to the correct server, but // errors out with a 403 since $user does not have the right permissions for this. - $this->actingAs($user)->json($method, $this->link($server2, '/users/'.$internal->uuid))->assertForbidden(); - $this->actingAs($user)->json($method, $this->link($server3, '/users/'.$internal->uuid))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server2, '/users/' . $internal->uuid))->assertForbidden(); + $this->actingAs($user)->json($method, $this->link($server3, '/users/' . $internal->uuid))->assertNotFound(); } public static function methodDataProvider(): array diff --git a/tests/Integration/Api/Daemon/DaemonAuthenticateTest.php b/tests/Integration/Api/Daemon/DaemonAuthenticateTest.php index 1dde92284..b18b3e5e8 100644 --- a/tests/Integration/Api/Daemon/DaemonAuthenticateTest.php +++ b/tests/Integration/Api/Daemon/DaemonAuthenticateTest.php @@ -69,7 +69,7 @@ class DaemonAuthenticateTest extends MiddlewareTestCase $this->expectException(AccessDeniedHttpException::class); $this->request->expects('route->getName')->withNoArgs()->andReturn('random.route'); - $this->request->expects('bearerToken')->withNoArgs()->andReturn($node->daemon_token_id.'.random_string_123'); + $this->request->expects('bearerToken')->withNoArgs()->andReturn($node->daemon_token_id . '.random_string_123'); $this->getMiddleware()->handle($this->request, $this->getClosureAssertions()); } @@ -98,7 +98,7 @@ class DaemonAuthenticateTest extends MiddlewareTestCase $node->save(); $this->request->expects('route->getName')->withNoArgs()->andReturn('random.route'); - $this->request->expects('bearerToken')->withNoArgs()->andReturn($node->daemon_token_id.'.the_same'); + $this->request->expects('bearerToken')->withNoArgs()->andReturn($node->daemon_token_id . '.the_same'); $this->getMiddleware()->handle($this->request, $this->getClosureAssertions()); $this->assertRequestHasAttribute('node'); diff --git a/tests/Integration/Api/Remote/SftpAuthenticationControllerTest.php b/tests/Integration/Api/Remote/SftpAuthenticationControllerTest.php index da340cbb4..3236266dc 100644 --- a/tests/Integration/Api/Remote/SftpAuthenticationControllerTest.php +++ b/tests/Integration/Api/Remote/SftpAuthenticationControllerTest.php @@ -143,7 +143,7 @@ class SftpAuthenticationControllerTest extends IntegrationTestCase $this->setAuthorization($server->node); $this->postJson('/api/remote/sftp/auth', [ - 'username' => $user->username.'.'.$server->uuid_short, + 'username' => $user->username . '.' . $server->uuid_short, 'password' => 'foobar', ]) ->assertForbidden() @@ -173,7 +173,7 @@ class SftpAuthenticationControllerTest extends IntegrationTestCase $this->setAuthorization($server->node); $data = [ - 'username' => $user->username.'.'.$server->uuid_short, + 'username' => $user->username . '.' . $server->uuid_short, 'password' => 'foobar', ]; @@ -188,7 +188,7 @@ class SftpAuthenticationControllerTest extends IntegrationTestCase ->assertJsonPath('permissions.0', '*'); $this->setAuthorization(); - $data['username'] = $user->username.'.'.$this->server->uuid_short; + $data['username'] = $user->username . '.' . $this->server->uuid_short; $this->post('/api/remote/sftp/auth', $data) ->assertOk() @@ -220,7 +220,7 @@ class SftpAuthenticationControllerTest extends IntegrationTestCase */ protected function getUsername(bool $long = false): string { - return $this->user->username.'.'.($long ? $this->server->uuid : $this->server->uuid_short); + return $this->user->username . '.' . ($long ? $this->server->uuid : $this->server->uuid_short); } /** @@ -230,6 +230,6 @@ class SftpAuthenticationControllerTest extends IntegrationTestCase { $node = $node ?? $this->server->node; - $this->withHeader('Authorization', 'Bearer '.$node->daemon_token_id.'.'.$node->daemon_token); + $this->withHeader('Authorization', 'Bearer ' . $node->daemon_token_id . '.' . $node->daemon_token); } } diff --git a/tests/Integration/Http/Controllers/Admin/UserControllerTest.php b/tests/Integration/Http/Controllers/Admin/UserControllerTest.php index b82aa61ab..cbd263501 100644 --- a/tests/Integration/Http/Controllers/Admin/UserControllerTest.php +++ b/tests/Integration/Http/Controllers/Admin/UserControllerTest.php @@ -21,8 +21,8 @@ class UserControllerTest extends IntegrationTestCase { $unique = Str::random(); $users = [ - User::factory()->create(['username' => $unique.'_1']), - User::factory()->create(['username' => $unique.'_2']), + User::factory()->create(['username' => $unique . '_1']), + User::factory()->create(['username' => $unique . '_2']), ]; $servers = [ @@ -38,7 +38,7 @@ class UserControllerTest extends IntegrationTestCase /** @var \App\Http\Controllers\Admin\UserController $controller */ $controller = $this->app->make(UserController::class); - $request = Request::create('/admin/users?filter[username]='.$unique); + $request = Request::create('/admin/users?filter[username]=' . $unique); $this->app->instance(Request::class, $request); $data = $controller->index($request)->getData(); diff --git a/tests/Integration/Services/Databases/DatabaseManagementServiceTest.php b/tests/Integration/Services/Databases/DatabaseManagementServiceTest.php index 1584c2000..060ed9f10 100644 --- a/tests/Integration/Services/Databases/DatabaseManagementServiceTest.php +++ b/tests/Integration/Services/Databases/DatabaseManagementServiceTest.php @@ -29,7 +29,7 @@ class DatabaseManagementServiceTest extends IntegrationTestCase { $this->assertSame('s1_example', DatabaseManagementService::generateUniqueDatabaseName('example', 1)); $this->assertSame('s123_something_else', DatabaseManagementService::generateUniqueDatabaseName('something_else', 123)); - $this->assertSame('s123_'.str_repeat('a', 43), DatabaseManagementService::generateUniqueDatabaseName(str_repeat('a', 100), 123)); + $this->assertSame('s123_' . str_repeat('a', 43), DatabaseManagementService::generateUniqueDatabaseName(str_repeat('a', 100), 123)); } /** diff --git a/tests/Traits/Http/RequestMockHelpers.php b/tests/Traits/Http/RequestMockHelpers.php index d4da1bb23..46a71e26a 100644 --- a/tests/Traits/Http/RequestMockHelpers.php +++ b/tests/Traits/Http/RequestMockHelpers.php @@ -68,7 +68,7 @@ trait RequestMockHelpers { $this->request = m::mock($this->requestMockClass); if (!$this->request instanceof Request) { - throw new \InvalidArgumentException('Request mock class must be an instance of '.Request::class.' when mocked.'); + throw new \InvalidArgumentException('Request mock class must be an instance of ' . Request::class . ' when mocked.'); } $this->request->attributes = new ParameterBag(); diff --git a/tests/Traits/MocksUuids.php b/tests/Traits/MocksUuids.php index 8b6d2b0a8..8cfa4b7ce 100644 --- a/tests/Traits/MocksUuids.php +++ b/tests/Traits/MocksUuids.php @@ -19,7 +19,7 @@ trait MocksUuids public function setKnownUuidFactory(): void { $uuid = Uuid::fromString($this->getKnownUuid()); - $factoryMock = m::mock(UuidFactory::class.'[uuid4]', [ + $factoryMock = m::mock(UuidFactory::class . '[uuid4]', [ 'uuid4' => $uuid, ]); From c621d2dad51f4c2051c83db25a71982de719c266 Mon Sep 17 00:00:00 2001 From: Lance Pioch Date: Sun, 20 Oct 2024 11:55:47 -0400 Subject: [PATCH 7/7] Remove superfluous doc block --- app/Http/Controllers/Auth/ForgotPasswordController.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/Http/Controllers/Auth/ForgotPasswordController.php b/app/Http/Controllers/Auth/ForgotPasswordController.php index 26f537640..f58aded82 100644 --- a/app/Http/Controllers/Auth/ForgotPasswordController.php +++ b/app/Http/Controllers/Auth/ForgotPasswordController.php @@ -28,8 +28,6 @@ class ForgotPasswordController extends Controller /** * Get the response for a successful password reset link. - * - * @param string $response */ protected function sendResetLinkResponse(Request $request, string $response): JsonResponse {