diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index f5e4a4f2e..99801aa3b 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -25,6 +25,12 @@ jobs: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.REGISTRY_TOKEN }} + - name: Bump Version + if: "!contains(github.ref, 'develop')" + env: + REF: ${{ github.ref }} + run: | + sed -i "s/ 'version' => 'canary',/ 'version' => '${REF:11}',/" config/app.php - name: Release Production Build uses: docker/build-push-action@v2 if: "!contains(github.ref, 'develop')" diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4370210f2..5db691bc5 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -19,9 +19,9 @@ jobs: - 3306 options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 strategy: - fail-fast: true + fail-fast: false matrix: - php: [7.4] + php: [7.4, 8.0] name: PHP ${{ matrix.php }} steps: - name: checkout @@ -59,9 +59,9 @@ jobs: env: DB_CONNECTION: testing TESTING_DB_HOST: UNIT_NO_DB -# - name: execute integration tests -# run: vendor/bin/phpunit tests/Integration -# if: ${{ always() }} -# env: -# TESTING_DB_PORT: ${{ job.services.mysql.ports[3306] }} -# TESTING_DB_USERNAME: root + - name: execute integration tests + run: vendor/bin/phpunit tests/Integration + if: ${{ always() }} + env: + TESTING_DB_PORT: ${{ job.services.mysql.ports[3306] }} + TESTING_DB_USERNAME: root diff --git a/.php_cs b/.php_cs index e72e8e70a..2da2c8ee4 100644 --- a/.php_cs +++ b/.php_cs @@ -1,58 +1,43 @@ in([ - 'app', - 'bootstrap', - 'config', - 'database', - 'resources/lang', - 'routes', - 'tests', - ]); +use PhpCsFixer\Config; +use PhpCsFixer\Finder; -return PhpCsFixer\Config::create() +$finder = (new Finder)->in([ + 'app', + 'bootstrap', + 'config', + 'database', + 'resources/lang', + 'routes', + 'tests', +]); + +return (new Config) + ->setRiskyAllowed(true) + ->setFinder($finder) ->setRules([ '@Symfony' => true, '@PSR1' => true, '@PSR2' => true, + '@PSR12' => true, 'align_multiline_comment' => ['comment_type' => 'phpdocs_like'], - 'array_syntax' => ['syntax' => 'short'], - 'blank_line_before_return' => true, - 'blank_line_before_statement' => false, 'combine_consecutive_unsets' => true, 'concat_space' => ['spacing' => 'one'], - 'declare_equal_normalize' => ['space' => 'single'], 'heredoc_to_nowdoc' => true, - 'increment_style' => ['style' => 'post'], - 'linebreak_after_opening_tag' => true, - 'method_argument_space' => [ - 'ensure_fully_multiline' => false, - 'keep_multiple_spaces_after_comma' => false, - ], - 'new_with_braces' => false, 'no_alias_functions' => true, - 'no_multiline_whitespace_before_semicolons' => true, - 'no_superfluous_phpdoc_tags' => false, 'no_unreachable_default_argument_value' => true, 'no_useless_return' => true, - 'not_operator_with_successor_space' => true, 'ordered_imports' => [ 'sortAlgorithm' => 'length', ], - 'phpdoc_align' => false, - 'phpdoc_separation' => false, - 'protected_to_private' => false, 'psr0' => ['dir' => 'app'], 'psr4' => true, 'random_api_migration' => true, - 'single_line_throw' => false, - 'single_trait_insert_per_statement' => false, - 'standardize_not_equals' => true, 'ternary_to_null_coalescing' => true, 'yoda_style' => [ 'equal' => false, 'identical' => false, 'less_and_greater' => false, ], - ])->setRiskyAllowed(true)->setFinder($finder); + ]); diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f04a6d88..e09ae67f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,9 @@ This file is a running track of new features and fixes to each version of the pa This project follows [Semantic Versioning](http://semver.org) guidelines. +## v1.2.2 +* **[security]** Fixes authentication bypass allowing a user to take control of specific server actions such as executing schedules, rotating database passwords, and viewing or deleting a backup. + ## v1.2.1 ### Fixed * Fixes URL-encoding of filenames when working in the filemanager to fix issues when moving, renaming, or deleting files. diff --git a/app/Console/Commands/Environment/AppSettingsCommand.php b/app/Console/Commands/Environment/AppSettingsCommand.php index 01518d610..cfe1d7981 100644 --- a/app/Console/Commands/Environment/AppSettingsCommand.php +++ b/app/Console/Commands/Environment/AppSettingsCommand.php @@ -19,13 +19,13 @@ class AppSettingsCommand extends Command { use EnvironmentWriterTrait; - const ALLOWED_CACHE_DRIVERS = [ + public const ALLOWED_CACHE_DRIVERS = [ 'redis' => 'Redis (recommended)', 'memcached' => 'Memcached', 'file' => 'Filesystem', ]; - const ALLOWED_SESSION_DRIVERS = [ + public const ALLOWED_SESSION_DRIVERS = [ 'redis' => 'Redis (recommended)', 'memcached' => 'Memcached', 'database' => 'MySQL Database', @@ -33,7 +33,7 @@ class AppSettingsCommand extends Command 'cookie' => 'Cookie', ]; - const ALLOWED_QUEUE_DRIVERS = [ + public const ALLOWED_QUEUE_DRIVERS = [ 'redis' => 'Redis (recommended)', 'database' => 'MySQL Database', 'sync' => 'Sync', @@ -77,9 +77,6 @@ class AppSettingsCommand extends Command /** * AppSettingsCommand constructor. - * - * @param \Illuminate\Contracts\Config\Repository $config - * @param \Illuminate\Contracts\Console\Kernel $command */ public function __construct(ConfigRepository $config, Kernel $command) { @@ -102,43 +99,45 @@ class AppSettingsCommand extends Command $this->output->comment(trans('command/messages.environment.app.author_help')); $this->variables['APP_SERVICE_AUTHOR'] = $this->option('author') ?? $this->ask( - trans('command/messages.environment.app.author'), $this->config->get('pterodactyl.service.author', 'unknown@unknown.com') - ); + trans('command/messages.environment.app.author'), + $this->config->get('pterodactyl.service.author', 'unknown@unknown.com') + ); $this->output->comment(trans('command/messages.environment.app.app_url_help')); $this->variables['APP_URL'] = $this->option('url') ?? $this->ask( - trans('command/messages.environment.app.app_url'), $this->config->get('app.url', 'http://example.org') - ); + trans('command/messages.environment.app.app_url'), + $this->config->get('app.url', 'http://example.org') + ); $this->output->comment(trans('command/messages.environment.app.timezone_help')); $this->variables['APP_TIMEZONE'] = $this->option('timezone') ?? $this->anticipate( - trans('command/messages.environment.app.timezone'), - DateTimeZone::listIdentifiers(DateTimeZone::ALL), - $this->config->get('app.timezone') - ); + trans('command/messages.environment.app.timezone'), + DateTimeZone::listIdentifiers(DateTimeZone::ALL), + $this->config->get('app.timezone') + ); $selected = $this->config->get('cache.default', 'redis'); $this->variables['CACHE_DRIVER'] = $this->option('cache') ?? $this->choice( - trans('command/messages.environment.app.cache_driver'), - self::ALLOWED_CACHE_DRIVERS, - array_key_exists($selected, self::ALLOWED_CACHE_DRIVERS) ? $selected : null - ); + trans('command/messages.environment.app.cache_driver'), + self::ALLOWED_CACHE_DRIVERS, + array_key_exists($selected, self::ALLOWED_CACHE_DRIVERS) ? $selected : null + ); $selected = $this->config->get('session.driver', 'redis'); $this->variables['SESSION_DRIVER'] = $this->option('session') ?? $this->choice( - trans('command/messages.environment.app.session_driver'), - self::ALLOWED_SESSION_DRIVERS, - array_key_exists($selected, self::ALLOWED_SESSION_DRIVERS) ? $selected : null - ); + trans('command/messages.environment.app.session_driver'), + self::ALLOWED_SESSION_DRIVERS, + array_key_exists($selected, self::ALLOWED_SESSION_DRIVERS) ? $selected : null + ); $selected = $this->config->get('queue.default', 'redis'); $this->variables['QUEUE_CONNECTION'] = $this->option('queue') ?? $this->choice( - trans('command/messages.environment.app.queue_driver'), - self::ALLOWED_QUEUE_DRIVERS, - array_key_exists($selected, self::ALLOWED_QUEUE_DRIVERS) ? $selected : null - ); + trans('command/messages.environment.app.queue_driver'), + self::ALLOWED_QUEUE_DRIVERS, + array_key_exists($selected, self::ALLOWED_QUEUE_DRIVERS) ? $selected : null + ); - if (! is_null($this->option('settings-ui'))) { + if (!is_null($this->option('settings-ui'))) { $this->variables['APP_ENVIRONMENT_ONLY'] = $this->option('settings-ui') == 'true' ? 'false' : 'true'; } else { $this->variables['APP_ENVIRONMENT_ONLY'] = $this->confirm(trans('command/messages.environment.app.settings'), true) ? 'false' : 'true'; @@ -171,11 +170,12 @@ class AppSettingsCommand extends Command $this->output->note(trans('command/messages.environment.app.using_redis')); $this->variables['REDIS_HOST'] = $this->option('redis-host') ?? $this->ask( - trans('command/messages.environment.app.redis_host'), $this->config->get('database.redis.default.host') - ); + trans('command/messages.environment.app.redis_host'), + $this->config->get('database.redis.default.host') + ); $askForRedisPassword = true; - if (! empty($this->config->get('database.redis.default.password'))) { + if (!empty($this->config->get('database.redis.default.password'))) { $this->variables['REDIS_PASSWORD'] = $this->config->get('database.redis.default.password'); $askForRedisPassword = $this->confirm(trans('command/messages.environment.app.redis_pass_defined')); } @@ -183,8 +183,8 @@ class AppSettingsCommand extends Command if ($askForRedisPassword) { $this->output->comment(trans('command/messages.environment.app.redis_pass_help')); $this->variables['REDIS_PASSWORD'] = $this->option('redis-pass') ?? $this->output->askHidden( - trans('command/messages.environment.app.redis_password') - ); + trans('command/messages.environment.app.redis_password') + ); } if (empty($this->variables['REDIS_PASSWORD'])) { @@ -192,7 +192,8 @@ class AppSettingsCommand extends Command } $this->variables['REDIS_PORT'] = $this->option('redis-port') ?? $this->ask( - trans('command/messages.environment.app.redis_port'), $this->config->get('database.redis.default.port') - ); + trans('command/messages.environment.app.redis_port'), + $this->config->get('database.redis.default.port') + ); } } diff --git a/app/Console/Commands/Environment/DatabaseSettingsCommand.php b/app/Console/Commands/Environment/DatabaseSettingsCommand.php index 0a0e56b28..b983fcc9f 100644 --- a/app/Console/Commands/Environment/DatabaseSettingsCommand.php +++ b/app/Console/Commands/Environment/DatabaseSettingsCommand.php @@ -57,10 +57,6 @@ class DatabaseSettingsCommand extends Command /** * DatabaseSettingsCommand constructor. - * - * @param \Illuminate\Contracts\Config\Repository $config - * @param \Illuminate\Database\DatabaseManager $database - * @param \Illuminate\Contracts\Console\Kernel $console */ public function __construct(ConfigRepository $config, DatabaseManager $database, Kernel $console) { @@ -82,24 +78,28 @@ class DatabaseSettingsCommand extends Command { $this->output->note(trans('command/messages.environment.database.host_warning')); $this->variables['DB_HOST'] = $this->option('host') ?? $this->ask( - trans('command/messages.environment.database.host'), $this->config->get('database.connections.mysql.host', '127.0.0.1') - ); + trans('command/messages.environment.database.host'), + $this->config->get('database.connections.mysql.host', '127.0.0.1') + ); $this->variables['DB_PORT'] = $this->option('port') ?? $this->ask( - trans('command/messages.environment.database.port'), $this->config->get('database.connections.mysql.port', 3306) - ); + trans('command/messages.environment.database.port'), + $this->config->get('database.connections.mysql.port', 3306) + ); $this->variables['DB_DATABASE'] = $this->option('database') ?? $this->ask( - trans('command/messages.environment.database.database'), $this->config->get('database.connections.mysql.database', 'panel') - ); + trans('command/messages.environment.database.database'), + $this->config->get('database.connections.mysql.database', 'panel') + ); $this->output->note(trans('command/messages.environment.database.username_warning')); $this->variables['DB_USERNAME'] = $this->option('username') ?? $this->ask( - trans('command/messages.environment.database.username'), $this->config->get('database.connections.mysql.username', 'pterodactyl') - ); + trans('command/messages.environment.database.username'), + $this->config->get('database.connections.mysql.username', 'pterodactyl') + ); $askForMySQLPassword = true; - if (! empty($this->config->get('database.connections.mysql.password')) && $this->input->isInteractive()) { + if (!empty($this->config->get('database.connections.mysql.password')) && $this->input->isInteractive()) { $this->variables['DB_PASSWORD'] = $this->config->get('database.connections.mysql.password'); $askForMySQLPassword = $this->confirm(trans('command/messages.environment.database.password_defined')); } diff --git a/app/Console/Commands/Environment/EmailSettingsCommand.php b/app/Console/Commands/Environment/EmailSettingsCommand.php index add1296e6..6d98b63c3 100644 --- a/app/Console/Commands/Environment/EmailSettingsCommand.php +++ b/app/Console/Commands/Environment/EmailSettingsCommand.php @@ -47,8 +47,6 @@ class EmailSettingsCommand extends Command /** * EmailSettingsCommand constructor. - * - * @param \Illuminate\Contracts\Config\Repository $config */ public function __construct(ConfigRepository $config) { @@ -65,13 +63,15 @@ class EmailSettingsCommand extends Command public function handle() { $this->variables['MAIL_DRIVER'] = $this->option('driver') ?? $this->choice( - trans('command/messages.environment.mail.ask_driver'), [ + trans('command/messages.environment.mail.ask_driver'), + [ 'smtp' => 'SMTP Server', 'mail' => 'PHP\'s Internal Mail Function', 'mailgun' => 'Mailgun Transactional Email', 'mandrill' => 'Mandrill Transactional Email', 'postmark' => 'Postmarkapp Transactional Email', - ], $this->config->get('mail.driver', 'smtp') + ], + $this->config->get('mail.driver', 'smtp') ); $method = 'setup' . studly_case($this->variables['MAIL_DRIVER']) . 'DriverVariables'; @@ -80,16 +80,20 @@ class EmailSettingsCommand extends Command } $this->variables['MAIL_FROM'] = $this->option('email') ?? $this->ask( - trans('command/messages.environment.mail.ask_mail_from'), $this->config->get('mail.from.address') - ); + trans('command/messages.environment.mail.ask_mail_from'), + $this->config->get('mail.from.address') + ); $this->variables['MAIL_FROM_NAME'] = $this->option('from') ?? $this->ask( - trans('command/messages.environment.mail.ask_mail_name'), $this->config->get('mail.from.name') - ); + trans('command/messages.environment.mail.ask_mail_name'), + $this->config->get('mail.from.name') + ); $this->variables['MAIL_ENCRYPTION'] = $this->option('encryption') ?? $this->choice( - trans('command/messages.environment.mail.ask_encryption'), ['tls' => 'TLS', 'ssl' => 'SSL', '' => 'None'], $this->config->get('mail.encryption', 'tls') - ); + trans('command/messages.environment.mail.ask_encryption'), + ['tls' => 'TLS', 'ssl' => 'SSL', '' => 'None'], + $this->config->get('mail.encryption', 'tls') + ); $this->writeToEnvironment($this->variables); @@ -103,20 +107,23 @@ class EmailSettingsCommand extends Command private function setupSmtpDriverVariables() { $this->variables['MAIL_HOST'] = $this->option('host') ?? $this->ask( - trans('command/messages.environment.mail.ask_smtp_host'), $this->config->get('mail.host') - ); + trans('command/messages.environment.mail.ask_smtp_host'), + $this->config->get('mail.host') + ); $this->variables['MAIL_PORT'] = $this->option('port') ?? $this->ask( - trans('command/messages.environment.mail.ask_smtp_port'), $this->config->get('mail.port') - ); + trans('command/messages.environment.mail.ask_smtp_port'), + $this->config->get('mail.port') + ); $this->variables['MAIL_USERNAME'] = $this->option('username') ?? $this->ask( - trans('command/messages.environment.mail.ask_smtp_username'), $this->config->get('mail.username') - ); + trans('command/messages.environment.mail.ask_smtp_username'), + $this->config->get('mail.username') + ); $this->variables['MAIL_PASSWORD'] = $this->option('password') ?? $this->secret( - trans('command/messages.environment.mail.ask_smtp_password') - ); + trans('command/messages.environment.mail.ask_smtp_password') + ); } /** @@ -125,12 +132,14 @@ class EmailSettingsCommand extends Command private function setupMailgunDriverVariables() { $this->variables['MAILGUN_DOMAIN'] = $this->option('host') ?? $this->ask( - trans('command/messages.environment.mail.ask_mailgun_domain'), $this->config->get('services.mailgun.domain') - ); + trans('command/messages.environment.mail.ask_mailgun_domain'), + $this->config->get('services.mailgun.domain') + ); $this->variables['MAILGUN_SECRET'] = $this->option('password') ?? $this->ask( - trans('command/messages.environment.mail.ask_mailgun_secret'), $this->config->get('services.mailgun.secret') - ); + trans('command/messages.environment.mail.ask_mailgun_secret'), + $this->config->get('services.mailgun.secret') + ); } /** @@ -139,8 +148,9 @@ class EmailSettingsCommand extends Command private function setupMandrillDriverVariables() { $this->variables['MANDRILL_SECRET'] = $this->option('password') ?? $this->ask( - trans('command/messages.environment.mail.ask_mandrill_secret'), $this->config->get('services.mandrill.secret') - ); + trans('command/messages.environment.mail.ask_mandrill_secret'), + $this->config->get('services.mandrill.secret') + ); } /** @@ -152,7 +162,8 @@ class EmailSettingsCommand extends Command $this->variables['MAIL_HOST'] = 'smtp.postmarkapp.com'; $this->variables['MAIL_PORT'] = 587; $this->variables['MAIL_USERNAME'] = $this->variables['MAIL_PASSWORD'] = $this->option('username') ?? $this->ask( - trans('command/messages.environment.mail.ask_postmark_username'), $this->config->get('mail.username') - ); + trans('command/messages.environment.mail.ask_postmark_username'), + $this->config->get('mail.username') + ); } } diff --git a/app/Console/Commands/InfoCommand.php b/app/Console/Commands/InfoCommand.php index 80e9d23d3..e712fd1e4 100644 --- a/app/Console/Commands/InfoCommand.php +++ b/app/Console/Commands/InfoCommand.php @@ -37,9 +37,6 @@ class InfoCommand extends Command /** * VersionCommand constructor. - * - * @param \Illuminate\Contracts\Config\Repository $config - * @param \Pterodactyl\Services\Helpers\SoftwareVersionService $versionService */ public function __construct(ConfigRepository $config, SoftwareVersionService $versionService) { @@ -65,7 +62,7 @@ class InfoCommand extends Command $this->output->title('Application Configuration'); $this->table([], [ ['Environment', $this->formatText($this->config->get('app.env'), $this->config->get('app.env') === 'production' ?: 'bg=red')], - ['Debug Mode', $this->formatText($this->config->get('app.debug') ? 'Yes' : 'No', ! $this->config->get('app.debug') ?: 'bg=red')], + ['Debug Mode', $this->formatText($this->config->get('app.debug') ? 'Yes' : 'No', !$this->config->get('app.debug') ?: 'bg=red')], ['Installation URL', $this->config->get('app.url')], ['Installation Directory', base_path()], ['Timezone', $this->config->get('app.timezone')], @@ -103,6 +100,7 @@ class InfoCommand extends Command * * @param string $value * @param string $opts + * * @return string */ private function formatText($value, $opts = '') diff --git a/app/Console/Commands/Location/DeleteLocationCommand.php b/app/Console/Commands/Location/DeleteLocationCommand.php index b6782207e..898dbb924 100644 --- a/app/Console/Commands/Location/DeleteLocationCommand.php +++ b/app/Console/Commands/Location/DeleteLocationCommand.php @@ -42,9 +42,6 @@ class DeleteLocationCommand extends Command /** * DeleteLocationCommand constructor. - * - * @param \Pterodactyl\Contracts\Repository\LocationRepositoryInterface $repository - * @param \Pterodactyl\Services\Locations\LocationDeletionService $deletionService */ public function __construct( LocationDeletionService $deletionService, @@ -66,8 +63,9 @@ class DeleteLocationCommand extends Command { $this->locations = $this->locations ?? $this->repository->all(); $short = $this->option('short') ?? $this->anticipate( - trans('command/messages.location.ask_short'), $this->locations->pluck('short')->toArray() - ); + trans('command/messages.location.ask_short'), + $this->locations->pluck('short')->toArray() + ); $location = $this->locations->where('short', $short)->first(); if (is_null($location)) { diff --git a/app/Console/Commands/Location/MakeLocationCommand.php b/app/Console/Commands/Location/MakeLocationCommand.php index 791129727..db4d4e2e0 100644 --- a/app/Console/Commands/Location/MakeLocationCommand.php +++ b/app/Console/Commands/Location/MakeLocationCommand.php @@ -33,8 +33,6 @@ class MakeLocationCommand extends Command /** * Create a new command instance. - * - * @param \Pterodactyl\Services\Locations\LocationCreationService $creationService */ public function __construct(LocationCreationService $creationService) { diff --git a/app/Console/Commands/Maintenance/CleanServiceBackupFilesCommand.php b/app/Console/Commands/Maintenance/CleanServiceBackupFilesCommand.php index 1b5ded4d6..69a3b118a 100644 --- a/app/Console/Commands/Maintenance/CleanServiceBackupFilesCommand.php +++ b/app/Console/Commands/Maintenance/CleanServiceBackupFilesCommand.php @@ -9,7 +9,7 @@ use Illuminate\Contracts\Filesystem\Factory as FilesystemFactory; class CleanServiceBackupFilesCommand extends Command { - const BACKUP_THRESHOLD_MINUTES = 5; + public const BACKUP_THRESHOLD_MINUTES = 5; /** * @var string @@ -28,8 +28,6 @@ class CleanServiceBackupFilesCommand extends Command /** * CleanServiceBackupFilesCommand constructor. - * - * @param \Illuminate\Contracts\Filesystem\Factory $filesystem */ public function __construct(FilesystemFactory $filesystem) { diff --git a/app/Console/Commands/Maintenance/PruneOrphanedBackupsCommand.php b/app/Console/Commands/Maintenance/PruneOrphanedBackupsCommand.php index af4590d47..77ad86ad4 100644 --- a/app/Console/Commands/Maintenance/PruneOrphanedBackupsCommand.php +++ b/app/Console/Commands/Maintenance/PruneOrphanedBackupsCommand.php @@ -19,13 +19,10 @@ class PruneOrphanedBackupsCommand extends Command */ protected $description = 'Marks all backups that have not completed in the last "n" minutes as being failed.'; - /** - * @param \Pterodactyl\Repositories\Eloquent\BackupRepository $repository - */ public function handle(BackupRepository $repository) { $since = $this->option('since-minutes'); - if (! is_digit($since)) { + if (!is_digit($since)) { throw new InvalidArgumentException('The --since-minutes option must be a valid numeric digit.'); } @@ -34,7 +31,7 @@ class PruneOrphanedBackupsCommand extends Command ->whereDate('created_at', '<=', CarbonImmutable::now()->subMinutes($since)); $count = $query->count(); - if (! $count) { + if (!$count) { $this->info('There are no orphaned backups to be marked as failed.'); return; diff --git a/app/Console/Commands/Migration/CleanOrphanedApiKeysCommand.php b/app/Console/Commands/Migration/CleanOrphanedApiKeysCommand.php index e7d863992..7a7ff33a9 100644 --- a/app/Console/Commands/Migration/CleanOrphanedApiKeysCommand.php +++ b/app/Console/Commands/Migration/CleanOrphanedApiKeysCommand.php @@ -25,8 +25,6 @@ class CleanOrphanedApiKeysCommand extends Command /** * CleanOrphanedApiKeysCommand constructor. - * - * @param \Pterodactyl\Contracts\Repository\ApiKeyRepositoryInterface $repository */ public function __construct(ApiKeyRepositoryInterface $repository) { @@ -44,10 +42,11 @@ class CleanOrphanedApiKeysCommand extends Command { $count = $this->repository->findCountWhere([['key_type', '=', ApiKey::TYPE_NONE]]); $continue = $this->confirm( - 'This action will remove ' . $count . ' keys from the database. Are you sure you wish to continue?', false + 'This action will remove ' . $count . ' keys from the database. Are you sure you wish to continue?', + false ); - if (! $continue) { + if (!$continue) { return null; } diff --git a/app/Console/Commands/Overrides/KeyGenerateCommand.php b/app/Console/Commands/Overrides/KeyGenerateCommand.php index aa9294999..8aa30a9e8 100644 --- a/app/Console/Commands/Overrides/KeyGenerateCommand.php +++ b/app/Console/Commands/Overrides/KeyGenerateCommand.php @@ -12,13 +12,13 @@ class KeyGenerateCommand extends BaseKeyGenerateCommand */ public function handle() { - if (! empty(config('app.key')) && $this->input->isInteractive()) { + if (!empty(config('app.key')) && $this->input->isInteractive()) { $this->output->warning(trans('command/messages.key.warning')); - if (! $this->confirm(trans('command/messages.key.confirm'))) { + if (!$this->confirm(trans('command/messages.key.confirm'))) { return; } - if (! $this->confirm(trans('command/messages.key.final_confirm'))) { + if (!$this->confirm(trans('command/messages.key.final_confirm'))) { return; } } diff --git a/app/Console/Commands/Schedule/ProcessRunnableCommand.php b/app/Console/Commands/Schedule/ProcessRunnableCommand.php index 310b2f3b1..9e51feaeb 100644 --- a/app/Console/Commands/Schedule/ProcessRunnableCommand.php +++ b/app/Console/Commands/Schedule/ProcessRunnableCommand.php @@ -2,8 +2,8 @@ namespace Pterodactyl\Console\Commands\Schedule; -use Throwable; use Exception; +use Throwable; use Illuminate\Console\Command; use Pterodactyl\Models\Schedule; use Illuminate\Support\Facades\Log; @@ -54,7 +54,6 @@ class ProcessRunnableCommand extends Command * never throw an exception out, otherwise you'll end up killing the entire run group causing * any other schedules to not process correctly. * - * @param \Pterodactyl\Models\Schedule $schedule * @see https://github.com/pterodactyl/panel/issues/2609 */ protected function processSchedule(Schedule $schedule) diff --git a/app/Console/Commands/Server/BulkPowerActionCommand.php b/app/Console/Commands/Server/BulkPowerActionCommand.php index 32d9868b5..460df7194 100644 --- a/app/Console/Commands/Server/BulkPowerActionCommand.php +++ b/app/Console/Commands/Server/BulkPowerActionCommand.php @@ -27,8 +27,6 @@ class BulkPowerActionCommand extends Command /** * Handle the bulk power request. * - * @param \Pterodactyl\Repositories\Wings\DaemonPowerRepository $powerRepository - * @param \Illuminate\Validation\Factory $validator * @throws \Illuminate\Validation\ValidationException */ public function handle(DaemonPowerRepository $powerRepository, ValidatorFactory $validator) @@ -58,7 +56,7 @@ class BulkPowerActionCommand extends Command } $count = $this->getQueryBuilder($servers, $nodes)->count(); - if (! $this->confirm(trans('command/messages.server.power.confirm', ['action' => $action, 'count' => $count])) && $this->input->isInteractive()) { + if (!$this->confirm(trans('command/messages.server.power.confirm', ['action' => $action, 'count' => $count])) && $this->input->isInteractive()) { return; } @@ -87,8 +85,6 @@ class BulkPowerActionCommand extends Command /** * Returns the query builder instance that will return the servers that should be affected. * - * @param array $servers - * @param array $nodes * @return \Illuminate\Database\Eloquent\Builder */ protected function getQueryBuilder(array $servers, array $nodes) @@ -97,11 +93,11 @@ class BulkPowerActionCommand extends Command ->where('suspended', false) ->where('installed', Server::STATUS_INSTALLED); - if (! empty($nodes) && ! empty($servers)) { + if (!empty($nodes) && !empty($servers)) { $instance->whereIn('id', $servers)->orWhereIn('node_id', $nodes); - } else if (empty($nodes) && ! empty($servers)) { + } elseif (empty($nodes) && !empty($servers)) { $instance->whereIn('id', $servers); - } else if (! empty($nodes) && empty($servers)) { + } elseif (!empty($nodes) && empty($servers)) { $instance->whereIn('node_id', $nodes); } diff --git a/app/Console/Commands/Server/BulkReinstallActionCommand.php b/app/Console/Commands/Server/BulkReinstallActionCommand.php index a56cefc79..e6250cc30 100644 --- a/app/Console/Commands/Server/BulkReinstallActionCommand.php +++ b/app/Console/Commands/Server/BulkReinstallActionCommand.php @@ -47,10 +47,6 @@ class BulkReinstallActionCommand extends Command /** * BulkReinstallActionCommand constructor. - * - * @param \Pterodactyl\Repositories\Wings\DaemonServerRepository $daemonRepository - * @param \Pterodactyl\Services\Servers\ServerConfigurationStructureService $configurationStructureService - * @param \Pterodactyl\Repositories\Eloquent\ServerRepository $repository */ public function __construct( DaemonServerRepository $daemonRepository, @@ -71,7 +67,7 @@ class BulkReinstallActionCommand extends Command { $servers = $this->getServersToProcess(); - if (! $this->confirm(trans('command/messages.server.reinstall.confirm')) && $this->input->isInteractive()) { + if (!$this->confirm(trans('command/messages.server.reinstall.confirm')) && $this->input->isInteractive()) { return; } diff --git a/app/Console/Commands/User/DeleteUserCommand.php b/app/Console/Commands/User/DeleteUserCommand.php index 64885dca1..4c847257e 100644 --- a/app/Console/Commands/User/DeleteUserCommand.php +++ b/app/Console/Commands/User/DeleteUserCommand.php @@ -9,11 +9,10 @@ namespace Pterodactyl\Console\Commands\User; -use Webmozart\Assert\Assert; use Pterodactyl\Models\User; +use Webmozart\Assert\Assert; use Illuminate\Console\Command; use Pterodactyl\Services\Users\UserDeletionService; -use Pterodactyl\Contracts\Repository\UserRepositoryInterface; class DeleteUserCommand extends Command { @@ -39,10 +38,9 @@ class DeleteUserCommand extends Command /** * DeleteUserCommand constructor. - * - * @param \Pterodactyl\Services\Users\UserDeletionService $deletionService */ - public function __construct(UserDeletionService $deletionService) { + public function __construct(UserDeletionService $deletionService) + { parent::__construct(); $this->deletionService = $deletionService; @@ -50,6 +48,7 @@ class DeleteUserCommand extends Command /** * @return bool + * * @throws \Pterodactyl\Exceptions\DisplayException */ public function handle() @@ -79,7 +78,7 @@ class DeleteUserCommand extends Command } $this->table(['User ID', 'Email', 'Name'], $tableValues); - if (! $deleteUser = $this->ask(trans('command/messages.user.select_search_user'))) { + if (!$deleteUser = $this->ask(trans('command/messages.user.select_search_user'))) { return $this->handle(); } } else { @@ -92,11 +91,9 @@ class DeleteUserCommand extends Command $deleteUser = $results->first(); } - if ($this->confirm(trans('command/messages.user.confirm_delete')) || ! $this->input->isInteractive()) { + if ($this->confirm(trans('command/messages.user.confirm_delete')) || !$this->input->isInteractive()) { $this->deletionService->handle($deleteUser); $this->info(trans('command/messages.user.deleted')); } - - return; } } diff --git a/app/Console/Commands/User/DisableTwoFactorCommand.php b/app/Console/Commands/User/DisableTwoFactorCommand.php index f2cab910d..05e98c045 100644 --- a/app/Console/Commands/User/DisableTwoFactorCommand.php +++ b/app/Console/Commands/User/DisableTwoFactorCommand.php @@ -31,8 +31,6 @@ class DisableTwoFactorCommand extends Command /** * DisableTwoFactorCommand constructor. - * - * @param \Pterodactyl\Contracts\Repository\UserRepositoryInterface $repository */ public function __construct(UserRepositoryInterface $repository) { diff --git a/app/Console/Commands/User/MakeUserCommand.php b/app/Console/Commands/User/MakeUserCommand.php index 35060b53f..f981a2f23 100644 --- a/app/Console/Commands/User/MakeUserCommand.php +++ b/app/Console/Commands/User/MakeUserCommand.php @@ -31,8 +31,6 @@ class MakeUserCommand extends Command /** * MakeUserCommand constructor. - * - * @param \Pterodactyl\Services\Users\UserCreationService $creationService */ public function __construct(UserCreationService $creationService) { @@ -55,7 +53,7 @@ class MakeUserCommand extends Command $name_first = $this->option('name-first') ?? $this->ask(trans('command/messages.user.ask_name_first')); $name_last = $this->option('name-last') ?? $this->ask(trans('command/messages.user.ask_name_last')); - if (is_null($password = $this->option('password')) && ! $this->option('no-password')) { + if (is_null($password = $this->option('password')) && !$this->option('no-password')) { $this->warn(trans('command/messages.user.ask_password_help')); $this->line(trans('command/messages.user.ask_password_tip')); $password = $this->secret(trans('command/messages.user.ask_password')); diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 4fa0845e5..b5f8067ee 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -17,8 +17,6 @@ class Kernel extends ConsoleKernel /** * Define the application's command schedule. - * - * @param \Illuminate\Console\Scheduling\Schedule $schedule */ protected function schedule(Schedule $schedule) { diff --git a/app/Console/RequiresDatabaseMigrations.php b/app/Console/RequiresDatabaseMigrations.php index f288ca1f1..479722b63 100644 --- a/app/Console/RequiresDatabaseMigrations.php +++ b/app/Console/RequiresDatabaseMigrations.php @@ -9,8 +9,6 @@ trait RequiresDatabaseMigrations { /** * Checks if the migrations have finished running by comparing the last migration file. - * - * @return bool */ protected function hasCompletedMigrations(): bool { @@ -19,7 +17,7 @@ trait RequiresDatabaseMigrations $files = $migrator->getMigrationFiles(database_path('migrations')); - if (! $migrator->repositoryExists()) { + if (!$migrator->repositoryExists()) { return false; } @@ -34,12 +32,10 @@ trait RequiresDatabaseMigrations * Throw a massive error into the console to hopefully catch the users attention and get * them to properly run the migrations rather than ignoring all of the other previous * errors... - * - * @return int */ protected function showMigrationWarning(): int { - $this->getOutput()->writeln(" + $this->getOutput()->writeln(' | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | | | | Your database has not been properly migrated! | @@ -52,9 +48,9 @@ You must run the following command to finish migrating your database: You will not be able to use Pterodactyl Panel as expected without fixing your database state by running the command above. -"); +'); - $this->getOutput()->error("You must correct the error above before continuing."); + $this->getOutput()->error('You must correct the error above before continuing.'); return 1; } diff --git a/app/Contracts/Core/ReceivesEvents.php b/app/Contracts/Core/ReceivesEvents.php index a6c1aa10f..dbbad4458 100644 --- a/app/Contracts/Core/ReceivesEvents.php +++ b/app/Contracts/Core/ReceivesEvents.php @@ -8,8 +8,6 @@ interface ReceivesEvents { /** * Handles receiving an event from the application. - * - * @param \Pterodactyl\Events\Event $notification */ public function handle(Event $notification): void; } diff --git a/app/Contracts/Criteria/CriteriaInterface.php b/app/Contracts/Criteria/CriteriaInterface.php index 1b8328192..cb9f56d7f 100644 --- a/app/Contracts/Criteria/CriteriaInterface.php +++ b/app/Contracts/Criteria/CriteriaInterface.php @@ -17,7 +17,7 @@ interface CriteriaInterface * Apply selected criteria to a repository call. * * @param \Illuminate\Database\Eloquent\Model $model - * @param \Pterodactyl\Repositories\Repository $repository + * * @return mixed */ public function apply($model, Repository $repository); diff --git a/app/Contracts/Extensions/HashidsInterface.php b/app/Contracts/Extensions/HashidsInterface.php index 8e1e69900..e8d525f34 100644 --- a/app/Contracts/Extensions/HashidsInterface.php +++ b/app/Contracts/Extensions/HashidsInterface.php @@ -17,7 +17,8 @@ interface HashidsInterface extends VendorHashidsInterface * Decode an encoded hashid and return the first result. * * @param string $encoded - * @param null $default + * @param null $default + * * @return mixed * * @throws \InvalidArgumentException diff --git a/app/Contracts/Http/ClientPermissionsRequest.php b/app/Contracts/Http/ClientPermissionsRequest.php index 6b863fce9..85eae2259 100644 --- a/app/Contracts/Http/ClientPermissionsRequest.php +++ b/app/Contracts/Http/ClientPermissionsRequest.php @@ -8,8 +8,6 @@ interface ClientPermissionsRequest * Returns the permissions string indicating which permission should be used to * validate that the authenticated user has permission to perform this action aganist * the given resource (server). - * - * @return string */ public function permission(): string; } diff --git a/app/Contracts/Repository/AllocationRepositoryInterface.php b/app/Contracts/Repository/AllocationRepositoryInterface.php index 400279733..24507f9a7 100644 --- a/app/Contracts/Repository/AllocationRepositoryInterface.php +++ b/app/Contracts/Repository/AllocationRepositoryInterface.php @@ -2,25 +2,17 @@ namespace Pterodactyl\Contracts\Repository; -use Illuminate\Support\Collection; - interface AllocationRepositoryInterface extends RepositoryInterface { /** * Return all of the allocations that exist for a node that are not currently * allocated. - * - * @param int $node - * @return array */ public function getUnassignedAllocationIds(int $node): array; /** * Return a single allocation from those meeting the requirements. * - * @param array $nodes - * @param array $ports - * @param bool $dedicated * @return \Pterodactyl\Models\Allocation|null */ public function getRandomAllocation(array $nodes, array $ports, bool $dedicated = false); diff --git a/app/Contracts/Repository/ApiKeyRepositoryInterface.php b/app/Contracts/Repository/ApiKeyRepositoryInterface.php index 89a722b22..91e0a3827 100644 --- a/app/Contracts/Repository/ApiKeyRepositoryInterface.php +++ b/app/Contracts/Repository/ApiKeyRepositoryInterface.php @@ -9,35 +9,21 @@ interface ApiKeyRepositoryInterface extends RepositoryInterface { /** * Get all of the account API keys that exist for a specific user. - * - * @param \Pterodactyl\Models\User $user - * @return \Illuminate\Support\Collection */ public function getAccountKeys(User $user): Collection; /** * Get all of the application API keys that exist for a specific user. - * - * @param \Pterodactyl\Models\User $user - * @return \Illuminate\Support\Collection */ public function getApplicationKeys(User $user): Collection; /** * Delete an account API key from the panel for a specific user. - * - * @param \Pterodactyl\Models\User $user - * @param string $identifier - * @return int */ public function deleteAccountKey(User $user, string $identifier): int; /** * Delete an application API key from the panel for a specific user. - * - * @param \Pterodactyl\Models\User $user - * @param string $identifier - * @return int */ public function deleteApplicationKey(User $user, string $identifier): int; } diff --git a/app/Contracts/Repository/DatabaseHostRepositoryInterface.php b/app/Contracts/Repository/DatabaseHostRepositoryInterface.php index a924d85a9..01f1ca4b4 100644 --- a/app/Contracts/Repository/DatabaseHostRepositoryInterface.php +++ b/app/Contracts/Repository/DatabaseHostRepositoryInterface.php @@ -9,8 +9,6 @@ interface DatabaseHostRepositoryInterface extends RepositoryInterface /** * Return database hosts with a count of databases and the node * information for which it is attached. - * - * @return \Illuminate\Support\Collection */ public function getWithViewDetails(): Collection; } diff --git a/app/Contracts/Repository/DatabaseRepositoryInterface.php b/app/Contracts/Repository/DatabaseRepositoryInterface.php index 5926adb7c..622072203 100644 --- a/app/Contracts/Repository/DatabaseRepositoryInterface.php +++ b/app/Contracts/Repository/DatabaseRepositoryInterface.php @@ -8,89 +8,60 @@ use Illuminate\Contracts\Pagination\LengthAwarePaginator; interface DatabaseRepositoryInterface extends RepositoryInterface { - const DEFAULT_CONNECTION_NAME = 'dynamic'; + public const DEFAULT_CONNECTION_NAME = 'dynamic'; /** * Set the connection name to execute statements against. * - * @param string $connection * @return $this */ public function setConnection(string $connection); /** * Return the connection to execute statements against. - * - * @return string */ public function getConnection(): string; /** * Return all of the databases belonging to a server. - * - * @param int $server - * @return \Illuminate\Support\Collection */ public function getDatabasesForServer(int $server): Collection; /** * Return all of the databases for a given host with the server relationship loaded. - * - * @param int $host - * @param int $count - * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator */ public function getDatabasesForHost(int $host, int $count = 25): LengthAwarePaginator; /** * Create a new database on a given connection. - * - * @param string $database - * @return bool */ public function createDatabase(string $database): bool; /** * Create a new database user on a given connection. * - * @param string $username - * @param string $remote - * @param string $password * @param $max_connections - * @return bool */ public function createUser(string $username, string $remote, string $password, string $max_connections): bool; /** * Give a specific user access to a given database. - * - * @param string $database - * @param string $username - * @param string $remote - * @return bool */ public function assignUserToDatabase(string $database, string $username, string $remote): bool; /** * Flush the privileges for a given connection. - * - * @return bool */ public function flush(): bool; /** * Drop a given database on a specific connection. - * - * @param string $database - * @return bool */ public function dropDatabase(string $database): bool; /** * Drop a given user on a specific connection. * - * @param string $username - * @param string $remote * @return mixed */ public function dropUser(string $username, string $remote): bool; diff --git a/app/Contracts/Repository/EggRepositoryInterface.php b/app/Contracts/Repository/EggRepositoryInterface.php index 0f6a88aa7..733e70cfb 100644 --- a/app/Contracts/Repository/EggRepositoryInterface.php +++ b/app/Contracts/Repository/EggRepositoryInterface.php @@ -17,17 +17,12 @@ interface EggRepositoryInterface extends RepositoryInterface /** * Return an egg with the variables relation attached. * - * @param int $id - * @return \Pterodactyl\Models\Egg - * * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ public function getWithVariables(int $id): Egg; /** * Return all eggs and their relations to be used in the daemon API. - * - * @return \Illuminate\Database\Eloquent\Collection */ public function getAllWithCopyAttributes(): Collection; @@ -35,27 +30,18 @@ interface EggRepositoryInterface extends RepositoryInterface * Return an egg with the scriptFrom and configFrom relations loaded onto the model. * * @param int|string $value - * @param string $column - * @return \Pterodactyl\Models\Egg */ public function getWithCopyAttributes($value, string $column = 'id'): Egg; /** * Return all of the data needed to export a service. * - * @param int $id - * @return \Pterodactyl\Models\Egg - * * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ public function getWithExportAttributes(int $id): Egg; /** * Confirm a copy script belongs to the same nest as the item trying to use it. - * - * @param int $copyFromId - * @param int $service - * @return bool */ public function isCopyableScript(int $copyFromId, int $service): bool; } diff --git a/app/Contracts/Repository/EggVariableRepositoryInterface.php b/app/Contracts/Repository/EggVariableRepositoryInterface.php index 77b46f96d..6a00955d4 100644 --- a/app/Contracts/Repository/EggVariableRepositoryInterface.php +++ b/app/Contracts/Repository/EggVariableRepositoryInterface.php @@ -16,9 +16,6 @@ interface EggVariableRepositoryInterface extends RepositoryInterface /** * Return editable variables for a given egg. Editable variables must be set to * user viewable in order to be picked up by this function. - * - * @param int $egg - * @return \Illuminate\Support\Collection */ public function getEditableVariables(int $egg): Collection; } diff --git a/app/Contracts/Repository/LocationRepositoryInterface.php b/app/Contracts/Repository/LocationRepositoryInterface.php index 76a952e43..d24cee5bd 100644 --- a/app/Contracts/Repository/LocationRepositoryInterface.php +++ b/app/Contracts/Repository/LocationRepositoryInterface.php @@ -9,22 +9,17 @@ interface LocationRepositoryInterface extends RepositoryInterface { /** * Return locations with a count of nodes and servers attached to it. - * - * @return \Illuminate\Support\Collection */ public function getAllWithDetails(): Collection; /** * Return all of the available locations with the nodes as a relationship. - * - * @return \Illuminate\Support\Collection */ public function getAllWithNodes(): Collection; /** * Return all of the nodes and their respective count of servers for a location. * - * @param int $id * @return mixed * * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException @@ -34,7 +29,6 @@ interface LocationRepositoryInterface extends RepositoryInterface /** * Return a location and the count of nodes in that location. * - * @param int $id * @return mixed * * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException diff --git a/app/Contracts/Repository/NestRepositoryInterface.php b/app/Contracts/Repository/NestRepositoryInterface.php index e457262f6..1f430dbf8 100644 --- a/app/Contracts/Repository/NestRepositoryInterface.php +++ b/app/Contracts/Repository/NestRepositoryInterface.php @@ -17,6 +17,7 @@ interface NestRepositoryInterface extends RepositoryInterface * Return a nest or all nests with their associated eggs and variables. * * @param int $id + * * @return \Illuminate\Database\Eloquent\Collection|\Pterodactyl\Models\Nest * * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException @@ -26,7 +27,6 @@ interface NestRepositoryInterface extends RepositoryInterface /** * Return a nest or all nests and the count of eggs and servers for that nest. * - * @param int|null $id * @return \Pterodactyl\Models\Nest|\Illuminate\Database\Eloquent\Collection * * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException @@ -36,9 +36,6 @@ interface NestRepositoryInterface extends RepositoryInterface /** * Return a nest along with its associated eggs and the servers relation on those eggs. * - * @param int $id - * @return \Pterodactyl\Models\Nest - * * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ public function getWithEggServers(int $id): Nest; diff --git a/app/Contracts/Repository/NodeRepositoryInterface.php b/app/Contracts/Repository/NodeRepositoryInterface.php index 76ed7da93..87d5b4de5 100644 --- a/app/Contracts/Repository/NodeRepositoryInterface.php +++ b/app/Contracts/Repository/NodeRepositoryInterface.php @@ -4,54 +4,35 @@ namespace Pterodactyl\Contracts\Repository; use Pterodactyl\Models\Node; use Illuminate\Support\Collection; -use Illuminate\Support\LazyCollection; -use Illuminate\Contracts\Pagination\LengthAwarePaginator; -use Pterodactyl\Contracts\Repository\Attributes\SearchableInterface; interface NodeRepositoryInterface extends RepositoryInterface { - const THRESHOLD_PERCENTAGE_LOW = 75; - const THRESHOLD_PERCENTAGE_MEDIUM = 90; + public const THRESHOLD_PERCENTAGE_LOW = 75; + public const THRESHOLD_PERCENTAGE_MEDIUM = 90; /** * Return the usage stats for a single node. - * - * @param \Pterodactyl\Models\Node $node - * @return array */ public function getUsageStats(Node $node): array; /** * Return the usage stats for a single node. - * - * @param \Pterodactyl\Models\Node $node - * @return array */ public function getUsageStatsRaw(Node $node): array; /** * Return a single node with location and server information. - * - * @param \Pterodactyl\Models\Node $node - * @param bool $refresh - * @return \Pterodactyl\Models\Node */ public function loadLocationAndServerCount(Node $node, bool $refresh = false): Node; /** * Attach a paginated set of allocations to a node mode including * any servers that are also attached to those allocations. - * - * @param \Pterodactyl\Models\Node $node - * @param bool $refresh - * @return \Pterodactyl\Models\Node */ public function loadNodeAllocations(Node $node, bool $refresh = false): Node; /** * Return a collection of nodes for all locations to use in server creation UI. - * - * @return \Illuminate\Support\Collection */ public function getNodesForServerCreation(): Collection; } diff --git a/app/Contracts/Repository/RepositoryInterface.php b/app/Contracts/Repository/RepositoryInterface.php index 5caaac907..e9350d5f0 100644 --- a/app/Contracts/Repository/RepositoryInterface.php +++ b/app/Contracts/Repository/RepositoryInterface.php @@ -39,6 +39,7 @@ interface RepositoryInterface * An array of columns to filter the response by. * * @param array|string $columns + * * @return $this */ public function setColumns($columns = ['*']); @@ -62,7 +63,6 @@ interface RepositoryInterface * Set whether or not the repository should return a fresh model * when changes are committed. * - * @param bool $fresh * @return $this */ public function setFreshModel(bool $fresh = true); @@ -70,9 +70,6 @@ interface RepositoryInterface /** * Create a new model instance and persist it to the database. * - * @param array $fields - * @param bool $validate - * @param bool $force * @return mixed * * @throws \Pterodactyl\Exceptions\Model\DataValidationException @@ -82,7 +79,6 @@ interface RepositoryInterface /** * Find a model that has the specific ID passed. * - * @param int $id * @return mixed * * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException @@ -91,16 +87,12 @@ interface RepositoryInterface /** * Find a model matching an array of where clauses. - * - * @param array $fields - * @return \Illuminate\Support\Collection */ public function findWhere(array $fields): Collection; /** * Find and return the first matching instance for the given fields. * - * @param array $fields * @return mixed * * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException @@ -109,25 +101,16 @@ interface RepositoryInterface /** * Return a count of records matching the passed arguments. - * - * @param array $fields - * @return int */ public function findCountWhere(array $fields): int; /** * Delete a given record from the database. - * - * @param int $id - * @return int */ public function delete(int $id): int; /** * Delete records matching the given attributes. - * - * @param array $attributes - * @return int */ public function deleteWhere(array $attributes): int; @@ -135,9 +118,7 @@ interface RepositoryInterface * Update a given ID with the passed array of fields. * * @param int $id - * @param array $fields - * @param bool $validate - * @param bool $force + * * @return mixed * * @throws \Pterodactyl\Exceptions\Model\DataValidationException @@ -148,21 +129,12 @@ interface RepositoryInterface /** * Perform a mass update where matching records are updated using whereIn. * This does not perform any model data validation. - * - * @param string $column - * @param array $values - * @param array $fields - * @return int */ public function updateWhereIn(string $column, array $values, array $fields): int; /** * Update a record if it exists in the database, otherwise create it. * - * @param array $where - * @param array $fields - * @param bool $validate - * @param bool $force * @return mixed * * @throws \Pterodactyl\Exceptions\Model\DataValidationException @@ -171,40 +143,27 @@ interface RepositoryInterface /** * Return all records associated with the given model. - * - * @return Collection */ public function all(): Collection; /** * Return a paginated result set using a search term if set on the repository. - * - * @param int $perPage - * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator */ public function paginated(int $perPage): LengthAwarePaginator; /** * Insert a single or multiple records into the database at once skipping * validation and mass assignment checking. - * - * @param array $data - * @return bool */ public function insert(array $data): bool; /** * Insert multiple records into the database and ignore duplicates. - * - * @param array $values - * @return bool */ public function insertIgnore(array $values): bool; /** * Get the amount of entries in the database. - * - * @return int */ public function count(): int; } diff --git a/app/Contracts/Repository/ScheduleRepositoryInterface.php b/app/Contracts/Repository/ScheduleRepositoryInterface.php index b6e73a2de..c7bb0ee26 100644 --- a/app/Contracts/Repository/ScheduleRepositoryInterface.php +++ b/app/Contracts/Repository/ScheduleRepositoryInterface.php @@ -9,18 +9,12 @@ interface ScheduleRepositoryInterface extends RepositoryInterface { /** * Return all of the schedules for a given server. - * - * @param int $server - * @return \Illuminate\Support\Collection */ public function findServerSchedules(int $server): Collection; /** * Return a schedule model with all of the associated tasks as a relationship. * - * @param int $schedule - * @return \Pterodactyl\Models\Schedule - * * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ public function getScheduleWithTasks(int $schedule): Schedule; diff --git a/app/Contracts/Repository/ServerRepositoryInterface.php b/app/Contracts/Repository/ServerRepositoryInterface.php index 55cf79a39..323e1cd36 100644 --- a/app/Contracts/Repository/ServerRepositoryInterface.php +++ b/app/Contracts/Repository/ServerRepositoryInterface.php @@ -10,37 +10,22 @@ interface ServerRepositoryInterface extends RepositoryInterface { /** * Load the egg relations onto the server model. - * - * @param \Pterodactyl\Models\Server $server - * @param bool $refresh - * @return \Pterodactyl\Models\Server */ public function loadEggRelations(Server $server, bool $refresh = false): Server; /** * Return a collection of servers with their associated data for rebuild operations. - * - * @param int|null $server - * @param int|null $node - * @return \Illuminate\Support\Collection */ public function getDataForRebuild(int $server = null, int $node = null): Collection; /** * Return a collection of servers with their associated data for reinstall operations. - * - * @param int|null $server - * @param int|null $node - * @return \Illuminate\Support\Collection */ public function getDataForReinstall(int $server = null, int $node = null): Collection; /** * Return a server model and all variables associated with the server. * - * @param int $id - * @return \Pterodactyl\Models\Server - * * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ public function findWithVariables(int $id): Server; @@ -49,28 +34,16 @@ interface ServerRepositoryInterface extends RepositoryInterface * Get the primary allocation for a given server. If a model is passed into * the function, load the allocation relationship onto it. Otherwise, find and * return the server from the database. - * - * @param \Pterodactyl\Models\Server $server - * @param bool $refresh - * @return \Pterodactyl\Models\Server */ public function getPrimaryAllocation(Server $server, bool $refresh = false): Server; /** * Return enough data to be used for the creation of a server via the daemon. - * - * @param \Pterodactyl\Models\Server $server - * @param bool $refresh - * @return \Pterodactyl\Models\Server */ public function getDataForCreation(Server $server, bool $refresh = false): Server; /** * Load associated databases onto the server model. - * - * @param \Pterodactyl\Models\Server $server - * @param bool $refresh - * @return \Pterodactyl\Models\Server */ public function loadDatabaseRelations(Server $server, bool $refresh = false): Server; @@ -78,46 +51,28 @@ interface ServerRepositoryInterface extends RepositoryInterface * Get data for use when updating a server on the Daemon. Returns an array of * the egg which is used for build and rebuild. Only loads relations * if they are missing, or refresh is set to true. - * - * @param \Pterodactyl\Models\Server $server - * @param bool $refresh - * @return array */ public function getDaemonServiceData(Server $server, bool $refresh = false): array; /** * Return a server by UUID. * - * @param string $uuid - * @return \Pterodactyl\Models\Server - * * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ public function getByUuid(string $uuid): Server; /** * Check if a given UUID and UUID-Short string are unique to a server. - * - * @param string $uuid - * @param string $short - * @return bool */ public function isUniqueUuidCombo(string $uuid, string $short): bool; /** * Get the amount of servers that are suspended. - * - * @return int */ public function getSuspendedServersCount(): int; /** * Returns all of the servers that exist for a given node in a paginated response. - * - * @param int $node - * @param int $limit - * - * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator */ public function loadAllServersForNode(int $node, int $limit): LengthAwarePaginator; } diff --git a/app/Contracts/Repository/SessionRepositoryInterface.php b/app/Contracts/Repository/SessionRepositoryInterface.php index e1dafed1e..305752fb4 100644 --- a/app/Contracts/Repository/SessionRepositoryInterface.php +++ b/app/Contracts/Repository/SessionRepositoryInterface.php @@ -8,17 +8,12 @@ interface SessionRepositoryInterface extends RepositoryInterface { /** * Return all of the active sessions for a user. - * - * @param int $user - * @return \Illuminate\Support\Collection */ public function getUserSessions(int $user): Collection; /** * Delete a session for a given user. * - * @param int $user - * @param string $session * @return int|null */ public function deleteUserSession(int $user, string $session); diff --git a/app/Contracts/Repository/SettingsRepositoryInterface.php b/app/Contracts/Repository/SettingsRepositoryInterface.php index 6c4db9dca..e5b2bb773 100644 --- a/app/Contracts/Repository/SettingsRepositoryInterface.php +++ b/app/Contracts/Repository/SettingsRepositoryInterface.php @@ -7,9 +7,6 @@ interface SettingsRepositoryInterface extends RepositoryInterface /** * Store a new persistent setting in the database. * - * @param string $key - * @param string|null $value - * * @throws \Pterodactyl\Exceptions\Model\DataValidationException * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ @@ -18,16 +15,14 @@ interface SettingsRepositoryInterface extends RepositoryInterface /** * Retrieve a persistent setting from the database. * - * @param string $key * @param mixed $default + * * @return mixed */ public function get(string $key, $default); /** * Remove a key from the database cache. - * - * @param string $key */ public function forget(string $key); } diff --git a/app/Contracts/Repository/SubuserRepositoryInterface.php b/app/Contracts/Repository/SubuserRepositoryInterface.php index 6babbfcc2..1379e120b 100644 --- a/app/Contracts/Repository/SubuserRepositoryInterface.php +++ b/app/Contracts/Repository/SubuserRepositoryInterface.php @@ -8,29 +8,17 @@ interface SubuserRepositoryInterface extends RepositoryInterface { /** * Return a subuser with the associated server relationship. - * - * @param \Pterodactyl\Models\Subuser $subuser - * @param bool $refresh - * @return \Pterodactyl\Models\Subuser */ public function loadServerAndUserRelations(Subuser $subuser, bool $refresh = false): Subuser; /** * Return a subuser with the associated permissions relationship. - * - * @param \Pterodactyl\Models\Subuser $subuser - * @param bool $refresh - * @return \Pterodactyl\Models\Subuser */ public function getWithPermissions(Subuser $subuser, bool $refresh = false): Subuser; /** * Return a subuser and associated permissions given a user_id and server_id. * - * @param int $user - * @param int $server - * @return \Pterodactyl\Models\Subuser - * * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ public function getWithPermissionsUsingUserAndServer(int $user, int $server): Subuser; diff --git a/app/Contracts/Repository/TaskRepositoryInterface.php b/app/Contracts/Repository/TaskRepositoryInterface.php index ea9486254..18811ba5c 100644 --- a/app/Contracts/Repository/TaskRepositoryInterface.php +++ b/app/Contracts/Repository/TaskRepositoryInterface.php @@ -9,9 +9,6 @@ interface TaskRepositoryInterface extends RepositoryInterface /** * Get a task and the server relationship for that task. * - * @param int $id - * @return \Pterodactyl\Models\Task - * * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ public function getTaskForJobProcess(int $id): Task; @@ -19,8 +16,6 @@ interface TaskRepositoryInterface extends RepositoryInterface /** * Returns the next task in a schedule. * - * @param int $schedule - * @param int $index * @return \Pterodactyl\Models\Task|null */ public function getNextTask(int $schedule, int $index); diff --git a/app/Events/Server/Created.php b/app/Events/Server/Created.php index 8ca547004..8963b3cbf 100644 --- a/app/Events/Server/Created.php +++ b/app/Events/Server/Created.php @@ -25,8 +25,6 @@ class Created /** * Create a new event instance. - * - * @param \Pterodactyl\Models\Server $server */ public function __construct(Server $server) { diff --git a/app/Events/Server/Creating.php b/app/Events/Server/Creating.php index 318156b6d..457f586ed 100644 --- a/app/Events/Server/Creating.php +++ b/app/Events/Server/Creating.php @@ -25,8 +25,6 @@ class Creating /** * Create a new event instance. - * - * @param \Pterodactyl\Models\Server $server */ public function __construct(Server $server) { diff --git a/app/Events/Server/Deleted.php b/app/Events/Server/Deleted.php index 258ac75b1..c9f69cab5 100644 --- a/app/Events/Server/Deleted.php +++ b/app/Events/Server/Deleted.php @@ -25,8 +25,6 @@ class Deleted /** * Create a new event instance. - * - * @param \Pterodactyl\Models\Server $server */ public function __construct(Server $server) { diff --git a/app/Events/Server/Deleting.php b/app/Events/Server/Deleting.php index 49219afc9..e411e2a70 100644 --- a/app/Events/Server/Deleting.php +++ b/app/Events/Server/Deleting.php @@ -25,8 +25,6 @@ class Deleting /** * Create a new event instance. - * - * @param \Pterodactyl\Models\Server $server */ public function __construct(Server $server) { diff --git a/app/Events/Server/Saved.php b/app/Events/Server/Saved.php index 4b8ae2165..c6dc024c5 100644 --- a/app/Events/Server/Saved.php +++ b/app/Events/Server/Saved.php @@ -25,8 +25,6 @@ class Saved /** * Create a new event instance. - * - * @param \Pterodactyl\Models\Server $server */ public function __construct(Server $server) { diff --git a/app/Events/Server/Saving.php b/app/Events/Server/Saving.php index 9bb8153fe..9e80d6265 100644 --- a/app/Events/Server/Saving.php +++ b/app/Events/Server/Saving.php @@ -25,8 +25,6 @@ class Saving /** * Create a new event instance. - * - * @param \Pterodactyl\Models\Server $server */ public function __construct(Server $server) { diff --git a/app/Events/Server/Updated.php b/app/Events/Server/Updated.php index 7157d4b34..b813b0997 100644 --- a/app/Events/Server/Updated.php +++ b/app/Events/Server/Updated.php @@ -25,8 +25,6 @@ class Updated /** * Create a new event instance. - * - * @param \Pterodactyl\Models\Server $server */ public function __construct(Server $server) { diff --git a/app/Events/Server/Updating.php b/app/Events/Server/Updating.php index c91c8a122..4c8ead093 100644 --- a/app/Events/Server/Updating.php +++ b/app/Events/Server/Updating.php @@ -25,8 +25,6 @@ class Updating /** * Create a new event instance. - * - * @param \Pterodactyl\Models\Server $server */ public function __construct(Server $server) { diff --git a/app/Events/Subuser/Created.php b/app/Events/Subuser/Created.php index 63941b2af..2467fe99a 100644 --- a/app/Events/Subuser/Created.php +++ b/app/Events/Subuser/Created.php @@ -25,8 +25,6 @@ class Created /** * Create a new event instance. - * - * @param \Pterodactyl\Models\Subuser $subuser */ public function __construct(Subuser $subuser) { diff --git a/app/Events/Subuser/Creating.php b/app/Events/Subuser/Creating.php index 5d6f6d800..03aa5f7fd 100644 --- a/app/Events/Subuser/Creating.php +++ b/app/Events/Subuser/Creating.php @@ -25,8 +25,6 @@ class Creating /** * Create a new event instance. - * - * @param \Pterodactyl\Models\Subuser $subuser */ public function __construct(Subuser $subuser) { diff --git a/app/Events/Subuser/Deleted.php b/app/Events/Subuser/Deleted.php index ee53388b7..0e9744c3f 100644 --- a/app/Events/Subuser/Deleted.php +++ b/app/Events/Subuser/Deleted.php @@ -25,8 +25,6 @@ class Deleted /** * Create a new event instance. - * - * @param \Pterodactyl\Models\Subuser $subuser */ public function __construct(Subuser $subuser) { diff --git a/app/Events/Subuser/Deleting.php b/app/Events/Subuser/Deleting.php index 6d25a3ebb..9d1e12c2f 100644 --- a/app/Events/Subuser/Deleting.php +++ b/app/Events/Subuser/Deleting.php @@ -25,8 +25,6 @@ class Deleting /** * Create a new event instance. - * - * @param \Pterodactyl\Models\Subuser $subuser */ public function __construct(Subuser $subuser) { diff --git a/app/Events/User/Created.php b/app/Events/User/Created.php index b66d531d4..72eba811c 100644 --- a/app/Events/User/Created.php +++ b/app/Events/User/Created.php @@ -25,8 +25,6 @@ class Created /** * Create a new event instance. - * - * @param \Pterodactyl\Models\User $user */ public function __construct(User $user) { diff --git a/app/Events/User/Creating.php b/app/Events/User/Creating.php index d6297440b..7948d7067 100644 --- a/app/Events/User/Creating.php +++ b/app/Events/User/Creating.php @@ -25,8 +25,6 @@ class Creating /** * Create a new event instance. - * - * @param \Pterodactyl\Models\User $user */ public function __construct(User $user) { diff --git a/app/Events/User/Deleted.php b/app/Events/User/Deleted.php index 1b1682ef0..48b524874 100644 --- a/app/Events/User/Deleted.php +++ b/app/Events/User/Deleted.php @@ -25,8 +25,6 @@ class Deleted /** * Create a new event instance. - * - * @param \Pterodactyl\Models\User $user */ public function __construct(User $user) { diff --git a/app/Events/User/Deleting.php b/app/Events/User/Deleting.php index 05e3ba252..a386bd951 100644 --- a/app/Events/User/Deleting.php +++ b/app/Events/User/Deleting.php @@ -25,8 +25,6 @@ class Deleting /** * Create a new event instance. - * - * @param \Pterodactyl\Models\User $user */ public function __construct(User $user) { diff --git a/app/Exceptions/DisplayException.php b/app/Exceptions/DisplayException.php index 94a920056..f3120471d 100644 --- a/app/Exceptions/DisplayException.php +++ b/app/Exceptions/DisplayException.php @@ -11,10 +11,10 @@ use Prologue\Alerts\AlertsMessageBag; class DisplayException extends PterodactylException { - const LEVEL_DEBUG = 'debug'; - const LEVEL_INFO = 'info'; - const LEVEL_WARNING = 'warning'; - const LEVEL_ERROR = 'error'; + public const LEVEL_DEBUG = 'debug'; + public const LEVEL_INFO = 'info'; + public const LEVEL_WARNING = 'warning'; + public const LEVEL_ERROR = 'error'; /** * @var string @@ -25,9 +25,8 @@ class DisplayException extends PterodactylException * Exception constructor. * * @param string $message - * @param Throwable|null $previous * @param string $level - * @param int $code + * @param int $code */ public function __construct($message, Throwable $previous = null, $level = self::LEVEL_ERROR, $code = 0) { @@ -58,6 +57,7 @@ class DisplayException extends PterodactylException * request originated from an API hit, return the error in JSONAPI spec format. * * @param \Illuminate\Http\Request $request + * * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse */ public function render($request) @@ -83,7 +83,7 @@ class DisplayException extends PterodactylException */ public function report() { - if (! $this->getPrevious() instanceof Exception || ! Handler::isReportable($this->getPrevious())) { + if (!$this->getPrevious() instanceof Exception || !Handler::isReportable($this->getPrevious())) { return null; } diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 00484d943..a94ad8aad 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -5,10 +5,14 @@ namespace Pterodactyl\Exceptions; use Exception; use Throwable; use PDOException; -use Psr\Log\LoggerInterface; +use Illuminate\Support\Arr; +use Illuminate\Support\Str; use Swift_TransportException; +use Illuminate\Http\JsonResponse; +use Illuminate\Support\Collection; use Illuminate\Container\Container; use Illuminate\Database\Connection; +use Illuminate\Foundation\Application; use Illuminate\Auth\AuthenticationException; use Illuminate\Session\TokenMismatchException; use Illuminate\Validation\ValidationException; @@ -43,17 +47,6 @@ class Handler extends ExceptionHandler ValidationException::class, ]; - /** - * A list of exceptions that should be logged with cleaned stack - * traces to avoid exposing credentials or other sensitive information. - * - * @var array - */ - protected $cleanStacks = [ - PDOException::class, - Swift_TransportException::class, - ]; - /** * A list of the inputs that are never flashed for validation exceptions. * @@ -67,56 +60,40 @@ class Handler extends ExceptionHandler ]; /** - * Report or log an exception. Skips Laravel's internal reporter since we - * don't need or want the user information in our logs by default. + * Registers the exception handling callbacks for the application. This + * will capture specific exception types that we do not want to include + * the detailed stack traces for since they could reveal credentials to + * whoever can read the logs. * - * If you want to implement logging in a different format to integrate with - * services such as AWS Cloudwatch or other monitoring you can replace the - * contents of this function with a call to the parent reporter. - * - * @param \Throwable $exception - * @return mixed - * - * @throws \Throwable + * @noinspection PhpUnusedLocalVariableInspection */ - public function report(Throwable $exception) + public function register() { - if (! config('app.exceptions.report_all', false) && $this->shouldntReport($exception)) { - return null; + if (config('app.exceptions.report_all', false)) { + $this->dontReport = []; } - if (method_exists($exception, 'report')) { - return $exception->report(); - } + $this->reportable(function (PDOException $ex) { + $ex = $this->generateCleanedExceptionStack($ex); + }); - try { - $logger = $this->container->make(LoggerInterface::class); - } catch (Exception $ex) { - throw $exception; - } - - foreach ($this->cleanStacks as $class) { - if ($exception instanceof $class) { - $exception = $this->generateCleanedExceptionStack($exception); - break; - } - } - - return $logger->error($exception); + $this->reportable(function (Swift_TransportException $ex) { + $ex = $this->generateCleanedExceptionStack($ex); + }); } - private function generateCleanedExceptionStack(Throwable $exception) + private function generateCleanedExceptionStack(Throwable $exception): string { $cleanedStack = ''; foreach ($exception->getTrace() as $index => $item) { $cleanedStack .= sprintf( "#%d %s(%d): %s%s%s\n", $index, - array_get($item, 'file'), - array_get($item, 'line'), - array_get($item, 'class'), - array_get($item, 'type'), - array_get($item, 'function') + Arr::get($item, 'file'), + Arr::get($item, 'line'), + Arr::get($item, 'class'), + Arr::get($item, 'type'), + Arr::get($item, 'function') ); } @@ -135,14 +112,14 @@ class Handler extends ExceptionHandler * Render an exception into an HTTP response. * * @param \Illuminate\Http\Request $request - * @param \Throwable $exception + * * @return \Symfony\Component\HttpFoundation\Response * * @throws \Throwable */ public function render($request, Throwable $exception) { - $connections = Container::getInstance()->make(Connection::class); + $connections = $this->container->make(Connection::class); // If we are currently wrapped up inside a transaction, we will roll all the way // back to the beginning. This needs to happen, otherwise session data does not @@ -165,27 +142,28 @@ class Handler extends ExceptionHandler * calls to the API. * * @param \Illuminate\Http\Request $request - * @param \Illuminate\Validation\ValidationException $exception + * * @return \Illuminate\Http\JsonResponse */ public function invalidJson($request, ValidationException $exception) { - $codes = collect($exception->validator->failed())->mapWithKeys(function ($reasons, $field) { + $codes = Collection::make($exception->validator->failed())->mapWithKeys(function ($reasons, $field) { $cleaned = []; foreach ($reasons as $reason => $attrs) { - $cleaned[] = snake_case($reason); + $cleaned[] = Str::snake($reason); } return [str_replace('.', '_', $field) => $cleaned]; })->toArray(); - $errors = collect($exception->errors())->map(function ($errors, $field) use ($codes, $exception) { + $errors = Collection::make($exception->errors())->map(function ($errors, $field) use ($codes, $exception) { $response = []; foreach ($errors as $key => $error) { $meta = [ 'source_field' => $field, - 'rule' => str_replace(self::PTERODACTYL_RULE_STRING, 'p_', array_get( - $codes, str_replace('.', '_', $field) . '.' . $key + 'rule' => str_replace(self::PTERODACTYL_RULE_STRING, 'p_', Arr::get( + $codes, + str_replace('.', '_', $field) . '.' . $key )), ]; @@ -206,10 +184,6 @@ class Handler extends ExceptionHandler /** * Return the exception as a JSONAPI representation for use on API requests. - * - * @param \Throwable $exception - * @param array $override - * @return array */ public static function convertToArray(Throwable $exception, array $override = []): array { @@ -235,7 +209,7 @@ class Handler extends ExceptionHandler 'detail' => $exception->getMessage(), 'source' => [ 'line' => $exception->getLine(), - 'file' => str_replace(base_path(), '', $exception->getFile()), + 'file' => str_replace(Application::getInstance()->basePath(), '', $exception->getFile()), ], 'meta' => [ 'trace' => explode("\n", $exception->getTraceAsString()), @@ -248,9 +222,6 @@ class Handler extends ExceptionHandler /** * Return an array of exceptions that should not be reported. - * - * @param \Exception $exception - * @return bool */ public static function isReportable(Exception $exception): bool { @@ -261,23 +232,22 @@ class Handler extends ExceptionHandler * Convert an authentication exception into an unauthenticated response. * * @param \Illuminate\Http\Request $request - * @param \Illuminate\Auth\AuthenticationException $exception - * @return \Illuminate\Http\Response + * + * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse */ protected function unauthenticated($request, AuthenticationException $exception) { if ($request->expectsJson()) { - return response()->json(self::convertToArray($exception), 401); + return new JsonResponse(self::convertToArray($exception), JsonResponse::HTTP_UNAUTHORIZED); } - return redirect()->guest(route('auth.login')); + return $this->container->make('redirect')->guest('/auth/login'); } /** * Converts an exception into an array to render in the response. Overrides * Laravel's built-in converter to output as a JSONAPI spec compliant object. * - * @param \Throwable $exception * @return array */ protected function convertExceptionToArray(Throwable $exception) diff --git a/app/Exceptions/Http/Connection/DaemonConnectionException.php b/app/Exceptions/Http/Connection/DaemonConnectionException.php index e6765b8a6..94778c033 100644 --- a/app/Exceptions/Http/Connection/DaemonConnectionException.php +++ b/app/Exceptions/Http/Connection/DaemonConnectionException.php @@ -19,9 +19,6 @@ class DaemonConnectionException extends DisplayException /** * Throw a displayable exception caused by a daemon connection error. - * - * @param \GuzzleHttp\Exception\GuzzleException $previous - * @param bool $useStatusCode */ public function __construct(GuzzleException $previous, bool $useStatusCode = true) { @@ -38,11 +35,11 @@ class DaemonConnectionException extends DisplayException // Attempt to pull the actual error message off the response and return that if it is not // a 500 level error. - if ($this->statusCode < 500 && ! is_null($response)) { + if ($this->statusCode < 500 && !is_null($response)) { $body = $response->getBody(); if (is_string($body) || (is_object($body) && method_exists($body, '__toString'))) { $body = json_decode(is_string($body) ? $body : $body->__toString(), true); - $message = "[Wings Error]: " . Arr::get($body, 'error', $message); + $message = '[Wings Error]: ' . Arr::get($body, 'error', $message); } } diff --git a/app/Exceptions/Http/HttpForbiddenException.php b/app/Exceptions/Http/HttpForbiddenException.php index fa2aae9be..1488265a9 100644 --- a/app/Exceptions/Http/HttpForbiddenException.php +++ b/app/Exceptions/Http/HttpForbiddenException.php @@ -9,9 +9,6 @@ class HttpForbiddenException extends HttpException { /** * HttpForbiddenException constructor. - * - * @param string|null $message - * @param \Throwable|null $previous */ public function __construct(string $message = null, \Throwable $previous = null) { diff --git a/app/Exceptions/Http/TwoFactorAuthRequiredException.php b/app/Exceptions/Http/TwoFactorAuthRequiredException.php index c38503572..cecb64626 100644 --- a/app/Exceptions/Http/TwoFactorAuthRequiredException.php +++ b/app/Exceptions/Http/TwoFactorAuthRequiredException.php @@ -11,11 +11,9 @@ class TwoFactorAuthRequiredException extends HttpException implements HttpExcept { /** * TwoFactorAuthRequiredException constructor. - * - * @param \Throwable|null $previous */ 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); + 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/Model/DataValidationException.php b/app/Exceptions/Model/DataValidationException.php index 5840e6d9c..1118081e5 100644 --- a/app/Exceptions/Model/DataValidationException.php +++ b/app/Exceptions/Model/DataValidationException.php @@ -18,8 +18,6 @@ class DataValidationException extends PterodactylException implements HttpExcept /** * DataValidationException constructor. - * - * @param \Illuminate\Contracts\Validation\Validator $validator */ public function __construct(Validator $validator) { diff --git a/app/Exceptions/Service/Backup/TooManyBackupsException.php b/app/Exceptions/Service/Backup/TooManyBackupsException.php index a96baed50..8ccbaf76b 100644 --- a/app/Exceptions/Service/Backup/TooManyBackupsException.php +++ b/app/Exceptions/Service/Backup/TooManyBackupsException.php @@ -8,8 +8,6 @@ class TooManyBackupsException extends DisplayException { /** * TooManyBackupsException constructor. - * - * @param int $backupLimit */ public function __construct(int $backupLimit) { diff --git a/app/Exceptions/Service/ServiceLimitExceededException.php b/app/Exceptions/Service/ServiceLimitExceededException.php index 55ee6c94b..7236034fe 100644 --- a/app/Exceptions/Service/ServiceLimitExceededException.php +++ b/app/Exceptions/Service/ServiceLimitExceededException.php @@ -10,9 +10,6 @@ class ServiceLimitExceededException extends DisplayException /** * Exception thrown when something goes over a defined limit, such as allocated * ports, tasks, databases, etc. - * - * @param string $message - * @param \Throwable|null $previous */ public function __construct(string $message, Throwable $previous = null) { diff --git a/app/Extensions/Backups/BackupManager.php b/app/Extensions/Backups/BackupManager.php index fb0e0a26a..80515848e 100644 --- a/app/Extensions/Backups/BackupManager.php +++ b/app/Extensions/Backups/BackupManager.php @@ -8,8 +8,8 @@ use Illuminate\Support\Arr; use Illuminate\Support\Str; use Webmozart\Assert\Assert; use InvalidArgumentException; -use League\Flysystem\AdapterInterface; use Illuminate\Foundation\Application; +use League\Flysystem\AdapterInterface; use League\Flysystem\AwsS3v3\AwsS3Adapter; use League\Flysystem\Memory\MemoryAdapter; use Illuminate\Contracts\Config\Repository; @@ -42,8 +42,6 @@ class BackupManager /** * BackupManager constructor. - * - * @param \Illuminate\Foundation\Application $app */ public function __construct(Application $app) { @@ -54,7 +52,6 @@ class BackupManager /** * Returns a backup adapter instance. * - * @param string|null $name * @return \League\Flysystem\AdapterInterface */ public function adapter(string $name = null) @@ -65,8 +62,8 @@ class BackupManager /** * Set the given backup adapter instance. * - * @param string $name * @param \League\Flysystem\AdapterInterface $disk + * * @return $this */ public function set(string $name, $disk) @@ -79,7 +76,6 @@ class BackupManager /** * Gets a backup adapter. * - * @param string $name * @return \League\Flysystem\AdapterInterface */ protected function get(string $name) @@ -90,7 +86,6 @@ class BackupManager /** * Resolve the given backup disk. * - * @param string $name * @return \League\Flysystem\AdapterInterface */ protected function resolve(string $name) @@ -98,9 +93,7 @@ class BackupManager $config = $this->getConfig($name); if (empty($config['adapter'])) { - throw new InvalidArgumentException( - "Backup disk [{$name}] does not have a configured adapter." - ); + throw new InvalidArgumentException("Backup disk [{$name}] does not have a configured adapter."); } $adapter = $config['adapter']; @@ -124,7 +117,6 @@ class BackupManager /** * Calls a custom creator for a given adapter type. * - * @param array $config * @return \League\Flysystem\AdapterInterface */ protected function callCustomCreator(array $config) @@ -139,7 +131,6 @@ class BackupManager /** * Creates a new wings adapter. * - * @param array $config * @return \League\Flysystem\AdapterInterface */ public function createWingsAdapter(array $config) @@ -150,14 +141,13 @@ class BackupManager /** * Creates a new S3 adapter. * - * @param array $config * @return \League\Flysystem\AdapterInterface */ public function createS3Adapter(array $config) { $config['version'] = 'latest'; - if (! empty($config['key']) && ! empty($config['secret'])) { + if (!empty($config['key']) && !empty($config['secret'])) { $config['credentials'] = Arr::only($config, ['key', 'secret', 'token']); } @@ -169,7 +159,6 @@ class BackupManager /** * Returns the configuration associated with a given backup type. * - * @param string $name * @return array */ protected function getConfig(string $name) @@ -189,8 +178,6 @@ class BackupManager /** * Set the default session driver name. - * - * @param string $name */ public function setDefaultAdapter(string $name) { @@ -201,6 +188,7 @@ class BackupManager * Unset the given adapter instances. * * @param string|string[] $adapter + * * @return $this */ public function forget($adapter) @@ -215,8 +203,6 @@ class BackupManager /** * Register a custom adapter creator closure. * - * @param string $adapter - * @param \Closure $callback * @return $this */ public function extend(string $adapter, Closure $callback) diff --git a/app/Extensions/DynamicDatabaseConnection.php b/app/Extensions/DynamicDatabaseConnection.php index f31a92b19..e45243e50 100644 --- a/app/Extensions/DynamicDatabaseConnection.php +++ b/app/Extensions/DynamicDatabaseConnection.php @@ -16,9 +16,9 @@ use Pterodactyl\Contracts\Repository\DatabaseHostRepositoryInterface; class DynamicDatabaseConnection { - const DB_CHARSET = 'utf8'; - const DB_COLLATION = 'utf8_unicode_ci'; - const DB_DRIVER = 'mysql'; + public const DB_CHARSET = 'utf8'; + public const DB_COLLATION = 'utf8_unicode_ci'; + public const DB_DRIVER = 'mysql'; /** * @var \Illuminate\Config\Repository @@ -37,10 +37,6 @@ class DynamicDatabaseConnection /** * DynamicDatabaseConnection constructor. - * - * @param \Illuminate\Config\Repository $config - * @param \Pterodactyl\Contracts\Repository\DatabaseHostRepositoryInterface $repository - * @param \Illuminate\Contracts\Encryption\Encrypter $encrypter */ public function __construct( ConfigRepository $config, @@ -55,15 +51,15 @@ class DynamicDatabaseConnection /** * Adds a dynamic database connection entry to the runtime config. * - * @param string $connection + * @param string $connection * @param \Pterodactyl\Models\DatabaseHost|int $host - * @param string $database + * @param string $database * * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ public function set($connection, $host, $database = 'mysql') { - if (! $host instanceof DatabaseHost) { + if (!$host instanceof DatabaseHost) { $host = $this->repository->find($host); } diff --git a/app/Extensions/Hashids.php b/app/Extensions/Hashids.php index 60e5d956b..ab07fc86d 100644 --- a/app/Extensions/Hashids.php +++ b/app/Extensions/Hashids.php @@ -20,7 +20,7 @@ class Hashids extends VendorHashids implements HashidsInterface public function decodeFirst($encoded, $default = null) { $result = $this->decode($encoded); - if (! is_array($result)) { + if (!is_array($result)) { return $default; } diff --git a/app/Extensions/Lcobucci/JWT/Encoding/TimestampDates.php b/app/Extensions/Lcobucci/JWT/Encoding/TimestampDates.php new file mode 100644 index 000000000..e13133c34 --- /dev/null +++ b/app/Extensions/Lcobucci/JWT/Encoding/TimestampDates.php @@ -0,0 +1,30 @@ +getTimestamp(); + } + + return $claims; + } +} diff --git a/app/Extensions/League/Fractal/Serializers/PterodactylSerializer.php b/app/Extensions/League/Fractal/Serializers/PterodactylSerializer.php index 4a76d8ff6..2481cf96e 100644 --- a/app/Extensions/League/Fractal/Serializers/PterodactylSerializer.php +++ b/app/Extensions/League/Fractal/Serializers/PterodactylSerializer.php @@ -10,7 +10,7 @@ class PterodactylSerializer extends ArraySerializer * Serialize an item. * * @param string $resourceKey - * @param array $data + * * @return array */ public function item($resourceKey, array $data) @@ -25,7 +25,7 @@ class PterodactylSerializer extends ArraySerializer * Serialize a collection. * * @param string $resourceKey - * @param array $data + * * @return array */ public function collection($resourceKey, array $data) @@ -59,6 +59,7 @@ class PterodactylSerializer extends ArraySerializer * * @param array $transformedData * @param array $includedData + * * @return array */ public function mergeIncludes($transformedData, $includedData) diff --git a/app/Extensions/Spatie/Fractalistic/Fractal.php b/app/Extensions/Spatie/Fractalistic/Fractal.php index 5bb0dd52b..b9c651d35 100644 --- a/app/Extensions/Spatie/Fractalistic/Fractal.php +++ b/app/Extensions/Spatie/Fractalistic/Fractal.php @@ -22,7 +22,7 @@ class Fractal extends SpatieFractal { // Set the serializer by default. if (is_null($this->serializer)) { - $this->serializer = new PterodactylSerializer; + $this->serializer = new PterodactylSerializer(); } // Automatically set the paginator on the response object if the diff --git a/app/Helpers/Time.php b/app/Helpers/Time.php index 248ff55f0..fd9a265a3 100644 --- a/app/Helpers/Time.php +++ b/app/Helpers/Time.php @@ -12,9 +12,6 @@ final class Time * for named timezones in MySQL. * * Returns the timezone as a string like +08:00 or -05:00 depending on the app timezone. - * - * @param string $timezone - * @return string */ public static function getMySQLTimezoneOffset(string $timezone): string { diff --git a/app/Helpers/Utilities.php b/app/Helpers/Utilities.php index 8379a3d8c..b48e9f091 100644 --- a/app/Helpers/Utilities.php +++ b/app/Helpers/Utilities.php @@ -13,9 +13,6 @@ class Utilities /** * Generates a random string and injects special characters into it, in addition to * the randomness of the alpha-numeric default response. - * - * @param int $length - * @return string */ public static function randomStringWithSpecialCharacters(int $length = 16): string { @@ -23,7 +20,7 @@ class Utilities // Given a random string of characters, randomly loop through the characters and replace some // with special characters to avoid issues with MySQL password requirements on some servers. try { - for ($i = 0; $i < random_int(2, 6); $i++) { + for ($i = 0; $i < random_int(2, 6); ++$i) { $character = ['!', '@', '=', '.', '+', '^'][random_int(0, 5)]; $string = substr_replace($string, $character, random_int(0, $length - 1), 1); @@ -39,16 +36,28 @@ class Utilities /** * Converts schedule cron data into a carbon object. * - * @param string $minute - * @param string $hour - * @param string $dayOfMonth - * @param string $dayOfWeek * @return \Carbon\Carbon */ - public static function getScheduleNextRunDate(string $minute, string $hour, string $dayOfMonth, string $dayOfWeek) + public static function getScheduleNextRunDate(string $minute, string $hour, string $dayOfMonth, string $month, string $dayOfWeek) { return Carbon::instance(CronExpression::factory( - sprintf('%s %s %s * %s', $minute, $hour, $dayOfMonth, $dayOfWeek) + sprintf('%s %s %s %s %s', $minute, $hour, $dayOfMonth, $month, $dayOfWeek) )->getNextRunDate()); } + + /** + * @param mixed $default + * + * @return string + */ + public static function checked(string $name, $default) + { + $errors = session('errors'); + + if (isset($errors) && $errors instanceof ViewErrorBag && $errors->any()) { + return old($name) ? 'checked' : ''; + } + + return ($default) ? 'checked' : ''; + } } diff --git a/app/Http/Controllers/Api/Application/Locations/LocationController.php b/app/Http/Controllers/Api/Application/Locations/LocationController.php index 6b3a6059c..43c17c164 100644 --- a/app/Http/Controllers/Api/Application/Locations/LocationController.php +++ b/app/Http/Controllers/Api/Application/Locations/LocationController.php @@ -2,6 +2,7 @@ namespace Pterodactyl\Http\Controllers\Api\Application\Locations; +use Illuminate\Http\Response; use Pterodactyl\Models\Location; use Illuminate\Http\JsonResponse; use Spatie\QueryBuilder\QueryBuilder; @@ -42,11 +43,6 @@ class LocationController extends ApplicationApiController /** * LocationController constructor. - * - * @param \Pterodactyl\Services\Locations\LocationCreationService $creationService - * @param \Pterodactyl\Services\Locations\LocationDeletionService $deletionService - * @param \Pterodactyl\Contracts\Repository\LocationRepositoryInterface $repository - * @param \Pterodactyl\Services\Locations\LocationUpdateService $updateService */ public function __construct( LocationCreationService $creationService, @@ -64,11 +60,6 @@ class LocationController extends ApplicationApiController /** * Return all of the locations currently registered on the Panel. - * - * @param \Pterodactyl\Http\Requests\Api\Application\Locations\GetLocationsRequest $request - * - * @return array - * @throws \Illuminate\Contracts\Container\BindingResolutionException */ public function index(GetLocationsRequest $request): array { @@ -91,12 +82,6 @@ class LocationController extends ApplicationApiController /** * Return a single location. - * - * @param \Pterodactyl\Http\Requests\Api\Application\Locations\GetLocationRequest $request - * @param \Pterodactyl\Models\Location $location - * - * @return array - * @throws \Illuminate\Contracts\Container\BindingResolutionException */ public function view(GetLocationRequest $request, Location $location): array { @@ -110,11 +95,9 @@ class LocationController extends ApplicationApiController * new location attached. * * @param \Pterodactyl\Http\Requests\Api\Application\Locations\StoreLocationRequest $request - * * @return \Illuminate\Http\JsonResponse * * @throws \Pterodactyl\Exceptions\Model\DataValidationException - * @throws \Illuminate\Contracts\Container\BindingResolutionException */ public function store(StoreLocationRequest $request): JsonResponse { @@ -133,11 +116,6 @@ class LocationController extends ApplicationApiController /** * Update a location on the Panel and return the updated record to the user. * - * @param \Pterodactyl\Http\Requests\Api\Application\Locations\UpdateLocationRequest $request - * @param \Pterodactyl\Models\Location $location - * - * @return array - * * @throws \Pterodactyl\Exceptions\Model\DataValidationException * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException * @throws \Illuminate\Contracts\Container\BindingResolutionException @@ -154,11 +132,6 @@ class LocationController extends ApplicationApiController /** * Delete a location from the Panel. * - * @param \Pterodactyl\Http\Requests\Api\Application\Locations\DeleteLocationRequest $request - * @param \Pterodactyl\Models\Location $location - * - * @return \Illuminate\Http\JsonResponse - * * @throws \Pterodactyl\Exceptions\Service\Location\HasActiveNodesException */ public function delete(DeleteLocationRequest $request, Location $location): JsonResponse diff --git a/app/Http/Controllers/Api/Application/Nests/NestController.php b/app/Http/Controllers/Api/Application/Nests/NestController.php index e37295be9..fbaae9025 100644 --- a/app/Http/Controllers/Api/Application/Nests/NestController.php +++ b/app/Http/Controllers/Api/Application/Nests/NestController.php @@ -41,11 +41,6 @@ class NestController extends ApplicationApiController /** * NestController constructor. - * - * @param \Pterodactyl\Contracts\Repository\NestRepositoryInterface $repository - * @param \Pterodactyl\Services\Nests\NestCreationService $nestCreationService - * @param \Pterodactyl\Services\Nests\NestDeletionService $nestDeletionService - * @param \Pterodactyl\Services\Nests\NestUpdateService $nestUpdateService */ public function __construct( NestRepositoryInterface $repository, @@ -64,11 +59,6 @@ class NestController extends ApplicationApiController /** * Return all Nests that exist on the Panel. - * - * @param \Pterodactyl\Http\Requests\Api\Application\Nests\GetNestsRequest $request - * - * @return array - * @throws \Illuminate\Contracts\Container\BindingResolutionException */ public function index(GetNestsRequest $request): array { diff --git a/app/Http/Controllers/Api/Application/Nodes/NodeConfigurationController.php b/app/Http/Controllers/Api/Application/Nodes/NodeConfigurationController.php index cb172140b..95ae70f3b 100644 --- a/app/Http/Controllers/Api/Application/Nodes/NodeConfigurationController.php +++ b/app/Http/Controllers/Api/Application/Nodes/NodeConfigurationController.php @@ -14,8 +14,6 @@ class NodeConfigurationController extends ApplicationApiController * to remote machines so long as an API key is provided to the machine to make the request * with, and the node is known. * - * @param \Pterodactyl\Http\Requests\Api\Application\Nodes\GetNodeRequest $request - * @param \Pterodactyl\Models\Node $node * @return \Illuminate\Http\JsonResponse */ public function __invoke(GetNodeRequest $request, Node $node) diff --git a/app/Http/Controllers/Api/Application/Nodes/NodeController.php b/app/Http/Controllers/Api/Application/Nodes/NodeController.php index dfa16fc22..725dfeda5 100644 --- a/app/Http/Controllers/Api/Application/Nodes/NodeController.php +++ b/app/Http/Controllers/Api/Application/Nodes/NodeController.php @@ -42,11 +42,6 @@ class NodeController extends ApplicationApiController /** * NodeController constructor. - * - * @param \Pterodactyl\Services\Nodes\NodeCreationService $creationService - * @param \Pterodactyl\Services\Nodes\NodeDeletionService $deletionService - * @param \Pterodactyl\Services\Nodes\NodeUpdateService $updateService - * @param \Pterodactyl\Contracts\Repository\NodeRepositoryInterface $repository */ public function __construct( NodeCreationService $creationService, @@ -64,11 +59,6 @@ class NodeController extends ApplicationApiController /** * Return all of the nodes currently available on the Panel. - * - * @param \Pterodactyl\Http\Requests\Api\Application\Nodes\GetNodesRequest $request - * - * @return array - * @throws \Illuminate\Contracts\Container\BindingResolutionException */ public function index(GetNodesRequest $request): array { @@ -91,12 +81,6 @@ class NodeController extends ApplicationApiController /** * Return data for a single instance of a node. - * - * @param \Pterodactyl\Http\Requests\Api\Application\Nodes\GetNodeRequest $request - * @param \Pterodactyl\Models\Node $node - * - * @return array - * @throws \Illuminate\Contracts\Container\BindingResolutionException */ public function view(GetNodeRequest $request, Node $node): array { @@ -109,11 +93,7 @@ class NodeController extends ApplicationApiController * Create a new node on the Panel. Returns the created node and a HTTP/201 * status response on success. * - * @param \Pterodactyl\Http\Requests\Api\Application\Nodes\StoreNodeRequest $request - * - * @return \Illuminate\Http\JsonResponse - * - * @throws \Pterodactyl\Exceptions\Model\DataValidationException*@throws \Illuminate\Contracts\Container\BindingResolutionException + * @throws \Pterodactyl\Exceptions\Model\DataValidationException */ public function store(StoreNodeRequest $request): JsonResponse { @@ -132,17 +112,14 @@ class NodeController extends ApplicationApiController /** * Update an existing node on the Panel. * - * @param \Pterodactyl\Http\Requests\Api\Application\Nodes\UpdateNodeRequest $request - * @param \Pterodactyl\Models\Node $node - * - * @return array - * * @throws \Throwable */ public function update(UpdateNodeRequest $request, Node $node): array { $node = $this->updateService->handle( - $node, $request->validated(), $request->input('reset_secret') === true + $node, + $request->validated(), + $request->input('reset_secret') === true ); return $this->fractal->item($node) @@ -154,11 +131,6 @@ class NodeController extends ApplicationApiController * Deletes a given node from the Panel as long as there are no servers * currently attached to it. * - * @param \Pterodactyl\Http\Requests\Api\Application\Nodes\DeleteNodeRequest $request - * @param \Pterodactyl\Models\Node $node - * - * @return \Illuminate\Http\JsonResponse - * * @throws \Pterodactyl\Exceptions\Service\HasActiveServersException */ public function delete(DeleteNodeRequest $request, Node $node): JsonResponse diff --git a/app/Http/Controllers/Api/Application/Nodes/NodeDeploymentController.php b/app/Http/Controllers/Api/Application/Nodes/NodeDeploymentController.php index 411b7d457..1714bf7ca 100644 --- a/app/Http/Controllers/Api/Application/Nodes/NodeDeploymentController.php +++ b/app/Http/Controllers/Api/Application/Nodes/NodeDeploymentController.php @@ -16,8 +16,6 @@ class NodeDeploymentController extends ApplicationApiController /** * NodeDeploymentController constructor. - * - * @param \Pterodactyl\Services\Deployment\FindViableNodesService $viableNodesService */ public function __construct(FindViableNodesService $viableNodesService) { @@ -31,9 +29,6 @@ class NodeDeploymentController extends ApplicationApiController * similarly to the server creation process, but allows you to pass the deployment object * to this endpoint and get back a list of all Nodes satisfying the requirements. * - * @param \Pterodactyl\Http\Requests\Api\Application\Nodes\GetDeployableNodesRequest $request - * @return array - * * @throws \Pterodactyl\Exceptions\Service\Deployment\NoViableNodeException */ public function __invoke(GetDeployableNodesRequest $request): array diff --git a/app/Http/Controllers/Api/Application/Servers/DatabaseController.php b/app/Http/Controllers/Api/Application/Servers/DatabaseController.php index 566bd98fd..8c0bfe615 100644 --- a/app/Http/Controllers/Api/Application/Servers/DatabaseController.php +++ b/app/Http/Controllers/Api/Application/Servers/DatabaseController.php @@ -35,17 +35,12 @@ class DatabaseController extends ApplicationApiController /** * DatabaseController constructor. - * - * @param \Pterodactyl\Services\Databases\DatabaseManagementService $databaseManagementService - * @param \Pterodactyl\Services\Databases\DatabasePasswordService $databasePasswordService - * @param \Pterodactyl\Contracts\Repository\DatabaseRepositoryInterface $repository */ public function __construct( DatabaseManagementService $databaseManagementService, DatabasePasswordService $databasePasswordService, DatabaseRepositoryInterface $repository - ) - { + ) { parent::__construct(); $this->databaseManagementService = $databaseManagementService; @@ -56,12 +51,6 @@ class DatabaseController extends ApplicationApiController /** * Return a listing of all databases currently available to a single * server. - * - * @param \Pterodactyl\Http\Requests\Api\Application\Servers\Databases\GetServerDatabasesRequest $request - * @param \Pterodactyl\Models\Server $server - * - * @return array - * @throws \Illuminate\Contracts\Container\BindingResolutionException */ public function index(GetServerDatabasesRequest $request, Server $server): array { @@ -72,13 +61,6 @@ class DatabaseController extends ApplicationApiController /** * Return a single server database. - * - * @param \Pterodactyl\Http\Requests\Api\Application\Servers\Databases\GetServerDatabaseRequest $request - * @param \Pterodactyl\Models\Server $server - * @param \Pterodactyl\Models\Database $database - * - * @return array - * @throws \Illuminate\Contracts\Container\BindingResolutionException */ public function view(GetServerDatabaseRequest $request, Server $server, Database $database): array { @@ -90,12 +72,6 @@ class DatabaseController extends ApplicationApiController /** * Reset the password for a specific server database. * - * @param \Pterodactyl\Http\Requests\Api\Application\Servers\Databases\ServerDatabaseWriteRequest $request - * @param \Pterodactyl\Models\Server $server - * @param \Pterodactyl\Models\Database $database - * - * @return \Illuminate\Http\JsonResponse - * * @throws \Throwable */ public function resetPassword(ServerDatabaseWriteRequest $request, Server $server, Database $database): JsonResponse @@ -108,11 +84,6 @@ class DatabaseController extends ApplicationApiController /** * Create a new database on the Panel for a given server. * - * @param \Pterodactyl\Http\Requests\Api\Application\Servers\Databases\StoreServerDatabaseRequest $request - * @param \Pterodactyl\Models\Server $server - * - * @return \Illuminate\Http\JsonResponse - * * @throws \Throwable */ public function store(StoreServerDatabaseRequest $request, Server $server): JsonResponse @@ -135,12 +106,7 @@ class DatabaseController extends ApplicationApiController /** * Handle a request to delete a specific server database from the Panel. * - * @param \Pterodactyl\Http\Requests\Api\Application\Servers\Databases\ServerDatabaseWriteRequest $request - * @param \Pterodactyl\Models\Database $database - * - * @return \Illuminate\Http\JsonResponse - * - * @throws \Exception + * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ public function delete(ServerDatabaseWriteRequest $request, Database $database): JsonResponse { diff --git a/app/Http/Controllers/Api/Application/Servers/ExternalServerController.php b/app/Http/Controllers/Api/Application/Servers/ExternalServerController.php index 45c0243cc..0cecb977a 100644 --- a/app/Http/Controllers/Api/Application/Servers/ExternalServerController.php +++ b/app/Http/Controllers/Api/Application/Servers/ExternalServerController.php @@ -10,11 +10,6 @@ class ExternalServerController extends ApplicationApiController { /** * Retrieve a specific server from the database using its external ID. - * - * @param \Pterodactyl\Http\Requests\Api\Application\Servers\GetExternalServerRequest $request - * - * @return array - * @throws \Illuminate\Contracts\Container\BindingResolutionException */ public function index(GetExternalServerRequest $request): array { diff --git a/app/Http/Controllers/Api/Application/Servers/ServerController.php b/app/Http/Controllers/Api/Application/Servers/ServerController.php index cdd965544..9481fe8e3 100644 --- a/app/Http/Controllers/Api/Application/Servers/ServerController.php +++ b/app/Http/Controllers/Api/Application/Servers/ServerController.php @@ -30,9 +30,6 @@ class ServerController extends ApplicationApiController /** * ServerController constructor. - * - * @param \Pterodactyl\Services\Servers\ServerCreationService $creationService - * @param \Pterodactyl\Services\Servers\ServerDeletionService $deletionService */ public function __construct( ServerCreationService $creationService, @@ -46,11 +43,6 @@ class ServerController extends ApplicationApiController /** * Return all of the servers that currently exist on the Panel. - * - * @param \Pterodactyl\Http\Requests\Api\Application\Servers\GetServersRequest $request - * - * @return array - * @throws \Illuminate\Contracts\Container\BindingResolutionException */ public function index(GetServersRequest $request): array { @@ -74,10 +66,6 @@ class ServerController extends ApplicationApiController /** * Create a new server on the system. * - * @param \Pterodactyl\Http\Requests\Api\Application\Servers\StoreServerRequest $request - * - * @return \Illuminate\Http\JsonResponse - * * @throws \Throwable * @throws \Illuminate\Validation\ValidationException * @throws \Pterodactyl\Exceptions\DisplayException @@ -96,12 +84,6 @@ class ServerController extends ApplicationApiController /** * Show a single server transformed for the application API. - * - * @param \Pterodactyl\Http\Requests\Api\Application\Servers\GetServerRequest $request - * @param \Pterodactyl\Models\Server $server - * - * @return array - * @throws \Illuminate\Contracts\Container\BindingResolutionException */ public function view(GetServerRequest $request, Server $server): array { @@ -111,15 +93,7 @@ class ServerController extends ApplicationApiController } /** - * Deletes a server. - * - * @param \Pterodactyl\Http\Requests\Api\Application\Servers\ServerWriteRequest $request - * @param \Pterodactyl\Models\Server $server - * @param string $force - * - * @return \Illuminate\Http\Response - * - * @throws \Throwable + * @throws \Pterodactyl\Exceptions\DisplayException */ public function delete(ServerWriteRequest $request, Server $server, string $force = ''): Response { diff --git a/app/Http/Controllers/Api/Application/Servers/ServerDetailsController.php b/app/Http/Controllers/Api/Application/Servers/ServerDetailsController.php index 4cd9bc3d2..fde6e03e3 100644 --- a/app/Http/Controllers/Api/Application/Servers/ServerDetailsController.php +++ b/app/Http/Controllers/Api/Application/Servers/ServerDetailsController.php @@ -24,9 +24,6 @@ class ServerDetailsController extends ApplicationApiController /** * ServerDetailsController constructor. - * - * @param \Pterodactyl\Services\Servers\BuildModificationService $buildModificationService - * @param \Pterodactyl\Services\Servers\DetailsModificationService $detailsModificationService */ public function __construct( BuildModificationService $buildModificationService, @@ -41,18 +38,15 @@ class ServerDetailsController extends ApplicationApiController /** * Update the details for a specific server. * - * @param \Pterodactyl\Http\Requests\Api\Application\Servers\UpdateServerDetailsRequest $request - * @param \Pterodactyl\Models\Server $server - * - * @return array - * - * @throws \Illuminate\Contracts\Container\BindingResolutionException - * @throws \Throwable + * @throws \Pterodactyl\Exceptions\DisplayException + * @throws \Pterodactyl\Exceptions\Model\DataValidationException + * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ public function details(UpdateServerDetailsRequest $request, Server $server): array { $server = $this->detailsModificationService->returnUpdatedModel()->handle( - $server, $request->validated() + $server, + $request->validated() ); return $this->fractal->item($server) @@ -65,11 +59,11 @@ class ServerDetailsController extends ApplicationApiController * * @param \Pterodactyl\Http\Requests\Api\Application\Servers\UpdateServerBuildConfigurationRequest $request * @param \Pterodactyl\Models\Server $server - * * @return array * - * @throws \Throwable * @throws \Pterodactyl\Exceptions\DisplayException + * @throws \Pterodactyl\Exceptions\Model\DataValidationException + * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ public function build(UpdateServerBuildConfigurationRequest $request, Server $server): array { diff --git a/app/Http/Controllers/Api/Application/Servers/ServerManagementController.php b/app/Http/Controllers/Api/Application/Servers/ServerManagementController.php index f1b78aca3..ddbbbe1dd 100644 --- a/app/Http/Controllers/Api/Application/Servers/ServerManagementController.php +++ b/app/Http/Controllers/Api/Application/Servers/ServerManagementController.php @@ -23,9 +23,6 @@ class ServerManagementController extends ApplicationApiController /** * SuspensionController constructor. - * - * @param \Pterodactyl\Services\Servers\ReinstallServerService $reinstallServerService - * @param \Pterodactyl\Services\Servers\SuspensionService $suspensionService */ public function __construct( ReinstallServerService $reinstallServerService, @@ -40,11 +37,6 @@ class ServerManagementController extends ApplicationApiController /** * Suspend a server on the Panel. * - * @param \Pterodactyl\Http\Requests\Api\Application\Servers\ServerWriteRequest $request - * @param \Pterodactyl\Models\Server $server - * - * @return \Illuminate\Http\Response - * * @throws \Throwable */ public function suspend(ServerWriteRequest $request, Server $server): Response @@ -57,11 +49,6 @@ class ServerManagementController extends ApplicationApiController /** * Unsuspend a server on the Panel. * - * @param \Pterodactyl\Http\Requests\Api\Application\Servers\ServerWriteRequest $request - * @param \Pterodactyl\Models\Server $server - * - * @return \Illuminate\Http\Response - * * @throws \Throwable */ public function unsuspend(ServerWriteRequest $request, Server $server): Response @@ -74,12 +61,9 @@ class ServerManagementController extends ApplicationApiController /** * Mark a server as needing to be reinstalled. * - * @param \Pterodactyl\Http\Requests\Api\Application\Servers\ServerWriteRequest $request - * @param \Pterodactyl\Models\Server $server - * - * @return \Illuminate\Http\Response - * - * @throws \Throwable + * @throws \Pterodactyl\Exceptions\DisplayException + * @throws \Pterodactyl\Exceptions\Model\DataValidationException + * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ public function reinstall(ServerWriteRequest $request, Server $server): Response { diff --git a/app/Http/Controllers/Api/Application/Servers/StartupController.php b/app/Http/Controllers/Api/Application/Servers/StartupController.php index f114132b2..6c854102b 100644 --- a/app/Http/Controllers/Api/Application/Servers/StartupController.php +++ b/app/Http/Controllers/Api/Application/Servers/StartupController.php @@ -18,8 +18,6 @@ class StartupController extends ApplicationApiController /** * StartupController constructor. - * - * @param \Pterodactyl\Services\Servers\StartupModificationService $modificationService */ public function __construct(StartupModificationService $modificationService) { @@ -31,11 +29,10 @@ class StartupController extends ApplicationApiController /** * Update the startup and environment settings for a specific server. * - * @param \Pterodactyl\Http\Requests\Api\Application\Servers\UpdateServerStartupRequest $request - * @param \Pterodactyl\Models\Server $server - * - * @return array - * @throws \Throwable + * @throws \Illuminate\Validation\ValidationException + * @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException + * @throws \Pterodactyl\Exceptions\Model\DataValidationException + * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ public function index(UpdateServerStartupRequest $request, Server $server): array { diff --git a/app/Http/Controllers/Api/Application/Users/ExternalUserController.php b/app/Http/Controllers/Api/Application/Users/ExternalUserController.php index 02d435f27..a253b6e19 100644 --- a/app/Http/Controllers/Api/Application/Users/ExternalUserController.php +++ b/app/Http/Controllers/Api/Application/Users/ExternalUserController.php @@ -10,11 +10,6 @@ class ExternalUserController extends ApplicationApiController { /** * Retrieve a specific user from the database using their external ID. - * - * @param \Pterodactyl\Http\Requests\Api\Application\Users\GetExternalUserRequest $request - * - * @return array - * @throws \Illuminate\Contracts\Container\BindingResolutionException */ public function index(GetExternalUserRequest $request): array { diff --git a/app/Http/Controllers/Api/Application/Users/UserController.php b/app/Http/Controllers/Api/Application/Users/UserController.php index 905abeb73..b6332f252 100644 --- a/app/Http/Controllers/Api/Application/Users/UserController.php +++ b/app/Http/Controllers/Api/Application/Users/UserController.php @@ -42,11 +42,6 @@ class UserController extends ApplicationApiController /** * UserController constructor. - * - * @param \Pterodactyl\Contracts\Repository\UserRepositoryInterface $repository - * @param \Pterodactyl\Services\Users\UserCreationService $creationService - * @param \Pterodactyl\Services\Users\UserDeletionService $deletionService - * @param \Pterodactyl\Services\Users\UserUpdateService $updateService */ public function __construct( UserRepositoryInterface $repository, @@ -94,12 +89,6 @@ class UserController extends ApplicationApiController /** * Handle a request to view a single user. Includes any relations that * were defined in the request. - * - * @param \Pterodactyl\Http\Requests\Api\Application\Users\GetUserRequest $request - * @param \Pterodactyl\Models\User $user - * - * @return array - * @throws \Illuminate\Contracts\Container\BindingResolutionException */ public function view(GetUserRequest $request, User $user): array { @@ -116,11 +105,6 @@ class UserController extends ApplicationApiController * Revocation errors are returned under the 'revocation_errors' key in the response * meta. If there are no errors this is an empty array. * - * @param \Pterodactyl\Http\Requests\Api\Application\Users\UpdateUserRequest $request - * @param \Pterodactyl\Models\User $user - * - * @return array - * * @throws \Pterodactyl\Exceptions\Model\DataValidationException * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException * @throws \Illuminate\Contracts\Container\BindingResolutionException @@ -139,10 +123,6 @@ class UserController extends ApplicationApiController * Store a new user on the system. Returns the created user and a HTTP/201 * header on successful creation. * - * @param \Pterodactyl\Http\Requests\Api\Application\Users\StoreUserRequest $request - * - * @return \Illuminate\Http\JsonResponse - * * @throws \Exception * @throws \Pterodactyl\Exceptions\Model\DataValidationException */ @@ -164,11 +144,6 @@ class UserController extends ApplicationApiController * Handle a request to delete a user from the Panel. Returns a HTTP/204 response * on successful deletion. * - * @param \Pterodactyl\Http\Requests\Api\Application\Users\DeleteUserRequest $request - * @param \Pterodactyl\Models\User $user - * - * @return \Illuminate\Http\JsonResponse - * * @throws \Pterodactyl\Exceptions\DisplayException */ public function delete(DeleteUserRequest $request, User $user): JsonResponse diff --git a/app/Http/Controllers/Api/Client/AccountController.php b/app/Http/Controllers/Api/Client/AccountController.php index 25900f059..5e790d474 100644 --- a/app/Http/Controllers/Api/Client/AccountController.php +++ b/app/Http/Controllers/Api/Client/AccountController.php @@ -25,9 +25,6 @@ class AccountController extends ClientApiController /** * AccountController constructor. - * - * @param \Illuminate\Auth\AuthManager $sessionGuard - * @param \Pterodactyl\Services\Users\UserUpdateService $updateService */ public function __construct(AuthManager $sessionGuard, UserUpdateService $updateService) { @@ -37,10 +34,6 @@ class AccountController extends ClientApiController $this->sessionGuard = $sessionGuard; } - /** - * @param Request $request - * @return array - */ public function index(Request $request): array { return $this->fractal->item($request->user()) @@ -51,9 +44,6 @@ class AccountController extends ClientApiController /** * Update the authenticated user's email address. * - * @param \Pterodactyl\Http\Requests\Api\Client\Account\UpdateEmailRequest $request - * @return \Illuminate\Http\JsonResponse - * * @throws \Pterodactyl\Exceptions\Model\DataValidationException * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ @@ -68,9 +58,6 @@ class AccountController extends ClientApiController * Update the authenticated user's password. All existing sessions will be logged * out immediately. * - * @param \Pterodactyl\Http\Requests\Api\Client\Account\UpdatePasswordRequest $request - * @return \Illuminate\Http\JsonResponse - * * @throws \Pterodactyl\Exceptions\Model\DataValidationException * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ diff --git a/app/Http/Controllers/Api/Client/ApiKeyController.php b/app/Http/Controllers/Api/Client/ApiKeyController.php index 5662e19cd..34694d66c 100644 --- a/app/Http/Controllers/Api/Client/ApiKeyController.php +++ b/app/Http/Controllers/Api/Client/ApiKeyController.php @@ -32,10 +32,6 @@ class ApiKeyController extends ClientApiController /** * ApiKeyController constructor. - * - * @param \Illuminate\Contracts\Encryption\Encrypter $encrypter - * @param \Pterodactyl\Services\Api\KeyCreationService $keyCreationService - * @param \Pterodactyl\Repositories\Eloquent\ApiKeyRepository $repository */ public function __construct( Encrypter $encrypter, @@ -52,7 +48,6 @@ class ApiKeyController extends ClientApiController /** * Returns all of the API keys that exist for the given client. * - * @param \Pterodactyl\Http\Requests\Api\Client\ClientApiRequest $request * @return array */ public function index(ClientApiRequest $request) @@ -65,7 +60,6 @@ class ApiKeyController extends ClientApiController /** * Store a new API key for a user's account. * - * @param \Pterodactyl\Http\Requests\Api\Client\Account\StoreApiKeyRequest $request * @return array * * @throws \Pterodactyl\Exceptions\DisplayException @@ -74,9 +68,7 @@ class ApiKeyController extends ClientApiController public function store(StoreApiKeyRequest $request) { if ($request->user()->apiKeys->count() >= 5) { - throw new DisplayException( - 'You have reached the account limit for number of API keys.' - ); + throw new DisplayException('You have reached the account limit for number of API keys.'); } $key = $this->keyCreationService->setKeyType(ApiKey::TYPE_ACCOUNT)->handle([ @@ -96,8 +88,6 @@ class ApiKeyController extends ClientApiController /** * Deletes a given API key. * - * @param \Pterodactyl\Http\Requests\Api\Client\ClientApiRequest $request - * @param string $identifier * @return \Illuminate\Http\JsonResponse */ public function delete(ClientApiRequest $request, string $identifier) @@ -108,8 +98,8 @@ class ApiKeyController extends ClientApiController 'identifier' => $identifier, ]); - if (! $response) { - throw new NotFoundHttpException; + if (!$response) { + throw new NotFoundHttpException(); } return JsonResponse::create([], JsonResponse::HTTP_NO_CONTENT); diff --git a/app/Http/Controllers/Api/Client/ClientApiController.php b/app/Http/Controllers/Api/Client/ClientApiController.php index 56c3db1f7..c7f6f1a49 100644 --- a/app/Http/Controllers/Api/Client/ClientApiController.php +++ b/app/Http/Controllers/Api/Client/ClientApiController.php @@ -13,8 +13,6 @@ abstract class ClientApiController extends ApplicationApiController /** * Returns only the includes which are valid for the given transformer. * - * @param \Pterodactyl\Transformers\Api\Client\BaseClientTransformer $transformer - * @param array $merge * @return string[] */ protected function getIncludesForTransformer(BaseClientTransformer $transformer, array $merge = []) @@ -35,7 +33,7 @@ abstract class ClientApiController extends ApplicationApiController { $includes = $this->request->query('include') ?? []; - if (! is_string($includes)) { + if (!is_string($includes)) { return $includes; } @@ -47,7 +45,6 @@ abstract class ClientApiController extends ApplicationApiController /** * Return an instance of an application transformer. * - * @param string $abstract * @return \Pterodactyl\Transformers\Api\Client\BaseClientTransformer */ public function getTransformer(string $abstract) diff --git a/app/Http/Controllers/Api/Client/ClientController.php b/app/Http/Controllers/Api/Client/ClientController.php index 243868b5e..16923c56f 100644 --- a/app/Http/Controllers/Api/Client/ClientController.php +++ b/app/Http/Controllers/Api/Client/ClientController.php @@ -20,8 +20,6 @@ class ClientController extends ClientApiController /** * ClientController constructor. - * - * @param \Pterodactyl\Repositories\Eloquent\ServerRepository $repository */ public function __construct(ServerRepository $repository) { @@ -33,9 +31,6 @@ class ClientController extends ClientApiController /** * Return all of the servers available to the client making the API * request, including servers the user has access to as a subuser. - * - * @param \Pterodactyl\Http\Requests\Api\Client\GetServersRequest $request - * @return array */ public function index(GetServersRequest $request): array { @@ -49,7 +44,7 @@ class ClientController extends ClientApiController 'uuid', 'name', 'external_id', - AllowedFilter::custom('*', new MultiFieldServerFilter), + AllowedFilter::custom('*', new MultiFieldServerFilter()), ]); $type = $request->input('type'); @@ -60,14 +55,14 @@ class ClientController extends ClientApiController if (in_array($type, ['admin', 'admin-all'])) { // If they aren't an admin but want all the admin servers don't fail the request, just // make it a query that will never return any results back. - if (! $user->root_admin) { + if (!$user->root_admin) { $builder->whereRaw('1 = 2'); } else { $builder = $type === 'admin-all' ? $builder : $builder->whereNotIn('servers.id', $user->accessibleServers()->pluck('id')->all()); } - } else if ($type === 'owner') { + } elseif ($type === 'owner') { $builder = $builder->where('servers.owner_id', $user->id); } else { $builder = $builder->whereIn('servers.id', $user->accessibleServers()->pluck('id')->all()); diff --git a/app/Http/Controllers/Api/Client/Servers/BackupController.php b/app/Http/Controllers/Api/Client/Servers/BackupController.php index 23daf1bc6..2b83c63e3 100644 --- a/app/Http/Controllers/Api/Client/Servers/BackupController.php +++ b/app/Http/Controllers/Api/Client/Servers/BackupController.php @@ -33,10 +33,6 @@ class BackupController extends ClientApiController /** * BackupController constructor. - * - * @param \Pterodactyl\Repositories\Eloquent\BackupRepository $repository - * @param \Pterodactyl\Services\Backups\DeleteBackupService $deleteBackupService - * @param \Pterodactyl\Services\Backups\InitiateBackupService $initiateBackupService */ public function __construct( BackupRepository $repository, @@ -54,13 +50,12 @@ class BackupController extends ClientApiController * Returns all of the backups for a given server instance in a paginated * result set. * - * @param \Pterodactyl\Http\Requests\Api\Client\Servers\Backups\GetBackupsRequest $request - * @param \Pterodactyl\Models\Server $server * @return array */ public function index(GetBackupsRequest $request, Server $server) { $limit = min($request->query('per_page') ?? 20, 50); + return $this->fractal->collection($server->backups()->paginate($limit)) ->transformWith($this->getTransformer(BackupTransformer::class)) ->toArray(); @@ -69,8 +64,6 @@ class BackupController extends ClientApiController /** * Starts the backup process for a server. * - * @param \Pterodactyl\Http\Requests\Api\Client\Servers\Backups\StoreBackupRequest $request - * @param \Pterodactyl\Models\Server $server * @return array * * @throws \Exception|\Throwable @@ -91,9 +84,6 @@ class BackupController extends ClientApiController /** * Returns information about a single backup. * - * @param \Pterodactyl\Http\Requests\Api\Client\Servers\Backups\GetBackupsRequest $request - * @param \Pterodactyl\Models\Server $server - * @param \Pterodactyl\Models\Backup $backup * @return array */ public function view(GetBackupsRequest $request, Server $server, Backup $backup) @@ -107,9 +97,6 @@ class BackupController extends ClientApiController * Deletes a backup from the panel as well as the remote source where it is currently * being stored. * - * @param \Pterodactyl\Http\Requests\Api\Client\Servers\Backups\DeleteBackupRequest $request - * @param \Pterodactyl\Models\Server $server - * @param \Pterodactyl\Models\Backup $backup * @return \Illuminate\Http\JsonResponse * * @throws \Throwable diff --git a/app/Http/Controllers/Api/Client/Servers/CommandController.php b/app/Http/Controllers/Api/Client/Servers/CommandController.php index b8390673e..f9663138c 100644 --- a/app/Http/Controllers/Api/Client/Servers/CommandController.php +++ b/app/Http/Controllers/Api/Client/Servers/CommandController.php @@ -21,8 +21,6 @@ class CommandController extends ClientApiController /** * CommandController constructor. - * - * @param \Pterodactyl\Repositories\Wings\DaemonCommandRepository $repository */ public function __construct(DaemonCommandRepository $repository) { @@ -34,10 +32,6 @@ class CommandController extends ClientApiController /** * Send a command to a running server. * - * @param \Pterodactyl\Http\Requests\Api\Client\Servers\SendCommandRequest $request - * @param \Pterodactyl\Models\Server $server - * @return \Illuminate\Http\Response - * * @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException */ public function index(SendCommandRequest $request, Server $server): Response @@ -52,9 +46,7 @@ class CommandController extends ClientApiController $previous->getResponse() instanceof ResponseInterface && $previous->getResponse()->getStatusCode() === Response::HTTP_BAD_GATEWAY ) { - throw new HttpException( - Response::HTTP_BAD_GATEWAY, 'Server must be online in order to send commands.', $exception - ); + throw new HttpException(Response::HTTP_BAD_GATEWAY, 'Server must be online in order to send commands.', $exception); } } diff --git a/app/Http/Controllers/Api/Client/Servers/DatabaseController.php b/app/Http/Controllers/Api/Client/Servers/DatabaseController.php index 2eacfb9e2..4f9aed59d 100644 --- a/app/Http/Controllers/Api/Client/Servers/DatabaseController.php +++ b/app/Http/Controllers/Api/Client/Servers/DatabaseController.php @@ -40,11 +40,6 @@ class DatabaseController extends ClientApiController /** * DatabaseController constructor. - * - * @param \Pterodactyl\Services\Databases\DatabaseManagementService $managementService - * @param \Pterodactyl\Services\Databases\DatabasePasswordService $passwordService - * @param \Pterodactyl\Repositories\Eloquent\DatabaseRepository $repository - * @param \Pterodactyl\Services\Databases\DeployServerDatabaseService $deployDatabaseService */ public function __construct( DatabaseManagementService $managementService, @@ -62,10 +57,6 @@ class DatabaseController extends ClientApiController /** * Return all of the databases that belong to the given server. - * - * @param \Pterodactyl\Http\Requests\Api\Client\Servers\Databases\GetDatabasesRequest $request - * @param \Pterodactyl\Models\Server $server - * @return array */ public function index(GetDatabasesRequest $request, Server $server): array { @@ -77,10 +68,6 @@ class DatabaseController extends ClientApiController /** * Create a new database for the given server and return it. * - * @param \Pterodactyl\Http\Requests\Api\Client\Servers\Databases\StoreDatabaseRequest $request - * @param \Pterodactyl\Models\Server $server - * @return array - * * @throws \Throwable * @throws \Pterodactyl\Exceptions\Service\Database\TooManyDatabasesException * @throws \Pterodactyl\Exceptions\Service\Database\DatabaseClientFeatureNotEnabledException @@ -99,9 +86,6 @@ class DatabaseController extends ClientApiController * Rotates the password for the given server model and returns a fresh instance to * the caller. * - * @param \Pterodactyl\Http\Requests\Api\Client\Servers\Databases\RotatePasswordRequest $request - * @param \Pterodactyl\Models\Server $server - * @param \Pterodactyl\Models\Database $database * @return array * * @throws \Throwable @@ -120,11 +104,6 @@ class DatabaseController extends ClientApiController /** * Removes a database from the server. * - * @param \Pterodactyl\Http\Requests\Api\Client\Servers\Databases\DeleteDatabaseRequest $request - * @param \Pterodactyl\Models\Server $server - * @param \Pterodactyl\Models\Database $database - * @return \Illuminate\Http\Response - * * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ public function delete(DeleteDatabaseRequest $request, Server $server, Database $database): Response diff --git a/app/Http/Controllers/Api/Client/Servers/DownloadBackupController.php b/app/Http/Controllers/Api/Client/Servers/DownloadBackupController.php index 52f18ec43..fb7bc4717 100644 --- a/app/Http/Controllers/Api/Client/Servers/DownloadBackupController.php +++ b/app/Http/Controllers/Api/Client/Servers/DownloadBackupController.php @@ -39,11 +39,6 @@ class DownloadBackupController extends ClientApiController /** * DownloadBackupController constructor. - * - * @param \Pterodactyl\Repositories\Wings\DaemonBackupRepository $daemonBackupRepository - * @param \Pterodactyl\Services\Nodes\NodeJWTService $jwtService - * @param \Pterodactyl\Extensions\Backups\BackupManager $backupManager - * @param \Illuminate\Contracts\Routing\ResponseFactory $responseFactory */ public function __construct( DaemonBackupRepository $daemonBackupRepository, @@ -64,9 +59,6 @@ class DownloadBackupController extends ClientApiController * will be streamed back through the Panel. For AWS S3 files, a signed URL will be generated * which the user is redirected to. * - * @param \Pterodactyl\Http\Requests\Api\Client\Servers\Backups\DownloadBackupRequest $request - * @param \Pterodactyl\Models\Server $server - * @param \Pterodactyl\Models\Backup $backup * @return \Illuminate\Http\JsonResponse */ public function __invoke(DownloadBackupRequest $request, Server $server, Backup $backup) @@ -79,7 +71,7 @@ class DownloadBackupController extends ClientApiController $url = $this->getS3BackupUrl($backup, $server); break; default: - throw new BadRequestHttpException; + throw new BadRequestHttpException(); } return new JsonResponse([ @@ -94,8 +86,6 @@ class DownloadBackupController extends ClientApiController * Returns a signed URL that allows us to download a file directly out of a non-public * S3 bucket by using a signed URL. * - * @param \Pterodactyl\Models\Backup $backup - * @param \Pterodactyl\Models\Server $server * @return string */ protected function getS3BackupUrl(Backup $backup, Server $server) @@ -120,9 +110,6 @@ class DownloadBackupController extends ClientApiController /** * Returns a download link a backup stored on a wings instance. * - * @param \Pterodactyl\Models\Backup $backup - * @param \Pterodactyl\Models\Server $server - * @param \Pterodactyl\Models\User $user * @return string */ protected function getLocalBackupUrl(Backup $backup, Server $server, User $user) @@ -138,7 +125,7 @@ class DownloadBackupController extends ClientApiController return sprintf( '%s/download/backup?token=%s', $server->node->getConnectionAddress(), - $token->__toString() + $token->toString() ); } } diff --git a/app/Http/Controllers/Api/Client/Servers/FileController.php b/app/Http/Controllers/Api/Client/Servers/FileController.php index 6174ebf9d..b3d697266 100644 --- a/app/Http/Controllers/Api/Client/Servers/FileController.php +++ b/app/Http/Controllers/Api/Client/Servers/FileController.php @@ -6,7 +6,6 @@ use Carbon\CarbonImmutable; use Illuminate\Http\Response; use Pterodactyl\Models\Server; use Illuminate\Http\JsonResponse; -use Illuminate\Support\Collection; use Pterodactyl\Services\Nodes\NodeJWTService; use Illuminate\Contracts\Routing\ResponseFactory; use Pterodactyl\Repositories\Wings\DaemonFileRepository; @@ -15,9 +14,9 @@ use Pterodactyl\Http\Controllers\Api\Client\ClientApiController; use Pterodactyl\Http\Requests\Api\Client\Servers\Files\CopyFileRequest; use Pterodactyl\Http\Requests\Api\Client\Servers\Files\PullFileRequest; use Pterodactyl\Http\Requests\Api\Client\Servers\Files\ListFilesRequest; +use Pterodactyl\Http\Requests\Api\Client\Servers\Files\ChmodFilesRequest; use Pterodactyl\Http\Requests\Api\Client\Servers\Files\DeleteFileRequest; use Pterodactyl\Http\Requests\Api\Client\Servers\Files\RenameFileRequest; -use Pterodactyl\Http\Requests\Api\Client\Servers\Files\ChmodFilesRequest; use Pterodactyl\Http\Requests\Api\Client\Servers\Files\CreateFolderRequest; use Pterodactyl\Http\Requests\Api\Client\Servers\Files\CompressFilesRequest; use Pterodactyl\Http\Requests\Api\Client\Servers\Files\DecompressFilesRequest; @@ -43,10 +42,6 @@ class FileController extends ClientApiController /** * FileController constructor. - * - * @param \Illuminate\Contracts\Routing\ResponseFactory $responseFactory - * @param \Pterodactyl\Services\Nodes\NodeJWTService $jwtService - * @param \Pterodactyl\Repositories\Wings\DaemonFileRepository $fileRepository */ public function __construct( ResponseFactory $responseFactory, @@ -63,10 +58,6 @@ class FileController extends ClientApiController /** * Returns a listing of files in a given directory. * - * @param \Pterodactyl\Http\Requests\Api\Client\Servers\Files\ListFilesRequest $request - * @param \Pterodactyl\Models\Server $server - * @return array - * * @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException */ public function directory(ListFilesRequest $request, Server $server): array @@ -83,10 +74,6 @@ class FileController extends ClientApiController /** * Return the contents of a specified file for the user. * - * @param \Pterodactyl\Http\Requests\Api\Client\Servers\Files\GetFileContentsRequest $request - * @param \Pterodactyl\Models\Server $server - * @return \Illuminate\Http\Response - * * @throws \Pterodactyl\Exceptions\Http\Server\FileSizeTooLargeException * @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException */ @@ -94,7 +81,8 @@ class FileController extends ClientApiController { return new Response( $this->fileRepository->setServer($server)->getContent( - $request->get('file'), config('pterodactyl.files.max_edit_size') + $request->get('file'), + config('pterodactyl.files.max_edit_size') ), Response::HTTP_OK, ['Content-Type' => 'text/plain'] @@ -105,8 +93,6 @@ class FileController extends ClientApiController * Generates a one-time token with a link that the user can use to * download a given file. * - * @param \Pterodactyl\Http\Requests\Api\Client\Servers\Files\GetFileContentsRequest $request - * @param \Pterodactyl\Models\Server $server * @return array * * @throws \Exception @@ -127,7 +113,7 @@ class FileController extends ClientApiController 'url' => sprintf( '%s/download/file?token=%s', $server->node->getConnectionAddress(), - $token->__toString() + $token->toString() ), ], ]; @@ -136,10 +122,6 @@ class FileController extends ClientApiController /** * Writes the contents of the specified file to the server. * - * @param \Pterodactyl\Http\Requests\Api\Client\Servers\Files\WriteFileContentRequest $request - * @param \Pterodactyl\Models\Server $server - * @return \Illuminate\Http\JsonResponse - * * @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException */ public function write(WriteFileContentRequest $request, Server $server): JsonResponse @@ -152,10 +134,6 @@ class FileController extends ClientApiController /** * Creates a new folder on the server. * - * @param \Pterodactyl\Http\Requests\Api\Client\Servers\Files\CreateFolderRequest $request - * @param \Pterodactyl\Models\Server $server - * @return \Illuminate\Http\JsonResponse - * * @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException */ public function create(CreateFolderRequest $request, Server $server): JsonResponse @@ -170,10 +148,6 @@ class FileController extends ClientApiController /** * Renames a file on the remote machine. * - * @param \Pterodactyl\Http\Requests\Api\Client\Servers\Files\RenameFileRequest $request - * @param \Pterodactyl\Models\Server $server - * @return \Illuminate\Http\JsonResponse - * * @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException */ public function rename(RenameFileRequest $request, Server $server): JsonResponse @@ -188,10 +162,6 @@ class FileController extends ClientApiController /** * Copies a file on the server. * - * @param \Pterodactyl\Http\Requests\Api\Client\Servers\Files\CopyFileRequest $request - * @param \Pterodactyl\Models\Server $server - * @return \Illuminate\Http\JsonResponse - * * @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException */ public function copy(CopyFileRequest $request, Server $server): JsonResponse @@ -204,10 +174,6 @@ class FileController extends ClientApiController } /** - * @param \Pterodactyl\Http\Requests\Api\Client\Servers\Files\CompressFilesRequest $request - * @param \Pterodactyl\Models\Server $server - * @return array - * * @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException */ public function compress(CompressFilesRequest $request, Server $server): array @@ -217,7 +183,8 @@ class FileController extends ClientApiController $file = $this->fileRepository->setServer($server) ->compressFiles( - $request->input('root'), $request->input('files') + $request->input('root'), + $request->input('files') ); return $this->fractal->item($file) @@ -226,10 +193,6 @@ class FileController extends ClientApiController } /** - * @param \Pterodactyl\Http\Requests\Api\Client\Servers\Files\DecompressFilesRequest $request - * @param \Pterodactyl\Models\Server $server - * @return \Illuminate\Http\JsonResponse - * * @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException */ public function decompress(DecompressFilesRequest $request, Server $server): JsonResponse @@ -246,17 +209,14 @@ class FileController extends ClientApiController /** * Deletes files or folders for the server in the given root directory. * - * @param \Pterodactyl\Http\Requests\Api\Client\Servers\Files\DeleteFileRequest $request - * @param \Pterodactyl\Models\Server $server - * @return \Illuminate\Http\JsonResponse - * * @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException */ public function delete(DeleteFileRequest $request, Server $server): JsonResponse { $this->fileRepository->setServer($server) ->deleteFiles( - $request->input('root'), $request->input('files') + $request->input('root'), + $request->input('files') ); return new JsonResponse([], Response::HTTP_NO_CONTENT); @@ -265,17 +225,14 @@ class FileController extends ClientApiController /** * Updates file permissions for file(s) in the given root directory. * - * @param \Pterodactyl\Http\Requests\Api\Client\Servers\Files\ChmodFilesRequest $request - * @param \Pterodactyl\Models\Server $server - * @return \Illuminate\Http\JsonResponse - * * @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException */ public function chmod(ChmodFilesRequest $request, Server $server): JsonResponse { $this->fileRepository->setServer($server) ->chmodFiles( - $request->input('root'), $request->input('files') + $request->input('root'), + $request->input('files') ); return new JsonResponse([], Response::HTTP_NO_CONTENT); @@ -285,8 +242,6 @@ class FileController extends ClientApiController * Requests that a file be downloaded from a remote location by Wings. * * @param $request - * @param \Pterodactyl\Models\Server $server - * @return \Illuminate\Http\JsonResponse * * @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException */ diff --git a/app/Http/Controllers/Api/Client/Servers/FileUploadController.php b/app/Http/Controllers/Api/Client/Servers/FileUploadController.php index aa06f22fd..130740c32 100644 --- a/app/Http/Controllers/Api/Client/Servers/FileUploadController.php +++ b/app/Http/Controllers/Api/Client/Servers/FileUploadController.php @@ -19,8 +19,6 @@ class FileUploadController extends ClientApiController /** * FileUploadController constructor. - * - * @param \Pterodactyl\Services\Nodes\NodeJWTService $jwtService */ public function __construct( NodeJWTService $jwtService @@ -33,9 +31,6 @@ class FileUploadController extends ClientApiController /** * Returns a url where files can be uploaded to. * - * @param \Pterodactyl\Http\Requests\Api\Client\Servers\Files\UploadFileRequest $request - * @param \Pterodactyl\Models\Server $server - * * @return \Illuminate\Http\JsonResponse */ public function __invoke(UploadFileRequest $request, Server $server) @@ -51,8 +46,6 @@ class FileUploadController extends ClientApiController /** * Returns a url where files can be uploaded to. * - * @param \Pterodactyl\Models\Server $server - * @param \Pterodactyl\Models\User $user * @return string */ protected function getUploadUrl(Server $server, User $user) @@ -67,7 +60,7 @@ class FileUploadController extends ClientApiController return sprintf( '%s/upload/file?token=%s', $server->node->getConnectionAddress(), - $token->__toString() + $token->toString() ); } } diff --git a/app/Http/Controllers/Api/Client/Servers/NetworkAllocationController.php b/app/Http/Controllers/Api/Client/Servers/NetworkAllocationController.php index 43140f622..855cb6780 100644 --- a/app/Http/Controllers/Api/Client/Servers/NetworkAllocationController.php +++ b/app/Http/Controllers/Api/Client/Servers/NetworkAllocationController.php @@ -36,10 +36,6 @@ class NetworkAllocationController extends ClientApiController /** * NetworkController constructor. - * - * @param \Pterodactyl\Repositories\Eloquent\AllocationRepository $repository - * @param \Pterodactyl\Repositories\Eloquent\ServerRepository $serverRepository - * @param \Pterodactyl\Services\Allocations\FindAssignableAllocationService $assignableAllocationService */ public function __construct( AllocationRepository $repository, @@ -56,10 +52,6 @@ class NetworkAllocationController extends ClientApiController /** * Lists all of the allocations available to a server and wether or * not they are currently assigned as the primary for this server. - * - * @param \Pterodactyl\Http\Requests\Api\Client\Servers\Network\GetNetworkRequest $request - * @param \Pterodactyl\Models\Server $server - * @return array */ public function index(GetNetworkRequest $request, Server $server): array { @@ -71,11 +63,6 @@ class NetworkAllocationController extends ClientApiController /** * Set the primary allocation for a server. * - * @param \Pterodactyl\Http\Requests\Api\Client\Servers\Network\UpdateAllocationRequest $request - * @param \Pterodactyl\Models\Server $server - * @param \Pterodactyl\Models\Allocation $allocation - * @return array - * * @throws \Pterodactyl\Exceptions\Model\DataValidationException * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ @@ -93,11 +80,6 @@ class NetworkAllocationController extends ClientApiController /** * Set the primary allocation for a server. * - * @param \Pterodactyl\Http\Requests\Api\Client\Servers\Network\SetPrimaryAllocationRequest $request - * @param \Pterodactyl\Models\Server $server - * @param \Pterodactyl\Models\Allocation $allocation - * @return array - * * @throws \Pterodactyl\Exceptions\Model\DataValidationException * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ @@ -112,20 +94,14 @@ class NetworkAllocationController extends ClientApiController /** * Set the notes for the allocation for a server. - *s - * - * @param \Pterodactyl\Http\Requests\Api\Client\Servers\Network\NewAllocationRequest $request - * @param \Pterodactyl\Models\Server $server - * @return array + *s. * * @throws \Pterodactyl\Exceptions\DisplayException */ public function store(NewAllocationRequest $request, Server $server): array { if ($server->allocations()->count() >= $server->allocation_limit) { - throw new DisplayException( - 'Cannot assign additional allocations to this server: limit has been reached.' - ); + throw new DisplayException('Cannot assign additional allocations to this server: limit has been reached.'); } $allocation = $this->assignableAllocationService->handle($server); @@ -138,9 +114,6 @@ class NetworkAllocationController extends ClientApiController /** * Delete an allocation from a server. * - * @param \Pterodactyl\Http\Requests\Api\Client\Servers\Network\DeleteAllocationRequest $request - * @param \Pterodactyl\Models\Server $server - * @param \Pterodactyl\Models\Allocation $allocation * @return \Illuminate\Http\JsonResponse * * @throws \Pterodactyl\Exceptions\DisplayException @@ -148,9 +121,7 @@ class NetworkAllocationController extends ClientApiController public function delete(DeleteAllocationRequest $request, Server $server, Allocation $allocation) { if ($allocation->id === $server->allocation_id) { - throw new DisplayException( - 'You cannot delete the primary allocation for this server.' - ); + throw new DisplayException('You cannot delete the primary allocation for this server.'); } Allocation::query()->where('id', $allocation->id)->update([ diff --git a/app/Http/Controllers/Api/Client/Servers/PowerController.php b/app/Http/Controllers/Api/Client/Servers/PowerController.php index 12e2d75bb..984a1edca 100644 --- a/app/Http/Controllers/Api/Client/Servers/PowerController.php +++ b/app/Http/Controllers/Api/Client/Servers/PowerController.php @@ -17,8 +17,6 @@ class PowerController extends ClientApiController /** * PowerController constructor. - * - * @param \Pterodactyl\Repositories\Wings\DaemonPowerRepository $repository */ public function __construct(DaemonPowerRepository $repository) { @@ -30,10 +28,6 @@ class PowerController extends ClientApiController /** * Send a power action to a server. * - * @param \Pterodactyl\Http\Requests\Api\Client\Servers\SendPowerRequest $request - * @param \Pterodactyl\Models\Server $server - * @return \Illuminate\Http\Response - * * @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException */ public function index(SendPowerRequest $request, Server $server): Response diff --git a/app/Http/Controllers/Api/Client/Servers/ResourceUtilizationController.php b/app/Http/Controllers/Api/Client/Servers/ResourceUtilizationController.php index 0d56c21bd..4cf0d249b 100644 --- a/app/Http/Controllers/Api/Client/Servers/ResourceUtilizationController.php +++ b/app/Http/Controllers/Api/Client/Servers/ResourceUtilizationController.php @@ -17,8 +17,6 @@ class ResourceUtilizationController extends ClientApiController /** * ResourceUtilizationController constructor. - * - * @param \Pterodactyl\Repositories\Wings\DaemonServerRepository $repository */ public function __construct(DaemonServerRepository $repository) { @@ -30,10 +28,6 @@ class ResourceUtilizationController extends ClientApiController /** * Return the current resource utilization for a server. * - * @param \Pterodactyl\Http\Requests\Api\Client\Servers\GetServerRequest $request - * @param \Pterodactyl\Models\Server $server - * @return array - * * @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException */ public function __invoke(GetServerRequest $request, Server $server): array diff --git a/app/Http/Controllers/Api/Client/Servers/ScheduleController.php b/app/Http/Controllers/Api/Client/Servers/ScheduleController.php index a9310abd6..320133595 100644 --- a/app/Http/Controllers/Api/Client/Servers/ScheduleController.php +++ b/app/Http/Controllers/Api/Client/Servers/ScheduleController.php @@ -10,7 +10,6 @@ use Pterodactyl\Models\Server; use Pterodactyl\Models\Schedule; use Illuminate\Http\JsonResponse; use Pterodactyl\Helpers\Utilities; -use Pterodactyl\Jobs\Schedule\RunTaskJob; use Pterodactyl\Exceptions\DisplayException; use Pterodactyl\Repositories\Eloquent\ScheduleRepository; use Pterodactyl\Services\Schedules\ProcessScheduleService; @@ -38,9 +37,6 @@ class ScheduleController extends ClientApiController /** * ScheduleController constructor. - * - * @param \Pterodactyl\Repositories\Eloquent\ScheduleRepository $repository - * @param \Pterodactyl\Services\Schedules\ProcessScheduleService $service */ public function __construct(ScheduleRepository $repository, ProcessScheduleService $service) { @@ -53,8 +49,6 @@ class ScheduleController extends ClientApiController /** * Returns all of the schedules belonging to a given server. * - * @param \Pterodactyl\Http\Requests\Api\Client\Servers\Schedules\ViewScheduleRequest $request - * @param \Pterodactyl\Models\Server $server * @return array */ public function index(ViewScheduleRequest $request, Server $server) @@ -70,8 +64,6 @@ class ScheduleController extends ClientApiController /** * Store a new schedule for a server. * - * @param \Pterodactyl\Http\Requests\Api\Client\Servers\Schedules\StoreScheduleRequest $request - * @param \Pterodactyl\Models\Server $server * @return array * * @throws \Pterodactyl\Exceptions\DisplayException @@ -84,6 +76,7 @@ class ScheduleController extends ClientApiController 'server_id' => $server->id, 'name' => $request->input('name'), 'cron_day_of_week' => $request->input('day_of_week'), + 'cron_month' => $request->input('month'), 'cron_day_of_month' => $request->input('day_of_month'), 'cron_hour' => $request->input('hour'), 'cron_minute' => $request->input('minute'), @@ -99,15 +92,12 @@ class ScheduleController extends ClientApiController /** * Returns a specific schedule for the server. * - * @param \Pterodactyl\Http\Requests\Api\Client\Servers\Schedules\ViewScheduleRequest $request - * @param \Pterodactyl\Models\Server $server - * @param \Pterodactyl\Models\Schedule $schedule * @return array */ public function view(ViewScheduleRequest $request, Server $server, Schedule $schedule) { if ($schedule->server_id !== $server->id) { - throw new NotFoundHttpException; + throw new NotFoundHttpException(); } $schedule->loadMissing('tasks'); @@ -120,9 +110,6 @@ class ScheduleController extends ClientApiController /** * Updates a given schedule with the new data provided. * - * @param \Pterodactyl\Http\Requests\Api\Client\Servers\Schedules\UpdateScheduleRequest $request - * @param \Pterodactyl\Models\Server $server - * @param \Pterodactyl\Models\Schedule $schedule * @return array * * @throws \Pterodactyl\Exceptions\DisplayException @@ -136,6 +123,7 @@ class ScheduleController extends ClientApiController $data = [ 'name' => $request->input('name'), 'cron_day_of_week' => $request->input('day_of_week'), + 'cron_month' => $request->input('month'), 'cron_day_of_month' => $request->input('day_of_month'), 'cron_hour' => $request->input('hour'), 'cron_minute' => $request->input('minute'), @@ -162,9 +150,6 @@ class ScheduleController extends ClientApiController * Executes a given schedule immediately rather than waiting on it's normally scheduled time * to pass. This does not care about the schedule state. * - * @param \Pterodactyl\Http\Requests\Api\Client\Servers\Schedules\TriggerScheduleRequest $request - * @param \Pterodactyl\Models\Server $server - * @param \Pterodactyl\Models\Schedule $schedule * @return \Illuminate\Http\JsonResponse * * @throws \Throwable @@ -172,9 +157,7 @@ class ScheduleController extends ClientApiController public function execute(TriggerScheduleRequest $request, Server $server, Schedule $schedule) { if (!$schedule->is_active) { - throw new BadRequestHttpException( - 'Cannot trigger schedule exection for a schedule that is not currently active.' - ); + throw new BadRequestHttpException('Cannot trigger schedule exection for a schedule that is not currently active.'); } $this->service->handle($schedule, true); @@ -185,9 +168,6 @@ class ScheduleController extends ClientApiController /** * Deletes a schedule and it's associated tasks. * - * @param \Pterodactyl\Http\Requests\Api\Client\Servers\Schedules\DeleteScheduleRequest $request - * @param \Pterodactyl\Models\Server $server - * @param \Pterodactyl\Models\Schedule $schedule * @return \Illuminate\Http\JsonResponse */ public function delete(DeleteScheduleRequest $request, Server $server, Schedule $schedule) @@ -200,8 +180,6 @@ class ScheduleController extends ClientApiController /** * Get the next run timestamp based on the cron data provided. * - * @param \Illuminate\Http\Request $request - * @return \Carbon\Carbon * @throws \Pterodactyl\Exceptions\DisplayException */ protected function getNextRunAt(Request $request): Carbon @@ -211,12 +189,11 @@ class ScheduleController extends ClientApiController $request->input('minute'), $request->input('hour'), $request->input('day_of_month'), + $request->input('month'), $request->input('day_of_week') ); } catch (Exception $exception) { - throw new DisplayException( - 'The cron data provided does not evaluate to a valid expression.' - ); + throw new DisplayException('The cron data provided does not evaluate to a valid expression.'); } } } diff --git a/app/Http/Controllers/Api/Client/Servers/ScheduleTaskController.php b/app/Http/Controllers/Api/Client/Servers/ScheduleTaskController.php index c6f8ee339..a652071a2 100644 --- a/app/Http/Controllers/Api/Client/Servers/ScheduleTaskController.php +++ b/app/Http/Controllers/Api/Client/Servers/ScheduleTaskController.php @@ -26,8 +26,6 @@ class ScheduleTaskController extends ClientApiController /** * ScheduleTaskController constructor. - * - * @param \Pterodactyl\Repositories\Eloquent\TaskRepository $repository */ public function __construct(TaskRepository $repository) { @@ -39,9 +37,6 @@ class ScheduleTaskController extends ClientApiController /** * Create a new task for a given schedule and store it in the database. * - * @param \Pterodactyl\Http\Requests\Api\Client\Servers\Schedules\StoreTaskRequest $request - * @param \Pterodactyl\Models\Server $server - * @param \Pterodactyl\Models\Schedule $schedule * @return array * * @throws \Pterodactyl\Exceptions\Model\DataValidationException @@ -51,9 +46,7 @@ class ScheduleTaskController extends ClientApiController { $limit = config('pterodactyl.client_features.schedules.per_schedule_task_limit', 10); if ($schedule->tasks()->count() >= $limit) { - throw new ServiceLimitExceededException( - "Schedules may not have more than {$limit} tasks associated with them. Creating this task would put this schedule over the limit." - ); + throw new ServiceLimitExceededException("Schedules may not have more than {$limit} tasks associated with them. Creating this task would put this schedule over the limit."); } /** @var \Pterodactyl\Models\Task|null $lastTask */ @@ -76,10 +69,6 @@ class ScheduleTaskController extends ClientApiController /** * Updates a given task for a server. * - * @param \Pterodactyl\Http\Requests\Api\Client\Servers\Schedules\StoreTaskRequest $request - * @param \Pterodactyl\Models\Server $server - * @param \Pterodactyl\Models\Schedule $schedule - * @param \Pterodactyl\Models\Task $task * @return array * * @throws \Pterodactyl\Exceptions\Model\DataValidationException @@ -88,7 +77,7 @@ class ScheduleTaskController extends ClientApiController public function update(StoreTaskRequest $request, Server $server, Schedule $schedule, Task $task) { if ($schedule->id !== $task->schedule_id || $server->id !== $schedule->server_id) { - throw new NotFoundHttpException; + throw new NotFoundHttpException(); } $this->repository->update($task->id, [ @@ -106,10 +95,6 @@ class ScheduleTaskController extends ClientApiController * Delete a given task for a schedule. If there are subsequent tasks stored in the database * for this schedule their sequence IDs are decremented properly. * - * @param \Pterodactyl\Http\Requests\Api\Client\ClientApiRequest $request - * @param \Pterodactyl\Models\Server $server - * @param \Pterodactyl\Models\Schedule $schedule - * @param \Pterodactyl\Models\Task $task * @return \Illuminate\Http\JsonResponse * * @throws \Exception @@ -117,10 +102,10 @@ class ScheduleTaskController extends ClientApiController public function delete(ClientApiRequest $request, Server $server, Schedule $schedule, Task $task) { if ($task->schedule_id !== $schedule->id || $schedule->server_id !== $server->id) { - throw new NotFoundHttpException; + throw new NotFoundHttpException(); } - if (! $request->user()->can(Permission::ACTION_SCHEDULE_UPDATE, $server)) { + if (!$request->user()->can(Permission::ACTION_SCHEDULE_UPDATE, $server)) { throw new HttpForbiddenException('You do not have permission to perform this action.'); } diff --git a/app/Http/Controllers/Api/Client/Servers/ServerController.php b/app/Http/Controllers/Api/Client/Servers/ServerController.php index 96e276324..82091c48b 100644 --- a/app/Http/Controllers/Api/Client/Servers/ServerController.php +++ b/app/Http/Controllers/Api/Client/Servers/ServerController.php @@ -23,9 +23,6 @@ class ServerController extends ClientApiController /** * ServerController constructor. - * - * @param \Pterodactyl\Services\Servers\GetUserPermissionsService $permissionsService - * @param \Pterodactyl\Repositories\Eloquent\SubuserRepository $repository */ public function __construct(GetUserPermissionsService $permissionsService, SubuserRepository $repository) { @@ -38,10 +35,6 @@ class ServerController extends ClientApiController /** * Transform an individual server into a response that can be consumed by a * client using the API. - * - * @param \Pterodactyl\Http\Requests\Api\Client\Servers\GetServerRequest $request - * @param \Pterodactyl\Models\Server $server - * @return array */ public function index(GetServerRequest $request, Server $server): array { diff --git a/app/Http/Controllers/Api/Client/Servers/SettingsController.php b/app/Http/Controllers/Api/Client/Servers/SettingsController.php index 80fc0e181..110cd0868 100644 --- a/app/Http/Controllers/Api/Client/Servers/SettingsController.php +++ b/app/Http/Controllers/Api/Client/Servers/SettingsController.php @@ -2,7 +2,6 @@ namespace Pterodactyl\Http\Controllers\Api\Client\Servers; -use Illuminate\Http\Request; use Illuminate\Http\Response; use Pterodactyl\Models\Server; use Illuminate\Http\JsonResponse; @@ -28,9 +27,6 @@ class SettingsController extends ClientApiController /** * SettingsController constructor. - * - * @param \Pterodactyl\Repositories\Eloquent\ServerRepository $repository - * @param \Pterodactyl\Services\Servers\ReinstallServerService $reinstallServerService */ public function __construct( ServerRepository $repository, @@ -45,8 +41,6 @@ class SettingsController extends ClientApiController /** * Renames a server. * - * @param \Pterodactyl\Http\Requests\Api\Client\Servers\Settings\RenameServerRequest $request - * @param \Pterodactyl\Models\Server $server * @return \Illuminate\Http\JsonResponse * * @throws \Pterodactyl\Exceptions\Model\DataValidationException @@ -64,8 +58,6 @@ class SettingsController extends ClientApiController /** * Reinstalls the server on the daemon. * - * @param \Pterodactyl\Http\Requests\Api\Client\Servers\Settings\ReinstallServerRequest $request - * @param \Pterodactyl\Models\Server $server * @return \Illuminate\Http\JsonResponse * * @throws \Throwable @@ -80,8 +72,6 @@ class SettingsController extends ClientApiController /** * Changes the Docker image in use by the server. * - * @param \Pterodactyl\Http\Requests\Api\Client\Servers\Settings\SetDockerImageRequest $request - * @param \Pterodactyl\Models\Server $server * @return \Illuminate\Http\JsonResponse * * @throws \Throwable @@ -89,9 +79,7 @@ class SettingsController extends ClientApiController public function dockerImage(SetDockerImageRequest $request, Server $server) { if (!in_array($server->image, $server->egg->docker_images)) { - throw new BadRequestHttpException( - 'This server\'s Docker image has been manually set by an administrator and cannot be updated.' - ); + throw new BadRequestHttpException('This server\'s Docker image has been manually set by an administrator and cannot be updated.'); } $server->forceFill(['image' => $request->input('docker_image')])->saveOrFail(); diff --git a/app/Http/Controllers/Api/Client/Servers/StartupController.php b/app/Http/Controllers/Api/Client/Servers/StartupController.php index 7e06abf8e..06b4a5066 100644 --- a/app/Http/Controllers/Api/Client/Servers/StartupController.php +++ b/app/Http/Controllers/Api/Client/Servers/StartupController.php @@ -31,10 +31,6 @@ class StartupController extends ClientApiController /** * StartupController constructor. - * - * @param \Pterodactyl\Services\Servers\VariableValidatorService $service - * @param \Pterodactyl\Services\Servers\StartupCommandService $startupCommandService - * @param \Pterodactyl\Repositories\Eloquent\ServerVariableRepository $repository */ public function __construct(VariableValidatorService $service, StartupCommandService $startupCommandService, ServerVariableRepository $repository) { @@ -48,8 +44,6 @@ class StartupController extends ClientApiController /** * Returns the startup information for the server including all of the variables. * - * @param \Pterodactyl\Http\Requests\Api\Client\Servers\Startup\GetStartupRequest $request - * @param \Pterodactyl\Models\Server $server * @return array */ public function index(GetStartupRequest $request, Server $server) @@ -71,8 +65,6 @@ class StartupController extends ClientApiController /** * Updates a single variable for a server. * - * @param \Pterodactyl\Http\Requests\Api\Client\Servers\Startup\UpdateStartupVariableRequest $request - * @param \Pterodactyl\Models\Server $server * @return array * * @throws \Illuminate\Validation\ValidationException @@ -84,14 +76,10 @@ class StartupController extends ClientApiController /** @var \Pterodactyl\Models\EggVariable $variable */ $variable = $server->variables()->where('env_variable', $request->input('key'))->first(); - if (is_null($variable) || ! $variable->user_viewable) { - throw new BadRequestHttpException( - "The environment variable you are trying to edit does not exist." - ); - } else if (! $variable->user_editable) { - throw new BadRequestHttpException( - "The environment variable you are trying to edit is read-only." - ); + if (is_null($variable) || !$variable->user_viewable) { + throw new BadRequestHttpException('The environment variable you are trying to edit does not exist.'); + } elseif (!$variable->user_editable) { + throw new BadRequestHttpException('The environment variable you are trying to edit is read-only.'); } // Revalidate the variable value using the egg variable specific validation rules for it. diff --git a/app/Http/Controllers/Api/Client/Servers/SubuserController.php b/app/Http/Controllers/Api/Client/Servers/SubuserController.php index 81238d33b..68f32cf8b 100644 --- a/app/Http/Controllers/Api/Client/Servers/SubuserController.php +++ b/app/Http/Controllers/Api/Client/Servers/SubuserController.php @@ -37,10 +37,6 @@ class SubuserController extends ClientApiController /** * SubuserController constructor. - * - * @param \Pterodactyl\Repositories\Eloquent\SubuserRepository $repository - * @param \Pterodactyl\Services\Subusers\SubuserCreationService $creationService - * @param \Pterodactyl\Repositories\Wings\DaemonServerRepository $serverRepository */ public function __construct( SubuserRepository $repository, @@ -57,8 +53,6 @@ class SubuserController extends ClientApiController /** * Return the users associated with this server instance. * - * @param \Pterodactyl\Http\Requests\Api\Client\Servers\Subusers\GetSubuserRequest $request - * @param \Pterodactyl\Models\Server $server * @return array */ public function index(GetSubuserRequest $request, Server $server) @@ -71,7 +65,6 @@ class SubuserController extends ClientApiController /** * Returns a single subuser associated with this server instance. * - * @param \Pterodactyl\Http\Requests\Api\Client\Servers\Subusers\GetSubuserRequest $request * @return array */ public function view(GetSubuserRequest $request) @@ -86,8 +79,6 @@ class SubuserController extends ClientApiController /** * Create a new subuser for the given server. * - * @param \Pterodactyl\Http\Requests\Api\Client\Servers\Subusers\StoreSubuserRequest $request - * @param \Pterodactyl\Models\Server $server * @return array * * @throws \Pterodactyl\Exceptions\Model\DataValidationException @@ -98,7 +89,9 @@ class SubuserController extends ClientApiController public function store(StoreSubuserRequest $request, Server $server) { $response = $this->creationService->handle( - $server, $request->input('email'), $this->getDefaultPermissions($request) + $server, + $request->input('email'), + $this->getDefaultPermissions($request) ); return $this->fractal->item($response) @@ -109,10 +102,6 @@ class SubuserController extends ClientApiController /** * Update a given subuser in the system for the server. * - * @param \Pterodactyl\Http\Requests\Api\Client\Servers\Subusers\UpdateSubuserRequest $request - * @param \Pterodactyl\Models\Server $server - * @return array - * * @throws \Pterodactyl\Exceptions\Model\DataValidationException * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ @@ -151,8 +140,6 @@ class SubuserController extends ClientApiController /** * Removes a subusers from a server's assignment. * - * @param \Pterodactyl\Http\Requests\Api\Client\Servers\Subusers\DeleteSubuserRequest $request - * @param \Pterodactyl\Models\Server $server * @return \Illuminate\Http\JsonResponse */ public function delete(DeleteSubuserRequest $request, Server $server) @@ -174,9 +161,6 @@ class SubuserController extends ClientApiController /** * Returns the default permissions for all subusers to ensure none are ever removed wrongly. - * - * @param \Illuminate\Http\Request $request - * @return array */ protected function getDefaultPermissions(Request $request): array { diff --git a/app/Http/Controllers/Api/Client/Servers/WebsocketController.php b/app/Http/Controllers/Api/Client/Servers/WebsocketController.php index 9003463b6..35c2c65bd 100644 --- a/app/Http/Controllers/Api/Client/Servers/WebsocketController.php +++ b/app/Http/Controllers/Api/Client/Servers/WebsocketController.php @@ -26,9 +26,6 @@ class WebsocketController extends ClientApiController /** * WebsocketController constructor. - * - * @param \Pterodactyl\Services\Nodes\NodeJWTService $jwtService - * @param \Pterodactyl\Services\Servers\GetUserPermissionsService $permissionsService */ public function __construct( NodeJWTService $jwtService, @@ -46,8 +43,6 @@ class WebsocketController extends ClientApiController * allows us to continually renew this token and avoid users mainitaining sessions wrongly, * as well as ensure that user's only perform actions they're allowed to. * - * @param \Pterodactyl\Http\Requests\Api\Client\ClientApiRequest $request - * @param \Pterodactyl\Models\Server $server * @return \Illuminate\Http\JsonResponse */ public function __invoke(ClientApiRequest $request, Server $server) @@ -60,9 +55,9 @@ class WebsocketController extends ClientApiController $permissions = $this->permissionsService->handle($server, $user); $node = $server->node; - if (! is_null($server->transfer)) { + if (!is_null($server->transfer)) { // Check if the user has permissions to receive transfer logs. - if (! in_array('admin.websocket.transfer', $permissions)) { + if (!in_array('admin.websocket.transfer', $permissions)) { throw new HttpForbiddenException('You do not have permission to view server transfer logs.'); } diff --git a/app/Http/Controllers/Api/Client/TwoFactorController.php b/app/Http/Controllers/Api/Client/TwoFactorController.php index 93be78fbc..4f7145add 100644 --- a/app/Http/Controllers/Api/Client/TwoFactorController.php +++ b/app/Http/Controllers/Api/Client/TwoFactorController.php @@ -31,10 +31,6 @@ class TwoFactorController extends ClientApiController /** * TwoFactorController constructor. - * - * @param \Pterodactyl\Services\Users\ToggleTwoFactorService $toggleTwoFactorService - * @param \Pterodactyl\Services\Users\TwoFactorSetupService $setupService - * @param \Illuminate\Contracts\Validation\Factory $validation */ public function __construct( ToggleTwoFactorService $toggleTwoFactorService, @@ -53,7 +49,6 @@ class TwoFactorController extends ClientApiController * it on their account. If two-factor is already enabled this endpoint * will return a 400 error. * - * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\JsonResponse * * @throws \Pterodactyl\Exceptions\Model\DataValidationException @@ -75,7 +70,6 @@ class TwoFactorController extends ClientApiController /** * Updates a user's account to have two-factor enabled. * - * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\JsonResponse * * @throws \Illuminate\Validation\ValidationException @@ -110,15 +104,12 @@ class TwoFactorController extends ClientApiController * Disables two-factor authentication on an account if the password provided * is valid. * - * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\JsonResponse */ public function delete(Request $request) { - if (! password_verify($request->input('password') ?? '', $request->user()->password)) { - throw new BadRequestHttpException( - 'The password provided was not valid.' - ); + if (!password_verify($request->input('password') ?? '', $request->user()->password)) { + throw new BadRequestHttpException('The password provided was not valid.'); } /** @var \Pterodactyl\Models\User $user */ diff --git a/app/Http/Controllers/Api/Remote/Backups/BackupRemoteUploadController.php b/app/Http/Controllers/Api/Remote/Backups/BackupRemoteUploadController.php index e89783b76..042486c24 100644 --- a/app/Http/Controllers/Api/Remote/Backups/BackupRemoteUploadController.php +++ b/app/Http/Controllers/Api/Remote/Backups/BackupRemoteUploadController.php @@ -15,7 +15,7 @@ use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; class BackupRemoteUploadController extends Controller { - const PART_SIZE = 5 * 1024 * 1024 * 1024; + public const PART_SIZE = 5 * 1024 * 1024 * 1024; /** * @var \Pterodactyl\Repositories\Eloquent\BackupRepository @@ -29,9 +29,6 @@ class BackupRemoteUploadController extends Controller /** * BackupRemoteUploadController constructor. - * - * @param \Pterodactyl\Repositories\Eloquent\BackupRepository $repository - * @param \Pterodactyl\Extensions\Backups\BackupManager $backupManager */ public function __construct(BackupRepository $repository, BackupManager $backupManager) { @@ -42,9 +39,6 @@ class BackupRemoteUploadController extends Controller /** * Returns the required presigned urls to upload a backup to S3 cloud storage. * - * @param \Illuminate\Http\Request $request - * @param string $backup - * * @return \Illuminate\Http\JsonResponse * * @throws \Exception @@ -64,13 +58,13 @@ class BackupRemoteUploadController extends Controller // Prevent backups that have already been completed from trying to // be uploaded again. - if (! is_null($backup->completed_at)) { + if (!is_null($backup->completed_at)) { throw new ConflictHttpException('This backup is already in a completed state.'); } // Ensure we are using the S3 adapter. $adapter = $this->backupManager->adapter(); - if (! $adapter instanceof AwsS3Adapter) { + if (!$adapter instanceof AwsS3Adapter) { throw new BadRequestHttpException('The configured backup adapter is not an S3 compatible adapter.'); } @@ -97,9 +91,10 @@ class BackupRemoteUploadController extends Controller // Create as many UploadPart presigned urls as needed $parts = []; - for ($i = 0; $i < ($size / self::PART_SIZE); $i++) { + for ($i = 0; $i < ($size / self::PART_SIZE); ++$i) { $parts[] = $client->createPresignedRequest( - $client->getCommand('UploadPart', array_merge($params, ['PartNumber' => $i + 1])), $expires + $client->getCommand('UploadPart', array_merge($params, ['PartNumber' => $i + 1])), + $expires )->getUri()->__toString(); } diff --git a/app/Http/Controllers/Api/Remote/Backups/BackupStatusController.php b/app/Http/Controllers/Api/Remote/Backups/BackupStatusController.php index b11c07ad8..6f1959e95 100644 --- a/app/Http/Controllers/Api/Remote/Backups/BackupStatusController.php +++ b/app/Http/Controllers/Api/Remote/Backups/BackupStatusController.php @@ -6,8 +6,8 @@ use Carbon\CarbonImmutable; use Pterodactyl\Models\Backup; use Illuminate\Http\JsonResponse; use League\Flysystem\AwsS3v3\AwsS3Adapter; -use Pterodactyl\Http\Controllers\Controller; use Pterodactyl\Exceptions\DisplayException; +use Pterodactyl\Http\Controllers\Controller; use Pterodactyl\Extensions\Backups\BackupManager; use Pterodactyl\Repositories\Eloquent\BackupRepository; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; @@ -27,9 +27,6 @@ class BackupStatusController extends Controller /** * BackupStatusController constructor. - * - * @param \Pterodactyl\Repositories\Eloquent\BackupRepository $repository - * @param \Pterodactyl\Extensions\Backups\BackupManager $backupManager */ public function __construct(BackupRepository $repository, BackupManager $backupManager) { @@ -40,8 +37,6 @@ class BackupStatusController extends Controller /** * Handles updating the state of a backup. * - * @param \Pterodactyl\Http\Requests\Api\Remote\ReportBackupCompleteRequest $request - * @param string $backup * @return \Illuminate\Http\JsonResponse * * @throws \Exception @@ -51,10 +46,8 @@ class BackupStatusController extends Controller /** @var \Pterodactyl\Models\Backup $model */ $model = Backup::query()->where('uuid', $backup)->firstOrFail(); - if (! is_null($model->completed_at)) { - throw new BadRequestHttpException( - 'Cannot update the status of a backup that is already marked as completed.' - ); + if (!is_null($model->completed_at)) { + throw new BadRequestHttpException('Cannot update the status of a backup that is already marked as completed.'); } $successful = $request->input('successful') ? true : false; @@ -80,10 +73,6 @@ class BackupStatusController extends Controller * Marks a multipart upload in a given S3-compatiable instance as failed or successful for * the given backup. * - * @param \Pterodactyl\Models\Backup $backup - * @param \League\Flysystem\AwsS3v3\AwsS3Adapter $adapter - * @param bool $successful - * * @throws \Exception * @throws \Pterodactyl\Exceptions\DisplayException */ @@ -95,7 +84,7 @@ class BackupStatusController extends Controller // A failed backup doesn't need to error here, this can happen if the backup encouters // an error before we even start the upload. AWS gives you tooling to clear these failed // multipart uploads as needed too. - if (! $successful) { + if (!$successful) { return; } throw new DisplayException('Cannot complete backup request: no upload_id present on model.'); @@ -108,7 +97,7 @@ class BackupStatusController extends Controller ]; $client = $adapter->getClient(); - if (! $successful) { + if (!$successful) { $client->execute($client->getCommand('AbortMultipartUpload', $params)); return; diff --git a/app/Http/Controllers/Api/Remote/EggInstallController.php b/app/Http/Controllers/Api/Remote/EggInstallController.php index d26da5c85..e1f804be2 100644 --- a/app/Http/Controllers/Api/Remote/EggInstallController.php +++ b/app/Http/Controllers/Api/Remote/EggInstallController.php @@ -22,9 +22,6 @@ class EggInstallController extends Controller /** * EggInstallController constructor. - * - * @param \Pterodactyl\Services\Servers\EnvironmentService $environment - * @param \Pterodactyl\Contracts\Repository\ServerRepositoryInterface $repository */ public function __construct(EnvironmentService $environment, ServerRepositoryInterface $repository) { @@ -36,10 +33,6 @@ class EggInstallController extends Controller * Handle request to get script and installation information for a server * that is being created on the node. * - * @param \Illuminate\Http\Request $request - * @param string $uuid - * @return \Illuminate\Http\JsonResponse - * * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ public function index(Request $request, string $uuid): JsonResponse @@ -57,7 +50,7 @@ class EggInstallController extends Controller return response()->json([ 'scripts' => [ - 'install' => ! $egg->copy_script_install ? null : str_replace(["\r\n", "\n", "\r"], "\n", $egg->copy_script_install), + 'install' => !$egg->copy_script_install ? null : str_replace(["\r\n", "\n", "\r"], "\n", $egg->copy_script_install), 'privileged' => $egg->script_is_privileged, ], 'config' => [ diff --git a/app/Http/Controllers/Api/Remote/Servers/ServerDetailsController.php b/app/Http/Controllers/Api/Remote/Servers/ServerDetailsController.php index 99ba71362..a409d494b 100644 --- a/app/Http/Controllers/Api/Remote/Servers/ServerDetailsController.php +++ b/app/Http/Controllers/Api/Remote/Servers/ServerDetailsController.php @@ -31,11 +31,6 @@ class ServerDetailsController extends Controller /** * ServerConfigurationController constructor. - * - * @param \Pterodactyl\Repositories\Eloquent\ServerRepository $repository - * @param \Pterodactyl\Services\Servers\ServerConfigurationStructureService $configurationStructureService - * @param \Pterodactyl\Services\Eggs\EggConfigurationService $eggConfigurationService - * @param \Pterodactyl\Repositories\Eloquent\NodeRepository $nodeRepository */ public function __construct( ServerRepository $repository, @@ -52,8 +47,8 @@ class ServerDetailsController extends Controller * Returns details about the server that allows Wings to self-recover and ensure * that the state of the server matches the Panel at all times. * - * @param \Illuminate\Http\Request $request * @param string $uuid + * * @return \Illuminate\Http\JsonResponse * * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException @@ -71,7 +66,6 @@ class ServerDetailsController extends Controller /** * Lists all servers with their configurations that are assigned to the requesting node. * - * @param \Illuminate\Http\Request $request * @return \Pterodactyl\Http\Resources\Wings\ServerConfigurationCollection */ public function list(Request $request) @@ -85,7 +79,7 @@ class ServerDetailsController extends Controller ->where('node_id', $node->id) // If you don't cast this to a string you'll end up with a stringified per_page returned in // the metadata, and then Wings will panic crash as a result. - ->paginate((int)$request->input('per_page', 50)); + ->paginate((int) $request->input('per_page', 50)); return new ServerConfigurationCollection($servers); } diff --git a/app/Http/Controllers/Api/Remote/Servers/ServerInstallController.php b/app/Http/Controllers/Api/Remote/Servers/ServerInstallController.php index 530832d4e..8009742c5 100644 --- a/app/Http/Controllers/Api/Remote/Servers/ServerInstallController.php +++ b/app/Http/Controllers/Api/Remote/Servers/ServerInstallController.php @@ -18,8 +18,6 @@ class ServerInstallController extends Controller /** * ServerInstallController constructor. - * - * @param \Pterodactyl\Repositories\Eloquent\ServerRepository $repository */ public function __construct(ServerRepository $repository) { @@ -29,8 +27,6 @@ class ServerInstallController extends Controller /** * Returns installation information for a server. * - * @param \Illuminate\Http\Request $request - * @param string $uuid * @return \Illuminate\Http\JsonResponse * * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException @@ -50,8 +46,6 @@ class ServerInstallController extends Controller /** * Updates the installation state of a server. * - * @param \Pterodactyl\Http\Requests\Api\Remote\InstallationDataRequest $request - * @param string $uuid * @return \Illuminate\Http\JsonResponse * * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException diff --git a/app/Http/Controllers/Api/Remote/Servers/ServerTransferController.php b/app/Http/Controllers/Api/Remote/Servers/ServerTransferController.php index 5e53b5daa..9259c32d8 100644 --- a/app/Http/Controllers/Api/Remote/Servers/ServerTransferController.php +++ b/app/Http/Controllers/Api/Remote/Servers/ServerTransferController.php @@ -53,13 +53,6 @@ class ServerTransferController extends Controller /** * ServerTransferController constructor. - * - * @param \Illuminate\Database\ConnectionInterface $connection - * @param \Pterodactyl\Repositories\Eloquent\ServerRepository $repository - * @param \Pterodactyl\Repositories\Wings\DaemonServerRepository $daemonServerRepository - * @param \Pterodactyl\Repositories\Wings\DaemonTransferRepository $daemonTransferRepository - * @param \Pterodactyl\Services\Servers\ServerConfigurationStructureService $configurationStructureService - * @param \Pterodactyl\Services\Nodes\NodeJWTService $jwtService */ public function __construct( ConnectionInterface $connection, @@ -80,8 +73,6 @@ class ServerTransferController extends Controller /** * The daemon notifies us about the archive status. * - * @param \Illuminate\Http\Request $request - * @param string $uuid * @return \Illuminate\Http\JsonResponse * * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException @@ -92,7 +83,7 @@ class ServerTransferController extends Controller $server = $this->repository->getByUuid($uuid); // Unsuspend the server and don't continue the transfer. - if (! $request->input('successful')) { + if (!$request->input('successful')) { return $this->processFailedTransfer($server->transfer); } @@ -110,11 +101,11 @@ class ServerTransferController extends Controller Arr::set($data, 'suspended', false); $this->connection->transaction(function () use ($data, $server) { - // This token is used by the new node the server is being transfered to. It allows + // This token is used by the new node the server is being transferred to. It allows // that node to communicate with the old node during the process to initiate the // actual file transfer. $token = $this->jwtService - ->setExpiresAt(CarbonImmutable::now()->addMinutes(15)->toDateTimeImmutable()) + ->setExpiresAt(CarbonImmutable::now()->addMinutes(15)) ->setSubject($server->uuid) ->handle($server->node, $server->uuid, 'sha256'); @@ -128,7 +119,7 @@ class ServerTransferController extends Controller $this->daemonTransferRepository ->setServer($server) ->setNode($server->transfer->newNode) - ->notify($server, $data, $server->node, $token->__toString()); + ->notify($server, $data, $server->node, $token->toString()); }); return new JsonResponse([], Response::HTTP_NO_CONTENT); @@ -137,7 +128,6 @@ class ServerTransferController extends Controller /** * The daemon notifies us about a transfer failure. * - * @param string $uuid * @return \Illuminate\Http\JsonResponse * * @throws \Throwable @@ -152,7 +142,6 @@ class ServerTransferController extends Controller /** * The daemon notifies us about a transfer success. * - * @param string $uuid * @return \Illuminate\Http\JsonResponse * * @throws \Throwable @@ -165,7 +154,7 @@ class ServerTransferController extends Controller /** @var \Pterodactyl\Models\Server $server */ $server = $this->connection->transaction(function () use ($server, $transfer) { $allocations = [$transfer->old_allocation]; - if (! empty($transfer->old_additional_allocations)) { + if (!empty($transfer->old_additional_allocations)) { array_push($allocations, $transfer->old_additional_allocations); } @@ -201,7 +190,6 @@ class ServerTransferController extends Controller * Release all of the reserved allocations for this transfer and mark it as failed in * the database. * - * @param \Pterodactyl\Models\ServerTransfer $transfer * @return \Illuminate\Http\JsonResponse * * @throws \Throwable @@ -212,7 +200,7 @@ class ServerTransferController extends Controller $transfer->forceFill(['successful' => false])->saveOrFail(); $allocations = [$transfer->new_allocation]; - if (! empty($transfer->new_additional_allocations)) { + if (!empty($transfer->new_additional_allocations)) { array_push($allocations, $transfer->new_additional_allocations); } diff --git a/app/Http/Controllers/Api/Remote/SftpAuthenticationController.php b/app/Http/Controllers/Api/Remote/SftpAuthenticationController.php index cab532e81..461dade4f 100644 --- a/app/Http/Controllers/Api/Remote/SftpAuthenticationController.php +++ b/app/Http/Controllers/Api/Remote/SftpAuthenticationController.php @@ -38,10 +38,6 @@ class SftpAuthenticationController extends Controller /** * SftpController constructor. - * - * @param \Pterodactyl\Services\Servers\GetUserPermissionsService $permissionsService - * @param \Pterodactyl\Repositories\Eloquent\UserRepository $userRepository - * @param \Pterodactyl\Repositories\Eloquent\ServerRepository $serverRepository */ public function __construct( GetUserPermissionsService $permissionsService, @@ -57,9 +53,6 @@ class SftpAuthenticationController extends Controller * Authenticate a set of credentials and return the associated server details * for a SFTP connection on the daemon. * - * @param \Pterodactyl\Http\Requests\Api\Remote\SftpAuthenticationFormRequest $request - * @return \Illuminate\Http\JsonResponse - * * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ public function __invoke(SftpAuthenticationFormRequest $request): JsonResponse @@ -76,15 +69,13 @@ class SftpAuthenticationController extends Controller if ($this->hasTooManyLoginAttempts($request)) { $seconds = $this->limiter()->availableIn($this->throttleKey($request)); - throw new TooManyRequestsHttpException( - $seconds, "Too many login attempts for this account, please try again in {$seconds} seconds." - ); + throw new TooManyRequestsHttpException($seconds, "Too many login attempts for this account, please try again in {$seconds} seconds."); } /** @var \Pterodactyl\Models\Node $node */ $node = $request->attributes->get('node'); if (empty($connection['server'])) { - throw new NotFoundHttpException; + throw new NotFoundHttpException(); } /** @var \Pterodactyl\Models\User $user */ @@ -93,35 +84,29 @@ class SftpAuthenticationController extends Controller ]); $server = $this->serverRepository->getByUuid($connection['server'] ?? ''); - if (! password_verify($request->input('password'), $user->password) || $server->node_id !== $node->id) { + if (!password_verify($request->input('password'), $user->password) || $server->node_id !== $node->id) { $this->incrementLoginAttempts($request); - throw new HttpForbiddenException( - 'Authorization credentials were not correct, please try again.' - ); + throw new HttpForbiddenException('Authorization credentials were not correct, please try again.'); } - if (! $user->root_admin && $server->owner_id !== $user->id) { + if (!$user->root_admin && $server->owner_id !== $user->id) { $permissions = $this->permissionsService->handle($server, $user); - if (! in_array(Permission::ACTION_FILE_SFTP, $permissions)) { - throw new HttpForbiddenException( - 'You do not have permission to access SFTP for this server.' - ); + if (!in_array(Permission::ACTION_FILE_SFTP, $permissions)) { + throw new HttpForbiddenException('You do not have permission to access SFTP for this server.'); } } // Prevent SFTP access to servers that are being transferred. - if (! is_null($server->transfer)) { - throw new ServerTransferringException; + if (!is_null($server->transfer)) { + throw new ServerTransferringException(); } // Remember, for security purposes, only reveal the existence of the server to people that // have provided valid credentials, and have permissions to know about it. if ($server->installed !== 1 || $server->suspended) { - throw new BadRequestHttpException( - 'Server is not installed or is currently suspended.' - ); + throw new BadRequestHttpException('Server is not installed or is currently suspended.'); } return new JsonResponse([ @@ -134,9 +119,6 @@ class SftpAuthenticationController extends Controller /** * Get the throttle key for the given request. - * - * @param \Illuminate\Http\Request $request - * @return string */ protected function throttleKey(Request $request): string { diff --git a/app/Http/Controllers/Auth/AbstractLoginController.php b/app/Http/Controllers/Auth/AbstractLoginController.php index d12ec1fd6..e9951fc32 100644 --- a/app/Http/Controllers/Auth/AbstractLoginController.php +++ b/app/Http/Controllers/Auth/AbstractLoginController.php @@ -50,9 +50,6 @@ abstract class AbstractLoginController extends Controller /** * LoginController constructor. - * - * @param \Illuminate\Auth\AuthManager $auth - * @param \Illuminate\Contracts\Config\Repository $config */ public function __construct(AuthManager $auth, Repository $config) { @@ -66,10 +63,6 @@ abstract class AbstractLoginController extends Controller /** * Get the failed login response instance. * - * @param \Illuminate\Http\Request $request - * @param \Illuminate\Contracts\Auth\Authenticatable|null $user - * @param string|null $message - * * @throws \Pterodactyl\Exceptions\DisplayException */ protected function sendFailedLoginResponse(Request $request, Authenticatable $user = null, string $message = null) @@ -80,9 +73,7 @@ abstract class AbstractLoginController extends Controller ]); if ($request->route()->named('auth.login-checkpoint')) { - throw new DisplayException( - $message ?? trans('auth.two_factor.checkpoint_failed') - ); + throw new DisplayException($message ?? trans('auth.two_factor.checkpoint_failed')); } throw new DisplayException(trans('auth.failed')); @@ -90,10 +81,6 @@ abstract class AbstractLoginController extends Controller /** * Send the response after the user was authenticated. - * - * @param \Pterodactyl\Models\User $user - * @param \Illuminate\Http\Request $request - * @return \Illuminate\Http\JsonResponse */ protected function sendLoginResponse(User $user, Request $request): JsonResponse { @@ -115,7 +102,6 @@ abstract class AbstractLoginController extends Controller * Determine if the user is logging in using an email or username,. * * @param string $input - * @return string */ protected function getField(string $input = null): string { @@ -124,9 +110,6 @@ abstract class AbstractLoginController extends Controller /** * Fire a failed login event. - * - * @param \Illuminate\Contracts\Auth\Authenticatable|null $user - * @param array $credentials */ protected function fireFailedLoginEvent(Authenticatable $user = null, array $credentials = []) { diff --git a/app/Http/Controllers/Auth/ForgotPasswordController.php b/app/Http/Controllers/Auth/ForgotPasswordController.php index 8f78f8c09..7b409e519 100644 --- a/app/Http/Controllers/Auth/ForgotPasswordController.php +++ b/app/Http/Controllers/Auth/ForgotPasswordController.php @@ -18,7 +18,6 @@ class ForgotPasswordController extends Controller * * @param \Illuminate\Http\Request * @param string $response - * @return \Illuminate\Http\JsonResponse */ protected function sendResetLinkFailedResponse(Request $request, $response): JsonResponse { @@ -33,9 +32,7 @@ class ForgotPasswordController extends Controller /** * Get the response for a successful password reset link. * - * @param \Illuminate\Http\Request $request * @param string $response - * @return \Illuminate\Http\JsonResponse */ protected function sendResetLinkResponse(Request $request, $response): JsonResponse { diff --git a/app/Http/Controllers/Auth/LoginCheckpointController.php b/app/Http/Controllers/Auth/LoginCheckpointController.php index 70d83a323..3710da3a2 100644 --- a/app/Http/Controllers/Auth/LoginCheckpointController.php +++ b/app/Http/Controllers/Auth/LoginCheckpointController.php @@ -12,7 +12,6 @@ use Illuminate\Database\Eloquent\ModelNotFoundException; use Pterodactyl\Http\Requests\Auth\LoginCheckpointRequest; use Illuminate\Contracts\Cache\Repository as CacheRepository; use Pterodactyl\Contracts\Repository\UserRepositoryInterface; -use Pterodactyl\Exceptions\Repository\RecordNotFoundException; use Pterodactyl\Repositories\Eloquent\RecoveryTokenRepository; class LoginCheckpointController extends AbstractLoginController @@ -44,14 +43,6 @@ class LoginCheckpointController extends AbstractLoginController /** * LoginCheckpointController constructor. - * - * @param \Illuminate\Auth\AuthManager $auth - * @param \Illuminate\Contracts\Encryption\Encrypter $encrypter - * @param \PragmaRX\Google2FA\Google2FA $google2FA - * @param \Illuminate\Contracts\Config\Repository $config - * @param \Illuminate\Contracts\Cache\Repository $cache - * @param \Pterodactyl\Repositories\Eloquent\RecoveryTokenRepository $recoveryTokenRepository - * @param \Pterodactyl\Contracts\Repository\UserRepositoryInterface $repository */ public function __construct( AuthManager $auth, @@ -76,7 +67,6 @@ class LoginCheckpointController extends AbstractLoginController * token. Once a user has reached this stage it is assumed that they have already * provided a valid username and password. * - * @param \Pterodactyl\Http\Requests\Auth\LoginCheckpointRequest $request * @return \Illuminate\Http\JsonResponse|void * * @throws \PragmaRX\Google2FA\Exceptions\IncompatibleWithGoogleAuthenticatorException @@ -99,12 +89,14 @@ class LoginCheckpointController extends AbstractLoginController $this->incrementLoginAttempts($request); return $this->sendFailedLoginResponse( - $request, null, 'The authentication token provided has expired, please refresh the page and try again.' + $request, + null, + 'The authentication token provided has expired, please refresh the page and try again.' ); } // Recovery tokens go through a slightly different pathway for usage. - if (! is_null($recoveryToken = $request->input('recovery_token'))) { + if (!is_null($recoveryToken = $request->input('recovery_token'))) { if ($this->isValidRecoveryToken($user, $recoveryToken)) { return $this->sendLoginResponse($user, $request); } @@ -120,15 +112,13 @@ class LoginCheckpointController extends AbstractLoginController $this->incrementLoginAttempts($request); - return $this->sendFailedLoginResponse($request, $user, ! empty($recoveryToken) ? 'The recovery token provided is not valid.' : null); + return $this->sendFailedLoginResponse($request, $user, !empty($recoveryToken) ? 'The recovery token provided is not valid.' : null); } /** * Determines if a given recovery token is valid for the user account. If we find a matching token * it will be deleted from the database. * - * @param \Pterodactyl\Models\User $user - * @param string $value * @return bool * * @throws \Exception diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index 593189db1..db74ab125 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -2,7 +2,7 @@ namespace Pterodactyl\Http\Controllers\Auth; -use Cake\Chronos\Chronos; +use Carbon\CarbonImmutable; use Illuminate\Support\Str; use Illuminate\Http\Request; use Illuminate\Auth\AuthManager; @@ -33,12 +33,6 @@ class LoginController extends AbstractLoginController /** * LoginController constructor. - * - * @param \Illuminate\Auth\AuthManager $auth - * @param \Illuminate\Contracts\Config\Repository $config - * @param \Illuminate\Contracts\Cache\Repository $cache - * @param \Pterodactyl\Contracts\Repository\UserRepositoryInterface $repository - * @param \Illuminate\Contracts\View\Factory $view */ public function __construct( AuthManager $auth, @@ -58,8 +52,6 @@ class LoginController extends AbstractLoginController * Handle all incoming requests for the authentication routes and render the * base authentication view component. Vuejs will take over at this point and * turn the login area into a SPA. - * - * @return \Illuminate\Contracts\View\View */ public function index(): View { @@ -69,7 +61,6 @@ class LoginController extends AbstractLoginController /** * Handle a login request to the application. * - * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\JsonResponse|void * * @throws \Pterodactyl\Exceptions\DisplayException @@ -95,13 +86,13 @@ class LoginController extends AbstractLoginController // continue. Previously this was handled in the 2FA checkpoint, however that has // a flaw in which you can discover if an account exists simply by seeing if you // can proceede to the next step in the login process. - if (! password_verify($request->input('password'), $user->password)) { + if (!password_verify($request->input('password'), $user->password)) { return $this->sendFailedLoginResponse($request, $user); } if ($user->use_totp) { $token = Str::random(64); - $this->cache->put($token, $user->id, Chronos::now()->addMinutes(5)); + $this->cache->put($token, $user->id, CarbonImmutable::now()->addMinutes(5)); return new JsonResponse([ 'data' => [ diff --git a/app/Http/Controllers/Auth/ResetPasswordController.php b/app/Http/Controllers/Auth/ResetPasswordController.php index fe5591516..b8a02ee72 100644 --- a/app/Http/Controllers/Auth/ResetPasswordController.php +++ b/app/Http/Controllers/Auth/ResetPasswordController.php @@ -47,10 +47,6 @@ class ResetPasswordController extends Controller /** * ResetPasswordController constructor. - * - * @param \Illuminate\Contracts\Events\Dispatcher $dispatcher - * @param \Illuminate\Contracts\Hashing\Hasher $hasher - * @param \Pterodactyl\Contracts\Repository\UserRepositoryInterface $userRepository */ public function __construct(Dispatcher $dispatcher, Hasher $hasher, UserRepositoryInterface $userRepository) { @@ -62,9 +58,6 @@ class ResetPasswordController extends Controller /** * Reset the given user's password. * - * @param \Pterodactyl\Http\Requests\Auth\ResetPasswordRequest $request - * @return \Illuminate\Http\JsonResponse - * * @throws \Pterodactyl\Exceptions\DisplayException */ public function __invoke(ResetPasswordRequest $request): JsonResponse @@ -73,7 +66,8 @@ class ResetPasswordController extends Controller // will update the password on an actual user model and persist it to the // database. Otherwise we will parse the error and return the response. $response = $this->broker()->reset( - $this->credentials($request), function ($user, $password) { + $this->credentials($request), + function ($user, $password) { $this->resetPassword($user, $password); } ); @@ -94,7 +88,7 @@ class ResetPasswordController extends Controller * form with a note telling them their password was changed and to log back in. * * @param \Illuminate\Contracts\Auth\CanResetPassword|\Pterodactyl\Models\User $user - * @param string $password + * @param string $password * * @throws \Pterodactyl\Exceptions\Model\DataValidationException * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException @@ -110,7 +104,7 @@ class ResetPasswordController extends Controller // If the user is not using 2FA log them in, otherwise skip this step and force a // fresh login where they'll be prompted to enter a token. - if (! $user->use_totp) { + if (!$user->use_totp) { $this->guard()->login($user); } @@ -119,8 +113,6 @@ class ResetPasswordController extends Controller /** * Send a successful password reset response back to the callee. - * - * @return \Illuminate\Http\JsonResponse */ protected function sendResetResponse(): JsonResponse { diff --git a/app/Http/Controllers/Base/IndexController.php b/app/Http/Controllers/Base/IndexController.php index 41ff988f7..058280be6 100644 --- a/app/Http/Controllers/Base/IndexController.php +++ b/app/Http/Controllers/Base/IndexController.php @@ -14,8 +14,6 @@ class IndexController extends Controller /** * IndexController constructor. - * - * @param \Pterodactyl\Contracts\Repository\ServerRepositoryInterface $repository */ public function __construct(ServerRepositoryInterface $repository) { diff --git a/app/Http/Controllers/Base/LocaleController.php b/app/Http/Controllers/Base/LocaleController.php index f29ba23d0..3bb6fbfba 100644 --- a/app/Http/Controllers/Base/LocaleController.php +++ b/app/Http/Controllers/Base/LocaleController.php @@ -16,8 +16,6 @@ class LocaleController extends Controller /** * LocaleController constructor. - * - * @param \Illuminate\Translation\Translator $translator */ public function __construct(Translator $translator) { @@ -27,9 +25,6 @@ class LocaleController extends Controller /** * Returns translation data given a specific locale and namespace. * - * @param \Illuminate\Http\Request $request - * @param string $locale - * @param string $namespace * @return \Illuminate\Http\JsonResponse */ public function __invoke(Request $request, string $locale, string $namespace) diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index 2581e8b98..ee7af2f7a 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -9,5 +9,7 @@ use Illuminate\Foundation\Auth\Access\AuthorizesRequests; abstract class Controller extends BaseController { - use AuthorizesRequests, DispatchesJobs, ValidatesRequests; + use AuthorizesRequests; + use DispatchesJobs; + use ValidatesRequests; } diff --git a/app/Http/Middleware/Admin/Servers/ServerInstalled.php b/app/Http/Middleware/Admin/Servers/ServerInstalled.php index 2f0a384f3..919d27ad6 100644 --- a/app/Http/Middleware/Admin/Servers/ServerInstalled.php +++ b/app/Http/Middleware/Admin/Servers/ServerInstalled.php @@ -14,8 +14,6 @@ class ServerInstalled /** * Checks that the server is installed before allowing access through the route. * - * @param \Illuminate\Http\Request $request - * @param \Closure $next * @return mixed */ public function handle(Request $request, Closure $next) @@ -23,16 +21,12 @@ class ServerInstalled /** @var \Pterodactyl\Models\Server|null $server */ $server = $request->route()->parameter('server'); - if (! $server instanceof Server) { - throw new NotFoundHttpException( - 'No server resource was located in the request parameters.' - ); + if (!$server instanceof Server) { + throw new NotFoundHttpException('No server resource was located in the request parameters.'); } if ($server->installed !== 1) { - throw new HttpException( - Response::HTTP_FORBIDDEN, 'Access to this resource is not allowed due to the current installation state.' - ); + throw new HttpException(Response::HTTP_FORBIDDEN, 'Access to this resource is not allowed due to the current installation state.'); } return $next($request); diff --git a/app/Http/Middleware/AdminAuthenticate.php b/app/Http/Middleware/AdminAuthenticate.php index 878e56bb7..72a7c8629 100644 --- a/app/Http/Middleware/AdminAuthenticate.php +++ b/app/Http/Middleware/AdminAuthenticate.php @@ -18,16 +18,14 @@ class AdminAuthenticate /** * Handle an incoming request. * - * @param \Illuminate\Http\Request $request - * @param \Closure $next * @return mixed * * @throws \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException */ public function handle(Request $request, Closure $next) { - if (! $request->user() || ! $request->user()->root_admin) { - throw new AccessDeniedHttpException; + if (!$request->user() || !$request->user()->root_admin) { + throw new AccessDeniedHttpException(); } return $next($request); diff --git a/app/Http/Middleware/Api/ApiSubstituteBindings.php b/app/Http/Middleware/Api/ApiSubstituteBindings.php index 5ef3bca30..7ade7452a 100644 --- a/app/Http/Middleware/Api/ApiSubstituteBindings.php +++ b/app/Http/Middleware/Api/ApiSubstituteBindings.php @@ -42,7 +42,7 @@ class ApiSubstituteBindings extends SubstituteBindings * a 404 error if a model is not found. * * @param \Illuminate\Http\Request $request - * @param \Closure $next + * * @return mixed */ public function handle($request, Closure $next) @@ -50,7 +50,7 @@ class ApiSubstituteBindings extends SubstituteBindings $route = $request->route(); foreach (self::$mappings as $key => $model) { - if (! is_null($this->router->getBindingCallback($key))) { + if (!is_null($this->router->getBindingCallback($key))) { continue; } diff --git a/app/Http/Middleware/Api/Application/AuthenticateApplicationUser.php b/app/Http/Middleware/Api/Application/AuthenticateApplicationUser.php index 70c52f5b5..bf9a64606 100644 --- a/app/Http/Middleware/Api/Application/AuthenticateApplicationUser.php +++ b/app/Http/Middleware/Api/Application/AuthenticateApplicationUser.php @@ -12,13 +12,11 @@ class AuthenticateApplicationUser * Authenticate that the currently authenticated user is an administrator * and should be allowed to proceed through the application API. * - * @param \Illuminate\Http\Request $request - * @param \Closure $next * @return mixed */ public function handle(Request $request, Closure $next) { - if (is_null($request->user()) || ! $request->user()->root_admin) { + if (is_null($request->user()) || !$request->user()->root_admin) { throw new AccessDeniedHttpException('This account does not have permission to access the API.'); } diff --git a/app/Http/Middleware/Api/AuthenticateIPAccess.php b/app/Http/Middleware/Api/AuthenticateIPAccess.php index 8f57b820d..2af34cfd9 100644 --- a/app/Http/Middleware/Api/AuthenticateIPAccess.php +++ b/app/Http/Middleware/Api/AuthenticateIPAccess.php @@ -13,8 +13,6 @@ class AuthenticateIPAccess /** * Determine if a request IP has permission to access the API. * - * @param \Illuminate\Http\Request $request - * @param \Closure $next * @return mixed * * @throws \Exception diff --git a/app/Http/Middleware/Api/AuthenticateKey.php b/app/Http/Middleware/Api/AuthenticateKey.php index 515cc1fcf..db469bc5e 100644 --- a/app/Http/Middleware/Api/AuthenticateKey.php +++ b/app/Http/Middleware/Api/AuthenticateKey.php @@ -3,7 +3,7 @@ namespace Pterodactyl\Http\Middleware\Api; use Closure; -use Cake\Chronos\Chronos; +use Carbon\CarbonImmutable; use Illuminate\Http\Request; use Pterodactyl\Models\User; use Pterodactyl\Models\ApiKey; @@ -33,10 +33,6 @@ class AuthenticateKey /** * AuthenticateKey constructor. - * - * @param \Pterodactyl\Contracts\Repository\ApiKeyRepositoryInterface $repository - * @param \Illuminate\Auth\AuthManager $auth - * @param \Illuminate\Contracts\Encryption\Encrypter $encrypter */ public function __construct(ApiKeyRepositoryInterface $repository, AuthManager $auth, Encrypter $encrypter) { @@ -49,9 +45,6 @@ class AuthenticateKey * Handle an API request by verifying that the provided API key * is in a valid format and exists in the database. * - * @param \Illuminate\Http\Request $request - * @param \Closure $next - * @param int $keyType * @return mixed * * @throws \Pterodactyl\Exceptions\Model\DataValidationException @@ -85,10 +78,6 @@ class AuthenticateKey /** * Authenticate an API key. * - * @param string $key - * @param int $keyType - * @return \Pterodactyl\Models\ApiKey - * * @throws \Pterodactyl\Exceptions\Model\DataValidationException * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ @@ -103,14 +92,14 @@ class AuthenticateKey ['key_type', '=', $keyType], ]); } catch (RecordNotFoundException $exception) { - throw new AccessDeniedHttpException; + throw new AccessDeniedHttpException(); } - if (! hash_equals($this->encrypter->decrypt($model->token), $token)) { - throw new AccessDeniedHttpException; + if (!hash_equals($this->encrypter->decrypt($model->token), $token)) { + throw new AccessDeniedHttpException(); } - $this->repository->withoutFreshModel()->update($model->id, ['last_used_at' => Chronos::now()]); + $this->repository->withoutFreshModel()->update($model->id, ['last_used_at' => CarbonImmutable::now()]); return $model; } diff --git a/app/Http/Middleware/Api/Client/Server/AllocationBelongsToServer.php b/app/Http/Middleware/Api/Client/Server/AllocationBelongsToServer.php deleted file mode 100644 index d027d563c..000000000 --- a/app/Http/Middleware/Api/Client/Server/AllocationBelongsToServer.php +++ /dev/null @@ -1,33 +0,0 @@ -route()->parameter('server'); - /** @var \Pterodactyl\Models\Allocation|null $allocation */ - $allocation = $request->route()->parameter('allocation'); - - if ($allocation && $allocation->server_id !== $server->id) { - throw new NotFoundHttpException; - } - - return $next($request); - } -} diff --git a/app/Http/Middleware/Api/Client/Server/AuthenticateServerAccess.php b/app/Http/Middleware/Api/Client/Server/AuthenticateServerAccess.php index e9eaa143e..4ab87ce44 100644 --- a/app/Http/Middleware/Api/Client/Server/AuthenticateServerAccess.php +++ b/app/Http/Middleware/Api/Client/Server/AuthenticateServerAccess.php @@ -8,8 +8,8 @@ use Pterodactyl\Models\Server; use Pterodactyl\Contracts\Repository\ServerRepositoryInterface; use Symfony\Component\HttpKernel\Exception\ConflictHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; -use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Pterodactyl\Exceptions\Http\Server\ServerTransferringException; +use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; class AuthenticateServerAccess { @@ -29,8 +29,6 @@ class AuthenticateServerAccess /** * AuthenticateServerAccess constructor. - * - * @param \Pterodactyl\Contracts\Repository\ServerRepositoryInterface $repository */ public function __construct(ServerRepositoryInterface $repository) { @@ -40,8 +38,6 @@ class AuthenticateServerAccess /** * Authenticate that this server exists and is not suspended or marked as installing. * - * @param \Illuminate\Http\Request $request - * @param \Closure $next * @return mixed */ public function handle(Request $request, Closure $next) @@ -50,39 +46,37 @@ class AuthenticateServerAccess $user = $request->user(); $server = $request->route()->parameter('server'); - if (! $server instanceof Server) { + if (!$server instanceof Server) { throw new NotFoundHttpException(trans('exceptions.api.resource_not_found')); } // At the very least, ensure that the user trying to make this request is the // server owner, a subuser, or a root admin. We'll leave it up to the controllers // to authenticate more detailed permissions if needed. - if ($user->id !== $server->owner_id && ! $user->root_admin) { + if ($user->id !== $server->owner_id && !$user->root_admin) { // Check for subuser status. - if (! $server->subusers->contains('user_id', $user->id)) { + if (!$server->subusers->contains('user_id', $user->id)) { throw new NotFoundHttpException(trans('exceptions.api.resource_not_found')); } } - if ($server->suspended && ! $request->routeIs('api:client:server.resources')) { - throw new BadRequestHttpException( - 'This server is currently suspended and the functionality requested is unavailable.' - ); + if ($server->suspended && !$request->routeIs('api:client:server.resources')) { + throw new BadRequestHttpException('This server is currently suspended and the functionality requested is unavailable.'); } // Still allow users to get information about their server if it is installing or being transferred. - if (! $request->routeIs('api:client:server.view')) { - if (! $server->isInstalled()) { + if (!$request->routeIs('api:client:server.view')) { + if (!$server->isInstalled()) { // Throw an exception for all server routes; however if the user is an admin and requesting the // server details, don't throw the exception for them. - if (! $user->root_admin || ($user->root_admin && ! $request->routeIs($this->except))) { + if (!$user->root_admin || ($user->root_admin && !$request->routeIs($this->except))) { throw new ConflictHttpException('Server has not completed the installation process.'); } } - if (! is_null($server->transfer)) { - if (! $user->root_admin || ($user->root_admin && ! $request->routeIs($this->except))) { - throw new ServerTransferringException; + if (!is_null($server->transfer)) { + if (!$user->root_admin || ($user->root_admin && !$request->routeIs($this->except))) { + throw new ServerTransferringException(); } } } diff --git a/app/Http/Middleware/Api/Client/Server/ResourceBelongsToServer.php b/app/Http/Middleware/Api/Client/Server/ResourceBelongsToServer.php new file mode 100644 index 000000000..d8c4731d3 --- /dev/null +++ b/app/Http/Middleware/Api/Client/Server/ResourceBelongsToServer.php @@ -0,0 +1,90 @@ +route()->parameters(); + if (is_null($params) || !$params['server'] instanceof Server) { + throw new InvalidArgumentException('This middleware cannot be used in a context that is missing a server in the parameters.'); + } + + /** @var \Pterodactyl\Models\Server $server */ + $server = $request->route()->parameter('server'); + $exception = new NotFoundHttpException('The requested resource was not found for this server.'); + foreach ($params as $key => $model) { + // Specifically skip the server, we're just trying to see if all of the + // other resources are assigned to this server. Also skip anything that + // is not currently a Model instance since those will just end up being + // a 404 down the road. + if ($key === 'server' || !$model instanceof Model) { + continue; + } + + switch (get_class($model)) { + // All of these models use "server_id" as the field key for the server + // they are assigned to, so the logic is identical for them all. + case Allocation::class: + case Backup::class: + case Database::class: + case Schedule::class: + case Subuser::class: + if ($model->server_id !== $server->id) { + throw $exception; + } + break; + // Regular users are a special case here as we need to make sure they're + // currently assigned as a subuser on the server. + case User::class: + $subuser = $server->subusers()->where('user_id', $model->id)->first(); + if (is_null($subuser)) { + throw $exception; + } + // This is a special case to avoid an additional query being triggered + // in the underlying logic. + $request->attributes->set('subuser', $subuser); + break; + // Tasks are special since they're (currently) the only item in the API + // that requires something in addition to the server in order to be accessed. + case Task::class: + $schedule = $request->route()->parameter('schedule'); + if ($model->schedule_id !== $schedule->id || $schedule->server_id !== $server->id) { + throw $exception; + } + break; + 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)); + } + } + + return $next($request); + } +} diff --git a/app/Http/Middleware/Api/Client/Server/SubuserBelongsToServer.php b/app/Http/Middleware/Api/Client/Server/SubuserBelongsToServer.php deleted file mode 100644 index a80f6eefd..000000000 --- a/app/Http/Middleware/Api/Client/Server/SubuserBelongsToServer.php +++ /dev/null @@ -1,36 +0,0 @@ -route()->parameter('server'); - /** @var \Pterodactyl\Models\User $user */ - $user = $request->route()->parameter('user'); - - // Don't do anything if there isn't a user present in the request. - if (is_null($user)) { - return $next($request); - } - - $request->attributes->set('subuser', $server->subusers()->where('user_id', $user->id)->firstOrFail()); - - return $next($request); - } -} diff --git a/app/Http/Middleware/Api/Client/SubstituteClientApiBindings.php b/app/Http/Middleware/Api/Client/SubstituteClientApiBindings.php index 7ab597b63..31590f28a 100644 --- a/app/Http/Middleware/Api/Client/SubstituteClientApiBindings.php +++ b/app/Http/Middleware/Api/Client/SubstituteClientApiBindings.php @@ -19,7 +19,7 @@ class SubstituteClientApiBindings extends ApiSubstituteBindings * a 404 error if a model is not found. * * @param \Illuminate\Http\Request $request - * @param \Closure $next + * * @return mixed */ public function handle($request, Closure $next) @@ -43,7 +43,7 @@ class SubstituteClientApiBindings extends ApiSubstituteBindings } }); - $this->router->bind('database', function ($value) use ($request) { + $this->router->bind('database', function ($value) { $id = Container::getInstance()->make(HashidsInterface::class)->decodeFirst($value); return Database::query()->where('id', $id)->firstOrFail(); diff --git a/app/Http/Middleware/Api/Daemon/DaemonAuthenticate.php b/app/Http/Middleware/Api/Daemon/DaemonAuthenticate.php index d222f58ec..174cef431 100644 --- a/app/Http/Middleware/Api/Daemon/DaemonAuthenticate.php +++ b/app/Http/Middleware/Api/Daemon/DaemonAuthenticate.php @@ -34,9 +34,6 @@ class DaemonAuthenticate /** * DaemonAuthenticate constructor. - * - * @param \Illuminate\Contracts\Encryption\Encrypter $encrypter - * @param \Pterodactyl\Repositories\Eloquent\NodeRepository $repository */ public function __construct(Encrypter $encrypter, NodeRepository $repository) { @@ -47,8 +44,6 @@ class DaemonAuthenticate /** * Check if a request from the daemon can be properly attributed back to a single node instance. * - * @param \Illuminate\Http\Request $request - * @param \Closure $next * @return mixed * * @throws \Symfony\Component\HttpKernel\Exception\HttpException @@ -60,17 +55,13 @@ class DaemonAuthenticate } if (is_null($bearer = $request->bearerToken())) { - throw new HttpException( - 401, 'Access this this endpoint must include an Authorization header.', null, ['WWW-Authenticate' => 'Bearer'] - ); + throw new HttpException(401, 'Access this this endpoint must include an Authorization header.', null, ['WWW-Authenticate' => 'Bearer']); } $parts = explode('.', $bearer); // Ensure that all of the correct parts are provided in the header. if (count($parts) !== 2 || empty($parts[0]) || empty($parts[1])) { - throw new BadRequestHttpException( - 'The Authorization header provided was not in a valid format.' - ); + throw new BadRequestHttpException('The Authorization header provided was not in a valid format.'); } try { @@ -88,8 +79,6 @@ class DaemonAuthenticate // Do nothing, we don't want to expose a node not existing at all. } - throw new AccessDeniedHttpException( - 'You are not authorized to access this resource.' - ); + throw new AccessDeniedHttpException('You are not authorized to access this resource.'); } } diff --git a/app/Http/Middleware/Api/IsValidJson.php b/app/Http/Middleware/Api/IsValidJson.php index 20c54dab4..c3c8d6c85 100644 --- a/app/Http/Middleware/Api/IsValidJson.php +++ b/app/Http/Middleware/Api/IsValidJson.php @@ -13,23 +13,15 @@ class IsValidJson * parsing the data. This avoids confusing validation errors where every field is flagged and * it is not immediately clear that there is an issue with the JSON being passed. * - * @param \Illuminate\Http\Request $request - * @param \Closure $next * @return mixed */ public function handle(Request $request, Closure $next) { - if ($request->isJson() && ! empty($request->getContent())) { + if ($request->isJson() && !empty($request->getContent())) { json_decode($request->getContent(), true); if (json_last_error() !== JSON_ERROR_NONE) { - throw new BadRequestHttpException( - sprintf( - 'The JSON data passed in the request appears to be malformed. err_code: %d err_message: "%s"', - json_last_error(), - json_last_error_msg() - ) - ); + throw new BadRequestHttpException(sprintf('The JSON data passed in the request appears to be malformed. err_code: %d err_message: "%s"', json_last_error(), json_last_error_msg())); } } diff --git a/app/Http/Middleware/Api/SetSessionDriver.php b/app/Http/Middleware/Api/SetSessionDriver.php index a04db7fab..1c8f59a0b 100644 --- a/app/Http/Middleware/Api/SetSessionDriver.php +++ b/app/Http/Middleware/Api/SetSessionDriver.php @@ -15,8 +15,6 @@ class SetSessionDriver /** * SetSessionDriver constructor. - * - * @param \Illuminate\Contracts\Config\Repository $config */ public function __construct(ConfigRepository $config) { @@ -26,8 +24,6 @@ class SetSessionDriver /** * Set the session for API calls to only last for the one request. * - * @param \Illuminate\Http\Request $request - * @param \Closure $next * @return mixed */ public function handle(Request $request, Closure $next) diff --git a/app/Http/Middleware/Authenticate.php b/app/Http/Middleware/Authenticate.php index ed8d31e02..f95180b20 100644 --- a/app/Http/Middleware/Authenticate.php +++ b/app/Http/Middleware/Authenticate.php @@ -11,16 +11,14 @@ class Authenticate /** * Handle an incoming request. * - * @param \Illuminate\Http\Request $request - * @param \Closure $next * @return mixed * * @throws \Illuminate\Auth\AuthenticationException */ public function handle(Request $request, Closure $next) { - if (! $request->user()) { - throw new AuthenticationException; + if (!$request->user()) { + throw new AuthenticationException(); } return $next($request); diff --git a/app/Http/Middleware/LanguageMiddleware.php b/app/Http/Middleware/LanguageMiddleware.php index 3dba67e22..914d4395f 100644 --- a/app/Http/Middleware/LanguageMiddleware.php +++ b/app/Http/Middleware/LanguageMiddleware.php @@ -15,8 +15,6 @@ class LanguageMiddleware /** * LanguageMiddleware constructor. - * - * @param \Illuminate\Foundation\Application $app */ public function __construct(Application $app) { @@ -26,8 +24,6 @@ class LanguageMiddleware /** * Handle an incoming request and set the user's preferred language. * - * @param \Illuminate\Http\Request $request - * @param \Closure $next * @return mixed */ public function handle(Request $request, Closure $next) diff --git a/app/Http/Middleware/MaintenanceMiddleware.php b/app/Http/Middleware/MaintenanceMiddleware.php index 8f733bcd3..582626162 100644 --- a/app/Http/Middleware/MaintenanceMiddleware.php +++ b/app/Http/Middleware/MaintenanceMiddleware.php @@ -14,8 +14,6 @@ class MaintenanceMiddleware /** * MaintenanceMiddleware constructor. - * - * @param \Illuminate\Contracts\Routing\ResponseFactory $response */ public function __construct(ResponseFactory $response) { @@ -26,7 +24,7 @@ class MaintenanceMiddleware * Handle an incoming request. * * @param \Illuminate\Http\Request $request - * @param \Closure $next + * * @return mixed */ public function handle($request, Closure $next) diff --git a/app/Http/Middleware/RedirectIfAuthenticated.php b/app/Http/Middleware/RedirectIfAuthenticated.php index a8c51bb04..6c4019af4 100644 --- a/app/Http/Middleware/RedirectIfAuthenticated.php +++ b/app/Http/Middleware/RedirectIfAuthenticated.php @@ -15,8 +15,6 @@ class RedirectIfAuthenticated /** * RedirectIfAuthenticated constructor. - * - * @param \Illuminate\Auth\AuthManager $authManager */ public function __construct(AuthManager $authManager) { @@ -26,9 +24,6 @@ class RedirectIfAuthenticated /** * Handle an incoming request. * - * @param \Illuminate\Http\Request $request - * @param \Closure $next - * @param string|null $guard * @return mixed */ public function handle(Request $request, Closure $next, string $guard = null) diff --git a/app/Http/Middleware/RequireTwoFactorAuthentication.php b/app/Http/Middleware/RequireTwoFactorAuthentication.php index d837df24d..6691179a3 100644 --- a/app/Http/Middleware/RequireTwoFactorAuthentication.php +++ b/app/Http/Middleware/RequireTwoFactorAuthentication.php @@ -10,9 +10,9 @@ use Pterodactyl\Exceptions\Http\TwoFactorAuthRequiredException; class RequireTwoFactorAuthentication { - const LEVEL_NONE = 0; - const LEVEL_ADMIN = 1; - const LEVEL_ALL = 2; + public const LEVEL_NONE = 0; + public const LEVEL_ADMIN = 1; + public const LEVEL_ALL = 2; /** * @var \Prologue\Alerts\AlertsMessageBag @@ -28,8 +28,6 @@ class RequireTwoFactorAuthentication /** * RequireTwoFactorAuthentication constructor. - * - * @param \Prologue\Alerts\AlertsMessageBag $alert */ public function __construct(AlertsMessageBag $alert) { @@ -42,8 +40,6 @@ class RequireTwoFactorAuthentication * order to perform actions. If so, we check the level at which it is required (all users * or just admins) and then check if the user has enabled it for their account. * - * @param \Illuminate\Http\Request $request - * @param \Closure $next * @return mixed * * @throws \Pterodactyl\Exceptions\Http\TwoFactorAuthRequiredException @@ -55,24 +51,24 @@ class RequireTwoFactorAuthentication $uri = rtrim($request->getRequestUri(), '/') . '/'; $current = $request->route()->getName(); - if (! $user || Str::startsWith($uri, ['/auth/']) || Str::startsWith($current, ['auth.', 'account.'])) { + if (!$user || Str::startsWith($uri, ['/auth/']) || Str::startsWith($current, ['auth.', 'account.'])) { return $next($request); } - $level = (int)config('pterodactyl.auth.2fa_required'); + $level = (int) config('pterodactyl.auth.2fa_required'); // If this setting is not configured, or the user is already using 2FA then we can just // send them right through, nothing else needs to be checked. // // If the level is set as admin and the user is not an admin, pass them through as well. if ($level === self::LEVEL_NONE || $user->use_totp) { return $next($request); - } else if ($level === self::LEVEL_ADMIN && ! $user->root_admin) { + } elseif ($level === self::LEVEL_ADMIN && !$user->root_admin) { return $next($request); } // For API calls return an exception which gets rendered nicely in the API response. if ($request->isJson() || Str::startsWith($uri, '/api/')) { - throw new TwoFactorAuthRequiredException; + throw new TwoFactorAuthRequiredException(); } $this->alert->danger(trans('auth.2fa_must_be_enabled'))->flash(); diff --git a/app/Http/Middleware/Server/AccessingValidServer.php b/app/Http/Middleware/Server/AccessingValidServer.php index 2491414c7..8f66bbec8 100644 --- a/app/Http/Middleware/Server/AccessingValidServer.php +++ b/app/Http/Middleware/Server/AccessingValidServer.php @@ -31,10 +31,6 @@ class AccessingValidServer /** * AccessingValidServer constructor. - * - * @param \Illuminate\Contracts\Config\Repository $config - * @param \Illuminate\Contracts\Routing\ResponseFactory $response - * @param \Pterodactyl\Contracts\Repository\ServerRepositoryInterface $repository */ public function __construct( ConfigRepository $config, @@ -49,8 +45,6 @@ class AccessingValidServer /** * Determine if a given user has permission to access a server. * - * @param \Illuminate\Http\Request $request - * @param \Closure $next * @return \Illuminate\Http\Response|mixed * * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException @@ -81,9 +75,9 @@ class AccessingValidServer return $this->response->view('errors.installing', [], 409); } - if (! is_null($server->transfer)) { + if (!is_null($server->transfer)) { if ($isApiRequest) { - throw new ServerTransferringException; + throw new ServerTransferringException(); } return $this->response->view('errors.transferring', [], 409); diff --git a/app/Http/Middleware/VerifyReCaptcha.php b/app/Http/Middleware/VerifyReCaptcha.php index 710360479..c0841f2c9 100644 --- a/app/Http/Middleware/VerifyReCaptcha.php +++ b/app/Http/Middleware/VerifyReCaptcha.php @@ -26,9 +26,6 @@ class VerifyReCaptcha /** * VerifyReCaptcha constructor. - * - * @param \Illuminate\Contracts\Events\Dispatcher $dispatcher - * @param \Illuminate\Contracts\Config\Repository $config */ public function __construct(Dispatcher $dispatcher, Repository $config) { @@ -40,12 +37,12 @@ class VerifyReCaptcha * Handle an incoming request. * * @param \Illuminate\Http\Request $request - * @param \Closure $next + * * @return \Illuminate\Http\RedirectResponse|mixed */ public function handle($request, Closure $next) { - if (! $this->config->get('recaptcha.enabled')) { + if (!$this->config->get('recaptcha.enabled')) { return $next($request); } @@ -61,7 +58,7 @@ class VerifyReCaptcha if ($res->getStatusCode() === 200) { $result = json_decode($res->getBody()); - if ($result->success && (! $this->config->get('recaptcha.verify_domain') || $this->isResponseVerified($result, $request))) { + if ($result->success && (!$this->config->get('recaptcha.verify_domain') || $this->isResponseVerified($result, $request))) { return $next($request); } } @@ -69,25 +66,20 @@ class VerifyReCaptcha $this->dispatcher->dispatch( new FailedCaptcha( - $request->ip(), ! empty($result) ? ($result->hostname ?? null) : null + $request->ip(), + !empty($result) ? ($result->hostname ?? null) : null ) ); - throw new HttpException( - Response::HTTP_BAD_REQUEST, 'Failed to validate reCAPTCHA data.' - ); + throw new HttpException(Response::HTTP_BAD_REQUEST, 'Failed to validate reCAPTCHA data.'); } /** * Determine if the response from the recaptcha servers was valid. - * - * @param stdClass $result - * @param \Illuminate\Http\Request $request - * @return bool */ private function isResponseVerified(stdClass $result, Request $request): bool { - if (! $this->config->get('recaptcha.verify_domain')) { + if (!$this->config->get('recaptcha.verify_domain')) { return false; } diff --git a/app/Http/Requests/Api/Application/Allocations/DeleteAllocationRequest.php b/app/Http/Requests/Api/Application/Allocations/DeleteAllocationRequest.php index 21da6bfb3..9fab4e2c3 100644 --- a/app/Http/Requests/Api/Application/Allocations/DeleteAllocationRequest.php +++ b/app/Http/Requests/Api/Application/Allocations/DeleteAllocationRequest.php @@ -22,8 +22,6 @@ class DeleteAllocationRequest extends ApplicationApiRequest /** * Determine if the requested allocation exists and belongs to the node that * is being passed in the URL. - * - * @return bool */ public function resourceExists(): bool { diff --git a/app/Http/Requests/Api/Application/Allocations/GetAllocationsRequest.php b/app/Http/Requests/Api/Application/Allocations/GetAllocationsRequest.php index 150bdb95e..524e201e1 100644 --- a/app/Http/Requests/Api/Application/Allocations/GetAllocationsRequest.php +++ b/app/Http/Requests/Api/Application/Allocations/GetAllocationsRequest.php @@ -21,8 +21,6 @@ class GetAllocationsRequest extends ApplicationApiRequest /** * Determine if the node that we are requesting the allocations * for exists on the Panel. - * - * @return bool */ public function resourceExists(): bool { diff --git a/app/Http/Requests/Api/Application/Allocations/StoreAllocationRequest.php b/app/Http/Requests/Api/Application/Allocations/StoreAllocationRequest.php index 1e68b82e5..d1f5415a6 100644 --- a/app/Http/Requests/Api/Application/Allocations/StoreAllocationRequest.php +++ b/app/Http/Requests/Api/Application/Allocations/StoreAllocationRequest.php @@ -17,9 +17,6 @@ class StoreAllocationRequest extends ApplicationApiRequest */ protected $permission = AdminAcl::WRITE; - /** - * @return array - */ public function rules(): array { return [ diff --git a/app/Http/Requests/Api/Application/ApplicationApiRequest.php b/app/Http/Requests/Api/Application/ApplicationApiRequest.php index d2d88052b..6bb3bed38 100644 --- a/app/Http/Requests/Api/Application/ApplicationApiRequest.php +++ b/app/Http/Requests/Api/Application/ApplicationApiRequest.php @@ -40,8 +40,6 @@ abstract class ApplicationApiRequest extends FormRequest * Determine if the current user is authorized to perform * the requested action against the API. * - * @return bool - * * @throws \Pterodactyl\Exceptions\PterodactylException */ public function authorize(): bool @@ -59,8 +57,6 @@ abstract class ApplicationApiRequest extends FormRequest /** * Determine if the requested resource exists on the server. - * - * @return bool */ public function resourceExists(): bool { @@ -69,8 +65,6 @@ abstract class ApplicationApiRequest extends FormRequest /** * Default set of rules to apply to API requests. - * - * @return array */ public function rules(): array { @@ -79,8 +73,6 @@ abstract class ApplicationApiRequest extends FormRequest /** * Return the API key being used for the request. - * - * @return \Pterodactyl\Models\ApiKey */ public function key(): ApiKey { @@ -91,8 +83,8 @@ abstract class ApplicationApiRequest extends FormRequest * Grab a model from the route parameters. If no model is found in the * binding mappings an exception will be thrown. * - * @param string $model * @return mixed + * * @deprecated * * @throws \Symfony\Component\Routing\Exception\InvalidParameterException @@ -102,7 +94,7 @@ abstract class ApplicationApiRequest extends FormRequest $parameterKey = array_get(array_flip(ApiSubstituteBindings::getMappings()), $model); if (is_null($parameterKey)) { - throw new InvalidParameterException; + throw new InvalidParameterException(); } return $this->route()->parameter($parameterKey); @@ -116,7 +108,7 @@ abstract class ApplicationApiRequest extends FormRequest */ protected function prepareForValidation() { - if (! $this->passesAuthorization()) { + if (!$this->passesAuthorization()) { $this->failedAuthorization(); } @@ -141,7 +133,7 @@ abstract class ApplicationApiRequest extends FormRequest return true; } - if (! parent::passesAuthorization()) { + if (!parent::passesAuthorization()) { return false; } @@ -149,7 +141,7 @@ abstract class ApplicationApiRequest extends FormRequest // authenticated to access the endpoint. This avoids exposing that // an item exists (or does not exist) to the user until they can prove // that they have permission to know about it. - if ($this->attributes->get('is_missing_model', false) || ! $this->resourceExists()) { + if ($this->attributes->get('is_missing_model', false) || !$this->resourceExists()) { throw new NotFoundHttpException(trans('exceptions.api.resource_not_found')); } diff --git a/app/Http/Requests/Api/Application/Eggs/DeleteEggRequest.php b/app/Http/Requests/Api/Application/Eggs/DeleteEggRequest.php index 20a4d109f..2a774d5c2 100644 --- a/app/Http/Requests/Api/Application/Eggs/DeleteEggRequest.php +++ b/app/Http/Requests/Api/Application/Eggs/DeleteEggRequest.php @@ -19,9 +19,7 @@ class DeleteEggRequest extends ApplicationApiRequest protected $permission = AdminAcl::WRITE; /** - * Determine if the requested egg exists on the Panel. - * - * @return bool + * Determine if the requested egg exists for the selected nest. */ public function resourceExists(): bool { diff --git a/app/Http/Requests/Api/Application/Locations/DeleteLocationRequest.php b/app/Http/Requests/Api/Application/Locations/DeleteLocationRequest.php index d1863eea7..ac58314f9 100644 --- a/app/Http/Requests/Api/Application/Locations/DeleteLocationRequest.php +++ b/app/Http/Requests/Api/Application/Locations/DeleteLocationRequest.php @@ -20,8 +20,6 @@ class DeleteLocationRequest extends ApplicationApiRequest /** * Determine if the requested location exists on the Panel. - * - * @return bool */ public function resourceExists(): bool { diff --git a/app/Http/Requests/Api/Application/Locations/GetLocationRequest.php b/app/Http/Requests/Api/Application/Locations/GetLocationRequest.php index d49fb266f..f7c10e0c0 100644 --- a/app/Http/Requests/Api/Application/Locations/GetLocationRequest.php +++ b/app/Http/Requests/Api/Application/Locations/GetLocationRequest.php @@ -8,8 +8,6 @@ class GetLocationRequest extends GetLocationsRequest { /** * Determine if the requested location exists on the Panel. - * - * @return bool */ public function resourceExists(): bool { diff --git a/app/Http/Requests/Api/Application/Locations/StoreLocationRequest.php b/app/Http/Requests/Api/Application/Locations/StoreLocationRequest.php index a02a38cac..c5586ead1 100644 --- a/app/Http/Requests/Api/Application/Locations/StoreLocationRequest.php +++ b/app/Http/Requests/Api/Application/Locations/StoreLocationRequest.php @@ -20,8 +20,6 @@ class StoreLocationRequest extends ApplicationApiRequest /** * Rules to validate the request against. - * - * @return array */ public function rules(): array { diff --git a/app/Http/Requests/Api/Application/Locations/UpdateLocationRequest.php b/app/Http/Requests/Api/Application/Locations/UpdateLocationRequest.php index 0877fa454..c775e2b1b 100644 --- a/app/Http/Requests/Api/Application/Locations/UpdateLocationRequest.php +++ b/app/Http/Requests/Api/Application/Locations/UpdateLocationRequest.php @@ -8,8 +8,6 @@ class UpdateLocationRequest extends StoreLocationRequest { /** * Determine if the requested location exists on the Panel. - * - * @return bool */ public function resourceExists(): bool { @@ -20,8 +18,6 @@ class UpdateLocationRequest extends StoreLocationRequest /** * Rules to validate this request against. - * - * @return array */ public function rules(): array { diff --git a/app/Http/Requests/Api/Application/Nodes/DeleteNodeRequest.php b/app/Http/Requests/Api/Application/Nodes/DeleteNodeRequest.php index 77dd24eac..eb1d1d9a5 100644 --- a/app/Http/Requests/Api/Application/Nodes/DeleteNodeRequest.php +++ b/app/Http/Requests/Api/Application/Nodes/DeleteNodeRequest.php @@ -21,8 +21,6 @@ class DeleteNodeRequest extends ApplicationApiRequest /** * Determine if the node being requested for editing exists * on the Panel before validating the data. - * - * @return bool */ public function resourceExists(): bool { diff --git a/app/Http/Requests/Api/Application/Nodes/GetNodeRequest.php b/app/Http/Requests/Api/Application/Nodes/GetNodeRequest.php index fbf957edd..bbb157035 100644 --- a/app/Http/Requests/Api/Application/Nodes/GetNodeRequest.php +++ b/app/Http/Requests/Api/Application/Nodes/GetNodeRequest.php @@ -8,8 +8,6 @@ class GetNodeRequest extends GetNodesRequest { /** * Determine if the requested node exists on the Panel. - * - * @return bool */ public function resourceExists(): bool { diff --git a/app/Http/Requests/Api/Application/Nodes/StoreNodeRequest.php b/app/Http/Requests/Api/Application/Nodes/StoreNodeRequest.php index 8e23db439..8c05c5a37 100644 --- a/app/Http/Requests/Api/Application/Nodes/StoreNodeRequest.php +++ b/app/Http/Requests/Api/Application/Nodes/StoreNodeRequest.php @@ -20,9 +20,6 @@ class StoreNodeRequest extends ApplicationApiRequest /** * Validation rules to apply to this request. - * - * @param array|null $rules - * @return array */ public function rules(array $rules = null): array { @@ -74,7 +71,7 @@ class StoreNodeRequest extends ApplicationApiRequest $response = parent::validated(); $response['daemonListen'] = $response['daemon_listen']; $response['daemonSFTP'] = $response['daemon_sftp']; - $response['daemonBase'] = $response['daemon_base'] ?? (new Node)->getAttribute('daemonBase'); + $response['daemonBase'] = $response['daemon_base'] ?? (new Node())->getAttribute('daemonBase'); unset($response['daemon_base'], $response['daemon_listen'], $response['daemon_sftp']); diff --git a/app/Http/Requests/Api/Application/Nodes/UpdateNodeRequest.php b/app/Http/Requests/Api/Application/Nodes/UpdateNodeRequest.php index bf228049f..2da2d4061 100644 --- a/app/Http/Requests/Api/Application/Nodes/UpdateNodeRequest.php +++ b/app/Http/Requests/Api/Application/Nodes/UpdateNodeRequest.php @@ -9,9 +9,6 @@ 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. - * - * @param array|null $rules - * @return array */ public function rules(array $rules = null): array { diff --git a/app/Http/Requests/Api/Application/Servers/Databases/GetServerDatabaseRequest.php b/app/Http/Requests/Api/Application/Servers/Databases/GetServerDatabaseRequest.php index e398a5bbf..2dff1374e 100644 --- a/app/Http/Requests/Api/Application/Servers/Databases/GetServerDatabaseRequest.php +++ b/app/Http/Requests/Api/Application/Servers/Databases/GetServerDatabaseRequest.php @@ -19,8 +19,6 @@ class GetServerDatabaseRequest extends ApplicationApiRequest /** * Determine if the requested server database exists. - * - * @return bool */ public function resourceExists(): bool { diff --git a/app/Http/Requests/Api/Application/Servers/Databases/StoreServerDatabaseRequest.php b/app/Http/Requests/Api/Application/Servers/Databases/StoreServerDatabaseRequest.php index 4ca019410..c37de870d 100644 --- a/app/Http/Requests/Api/Application/Servers/Databases/StoreServerDatabaseRequest.php +++ b/app/Http/Requests/Api/Application/Servers/Databases/StoreServerDatabaseRequest.php @@ -24,8 +24,6 @@ class StoreServerDatabaseRequest extends ApplicationApiRequest /** * Validation rules for database creation. - * - * @return array */ public function rules(): array { @@ -76,8 +74,6 @@ class StoreServerDatabaseRequest extends ApplicationApiRequest /** * Returns the database name in the expected format. - * - * @return string */ public function databaseName(): string { diff --git a/app/Http/Requests/Api/Application/Servers/GetExternalServerRequest.php b/app/Http/Requests/Api/Application/Servers/GetExternalServerRequest.php index f783dc715..902bc60c5 100644 --- a/app/Http/Requests/Api/Application/Servers/GetExternalServerRequest.php +++ b/app/Http/Requests/Api/Application/Servers/GetExternalServerRequest.php @@ -27,8 +27,6 @@ class GetExternalServerRequest extends ApplicationApiRequest /** * Determine if the requested external user exists. - * - * @return bool */ public function resourceExists(): bool { @@ -47,8 +45,6 @@ class GetExternalServerRequest extends ApplicationApiRequest /** * Return the server model for the requested external server. - * - * @return \Pterodactyl\Models\Server */ public function getServerModel(): Server { diff --git a/app/Http/Requests/Api/Application/Servers/GetServersRequest.php b/app/Http/Requests/Api/Application/Servers/GetServersRequest.php index 8a0a30535..ece977662 100644 --- a/app/Http/Requests/Api/Application/Servers/GetServersRequest.php +++ b/app/Http/Requests/Api/Application/Servers/GetServersRequest.php @@ -4,9 +4,6 @@ namespace Pterodactyl\Http\Requests\Api\Application\Servers; class GetServersRequest extends GetServerRequest { - /** - * @return array - */ public function rules(): array { return [ diff --git a/app/Http/Requests/Api/Application/Servers/StoreServerRequest.php b/app/Http/Requests/Api/Application/Servers/StoreServerRequest.php index 5e4f9c200..dd24e1efc 100644 --- a/app/Http/Requests/Api/Application/Servers/StoreServerRequest.php +++ b/app/Http/Requests/Api/Application/Servers/StoreServerRequest.php @@ -23,8 +23,6 @@ class StoreServerRequest extends ApplicationApiRequest /** * Rules to be applied to this request. - * - * @return array */ public function rules(): array { @@ -120,7 +118,7 @@ class StoreServerRequest extends ApplicationApiRequest $query->whereNull('server_id'); }), ], function ($input) { - return ! ($input->deploy); + return !($input->deploy); }); $validator->sometimes('allocation.additional.*', [ @@ -129,7 +127,7 @@ class StoreServerRequest extends ApplicationApiRequest $query->whereNull('server_id'); }), ], function ($input) { - return ! ($input->deploy); + return !($input->deploy); }); $validator->sometimes('deploy.locations', 'present', function ($input) { @@ -152,7 +150,7 @@ class StoreServerRequest extends ApplicationApiRequest return null; } - $object = new DeploymentObject; + $object = new DeploymentObject(); $object->setDedicated($this->input('deploy.dedicated_ip', false)); $object->setLocations($this->input('deploy.locations', [])); $object->setPorts($this->input('deploy.port_range', [])); diff --git a/app/Http/Requests/Api/Application/Servers/UpdateServerBuildConfigurationRequest.php b/app/Http/Requests/Api/Application/Servers/UpdateServerBuildConfigurationRequest.php index a387634c1..3f534b08a 100644 --- a/app/Http/Requests/Api/Application/Servers/UpdateServerBuildConfigurationRequest.php +++ b/app/Http/Requests/Api/Application/Servers/UpdateServerBuildConfigurationRequest.php @@ -9,8 +9,6 @@ class UpdateServerBuildConfigurationRequest extends ServerWriteRequest { /** * Return the rules to validate this request against. - * - * @return array */ public function rules(): array { @@ -67,7 +65,7 @@ class UpdateServerBuildConfigurationRequest extends ServerWriteRequest unset($data['allocation'], $data['feature_limits']); // Adjust the limits field to match what is expected by the model. - if (! empty($data['limits'])) { + if (!empty($data['limits'])) { foreach ($data['limits'] as $key => $value) { $data[$key] = $value; } @@ -101,16 +99,13 @@ class UpdateServerBuildConfigurationRequest extends ServerWriteRequest * compatability with the old API endpoint while also supporting a more correct API * call. * - * @param string $field - * @param array $rules - * @param bool $limits * @return array * * @see https://github.com/pterodactyl/panel/issues/1500 */ protected function requiredToOptional(string $field, array $rules, bool $limits = false) { - if (! in_array('required', $rules)) { + if (!in_array('required', $rules)) { return $rules; } diff --git a/app/Http/Requests/Api/Application/Servers/UpdateServerDetailsRequest.php b/app/Http/Requests/Api/Application/Servers/UpdateServerDetailsRequest.php index 172dd1e31..06bd22f5f 100644 --- a/app/Http/Requests/Api/Application/Servers/UpdateServerDetailsRequest.php +++ b/app/Http/Requests/Api/Application/Servers/UpdateServerDetailsRequest.php @@ -8,8 +8,6 @@ class UpdateServerDetailsRequest extends ServerWriteRequest { /** * Rules to apply to a server details update request. - * - * @return array */ public function rules(): array { @@ -26,8 +24,6 @@ class UpdateServerDetailsRequest extends ServerWriteRequest /** * Convert the posted data into the correct format that is expected * by the application. - * - * @return array */ public function validated(): array { @@ -42,8 +38,6 @@ class UpdateServerDetailsRequest extends ServerWriteRequest /** * Rename some of the attributes in error messages to clarify the field * being discussed. - * - * @return array */ public function attributes(): array { diff --git a/app/Http/Requests/Api/Application/Servers/UpdateServerStartupRequest.php b/app/Http/Requests/Api/Application/Servers/UpdateServerStartupRequest.php index fc367cdaf..a873e0198 100644 --- a/app/Http/Requests/Api/Application/Servers/UpdateServerStartupRequest.php +++ b/app/Http/Requests/Api/Application/Servers/UpdateServerStartupRequest.php @@ -20,8 +20,6 @@ class UpdateServerStartupRequest extends ApplicationApiRequest /** * Validation rules to run the input against. - * - * @return array */ public function rules(): array { diff --git a/app/Http/Requests/Api/Application/Users/DeleteUserRequest.php b/app/Http/Requests/Api/Application/Users/DeleteUserRequest.php index 571b29c63..56c028a6e 100644 --- a/app/Http/Requests/Api/Application/Users/DeleteUserRequest.php +++ b/app/Http/Requests/Api/Application/Users/DeleteUserRequest.php @@ -20,8 +20,6 @@ class DeleteUserRequest extends ApplicationApiRequest /** * Determine if the requested user exists on the Panel. - * - * @return bool */ public function resourceExists(): bool { diff --git a/app/Http/Requests/Api/Application/Users/GetExternalUserRequest.php b/app/Http/Requests/Api/Application/Users/GetExternalUserRequest.php index acad394a2..5f63d04ba 100644 --- a/app/Http/Requests/Api/Application/Users/GetExternalUserRequest.php +++ b/app/Http/Requests/Api/Application/Users/GetExternalUserRequest.php @@ -27,9 +27,6 @@ class GetExternalUserRequest extends ApplicationApiRequest /** * Determine if the requested external user exists. - * - * @return bool - * @throws \Illuminate\Contracts\Container\BindingResolutionException */ public function resourceExists(): bool { @@ -48,8 +45,6 @@ class GetExternalUserRequest extends ApplicationApiRequest /** * Return the user model for the requested external user. - * - * @return \Pterodactyl\Models\User */ public function getUserModel(): User { diff --git a/app/Http/Requests/Api/Application/Users/StoreUserRequest.php b/app/Http/Requests/Api/Application/Users/StoreUserRequest.php index 9cddad7e0..10a2d6b28 100644 --- a/app/Http/Requests/Api/Application/Users/StoreUserRequest.php +++ b/app/Http/Requests/Api/Application/Users/StoreUserRequest.php @@ -20,9 +20,6 @@ class StoreUserRequest extends ApplicationApiRequest /** * Return the validation rules for this request. - * - * @param array|null $rules - * @return array */ public function rules(array $rules = null): array { diff --git a/app/Http/Requests/Api/Application/Users/UpdateUserRequest.php b/app/Http/Requests/Api/Application/Users/UpdateUserRequest.php index ce38348d8..b341eaa24 100644 --- a/app/Http/Requests/Api/Application/Users/UpdateUserRequest.php +++ b/app/Http/Requests/Api/Application/Users/UpdateUserRequest.php @@ -8,9 +8,6 @@ class UpdateUserRequest extends StoreUserRequest { /** * Return the validation rules for this request. - * - * @param array|null $rules - * @return array */ public function rules(array $rules = null): array { diff --git a/app/Http/Requests/Api/Client/Account/StoreApiKeyRequest.php b/app/Http/Requests/Api/Client/Account/StoreApiKeyRequest.php index 1a2632862..c2a21c4c0 100644 --- a/app/Http/Requests/Api/Client/Account/StoreApiKeyRequest.php +++ b/app/Http/Requests/Api/Client/Account/StoreApiKeyRequest.php @@ -7,9 +7,6 @@ use Pterodactyl\Http\Requests\Api\Client\ClientApiRequest; class StoreApiKeyRequest extends ClientApiRequest { - /** - * @return array - */ public function rules(): array { $rules = ApiKey::getRules(); diff --git a/app/Http/Requests/Api/Client/Account/UpdateEmailRequest.php b/app/Http/Requests/Api/Client/Account/UpdateEmailRequest.php index c9936508c..193d2fd70 100644 --- a/app/Http/Requests/Api/Client/Account/UpdateEmailRequest.php +++ b/app/Http/Requests/Api/Client/Account/UpdateEmailRequest.php @@ -9,27 +9,22 @@ use Pterodactyl\Exceptions\Http\Base\InvalidPasswordProvidedException; class UpdateEmailRequest extends ClientApiRequest { /** - * @return bool - * * @throws \Pterodactyl\Exceptions\Http\Base\InvalidPasswordProvidedException */ public function authorize(): bool { - if (! parent::authorize()) { + if (!parent::authorize()) { return false; } // Verify password matches when changing password or email. - if (! password_verify($this->input('password'), $this->user()->password)) { + if (!password_verify($this->input('password'), $this->user()->password)) { throw new InvalidPasswordProvidedException(trans('validation.internal.invalid_password')); } return true; } - /** - * @return array - */ public function rules(): array { $rules = User::getRulesForUpdate($this->user()); diff --git a/app/Http/Requests/Api/Client/Account/UpdatePasswordRequest.php b/app/Http/Requests/Api/Client/Account/UpdatePasswordRequest.php index 3bbff3d48..c0e27bdb5 100644 --- a/app/Http/Requests/Api/Client/Account/UpdatePasswordRequest.php +++ b/app/Http/Requests/Api/Client/Account/UpdatePasswordRequest.php @@ -8,27 +8,22 @@ use Pterodactyl\Exceptions\Http\Base\InvalidPasswordProvidedException; class UpdatePasswordRequest extends ClientApiRequest { /** - * @return bool - * * @throws \Pterodactyl\Exceptions\Http\Base\InvalidPasswordProvidedException */ public function authorize(): bool { - if (! parent::authorize()) { + if (!parent::authorize()) { return false; } // Verify password matches when changing password or email. - if (! password_verify($this->input('current_password'), $this->user()->password)) { + if (!password_verify($this->input('current_password'), $this->user()->password)) { throw new InvalidPasswordProvidedException(trans('validation.internal.invalid_password')); } return true; } - /** - * @return array - */ public function rules(): array { return [ diff --git a/app/Http/Requests/Api/Client/ClientApiRequest.php b/app/Http/Requests/Api/Client/ClientApiRequest.php index 465d5a48d..5ae1680a4 100644 --- a/app/Http/Requests/Api/Client/ClientApiRequest.php +++ b/app/Http/Requests/Api/Client/ClientApiRequest.php @@ -13,8 +13,6 @@ class ClientApiRequest extends ApplicationApiRequest { /** * Determine if the current user is authorized to perform the requested action against the API. - * - * @return bool */ public function authorize(): bool { diff --git a/app/Http/Requests/Api/Client/GetServersRequest.php b/app/Http/Requests/Api/Client/GetServersRequest.php index 9b4601f25..28b4c2ded 100644 --- a/app/Http/Requests/Api/Client/GetServersRequest.php +++ b/app/Http/Requests/Api/Client/GetServersRequest.php @@ -4,9 +4,6 @@ namespace Pterodactyl\Http\Requests\Api\Client; class GetServersRequest extends ClientApiRequest { - /** - * @return bool - */ public function authorize(): bool { return true; diff --git a/app/Http/Requests/Api/Client/Servers/Backups/DownloadBackupRequest.php b/app/Http/Requests/Api/Client/Servers/Backups/DownloadBackupRequest.php index cfa38e688..de02f44bd 100644 --- a/app/Http/Requests/Api/Client/Servers/Backups/DownloadBackupRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Backups/DownloadBackupRequest.php @@ -20,8 +20,6 @@ class DownloadBackupRequest extends ClientApiRequest /** * Ensure that this backup belongs to the server that is also present in the * request. - * - * @return bool */ public function resourceExists(): bool { diff --git a/app/Http/Requests/Api/Client/Servers/Backups/StoreBackupRequest.php b/app/Http/Requests/Api/Client/Servers/Backups/StoreBackupRequest.php index 4ca892155..538588ab0 100644 --- a/app/Http/Requests/Api/Client/Servers/Backups/StoreBackupRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Backups/StoreBackupRequest.php @@ -15,9 +15,6 @@ class StoreBackupRequest extends ClientApiRequest return Permission::ACTION_BACKUP_CREATE; } - /** - * @return array - */ public function rules(): array { return [ diff --git a/app/Http/Requests/Api/Client/Servers/Databases/DeleteDatabaseRequest.php b/app/Http/Requests/Api/Client/Servers/Databases/DeleteDatabaseRequest.php index c2161680a..92b14157a 100644 --- a/app/Http/Requests/Api/Client/Servers/Databases/DeleteDatabaseRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Databases/DeleteDatabaseRequest.php @@ -10,17 +10,11 @@ use Pterodactyl\Http\Requests\Api\Client\ClientApiRequest; class DeleteDatabaseRequest extends ClientApiRequest implements ClientPermissionsRequest { - /** - * @return string - */ public function permission(): string { return Permission::ACTION_DATABASE_DELETE; } - /** - * @return bool - */ public function resourceExists(): bool { return $this->getModel(Server::class)->id === $this->getModel(Database::class)->server_id; diff --git a/app/Http/Requests/Api/Client/Servers/Databases/GetDatabasesRequest.php b/app/Http/Requests/Api/Client/Servers/Databases/GetDatabasesRequest.php index be78b5ebb..80eabf945 100644 --- a/app/Http/Requests/Api/Client/Servers/Databases/GetDatabasesRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Databases/GetDatabasesRequest.php @@ -8,9 +8,6 @@ use Pterodactyl\Http\Requests\Api\Client\ClientApiRequest; class GetDatabasesRequest extends ClientApiRequest implements ClientPermissionsRequest { - /** - * @return string - */ public function permission(): string { return Permission::ACTION_DATABASE_READ; diff --git a/app/Http/Requests/Api/Client/Servers/Databases/RotatePasswordRequest.php b/app/Http/Requests/Api/Client/Servers/Databases/RotatePasswordRequest.php index 7869cbf35..b2a9163ad 100644 --- a/app/Http/Requests/Api/Client/Servers/Databases/RotatePasswordRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Databases/RotatePasswordRequest.php @@ -9,8 +9,6 @@ class RotatePasswordRequest extends ClientApiRequest { /** * Check that the user has permission to rotate the password. - * - * @return string */ public function permission(): string { diff --git a/app/Http/Requests/Api/Client/Servers/Databases/StoreDatabaseRequest.php b/app/Http/Requests/Api/Client/Servers/Databases/StoreDatabaseRequest.php index 42bc8587c..b8f12bd8a 100644 --- a/app/Http/Requests/Api/Client/Servers/Databases/StoreDatabaseRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Databases/StoreDatabaseRequest.php @@ -13,17 +13,11 @@ use Pterodactyl\Services\Databases\DatabaseManagementService; class StoreDatabaseRequest extends ClientApiRequest implements ClientPermissionsRequest { - /** - * @return string - */ public function permission(): string { return Permission::ACTION_DATABASE_CREATE; } - /** - * @return array - */ public function rules(): array { $server = $this->route()->parameter('server'); diff --git a/app/Http/Requests/Api/Client/Servers/Files/ChmodFilesRequest.php b/app/Http/Requests/Api/Client/Servers/Files/ChmodFilesRequest.php index 158a0a7fd..bf94cb6ba 100644 --- a/app/Http/Requests/Api/Client/Servers/Files/ChmodFilesRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Files/ChmodFilesRequest.php @@ -8,17 +8,11 @@ use Pterodactyl\Http\Requests\Api\Client\ClientApiRequest; class ChmodFilesRequest extends ClientApiRequest implements ClientPermissionsRequest { - /** - * @return string - */ public function permission(): string { return Permission::ACTION_FILE_UPDATE; } - /** - * @return array - */ public function rules(): array { return [ diff --git a/app/Http/Requests/Api/Client/Servers/Files/CompressFilesRequest.php b/app/Http/Requests/Api/Client/Servers/Files/CompressFilesRequest.php index bd574cf5b..3d6e96aac 100644 --- a/app/Http/Requests/Api/Client/Servers/Files/CompressFilesRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Files/CompressFilesRequest.php @@ -9,17 +9,12 @@ class CompressFilesRequest extends ClientApiRequest { /** * Checks that the authenticated user is allowed to create archives for this server. - * - * @return string */ public function permission(): string { return Permission::ACTION_FILE_ARCHIVE; } - /** - * @return array - */ public function rules(): array { return [ diff --git a/app/Http/Requests/Api/Client/Servers/Files/CopyFileRequest.php b/app/Http/Requests/Api/Client/Servers/Files/CopyFileRequest.php index 97bfc3fba..686c23a23 100644 --- a/app/Http/Requests/Api/Client/Servers/Files/CopyFileRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Files/CopyFileRequest.php @@ -8,17 +8,11 @@ use Pterodactyl\Http\Requests\Api\Client\ClientApiRequest; class CopyFileRequest extends ClientApiRequest implements ClientPermissionsRequest { - /** - * @return string - */ public function permission(): string { return Permission::ACTION_FILE_CREATE; } - /** - * @return array - */ public function rules(): array { return [ diff --git a/app/Http/Requests/Api/Client/Servers/Files/CreateFolderRequest.php b/app/Http/Requests/Api/Client/Servers/Files/CreateFolderRequest.php index 10457ffea..e4655575d 100644 --- a/app/Http/Requests/Api/Client/Servers/Files/CreateFolderRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Files/CreateFolderRequest.php @@ -9,17 +9,12 @@ class CreateFolderRequest extends ClientApiRequest { /** * Checks that the authenticated user is allowed to create files on the server. - * - * @return string */ public function permission(): string { return Permission::ACTION_FILE_CREATE; } - /** - * @return array - */ public function rules(): array { return [ diff --git a/app/Http/Requests/Api/Client/Servers/Files/DecompressFilesRequest.php b/app/Http/Requests/Api/Client/Servers/Files/DecompressFilesRequest.php index f8493ec4a..6e24682e4 100644 --- a/app/Http/Requests/Api/Client/Servers/Files/DecompressFilesRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Files/DecompressFilesRequest.php @@ -11,17 +11,12 @@ class DecompressFilesRequest extends ClientApiRequest * Checks that the authenticated user is allowed to create new files for the server. We don't * rely on the archive permission here as it makes more sense to make sure the user can create * additional files rather than make an archive. - * - * @return string */ public function permission(): string { return Permission::ACTION_FILE_CREATE; } - /** - * @return array - */ public function rules(): array { return [ diff --git a/app/Http/Requests/Api/Client/Servers/Files/DeleteFileRequest.php b/app/Http/Requests/Api/Client/Servers/Files/DeleteFileRequest.php index 7f5ccbf72..10db32811 100644 --- a/app/Http/Requests/Api/Client/Servers/Files/DeleteFileRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Files/DeleteFileRequest.php @@ -8,17 +8,11 @@ use Pterodactyl\Http\Requests\Api\Client\ClientApiRequest; class DeleteFileRequest extends ClientApiRequest implements ClientPermissionsRequest { - /** - * @return string - */ public function permission(): string { return Permission::ACTION_FILE_DELETE; } - /** - * @return array - */ public function rules(): array { return [ diff --git a/app/Http/Requests/Api/Client/Servers/Files/DownloadFileRequest.php b/app/Http/Requests/Api/Client/Servers/Files/DownloadFileRequest.php index 0eb9791c8..0386b8555 100644 --- a/app/Http/Requests/Api/Client/Servers/Files/DownloadFileRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Files/DownloadFileRequest.php @@ -10,8 +10,6 @@ class DownloadFileRequest extends ClientApiRequest /** * Ensure that the user making this request has permission to download files * from this server. - * - * @return bool */ public function authorize(): bool { diff --git a/app/Http/Requests/Api/Client/Servers/Files/GetFileContentsRequest.php b/app/Http/Requests/Api/Client/Servers/Files/GetFileContentsRequest.php index 008b44436..ea6ed7b69 100644 --- a/app/Http/Requests/Api/Client/Servers/Files/GetFileContentsRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Files/GetFileContentsRequest.php @@ -12,17 +12,12 @@ class GetFileContentsRequest extends ClientApiRequest implements ClientPermissio * Returns the permissions string indicating which permission should be used to * validate that the authenticated user has permission to perform this action aganist * the given resource (server). - * - * @return string */ public function permission(): string { return Permission::ACTION_FILE_READ_CONTENT; } - /** - * @return array - */ public function rules(): array { return [ diff --git a/app/Http/Requests/Api/Client/Servers/Files/ListFilesRequest.php b/app/Http/Requests/Api/Client/Servers/Files/ListFilesRequest.php index 4f71648c6..cc66d69b8 100644 --- a/app/Http/Requests/Api/Client/Servers/Files/ListFilesRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Files/ListFilesRequest.php @@ -10,17 +10,12 @@ class ListFilesRequest extends ClientApiRequest /** * Check that the user making this request to the API is authorized to list all * of the files that exist for a given server. - * - * @return string */ public function permission(): string { return Permission::ACTION_FILE_READ; } - /** - * @return array - */ public function rules(): array { return [ diff --git a/app/Http/Requests/Api/Client/Servers/Files/PullFileRequest.php b/app/Http/Requests/Api/Client/Servers/Files/PullFileRequest.php index 02a2fd376..ad3d57897 100644 --- a/app/Http/Requests/Api/Client/Servers/Files/PullFileRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Files/PullFileRequest.php @@ -8,9 +8,6 @@ use Pterodactyl\Http\Requests\Api\Client\ClientApiRequest; class PullFileRequest extends ClientApiRequest implements ClientPermissionsRequest { - /** - * @return string - */ public function permission(): string { return Permission::ACTION_FILE_CREATE; diff --git a/app/Http/Requests/Api/Client/Servers/Files/RenameFileRequest.php b/app/Http/Requests/Api/Client/Servers/Files/RenameFileRequest.php index c8529a35e..61c4a0c5f 100644 --- a/app/Http/Requests/Api/Client/Servers/Files/RenameFileRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Files/RenameFileRequest.php @@ -11,17 +11,12 @@ class RenameFileRequest extends ClientApiRequest implements ClientPermissionsReq /** * The permission the user is required to have in order to perform this * request action. - * - * @return string */ public function permission(): string { return Permission::ACTION_FILE_UPDATE; } - /** - * @return array - */ public function rules(): array { return [ diff --git a/app/Http/Requests/Api/Client/Servers/Files/WriteFileContentRequest.php b/app/Http/Requests/Api/Client/Servers/Files/WriteFileContentRequest.php index d5db8c241..82a994c36 100644 --- a/app/Http/Requests/Api/Client/Servers/Files/WriteFileContentRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Files/WriteFileContentRequest.php @@ -12,8 +12,6 @@ class WriteFileContentRequest extends ClientApiRequest implements ClientPermissi * Returns the permissions string indicating which permission should be used to * validate that the authenticated user has permission to perform this action aganist * the given resource (server). - * - * @return string */ public function permission(): string { @@ -24,8 +22,6 @@ class WriteFileContentRequest extends ClientApiRequest implements ClientPermissi * There is no rule here for the file contents since we just use the body content * on the request to set the file contents. If nothing is passed that is fine since * it just means we want to set the file to be empty. - * - * @return array */ public function rules(): array { diff --git a/app/Http/Requests/Api/Client/Servers/GetServerRequest.php b/app/Http/Requests/Api/Client/Servers/GetServerRequest.php index b69203fc1..3798d77ab 100644 --- a/app/Http/Requests/Api/Client/Servers/GetServerRequest.php +++ b/app/Http/Requests/Api/Client/Servers/GetServerRequest.php @@ -10,8 +10,6 @@ class GetServerRequest extends ClientApiRequest * Determine if a client has permission to view this server on the API. This * should never be false since this would be checking the same permission as * resourceExists(). - * - * @return bool */ public function authorize(): bool { diff --git a/app/Http/Requests/Api/Client/Servers/Network/DeleteAllocationRequest.php b/app/Http/Requests/Api/Client/Servers/Network/DeleteAllocationRequest.php index 9c0d911f0..b7f6ca7b2 100644 --- a/app/Http/Requests/Api/Client/Servers/Network/DeleteAllocationRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Network/DeleteAllocationRequest.php @@ -7,9 +7,6 @@ use Pterodactyl\Http\Requests\Api\Client\ClientApiRequest; class DeleteAllocationRequest extends ClientApiRequest { - /** - * @return string - */ public function permission(): string { return Permission::ACTION_ALLOCATION_DELETE; diff --git a/app/Http/Requests/Api/Client/Servers/Network/GetNetworkRequest.php b/app/Http/Requests/Api/Client/Servers/Network/GetNetworkRequest.php index bf737de72..7304bbd97 100644 --- a/app/Http/Requests/Api/Client/Servers/Network/GetNetworkRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Network/GetNetworkRequest.php @@ -10,8 +10,6 @@ class GetNetworkRequest extends ClientApiRequest /** * Check that the user has permission to view the allocations for * this server. - * - * @return string */ public function permission(): string { diff --git a/app/Http/Requests/Api/Client/Servers/Network/NewAllocationRequest.php b/app/Http/Requests/Api/Client/Servers/Network/NewAllocationRequest.php index 4a29378dd..e6fc19b3f 100644 --- a/app/Http/Requests/Api/Client/Servers/Network/NewAllocationRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Network/NewAllocationRequest.php @@ -7,9 +7,6 @@ use Pterodactyl\Http\Requests\Api\Client\ClientApiRequest; class NewAllocationRequest extends ClientApiRequest { - /** - * @return string - */ public function permission(): string { return Permission::ACTION_ALLOCATION_CREATE; diff --git a/app/Http/Requests/Api/Client/Servers/Network/SetPrimaryAllocationRequest.php b/app/Http/Requests/Api/Client/Servers/Network/SetPrimaryAllocationRequest.php index f698f18ee..30186d731 100644 --- a/app/Http/Requests/Api/Client/Servers/Network/SetPrimaryAllocationRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Network/SetPrimaryAllocationRequest.php @@ -4,9 +4,6 @@ namespace Pterodactyl\Http\Requests\Api\Client\Servers\Network; class SetPrimaryAllocationRequest extends UpdateAllocationRequest { - /** - * @return array - */ public function rules(): array { return []; diff --git a/app/Http/Requests/Api/Client/Servers/Network/UpdateAllocationRequest.php b/app/Http/Requests/Api/Client/Servers/Network/UpdateAllocationRequest.php index 766a66b78..570a8df98 100644 --- a/app/Http/Requests/Api/Client/Servers/Network/UpdateAllocationRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Network/UpdateAllocationRequest.php @@ -8,17 +8,11 @@ use Pterodactyl\Http\Requests\Api\Client\ClientApiRequest; class UpdateAllocationRequest extends ClientApiRequest { - /** - * @return string - */ public function permission(): string { return Permission::ACTION_ALLOCATION_UPDATE; } - /** - * @return array - */ public function rules(): array { $rules = Allocation::getRules(); diff --git a/app/Http/Requests/Api/Client/Servers/Schedules/DeleteScheduleRequest.php b/app/Http/Requests/Api/Client/Servers/Schedules/DeleteScheduleRequest.php index 8ecc7af0e..19d972265 100644 --- a/app/Http/Requests/Api/Client/Servers/Schedules/DeleteScheduleRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Schedules/DeleteScheduleRequest.php @@ -6,9 +6,6 @@ use Pterodactyl\Models\Permission; class DeleteScheduleRequest extends ViewScheduleRequest { - /** - * @return string - */ public function permission(): string { return Permission::ACTION_SCHEDULE_DELETE; diff --git a/app/Http/Requests/Api/Client/Servers/Schedules/StoreScheduleRequest.php b/app/Http/Requests/Api/Client/Servers/Schedules/StoreScheduleRequest.php index a8dfbc3a4..771407f10 100644 --- a/app/Http/Requests/Api/Client/Servers/Schedules/StoreScheduleRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Schedules/StoreScheduleRequest.php @@ -7,17 +7,11 @@ use Pterodactyl\Models\Permission; class StoreScheduleRequest extends ViewScheduleRequest { - /** - * @return string - */ public function permission(): string { return Permission::ACTION_SCHEDULE_CREATE; } - /** - * @return array - */ public function rules(): array { $rules = Schedule::getRules(); diff --git a/app/Http/Requests/Api/Client/Servers/Schedules/StoreTaskRequest.php b/app/Http/Requests/Api/Client/Servers/Schedules/StoreTaskRequest.php index cd95bf5e8..811b87dfb 100644 --- a/app/Http/Requests/Api/Client/Servers/Schedules/StoreTaskRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Schedules/StoreTaskRequest.php @@ -10,17 +10,12 @@ class StoreTaskRequest extends ViewScheduleRequest * Determine if the user is allowed to create a new task for this schedule. We simply * check if they can modify a schedule to determine if they're able to do this. There * are no task specific permissions. - * - * @return string */ public function permission(): string { return Permission::ACTION_SCHEDULE_UPDATE; } - /** - * @return array - */ public function rules(): array { return [ diff --git a/app/Http/Requests/Api/Client/Servers/Schedules/TriggerScheduleRequest.php b/app/Http/Requests/Api/Client/Servers/Schedules/TriggerScheduleRequest.php index d89f5ed30..216274acf 100644 --- a/app/Http/Requests/Api/Client/Servers/Schedules/TriggerScheduleRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Schedules/TriggerScheduleRequest.php @@ -7,17 +7,11 @@ use Pterodactyl\Http\Requests\Api\Client\ClientApiRequest; class TriggerScheduleRequest extends ClientApiRequest { - /** - * @return string - */ public function permission(): string { return Permission::ACTION_SCHEDULE_UPDATE; } - /** - * @return array - */ public function rules(): array { return []; diff --git a/app/Http/Requests/Api/Client/Servers/Schedules/UpdateScheduleRequest.php b/app/Http/Requests/Api/Client/Servers/Schedules/UpdateScheduleRequest.php index 844388e29..4b9fe431b 100644 --- a/app/Http/Requests/Api/Client/Servers/Schedules/UpdateScheduleRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Schedules/UpdateScheduleRequest.php @@ -6,9 +6,6 @@ use Pterodactyl\Models\Permission; class UpdateScheduleRequest extends StoreScheduleRequest { - /** - * @return string - */ public function permission(): string { return Permission::ACTION_SCHEDULE_UPDATE; diff --git a/app/Http/Requests/Api/Client/Servers/Schedules/ViewScheduleRequest.php b/app/Http/Requests/Api/Client/Servers/Schedules/ViewScheduleRequest.php index f57afef69..72674a354 100644 --- a/app/Http/Requests/Api/Client/Servers/Schedules/ViewScheduleRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Schedules/ViewScheduleRequest.php @@ -13,12 +13,10 @@ class ViewScheduleRequest extends ClientApiRequest { /** * Determine if this resource can be viewed. - * - * @return bool */ public function authorize(): bool { - if (! parent::authorize()) { + if (!parent::authorize()) { return false; } @@ -31,18 +29,13 @@ class ViewScheduleRequest extends ClientApiRequest $task = $this->route()->parameter('task'); if ($schedule->server_id !== $server->id || ($task instanceof Task && $task->schedule_id !== $schedule->id)) { - throw new NotFoundHttpException( - 'The requested resource does not exist on the system.' - ); + throw new NotFoundHttpException('The requested resource does not exist on the system.'); } } return true; } - /** - * @return string - */ public function permission(): string { return Permission::ACTION_SCHEDULE_READ; diff --git a/app/Http/Requests/Api/Client/Servers/SendCommandRequest.php b/app/Http/Requests/Api/Client/Servers/SendCommandRequest.php index 3f2f6c196..171cd19d9 100644 --- a/app/Http/Requests/Api/Client/Servers/SendCommandRequest.php +++ b/app/Http/Requests/Api/Client/Servers/SendCommandRequest.php @@ -9,8 +9,6 @@ class SendCommandRequest extends ClientApiRequest { /** * Determine if the API user has permission to perform this action. - * - * @return string */ public function permission(): string { @@ -19,8 +17,6 @@ class SendCommandRequest extends ClientApiRequest /** * Rules to validate this request against. - * - * @return array */ public function rules(): array { diff --git a/app/Http/Requests/Api/Client/Servers/SendPowerRequest.php b/app/Http/Requests/Api/Client/Servers/SendPowerRequest.php index ea7e00fcc..e071388cf 100644 --- a/app/Http/Requests/Api/Client/Servers/SendPowerRequest.php +++ b/app/Http/Requests/Api/Client/Servers/SendPowerRequest.php @@ -9,8 +9,6 @@ class SendPowerRequest extends ClientApiRequest { /** * Determine if the user has permission to send a power command to a server. - * - * @return string */ public function permission(): string { @@ -29,8 +27,6 @@ class SendPowerRequest extends ClientApiRequest /** * Rules to validate this request against. - * - * @return array */ public function rules(): array { diff --git a/app/Http/Requests/Api/Client/Servers/Settings/RenameServerRequest.php b/app/Http/Requests/Api/Client/Servers/Settings/RenameServerRequest.php index 14b117211..8cb5efa35 100644 --- a/app/Http/Requests/Api/Client/Servers/Settings/RenameServerRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Settings/RenameServerRequest.php @@ -13,8 +13,6 @@ class RenameServerRequest extends ClientApiRequest implements ClientPermissionsR * Returns the permissions string indicating which permission should be used to * validate that the authenticated user has permission to perform this action aganist * the given resource (server). - * - * @return string */ public function permission(): string { @@ -23,8 +21,6 @@ class RenameServerRequest extends ClientApiRequest implements ClientPermissionsR /** * The rules to apply when validating this request. - * - * @return array */ public function rules(): array { diff --git a/app/Http/Requests/Api/Client/Servers/Settings/SetDockerImageRequest.php b/app/Http/Requests/Api/Client/Servers/Settings/SetDockerImageRequest.php index be0b7213a..bd3a1e65f 100644 --- a/app/Http/Requests/Api/Client/Servers/Settings/SetDockerImageRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Settings/SetDockerImageRequest.php @@ -11,9 +11,6 @@ use Pterodactyl\Http\Requests\Api\Client\ClientApiRequest; class SetDockerImageRequest extends ClientApiRequest implements ClientPermissionsRequest { - /** - * @return string - */ public function permission(): string { return Permission::ACTION_STARTUP_DOCKER_IMAGE; diff --git a/app/Http/Requests/Api/Client/Servers/Subusers/GetSubuserRequest.php b/app/Http/Requests/Api/Client/Servers/Subusers/GetSubuserRequest.php index 3affcbacb..ee43e0d62 100644 --- a/app/Http/Requests/Api/Client/Servers/Subusers/GetSubuserRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Subusers/GetSubuserRequest.php @@ -8,8 +8,6 @@ class GetSubuserRequest extends SubuserRequest { /** * Confirm that a user is able to view subusers for the specified server. - * - * @return string */ public function permission(): string { diff --git a/app/Http/Requests/Api/Client/Servers/Subusers/StoreSubuserRequest.php b/app/Http/Requests/Api/Client/Servers/Subusers/StoreSubuserRequest.php index 0848770f9..5bc93ab2f 100644 --- a/app/Http/Requests/Api/Client/Servers/Subusers/StoreSubuserRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Subusers/StoreSubuserRequest.php @@ -14,9 +14,6 @@ class StoreSubuserRequest extends SubuserRequest return Permission::ACTION_USER_CREATE; } - /** - * @return array - */ public function rules(): array { return [ diff --git a/app/Http/Requests/Api/Client/Servers/Subusers/SubuserRequest.php b/app/Http/Requests/Api/Client/Servers/Subusers/SubuserRequest.php index 98d0d9643..5a20084d3 100644 --- a/app/Http/Requests/Api/Client/Servers/Subusers/SubuserRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Subusers/SubuserRequest.php @@ -18,13 +18,11 @@ abstract class SubuserRequest extends ClientApiRequest /** * Authorize the request and ensure that a user is not trying to modify themselves. * - * @return bool - * * @throws \Illuminate\Contracts\Container\BindingResolutionException */ public function authorize(): bool { - if (! parent::authorize()) { + if (!parent::authorize()) { return false; } @@ -51,8 +49,6 @@ abstract class SubuserRequest extends ClientApiRequest * Validates that the permissions we are trying to assign can actually be assigned * by the user making the request. * - * @param array $permissions - * * @throws \Illuminate\Contracts\Container\BindingResolutionException */ protected function validatePermissionsCanBeAssigned(array $permissions) @@ -74,9 +70,7 @@ abstract class SubuserRequest extends ClientApiRequest $service = $this->container->make(GetUserPermissionsService::class); if (count(array_diff($permissions, $service->handle($server, $user))) > 0) { - throw new HttpForbiddenException( - 'Cannot assign permissions to a subuser that your account does not actively possess.' - ); + throw new HttpForbiddenException('Cannot assign permissions to a subuser that your account does not actively possess.'); } } } diff --git a/app/Http/Requests/Api/Client/Servers/Subusers/UpdateSubuserRequest.php b/app/Http/Requests/Api/Client/Servers/Subusers/UpdateSubuserRequest.php index 3a84a0278..997b2daee 100644 --- a/app/Http/Requests/Api/Client/Servers/Subusers/UpdateSubuserRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Subusers/UpdateSubuserRequest.php @@ -14,9 +14,6 @@ class UpdateSubuserRequest extends SubuserRequest return Permission::ACTION_USER_UPDATE; } - /** - * @return array - */ public function rules(): array { return [ diff --git a/app/Http/Requests/Auth/LoginCheckpointRequest.php b/app/Http/Requests/Auth/LoginCheckpointRequest.php index 87d84ce97..3c9392a63 100644 --- a/app/Http/Requests/Auth/LoginCheckpointRequest.php +++ b/app/Http/Requests/Auth/LoginCheckpointRequest.php @@ -9,8 +9,6 @@ class LoginCheckpointRequest extends FormRequest { /** * Determine if the request is authorized. - * - * @return bool */ public function authorize(): bool { @@ -19,8 +17,6 @@ class LoginCheckpointRequest extends FormRequest /** * Rules to apply to the request. - * - * @return array */ public function rules(): array { diff --git a/app/Http/Requests/Auth/LoginRequest.php b/app/Http/Requests/Auth/LoginRequest.php index 7fed20939..d08846929 100644 --- a/app/Http/Requests/Auth/LoginRequest.php +++ b/app/Http/Requests/Auth/LoginRequest.php @@ -6,17 +6,11 @@ use Illuminate\Foundation\Http\FormRequest; class LoginRequest extends FormRequest { - /** - * @return bool - */ public function authorized(): bool { return true; } - /** - * @return array - */ public function rules(): array { return [ diff --git a/app/Http/Requests/Auth/ResetPasswordRequest.php b/app/Http/Requests/Auth/ResetPasswordRequest.php index e06883c2a..e5bb3299c 100644 --- a/app/Http/Requests/Auth/ResetPasswordRequest.php +++ b/app/Http/Requests/Auth/ResetPasswordRequest.php @@ -6,17 +6,11 @@ use Illuminate\Foundation\Http\FormRequest; class ResetPasswordRequest extends FormRequest { - /** - * @return bool - */ public function authorize(): bool { return true; } - /** - * @return array - */ public function rules(): array { return [ diff --git a/app/Http/Requests/FrontendUserFormRequest.php b/app/Http/Requests/FrontendUserFormRequest.php index 6be818e7b..b5553dc16 100644 --- a/app/Http/Requests/FrontendUserFormRequest.php +++ b/app/Http/Requests/FrontendUserFormRequest.php @@ -22,7 +22,7 @@ abstract class FrontendUserFormRequest extends FormRequest */ public function authorize() { - return ! is_null($this->user()); + return !is_null($this->user()); } /** diff --git a/app/Http/Resources/Wings/ServerConfigurationCollection.php b/app/Http/Resources/Wings/ServerConfigurationCollection.php index 5ee877a98..fe352301c 100644 --- a/app/Http/Resources/Wings/ServerConfigurationCollection.php +++ b/app/Http/Resources/Wings/ServerConfigurationCollection.php @@ -17,6 +17,7 @@ class ServerConfigurationCollection extends ResourceCollection * have some serious performance issues from all of the N+1 queries. * * @param \Illuminate\Http\Request $request + * * @return array */ public function toArray($request) @@ -24,7 +25,7 @@ class ServerConfigurationCollection extends ResourceCollection $egg = Container::getInstance()->make(EggConfigurationService::class); $configuration = Container::getInstance()->make(ServerConfigurationStructureService::class); - return $this->collection->map(function (Server $server) use ($configuration, $egg) { + return $this->collection->map(function (Server $server) use ($configuration, $egg) { return [ 'uuid' => $server->uuid, 'settings' => $configuration->handle($server), diff --git a/app/Http/ViewComposers/AssetComposer.php b/app/Http/ViewComposers/AssetComposer.php index 6da825ad4..32ec9fb88 100644 --- a/app/Http/ViewComposers/AssetComposer.php +++ b/app/Http/ViewComposers/AssetComposer.php @@ -14,8 +14,6 @@ class AssetComposer /** * AssetComposer constructor. - * - * @param \Pterodactyl\Services\Helpers\AssetHashService $assetHashService */ public function __construct(AssetHashService $assetHashService) { @@ -24,8 +22,6 @@ class AssetComposer /** * Provide access to the asset service in the views. - * - * @param \Illuminate\View\View $view */ public function compose(View $view) { diff --git a/app/Jobs/Schedule/RunTaskJob.php b/app/Jobs/Schedule/RunTaskJob.php index ee3c3e16d..3dd8e920d 100644 --- a/app/Jobs/Schedule/RunTaskJob.php +++ b/app/Jobs/Schedule/RunTaskJob.php @@ -8,7 +8,6 @@ use Carbon\CarbonImmutable; use Pterodactyl\Models\Task; use InvalidArgumentException; use Pterodactyl\Models\Schedule; -use Illuminate\Support\Facades\Log; use Illuminate\Queue\SerializesModels; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Contracts\Queue\ShouldQueue; @@ -19,7 +18,9 @@ use Pterodactyl\Repositories\Wings\DaemonCommandRepository; class RunTaskJob extends Job implements ShouldQueue { - use DispatchesJobs, InteractsWithQueue, SerializesModels; + use DispatchesJobs; + use InteractsWithQueue; + use SerializesModels; /** * @var \Pterodactyl\Models\Task @@ -28,8 +29,6 @@ class RunTaskJob extends Job implements ShouldQueue /** * RunTaskJob constructor. - * - * @param \Pterodactyl\Models\Task $task */ public function __construct(Task $task) { @@ -40,10 +39,6 @@ class RunTaskJob extends Job implements ShouldQueue /** * Run the job and send actions to the daemon running the server. * - * @param \Pterodactyl\Repositories\Wings\DaemonCommandRepository $commandRepository - * @param \Pterodactyl\Services\Backups\InitiateBackupService $backupService - * @param \Pterodactyl\Repositories\Wings\DaemonPowerRepository $powerRepository - * * @throws \Throwable */ public function handle( @@ -52,7 +47,7 @@ class RunTaskJob extends Job implements ShouldQueue DaemonPowerRepository $powerRepository ) { // Do not process a task that is not set to active. - if (! $this->task->schedule->is_active) { + if (!$this->task->schedule->is_active) { $this->markTaskNotQueued(); $this->markScheduleComplete(); @@ -81,8 +76,6 @@ class RunTaskJob extends Job implements ShouldQueue /** * Handle a failure while sending the action to the daemon or otherwise processing the job. - * - * @param \Exception|null $exception */ public function failed(Exception $exception = null) { diff --git a/app/Models/Allocation.php b/app/Models/Allocation.php index 81e596523..9d609ba24 100644 --- a/app/Models/Allocation.php +++ b/app/Models/Allocation.php @@ -3,21 +3,19 @@ namespace Pterodactyl\Models; /** - * @property int $id - * @property int $node_id - * @property string $ip - * @property string|null $ip_alias - * @property int $port - * @property int|null $server_id - * @property string|null $notes - * @property \Carbon\Carbon|null $created_at - * @property \Carbon\Carbon|null $updated_at - * - * @property string $alias - * @property bool $has_alias - * + * @property int $id + * @property int $node_id + * @property string $ip + * @property string|null $ip_alias + * @property int $port + * @property int|null $server_id + * @property string|null $notes + * @property \Carbon\Carbon|null $created_at + * @property \Carbon\Carbon|null $updated_at + * @property string $alias + * @property bool $has_alias * @property \Pterodactyl\Models\Server|null $server - * @property \Pterodactyl\Models\Node $node + * @property \Pterodactyl\Models\Node $node */ class Allocation extends Model { @@ -25,7 +23,7 @@ class Allocation extends Model * The resource name for this model when it is transformed into an * API representation using fractal. */ - const RESOURCE_NAME = 'allocation'; + public const RESOURCE_NAME = 'allocation'; /** * The table associated with the model. @@ -78,6 +76,7 @@ class Allocation extends Model * Accessor to automatically provide the IP alias if defined. * * @param string|null $value + * * @return string */ public function getAliasAttribute($value) @@ -89,11 +88,12 @@ class Allocation extends Model * Accessor to quickly determine if this allocation has an alias. * * @param string|null $value + * * @return bool */ public function getHasAliasAttribute($value) { - return ! is_null($this->ip_alias); + return !is_null($this->ip_alias); } /** diff --git a/app/Models/ApiKey.php b/app/Models/ApiKey.php index ea1c54e56..ba515b2c1 100644 --- a/app/Models/ApiKey.php +++ b/app/Models/ApiKey.php @@ -5,40 +5,44 @@ namespace Pterodactyl\Models; use Pterodactyl\Services\Acl\Api\AdminAcl; /** - * @property int $id - * @property int $user_id - * @property int $key_type - * @property string $identifier - * @property string $token - * @property array $allowed_ips - * @property string $memo + * @property int $id + * @property int $user_id + * @property int $key_type + * @property string $identifier + * @property string $token + * @property array $allowed_ips + * @property string $memo * @property \Carbon\Carbon|null $last_used_at - * @property \Carbon\Carbon $created_at - * @property \Carbon\Carbon $updated_at + * @property \Carbon\Carbon $created_at + * @property \Carbon\Carbon $updated_at */ class ApiKey extends Model { - const RESOURCE_NAME = 'api_key'; + /** + * The resource name for this model when it is transformed into an + * API representation using fractal. + */ + public const RESOURCE_NAME = 'api_key'; /** * Different API keys that can exist on the system. */ - const TYPE_NONE = 0; - const TYPE_ACCOUNT = 1; - const TYPE_APPLICATION = 2; - const TYPE_DAEMON_USER = 3; - const TYPE_DAEMON_APPLICATION = 4; + public const TYPE_NONE = 0; + public const TYPE_ACCOUNT = 1; + public const TYPE_APPLICATION = 2; + public const TYPE_DAEMON_USER = 3; + public const TYPE_DAEMON_APPLICATION = 4; /** * The length of API key identifiers. */ - const IDENTIFIER_LENGTH = 16; + public const IDENTIFIER_LENGTH = 16; /** * The length of the actual API key that is encrypted and stored * in the database. */ - const KEY_LENGTH = 32; + public const KEY_LENGTH = 32; /** * The table associated with the model. diff --git a/app/Models/Backup.php b/app/Models/Backup.php index 6569d9f30..5e3940a88 100644 --- a/app/Models/Backup.php +++ b/app/Models/Backup.php @@ -5,31 +5,30 @@ namespace Pterodactyl\Models; use Illuminate\Database\Eloquent\SoftDeletes; /** - * @property int $id - * @property int $server_id - * @property string $uuid - * @property bool $is_successful - * @property string $name - * @property string[] $ignored_files - * @property string $disk - * @property string|null $checksum - * @property int $bytes - * @property string|null $upload_id + * @property int $id + * @property int $server_id + * @property string $uuid + * @property bool $is_successful + * @property string $name + * @property string[] $ignored_files + * @property string $disk + * @property string|null $checksum + * @property int $bytes + * @property string|null $upload_id * @property \Carbon\CarbonImmutable|null $completed_at - * @property \Carbon\CarbonImmutable $created_at - * @property \Carbon\CarbonImmutable $updated_at + * @property \Carbon\CarbonImmutable $created_at + * @property \Carbon\CarbonImmutable $updated_at * @property \Carbon\CarbonImmutable|null $deleted_at - * - * @property \Pterodactyl\Models\Server $server + * @property \Pterodactyl\Models\Server $server */ class Backup extends Model { use SoftDeletes; - const RESOURCE_NAME = 'backup'; + public const RESOURCE_NAME = 'backup'; - const ADAPTER_WINGS = 'wings'; - const ADAPTER_AWS_S3 = 's3'; + public const ADAPTER_WINGS = 'wings'; + public const ADAPTER_AWS_S3 = 's3'; /** * @var string diff --git a/app/Models/Database.php b/app/Models/Database.php index 8e66219f5..8fb121d1b 100644 --- a/app/Models/Database.php +++ b/app/Models/Database.php @@ -3,18 +3,17 @@ namespace Pterodactyl\Models; /** - * @property int $id - * @property int $server_id - * @property int $database_host_id - * @property string $database - * @property string $username - * @property string $remote - * @property string $password - * @property int $max_connections - * @property \Carbon\Carbon $created_at - * @property \Carbon\Carbon $updated_at - * - * @property \Pterodactyl\Models\Server $server + * @property int $id + * @property int $server_id + * @property int $database_host_id + * @property string $database + * @property string $username + * @property string $remote + * @property string $password + * @property int $max_connections + * @property \Carbon\Carbon $created_at + * @property \Carbon\Carbon $updated_at + * @property \Pterodactyl\Models\Server $server * @property \Pterodactyl\Models\DatabaseHost $host */ class Database extends Model @@ -23,7 +22,7 @@ class Database extends Model * The resource name for this model when it is transformed into an * API representation using fractal. */ - const RESOURCE_NAME = 'server_database'; + public const RESOURCE_NAME = 'server_database'; /** * The table associated with the model. diff --git a/app/Models/DatabaseHost.php b/app/Models/DatabaseHost.php index a005974e5..19f212aa9 100644 --- a/app/Models/DatabaseHost.php +++ b/app/Models/DatabaseHost.php @@ -3,16 +3,16 @@ namespace Pterodactyl\Models; /** - * @property int $id - * @property string $name - * @property string $host - * @property int $port - * @property string $username - * @property \Carbon\Carbon|null $created_at - * @property \Carbon\Carbon|null $updated_at - * - * @property \Pterodactyl\Models\Database[]|\Illuminate\Database\Eloquent\Collection $databases - * @property \Pterodactyl\Models\Node[]|\Illuminate\Database\Eloquent\Collection $nodes + * @property int $id + * @property string $name + * @property string $host + * @property int $port + * @property string $username + * @property string $password + * @property int|null $max_databases + * @property int|null $node_id + * @property \Carbon\CarbonImmutable $created_at + * @property \Carbon\CarbonImmutable $updated_at */ class DatabaseHost extends Model { @@ -20,7 +20,12 @@ class DatabaseHost extends Model * The resource name for this model when it is transformed into an * API representation using fractal. */ - const RESOURCE_NAME = 'database_host'; + public const RESOURCE_NAME = 'database_host'; + + /** + * @var bool + */ + protected $immutableDates = true; /** * The table associated with the model. diff --git a/app/Models/Egg.php b/app/Models/Egg.php index 03d5fa5f8..70e7b305c 100644 --- a/app/Models/Egg.php +++ b/app/Models/Egg.php @@ -3,46 +3,44 @@ namespace Pterodactyl\Models; /** - * @property int $id - * @property string $uuid - * @property int $nest_id - * @property string $author - * @property string $name - * @property string|null $description - * @property array|null $features - * @property string $docker_image -- deprecated, use $docker_images - * @property string $update_url - * @property array $docker_images - * @property string $file_denylist - * @property string|null $config_files - * @property string|null $config_startup - * @property string|null $config_logs - * @property string|null $config_stop - * @property int|null $config_from - * @property string|null $startup - * @property bool $script_is_privileged - * @property string|null $script_install - * @property string $script_entry - * @property string $script_container - * @property int|null $copy_script_from - * @property \Carbon\Carbon $created_at - * @property \Carbon\Carbon $updated_at - * - * @property string|null $copy_script_install - * @property string $copy_script_entry - * @property string $copy_script_container - * @property string|null $inherit_config_files - * @property string|null $inherit_config_startup - * @property string|null $inherit_config_logs - * @property string|null $inherit_config_stop - * @property string $inherit_file_denylist - * @property array|null $inherit_features - * - * @property \Pterodactyl\Models\Nest $nest - * @property \Illuminate\Database\Eloquent\Collection|\Pterodactyl\Models\Server[] $servers + * @property int $id + * @property string $uuid + * @property int $nest_id + * @property string $author + * @property string $name + * @property string|null $description + * @property array|null $features + * @property string $docker_image -- deprecated, use $docker_images + * @property string $update_url + * @property array $docker_images + * @property string $file_denylist + * @property string|null $config_files + * @property string|null $config_startup + * @property string|null $config_logs + * @property string|null $config_stop + * @property int|null $config_from + * @property string|null $startup + * @property bool $script_is_privileged + * @property string|null $script_install + * @property string $script_entry + * @property string $script_container + * @property int|null $copy_script_from + * @property \Carbon\Carbon $created_at + * @property \Carbon\Carbon $updated_at + * @property string|null $copy_script_install + * @property string $copy_script_entry + * @property string $copy_script_container + * @property string|null $inherit_config_files + * @property string|null $inherit_config_startup + * @property string|null $inherit_config_logs + * @property string|null $inherit_config_stop + * @property string $inherit_file_denylist + * @property array|null $inherit_features + * @property \Pterodactyl\Models\Nest $nest + * @property \Illuminate\Database\Eloquent\Collection|\Pterodactyl\Models\Server[] $servers * @property \Illuminate\Database\Eloquent\Collection|\Pterodactyl\Models\EggVariable[] $variables - * @property \Pterodactyl\Models\Egg|null $scriptFrom - * @property \Pterodactyl\Models\Egg|null $configFrom + * @property \Pterodactyl\Models\Egg|null $scriptFrom + * @property \Pterodactyl\Models\Egg|null $configFrom */ class Egg extends Model { @@ -50,7 +48,7 @@ class Egg extends Model * The resource name for this model when it is transformed into an * API representation using fractal. */ - const RESOURCE_NAME = 'egg'; + public const RESOURCE_NAME = 'egg'; /** * Different features that can be enabled on any given egg. These are used internally @@ -61,8 +59,8 @@ class Egg extends Model * To skip copying the features, an empty array value should be passed in ("[]") rather * than leaving it null. */ - const FEATURE_EULA_POPUP = 'eula'; - const FEATURE_FASTDL = 'fastdl'; + public const FEATURE_EULA_POPUP = 'eula'; + public const FEATURE_FASTDL = 'fastdl'; /** * The table associated with the model. @@ -150,7 +148,7 @@ class Egg extends Model */ public function getCopyScriptInstallAttribute() { - if (! is_null($this->script_install) || is_null($this->copy_script_from)) { + if (!is_null($this->script_install) || is_null($this->copy_script_from)) { return $this->script_install; } @@ -165,7 +163,7 @@ class Egg extends Model */ public function getCopyScriptEntryAttribute() { - if (! is_null($this->script_entry) || is_null($this->copy_script_from)) { + if (!is_null($this->script_entry) || is_null($this->copy_script_from)) { return $this->script_entry; } @@ -180,7 +178,7 @@ class Egg extends Model */ public function getCopyScriptContainerAttribute() { - if (! is_null($this->script_container) || is_null($this->copy_script_from)) { + if (!is_null($this->script_container) || is_null($this->copy_script_from)) { return $this->script_container; } @@ -194,7 +192,7 @@ class Egg extends Model */ public function getInheritConfigFilesAttribute() { - if (! is_null($this->config_files) || is_null($this->config_from)) { + if (!is_null($this->config_files) || is_null($this->config_from)) { return $this->config_files; } @@ -208,7 +206,7 @@ class Egg extends Model */ public function getInheritConfigStartupAttribute() { - if (! is_null($this->config_startup) || is_null($this->config_from)) { + if (!is_null($this->config_startup) || is_null($this->config_from)) { return $this->config_startup; } @@ -222,7 +220,7 @@ class Egg extends Model */ public function getInheritConfigLogsAttribute() { - if (! is_null($this->config_logs) || is_null($this->config_from)) { + if (!is_null($this->config_logs) || is_null($this->config_from)) { return $this->config_logs; } @@ -236,7 +234,7 @@ class Egg extends Model */ public function getInheritConfigStopAttribute() { - if (! is_null($this->config_stop) || is_null($this->config_from)) { + if (!is_null($this->config_stop) || is_null($this->config_from)) { return $this->config_stop; } @@ -251,7 +249,7 @@ class Egg extends Model */ public function getInheritFeaturesAttribute() { - if (! is_null($this->features) || is_null($this->config_from)) { + if (!is_null($this->features) || is_null($this->config_from)) { return $this->features; } diff --git a/app/Models/EggVariable.php b/app/Models/EggVariable.php index 2adc35134..aaddf121a 100644 --- a/app/Models/EggVariable.php +++ b/app/Models/EggVariable.php @@ -3,20 +3,19 @@ namespace Pterodactyl\Models; /** - * @property int $id - * @property int $egg_id - * @property string $name - * @property string $description - * @property string $env_variable - * @property string $default_value - * @property bool $user_viewable - * @property bool $user_editable - * @property string $rules - * @property \Carbon\CarbonImmutable $created_at - * @property \Carbon\CarbonImmutable $updated_at - * - * @property bool $required - * @property \Pterodactyl\Models\Egg $egg + * @property int $id + * @property int $egg_id + * @property string $name + * @property string $description + * @property string $env_variable + * @property string $default_value + * @property bool $user_viewable + * @property bool $user_editable + * @property string $rules + * @property \Carbon\CarbonImmutable $created_at + * @property \Carbon\CarbonImmutable $updated_at + * @property bool $required + * @property \Pterodactyl\Models\Egg $egg * @property \Pterodactyl\Models\ServerVariable $serverVariable * * The "server_value" variable is only present on the object if you've loaded this model @@ -29,14 +28,14 @@ class EggVariable extends Model * The resource name for this model when it is transformed into an * API representation using fractal. */ - const RESOURCE_NAME = 'egg_variable'; + public const RESOURCE_NAME = 'egg_variable'; /** * Reserved environment variable names. * * @var string */ - const RESERVED_ENV_NAMES = 'SERVER_MEMORY,SERVER_IP,SERVER_PORT,ENV,HOME,USER,STARTUP,SERVER_UUID,UUID'; + public const RESERVED_ENV_NAMES = 'SERVER_MEMORY,SERVER_IP,SERVER_PORT,ENV,HOME,USER,STARTUP,SERVER_UUID,UUID'; /** * @var bool diff --git a/app/Models/Filters/AdminServerFilter.php b/app/Models/Filters/AdminServerFilter.php index d523e48e0..32580ea51 100644 --- a/app/Models/Filters/AdminServerFilter.php +++ b/app/Models/Filters/AdminServerFilter.php @@ -12,16 +12,12 @@ 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 \Illuminate\Database\Eloquent\Builder $query * @param string $value - * @param string $property */ public function __invoke(Builder $query, $value, string $property) { if ($query->getQuery()->from !== 'servers') { - throw new BadMethodCallException( - 'Cannot use the AdminServerFilter against a non-server model.' - ); + throw new BadMethodCallException('Cannot use the AdminServerFilter against a non-server model.'); } $query ->select('servers.*') diff --git a/app/Models/Filters/MultiFieldServerFilter.php b/app/Models/Filters/MultiFieldServerFilter.php index 21c45b779..2aac64e81 100644 --- a/app/Models/Filters/MultiFieldServerFilter.php +++ b/app/Models/Filters/MultiFieldServerFilter.php @@ -20,16 +20,12 @@ class MultiFieldServerFilter implements Filter * search across multiple columns. This allows us to provide a very generic search ability for * the frontend. * - * @param \Illuminate\Database\Eloquent\Builder $query * @param string $value - * @param string $property */ public function __invoke(Builder $query, $value, string $property) { if ($query->getQuery()->from !== 'servers') { - throw new BadMethodCallException( - 'Cannot use the MultiFieldServerFilter against a non-server model.' - ); + throw new BadMethodCallException('Cannot use the MultiFieldServerFilter against a non-server model.'); } if (preg_match(self::IPV4_REGEX, $value) || preg_match('/^:\d{1,5}$/', $value)) { diff --git a/app/Models/Location.php b/app/Models/Location.php index 74fed1812..5e497fc99 100644 --- a/app/Models/Location.php +++ b/app/Models/Location.php @@ -3,13 +3,12 @@ namespace Pterodactyl\Models; /** - * @property int $id - * @property string $short - * @property string $long - * @property \Carbon\Carbon $created_at - * @property \Carbon\Carbon $updated_at - * - * @property \Pterodactyl\Models\Node[] $nodes + * @property int $id + * @property string $short + * @property string $long + * @property \Carbon\Carbon $created_at + * @property \Carbon\Carbon $updated_at + * @property \Pterodactyl\Models\Node[] $nodes * @property \Pterodactyl\Models\Server[] $servers */ class Location extends Model @@ -18,7 +17,7 @@ class Location extends Model * The resource name for this model when it is transformed into an * API representation using fractal. */ - const RESOURCE_NAME = 'location'; + public const RESOURCE_NAME = 'location'; /** * The table associated with the model. diff --git a/app/Models/Model.php b/app/Models/Model.php index a050746bc..42cd92246 100644 --- a/app/Models/Model.php +++ b/app/Models/Model.php @@ -7,11 +7,14 @@ use Illuminate\Validation\Rule; use Illuminate\Container\Container; use Illuminate\Validation\Validator; use Illuminate\Contracts\Validation\Factory; -use Illuminate\Database\Eloquent\Model as IlluminateModel; +use Illuminate\Database\Eloquent\Factories\HasFactory; use Pterodactyl\Exceptions\Model\DataValidationException; +use Illuminate\Database\Eloquent\Model as IlluminateModel; abstract class Model extends IlluminateModel { + use HasFactory; + /** * Set to true to return immutable Carbon date instances from the model. * @@ -57,7 +60,7 @@ abstract class Model extends IlluminateModel static::$validatorFactory = Container::getInstance()->make(Factory::class); static::saving(function (Model $model) { - if (! $model->validate()) { + if (!$model->validate()) { throw new DataValidationException($model->getValidator()); } @@ -87,7 +90,10 @@ abstract class Model extends IlluminateModel $rules = $this->getKey() ? static::getRulesForUpdate($this) : static::getRules(); return $this->validator ?: $this->validator = static::$validatorFactory->make( - [], $rules, [], [] + [], + $rules, + [], + [] ); } @@ -111,7 +117,7 @@ abstract class Model extends IlluminateModel * rather than just creating it. * * @param \Illuminate\Database\Eloquent\Model|int|string $id - * @param string $primaryKey + * * @return array */ public static function getRulesForUpdate($id, string $primaryKey = 'id') @@ -127,7 +133,7 @@ abstract class Model extends IlluminateModel // working model so we don't run into errors due to the way that field validation // works. foreach ($data as &$datum) { - if (! is_string($datum) || ! Str::startsWith($datum, 'unique')) { + if (!is_string($datum) || !Str::startsWith($datum, 'unique')) { continue; } @@ -157,7 +163,8 @@ abstract class Model extends IlluminateModel // for that model. Doing this will return all of the attributes in a format that can // properly be validated. $this->addCastAttributesToArray( - $this->getAttributes(), $this->getMutatedAttributes() + $this->getAttributes(), + $this->getMutatedAttributes() ) )->passes(); } @@ -166,11 +173,12 @@ abstract class Model extends IlluminateModel * Return a timestamp as DateTime object. * * @param mixed $value + * * @return \Illuminate\Support\Carbon|\Carbon\CarbonImmutable */ protected function asDateTime($value) { - if (! $this->immutableDates) { + if (!$this->immutableDates) { return parent::asDateTime($value); } diff --git a/app/Models/Mount.php b/app/Models/Mount.php index ee9879b19..fb4f511e8 100644 --- a/app/Models/Mount.php +++ b/app/Models/Mount.php @@ -5,17 +5,16 @@ namespace Pterodactyl\Models; use Illuminate\Validation\Rules\NotIn; /** - * @property int $id - * @property string $uuid - * @property string $name - * @property string $description - * @property string $source - * @property string $target - * @property bool $read_only - * @property bool $user_mountable - * - * @property \Pterodactyl\Models\Egg[]|\Illuminate\Database\Eloquent\Collection $eggs - * @property \Pterodactyl\Models\Node[]|\Illuminate\Database\Eloquent\Collection $nodes + * @property int $id + * @property string $uuid + * @property string $name + * @property string $description + * @property string $source + * @property string $target + * @property bool $read_only + * @property bool $user_mountable + * @property \Pterodactyl\Models\Egg[]|\Illuminate\Database\Eloquent\Collection $eggs + * @property \Pterodactyl\Models\Node[]|\Illuminate\Database\Eloquent\Collection $nodes * @property \Pterodactyl\Models\Server[]|\Illuminate\Database\Eloquent\Collection $servers */ class Mount extends Model @@ -24,7 +23,7 @@ class Mount extends Model * The resource name for this model when it is transformed into an * API representation using fractal. */ - const RESOURCE_NAME = 'mount'; + public const RESOURCE_NAME = 'mount'; /** * The table associated with the model. @@ -87,7 +86,7 @@ class Mount extends Model public $timestamps = false; /** - * Blacklisted source paths + * Blacklisted source paths. * * @var string[] */ @@ -98,7 +97,7 @@ class Mount extends Model ]; /** - * Blacklisted target paths + * Blacklisted target paths. * * @var string[] */ diff --git a/app/Models/Nest.php b/app/Models/Nest.php index c3d08d860..d8e81d462 100644 --- a/app/Models/Nest.php +++ b/app/Models/Nest.php @@ -3,16 +3,15 @@ namespace Pterodactyl\Models; /** - * @property int $id - * @property string $uuid - * @property string $author - * @property string $name - * @property string|null $description - * @property \Carbon\Carbon $created_at - * @property \Carbon\Carbon $updated_at - * + * @property int $id + * @property string $uuid + * @property string $author + * @property string $name + * @property string|null $description + * @property \Carbon\Carbon $created_at + * @property \Carbon\Carbon $updated_at * @property \Illuminate\Database\Eloquent\Collection|\Pterodactyl\Models\Server[] $servers - * @property \Illuminate\Database\Eloquent\Collection|\Pterodactyl\Models\Egg[] $eggs + * @property \Illuminate\Database\Eloquent\Collection|\Pterodactyl\Models\Egg[] $eggs */ class Nest extends Model { @@ -20,7 +19,7 @@ class Nest extends Model * The resource name for this model when it is transformed into an * API representation using fractal. */ - const RESOURCE_NAME = 'nest'; + public const RESOURCE_NAME = 'nest'; /** * The table associated with the model. diff --git a/app/Models/Node.php b/app/Models/Node.php index bbf06b92e..b267a6692 100644 --- a/app/Models/Node.php +++ b/app/Models/Node.php @@ -8,32 +8,31 @@ use Illuminate\Notifications\Notifiable; use Illuminate\Contracts\Encryption\Encrypter; /** - * @property int $id - * @property string $uuid - * @property bool $public - * @property string $name - * @property string|null $description - * @property int $location_id - * @property string $fqdn - * @property string $scheme - * @property bool $behind_proxy - * @property bool $maintenance_mode - * @property int $memory - * @property int $memory_overallocate - * @property int $disk - * @property int $disk_overallocate - * @property int $upload_size - * @property string $daemon_token_id - * @property string $daemon_token - * @property int $daemonListen - * @property int $daemonSFTP - * @property string $daemonBase - * @property \Carbon\Carbon $created_at - * @property \Carbon\Carbon $updated_at - * - * @property \Pterodactyl\Models\Location $location - * @property \Pterodactyl\Models\Mount[]|\Illuminate\Database\Eloquent\Collection $mounts - * @property \Pterodactyl\Models\Server[]|\Illuminate\Database\Eloquent\Collection $servers + * @property int $id + * @property string $uuid + * @property bool $public + * @property string $name + * @property string|null $description + * @property int $location_id + * @property string $fqdn + * @property string $scheme + * @property bool $behind_proxy + * @property bool $maintenance_mode + * @property int $memory + * @property int $memory_overallocate + * @property int $disk + * @property int $disk_overallocate + * @property int $upload_size + * @property string $daemon_token_id + * @property string $daemon_token + * @property int $daemonListen + * @property int $daemonSFTP + * @property string $daemonBase + * @property \Carbon\Carbon $created_at + * @property \Carbon\Carbon $updated_at + * @property \Pterodactyl\Models\Location $location + * @property \Pterodactyl\Models\Mount[]|\Illuminate\Database\Eloquent\Collection $mounts + * @property \Pterodactyl\Models\Server[]|\Illuminate\Database\Eloquent\Collection $servers * @property \Pterodactyl\Models\Allocation[]|\Illuminate\Database\Eloquent\Collection $allocations */ class Node extends Model @@ -44,10 +43,10 @@ class Node extends Model * The resource name for this model when it is transformed into an * API representation using fractal. */ - const RESOURCE_NAME = 'node'; + public const RESOURCE_NAME = 'node'; - const DAEMON_TOKEN_ID_LENGTH = 16; - const DAEMON_TOKEN_LENGTH = 64; + public const DAEMON_TOKEN_ID_LENGTH = 16; + public const DAEMON_TOKEN_LENGTH = 64; /** * The table associated with the model. @@ -133,8 +132,6 @@ class Node extends Model /** * Get the connection address to use when making calls to this node. - * - * @return string */ public function getConnectionAddress(): string { @@ -157,7 +154,7 @@ class Node extends Model 'host' => '0.0.0.0', 'port' => $this->daemonListen, 'ssl' => [ - 'enabled' => (! $this->behind_proxy && $this->scheme === 'https'), + 'enabled' => (!$this->behind_proxy && $this->scheme === 'https'), 'cert' => '/etc/letsencrypt/live/' . $this->fqdn . '/fullchain.pem', 'key' => '/etc/letsencrypt/live/' . $this->fqdn . '/privkey.pem', ], @@ -187,7 +184,6 @@ class Node extends Model /** * Returns the configuration in JSON format. * - * @param bool $pretty * @return string */ public function getJsonConfiguration(bool $pretty = false) @@ -197,13 +193,10 @@ class Node extends Model /** * Helper function to return the decrypted key for a node. - * - * @return string - * @throws \Illuminate\Contracts\Container\BindingResolutionException */ public function getDecryptedKey(): string { - return (string)Container::getInstance()->make(Encrypter::class)->decrypt( + return (string) Container::getInstance()->make(Encrypter::class)->decrypt( $this->daemon_token ); } @@ -248,10 +241,6 @@ class Node extends Model /** * Returns a boolean if the node is viable for an additional server to be placed on it. - * - * @param int $memory - * @param int $disk - * @return bool */ public function isViable(int $memory, int $disk): bool { diff --git a/app/Models/Objects/DeploymentObject.php b/app/Models/Objects/DeploymentObject.php index 52857410f..3c62f0bae 100644 --- a/app/Models/Objects/DeploymentObject.php +++ b/app/Models/Objects/DeploymentObject.php @@ -19,16 +19,12 @@ class DeploymentObject */ private $ports = []; - /** - * @return bool - */ public function isDedicated(): bool { return $this->dedicated; } /** - * @param bool $dedicated * @return $this */ public function setDedicated(bool $dedicated) @@ -38,16 +34,12 @@ class DeploymentObject return $this; } - /** - * @return array - */ public function getLocations(): array { return $this->locations; } /** - * @param array $locations * @return $this */ public function setLocations(array $locations) @@ -57,16 +49,12 @@ class DeploymentObject return $this; } - /** - * @return array - */ public function getPorts(): array { return $this->ports; } /** - * @param array $ports * @return $this */ public function setPorts(array $ports) diff --git a/app/Models/Permission.php b/app/Models/Permission.php index 8f6f219c3..3fc2efdff 100644 --- a/app/Models/Permission.php +++ b/app/Models/Permission.php @@ -10,58 +10,58 @@ class Permission extends Model * The resource name for this model when it is transformed into an * API representation using fractal. */ - const RESOURCE_NAME = 'subuser_permission'; + public const RESOURCE_NAME = 'subuser_permission'; /** * Constants defining different permissions available. */ - const ACTION_WEBSOCKET_CONNECT = 'websocket.connect'; - const ACTION_CONTROL_CONSOLE = 'control.console'; - const ACTION_CONTROL_START = 'control.start'; - const ACTION_CONTROL_STOP = 'control.stop'; - const ACTION_CONTROL_RESTART = 'control.restart'; + 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'; - const ACTION_DATABASE_READ = 'database.read'; - const ACTION_DATABASE_CREATE = 'database.create'; - const ACTION_DATABASE_UPDATE = 'database.update'; - const ACTION_DATABASE_DELETE = 'database.delete'; - const ACTION_DATABASE_VIEW_PASSWORD = 'database.view_password'; + 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'; - const ACTION_SCHEDULE_READ = 'schedule.read'; - const ACTION_SCHEDULE_CREATE = 'schedule.create'; - const ACTION_SCHEDULE_UPDATE = 'schedule.update'; - const ACTION_SCHEDULE_DELETE = 'schedule.delete'; + 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'; - const ACTION_USER_READ = 'user.read'; - const ACTION_USER_CREATE = 'user.create'; - const ACTION_USER_UPDATE = 'user.update'; - const ACTION_USER_DELETE = 'user.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'; - const ACTION_BACKUP_READ = 'backup.read'; - const ACTION_BACKUP_CREATE = 'backup.create'; - const ACTION_BACKUP_UPDATE = 'backup.update'; - const ACTION_BACKUP_DELETE = 'backup.delete'; - const ACTION_BACKUP_DOWNLOAD = 'backup.download'; + public const ACTION_BACKUP_READ = 'backup.read'; + public const ACTION_BACKUP_CREATE = 'backup.create'; + public const ACTION_BACKUP_UPDATE = 'backup.update'; + public const ACTION_BACKUP_DELETE = 'backup.delete'; + public const ACTION_BACKUP_DOWNLOAD = 'backup.download'; - const ACTION_ALLOCATION_READ = 'allocation.read'; - const ACTION_ALLOCATION_CREATE = 'allocation.create'; - const ACTION_ALLOCATION_UPDATE = 'allocation.update'; - const ACTION_ALLOCATION_DELETE = 'allocation.delete'; + 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'; - const ACTION_FILE_READ = 'file.read'; - const ACTION_FILE_READ_CONTENT = 'file.read-content'; - const ACTION_FILE_CREATE = 'file.create'; - const ACTION_FILE_UPDATE = 'file.update'; - const ACTION_FILE_DELETE = 'file.delete'; - const ACTION_FILE_ARCHIVE = 'file.archive'; - const ACTION_FILE_SFTP = 'file.sftp'; + 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'; - const ACTION_STARTUP_READ = 'startup.read'; - const ACTION_STARTUP_UPDATE = 'startup.update'; - const ACTION_STARTUP_DOCKER_IMAGE = 'startup.docker-image'; + public const ACTION_STARTUP_READ = 'startup.read'; + public const ACTION_STARTUP_UPDATE = 'startup.update'; + public const ACTION_STARTUP_DOCKER_IMAGE = 'startup.docker-image'; - const ACTION_SETTINGS_RENAME = 'settings.rename'; - const ACTION_SETTINGS_REINSTALL = 'settings.reinstall'; + public const ACTION_SETTINGS_RENAME = 'settings.rename'; + public const ACTION_SETTINGS_REINSTALL = 'settings.reinstall'; /** * Should timestamps be used on this model. @@ -106,6 +106,7 @@ class Permission extends Model * to retrieve them, and not directly access this array as it is subject to change. * * @var array + * * @see \Pterodactyl\Models\Permission::permissions() */ protected static $permissions = [ diff --git a/app/Models/RecoveryToken.php b/app/Models/RecoveryToken.php index 5cd00a9d0..d4ef5a7a0 100644 --- a/app/Models/RecoveryToken.php +++ b/app/Models/RecoveryToken.php @@ -3,11 +3,10 @@ namespace Pterodactyl\Models; /** - * @property int $id - * @property int $user_id - * @property string $token - * @property \Carbon\CarbonImmutable $created_at - * + * @property int $id + * @property int $user_id + * @property string $token + * @property \Carbon\CarbonImmutable $created_at * @property \Pterodactyl\Models\User $user */ class RecoveryToken extends Model @@ -15,7 +14,7 @@ class RecoveryToken extends Model /** * There are no updates to this model, only inserts and deletes. */ - const UPDATED_AT = null; + public const UPDATED_AT = null; /** * @var bool diff --git a/app/Models/Schedule.php b/app/Models/Schedule.php index de0475639..31eec5a6b 100644 --- a/app/Models/Schedule.php +++ b/app/Models/Schedule.php @@ -8,23 +8,22 @@ use Illuminate\Container\Container; use Pterodactyl\Contracts\Extensions\HashidsInterface; /** - * @property int $id - * @property int $server_id - * @property string $name - * @property string $cron_day_of_week - * @property string $cron_day_of_month - * @property string $cron_hour - * @property string $cron_minute - * @property bool $is_active - * @property bool $is_processing - * @property \Carbon\Carbon|null $last_run_at - * @property \Carbon\Carbon|null $next_run_at - * @property \Carbon\Carbon $created_at - * @property \Carbon\Carbon $updated_at - * - * @property string $hashid - * - * @property \Pterodactyl\Models\Server $server + * @property int $id + * @property int $server_id + * @property string $name + * @property string $cron_day_of_week + * @property string $cron_month + * @property string $cron_day_of_month + * @property string $cron_hour + * @property string $cron_minute + * @property bool $is_active + * @property bool $is_processing + * @property \Carbon\Carbon|null $last_run_at + * @property \Carbon\Carbon|null $next_run_at + * @property \Carbon\Carbon $created_at + * @property \Carbon\Carbon $updated_at + * @property string $hashid + * @property \Pterodactyl\Models\Server $server * @property \Pterodactyl\Models\Task[]|\Illuminate\Support\Collection $tasks */ class Schedule extends Model @@ -33,7 +32,7 @@ class Schedule extends Model * The resource name for this model when it is transformed into an * API representation using fractal. */ - const RESOURCE_NAME = 'server_schedule'; + public const RESOURCE_NAME = 'server_schedule'; /** * The table associated with the model. @@ -58,6 +57,7 @@ class Schedule extends Model 'server_id', 'name', 'cron_day_of_week', + 'cron_month', 'cron_day_of_month', 'cron_hour', 'cron_minute', @@ -93,6 +93,7 @@ class Schedule extends Model protected $attributes = [ 'name' => null, 'cron_day_of_week' => '*', + 'cron_month' => '*', 'cron_day_of_month' => '*', 'cron_hour' => '*', 'cron_minute' => '*', @@ -107,6 +108,7 @@ class Schedule extends Model 'server_id' => 'required|exists:servers,id', 'name' => 'required|string|max:191', 'cron_day_of_week' => 'required|string', + 'cron_month' => 'required|string', 'cron_day_of_month' => 'required|string', 'cron_hour' => 'required|string', 'cron_minute' => 'required|string', @@ -123,7 +125,7 @@ class Schedule extends Model */ public function getNextRunDate() { - $formatted = sprintf('%s %s %s * %s', $this->cron_minute, $this->cron_hour, $this->cron_day_of_month, $this->cron_day_of_week); + $formatted = sprintf('%s %s %s %s %s', $this->cron_minute, $this->cron_hour, $this->cron_day_of_month, $this->cron_month, $this->cron_day_of_week); return CarbonImmutable::createFromTimestamp( CronExpression::factory($formatted)->getNextRunDate()->getTimestamp() diff --git a/app/Models/Server.php b/app/Models/Server.php index aace86d0b..1248d5b18 100644 --- a/app/Models/Server.php +++ b/app/Models/Server.php @@ -7,49 +7,48 @@ use Illuminate\Database\Query\JoinClause; use Znck\Eloquent\Traits\BelongsToThrough; /** - * @property int $id - * @property string|null $external_id - * @property string $uuid - * @property string $uuidShort - * @property int $node_id - * @property string $name - * @property string $description - * @property bool $skip_scripts - * @property bool $suspended - * @property int $owner_id - * @property int $memory - * @property int $swap - * @property int $disk - * @property int $io - * @property int $cpu - * @property string $threads - * @property bool $oom_disabled - * @property int $allocation_id - * @property int $nest_id - * @property int $egg_id - * @property string $startup - * @property string $image - * @property int $installed - * @property int $allocation_limit - * @property int $database_limit - * @property int $backup_limit - * @property \Carbon\Carbon $created_at - * @property \Carbon\Carbon $updated_at - * - * @property \Pterodactyl\Models\User $user - * @property \Pterodactyl\Models\Subuser[]|\Illuminate\Database\Eloquent\Collection $subusers - * @property \Pterodactyl\Models\Allocation $allocation - * @property \Pterodactyl\Models\Allocation[]|\Illuminate\Database\Eloquent\Collection $allocations - * @property \Pterodactyl\Models\Node $node - * @property \Pterodactyl\Models\Nest $nest - * @property \Pterodactyl\Models\Egg $egg + * @property int $id + * @property string|null $external_id + * @property string $uuid + * @property string $uuidShort + * @property int $node_id + * @property string $name + * @property string $description + * @property bool $skip_scripts + * @property bool $suspended + * @property int $owner_id + * @property int $memory + * @property int $swap + * @property int $disk + * @property int $io + * @property int $cpu + * @property string $threads + * @property bool $oom_disabled + * @property int $allocation_id + * @property int $nest_id + * @property int $egg_id + * @property string $startup + * @property string $image + * @property int $installed + * @property int $allocation_limit + * @property int $database_limit + * @property int $backup_limit + * @property \Carbon\Carbon $created_at + * @property \Carbon\Carbon $updated_at + * @property \Pterodactyl\Models\User $user + * @property \Pterodactyl\Models\Subuser[]|\Illuminate\Database\Eloquent\Collection $subusers + * @property \Pterodactyl\Models\Allocation $allocation + * @property \Pterodactyl\Models\Allocation[]|\Illuminate\Database\Eloquent\Collection $allocations + * @property \Pterodactyl\Models\Node $node + * @property \Pterodactyl\Models\Nest $nest + * @property \Pterodactyl\Models\Egg $egg * @property \Pterodactyl\Models\EggVariable[]|\Illuminate\Database\Eloquent\Collection $variables - * @property \Pterodactyl\Models\Schedule[]|\Illuminate\Database\Eloquent\Collection $schedule - * @property \Pterodactyl\Models\Database[]|\Illuminate\Database\Eloquent\Collection $databases - * @property \Pterodactyl\Models\Location $location - * @property \Pterodactyl\Models\ServerTransfer $transfer - * @property \Pterodactyl\Models\Backup[]|\Illuminate\Database\Eloquent\Collection $backups - * @property \Pterodactyl\Models\Mount[]|\Illuminate\Database\Eloquent\Collection $mounts + * @property \Pterodactyl\Models\Schedule[]|\Illuminate\Database\Eloquent\Collection $schedule + * @property \Pterodactyl\Models\Database[]|\Illuminate\Database\Eloquent\Collection $databases + * @property \Pterodactyl\Models\Location $location + * @property \Pterodactyl\Models\ServerTransfer $transfer + * @property \Pterodactyl\Models\Backup[]|\Illuminate\Database\Eloquent\Collection $backups + * @property \Pterodactyl\Models\Mount[]|\Illuminate\Database\Eloquent\Collection $mounts */ class Server extends Model { @@ -60,11 +59,11 @@ class Server extends Model * The resource name for this model when it is transformed into an * API representation using fractal. */ - const RESOURCE_NAME = 'server'; + public const RESOURCE_NAME = 'server'; - const STATUS_INSTALLING = 0; - const STATUS_INSTALLED = 1; - const STATUS_INSTALL_FAILED = 2; + public const STATUS_INSTALLING = 0; + public const STATUS_INSTALLED = 1; + public const STATUS_INSTALL_FAILED = 2; /** * The table associated with the model. @@ -159,8 +158,6 @@ class Server extends Model /** * Returns the format for server allocations when communicating with the Daemon. - * - * @return array */ public function getAllocationMappings(): array { @@ -169,9 +166,6 @@ class Server extends Model })->toArray(); } - /** - * @return bool - */ public function isInstalled(): bool { return $this->installed === 1; diff --git a/app/Models/ServerTransfer.php b/app/Models/ServerTransfer.php index 1af9ab7e4..d2b497712 100644 --- a/app/Models/ServerTransfer.php +++ b/app/Models/ServerTransfer.php @@ -3,22 +3,21 @@ namespace Pterodactyl\Models; /** - * @property int $id - * @property int $server_id - * @property int $old_node - * @property int $new_node - * @property int $old_allocation - * @property int $new_allocation - * @property array|null $old_additional_allocations - * @property array|null $new_additional_allocations - * @property bool|null $successful - * @property bool $archived - * @property \Carbon\Carbon $created_at - * @property \Carbon\Carbon $updated_at - * + * @property int $id + * @property int $server_id + * @property int $old_node + * @property int $new_node + * @property int $old_allocation + * @property int $new_allocation + * @property array|null $old_additional_allocations + * @property array|null $new_additional_allocations + * @property bool|null $successful + * @property bool $archived + * @property \Carbon\Carbon $created_at + * @property \Carbon\Carbon $updated_at * @property \Pterodactyl\Models\Server $server - * @property \Pterodactyl\Models\Node $oldNode - * @property \Pterodactyl\Models\Node $newNode + * @property \Pterodactyl\Models\Node $oldNode + * @property \Pterodactyl\Models\Node $newNode */ class ServerTransfer extends Model { @@ -26,7 +25,7 @@ class ServerTransfer extends Model * The resource name for this model when it is transformed into an * API representation using fractal. */ - const RESOURCE_NAME = 'server_transfer'; + public const RESOURCE_NAME = 'server_transfer'; /** * The table associated with the model. diff --git a/app/Models/ServerVariable.php b/app/Models/ServerVariable.php index b2bb4b7d5..7fdfbb1ab 100644 --- a/app/Models/ServerVariable.php +++ b/app/Models/ServerVariable.php @@ -10,7 +10,7 @@ class ServerVariable extends Model * The resource name for this model when it is transformed into an * API representation using fractal. */ - const RESOURCE_NAME = 'server_variable'; + public const RESOURCE_NAME = 'server_variable'; /** * The table associated with the model. diff --git a/app/Models/Subuser.php b/app/Models/Subuser.php index ab85b85dd..87417cea0 100644 --- a/app/Models/Subuser.php +++ b/app/Models/Subuser.php @@ -5,14 +5,13 @@ namespace Pterodactyl\Models; use Illuminate\Notifications\Notifiable; /** - * @property int $id - * @property int $user_id - * @property int $server_id - * @property array $permissions - * @property \Carbon\Carbon $created_at - * @property \Carbon\Carbon $updated_at - * - * @property \Pterodactyl\Models\User $user + * @property int $id + * @property int $user_id + * @property int $server_id + * @property array $permissions + * @property \Carbon\Carbon $created_at + * @property \Carbon\Carbon $updated_at + * @property \Pterodactyl\Models\User $user * @property \Pterodactyl\Models\Server $server */ class Subuser extends Model @@ -23,7 +22,7 @@ class Subuser extends Model * The resource name for this model when it is transformed into an * API representation using fractal. */ - const RESOURCE_NAME = 'server_subuser'; + public const RESOURCE_NAME = 'server_subuser'; /** * The table associated with the model. diff --git a/app/Models/Task.php b/app/Models/Task.php index f241b0717..d88999184 100644 --- a/app/Models/Task.php +++ b/app/Models/Task.php @@ -7,20 +7,18 @@ use Znck\Eloquent\Traits\BelongsToThrough; use Pterodactyl\Contracts\Extensions\HashidsInterface; /** - * @property int $id - * @property int $schedule_id - * @property int $sequence_id - * @property string $action - * @property string $payload - * @property int $time_offset - * @property bool $is_queued - * @property \Carbon\Carbon $created_at - * @property \Carbon\Carbon $updated_at - * - * @property string $hashid - * + * @property int $id + * @property int $schedule_id + * @property int $sequence_id + * @property string $action + * @property string $payload + * @property int $time_offset + * @property bool $is_queued + * @property \Carbon\Carbon $created_at + * @property \Carbon\Carbon $updated_at + * @property string $hashid * @property \Pterodactyl\Models\Schedule $schedule - * @property \Pterodactyl\Models\Server $server + * @property \Pterodactyl\Models\Server $server */ class Task extends Model { @@ -30,7 +28,7 @@ class Task extends Model * The resource name for this model when it is transformed into an * API representation using fractal. */ - const RESOURCE_NAME = 'schedule_task'; + public const RESOURCE_NAME = 'schedule_task'; /** * The table associated with the model. @@ -119,6 +117,7 @@ class Task extends Model * Return the server a task is assigned to, acts as a belongsToThrough. * * @return \Znck\Eloquent\Relations\BelongsToThrough + * * @throws \Exception */ public function server() diff --git a/app/Models/User.php b/app/Models/User.php index b0d2ea614..5288d4d0c 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -17,28 +17,26 @@ use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract; use Pterodactyl\Notifications\SendPasswordReset as ResetPasswordNotification; /** - * @property int $id - * @property string|null $external_id - * @property string $uuid - * @property string $username - * @property string $email - * @property string|null $name_first - * @property string|null $name_last - * @property string $password - * @property string|null $remember_token - * @property string $language - * @property bool $root_admin - * @property bool $use_totp - * @property string|null $totp_secret - * @property \Carbon\Carbon|null $totp_authenticated_at - * @property bool $gravatar - * @property \Carbon\Carbon $created_at - * @property \Carbon\Carbon $updated_at - * - * @property string $name - * @property \Pterodactyl\Models\AdminRole $adminRole - * @property \Pterodactyl\Models\ApiKey[]|\Illuminate\Database\Eloquent\Collection $apiKeys - * @property \Pterodactyl\Models\Server[]|\Illuminate\Database\Eloquent\Collection $servers + * @property int $id + * @property string|null $external_id + * @property string $uuid + * @property string $username + * @property string $email + * @property string|null $name_first + * @property string|null $name_last + * @property string $password + * @property string|null $remeber_token + * @property string $language + * @property bool $root_admin + * @property bool $use_totp + * @property string|null $totp_secret + * @property \Carbon\Carbon|null $totp_authenticated_at + * @property bool $gravatar + * @property \Carbon\Carbon $created_at + * @property \Carbon\Carbon $updated_at + * @property string $name + * @property \Pterodactyl\Models\ApiKey[]|\Illuminate\Database\Eloquent\Collection $apiKeys + * @property \Pterodactyl\Models\Server[]|\Illuminate\Database\Eloquent\Collection $servers * @property \Pterodactyl\Models\RecoveryToken[]|\Illuminate\Database\Eloquent\Collection $recoveryTokens */ class User extends Model implements @@ -52,14 +50,14 @@ class User extends Model implements use CanResetPassword; use Notifiable; - const USER_LEVEL_USER = 0; - const USER_LEVEL_ADMIN = 1; + public const USER_LEVEL_USER = 0; + public const USER_LEVEL_ADMIN = 1; /** * The resource name for this model when it is transformed into an * API representation using fractal. */ - const RESOURCE_NAME = 'user'; + public const RESOURCE_NAME = 'user'; /** * Level of servers to display when using access() on a user. @@ -158,16 +156,14 @@ class User extends Model implements { $rules = parent::getRules(); - $rules['language'][] = new In(array_keys((new self)->getAvailableLanguages())); - $rules['username'][] = new Username; + $rules['language'][] = new In(array_keys((new self())->getAvailableLanguages())); + $rules['username'][] = new Username(); return $rules; } /** * Return the user model in a format that can be passed over to Vue templates. - * - * @return array */ public function toReactObject(): array { @@ -190,8 +186,6 @@ class User extends Model implements /** * Store the username as a lowercase string. - * - * @param string $value */ public function setUsernameAttribute(string $value) { diff --git a/app/Notifications/AccountCreated.php b/app/Notifications/AccountCreated.php index 304978048..e52bed5fe 100644 --- a/app/Notifications/AccountCreated.php +++ b/app/Notifications/AccountCreated.php @@ -29,9 +29,6 @@ class AccountCreated extends Notification implements ShouldQueue /** * Create a new notification instance. - * - * @param \Pterodactyl\Models\User $user - * @param string|null $token */ public function __construct(User $user, string $token = null) { @@ -43,6 +40,7 @@ class AccountCreated extends Notification implements ShouldQueue * Get the notification's delivery channels. * * @param mixed $notifiable + * * @return array */ public function via($notifiable) @@ -54,17 +52,18 @@ class AccountCreated extends Notification implements ShouldQueue * Get the mail representation of the notification. * * @param mixed $notifiable + * * @return \Illuminate\Notifications\Messages\MailMessage */ public function toMail($notifiable) { - $message = (new 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); - if (! is_null($this->token)) { + if (!is_null($this->token)) { return $message->action('Setup Your Account', url('/auth/password/reset/' . $this->token . '?email=' . urlencode($this->user->email))); } diff --git a/app/Notifications/AddedToServer.php b/app/Notifications/AddedToServer.php index 7b6cac8ca..c116a2e29 100644 --- a/app/Notifications/AddedToServer.php +++ b/app/Notifications/AddedToServer.php @@ -25,8 +25,6 @@ class AddedToServer extends Notification implements ShouldQueue /** * Create a new notification instance. - * - * @param array $server */ public function __construct(array $server) { @@ -37,6 +35,7 @@ class AddedToServer extends Notification implements ShouldQueue * Get the notification's delivery channels. * * @param mixed $notifiable + * * @return array */ public function via($notifiable) @@ -48,11 +47,12 @@ class AddedToServer extends Notification implements ShouldQueue * Get the mail representation of the notification. * * @param mixed $notifiable + * * @return \Illuminate\Notifications\Messages\MailMessage */ public function toMail($notifiable) { - return (new MailMessage) + return (new MailMessage()) ->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) diff --git a/app/Notifications/MailTested.php b/app/Notifications/MailTested.php index fdb95f5cb..d0f083acc 100644 --- a/app/Notifications/MailTested.php +++ b/app/Notifications/MailTested.php @@ -25,7 +25,7 @@ class MailTested extends Notification public function toMail() { - return (new MailMessage) + return (new MailMessage()) ->subject('Pterodactyl Test Message') ->greeting('Hello ' . $this->user->name . '!') ->line('This is a test of the Pterodactyl mail system. You\'re good to go!'); diff --git a/app/Notifications/RemovedFromServer.php b/app/Notifications/RemovedFromServer.php index d23aae54a..24418e51c 100644 --- a/app/Notifications/RemovedFromServer.php +++ b/app/Notifications/RemovedFromServer.php @@ -25,8 +25,6 @@ class RemovedFromServer extends Notification implements ShouldQueue /** * Create a new notification instance. - * - * @param array $server */ public function __construct(array $server) { @@ -37,6 +35,7 @@ class RemovedFromServer extends Notification implements ShouldQueue * Get the notification's delivery channels. * * @param mixed $notifiable + * * @return array */ public function via($notifiable) @@ -48,11 +47,12 @@ class RemovedFromServer extends Notification implements ShouldQueue * Get the mail representation of the notification. * * @param mixed $notifiable + * * @return \Illuminate\Notifications\Messages\MailMessage */ public function toMail($notifiable) { - return (new MailMessage) + return (new MailMessage()) ->error() ->greeting('Hello ' . $this->server->user . '.') ->line('You have been removed as a subuser for the following server.') diff --git a/app/Notifications/SendPasswordReset.php b/app/Notifications/SendPasswordReset.php index 83d88216c..cd6d46050 100644 --- a/app/Notifications/SendPasswordReset.php +++ b/app/Notifications/SendPasswordReset.php @@ -39,6 +39,7 @@ class SendPasswordReset extends Notification implements ShouldQueue * Get the notification's delivery channels. * * @param mixed $notifiable + * * @return array */ public function via($notifiable) @@ -50,11 +51,12 @@ class SendPasswordReset extends Notification implements ShouldQueue * Get the mail representation of the notification. * * @param mixed $notifiable + * * @return \Illuminate\Notifications\Messages\MailMessage */ public function toMail($notifiable) { - return (new MailMessage) + 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))) diff --git a/app/Notifications/ServerInstalled.php b/app/Notifications/ServerInstalled.php index fe9747223..cc5a94313 100644 --- a/app/Notifications/ServerInstalled.php +++ b/app/Notifications/ServerInstalled.php @@ -60,7 +60,7 @@ class ServerInstalled extends Notification implements ShouldQueue, ReceivesEvent */ public function toMail() { - return (new MailMessage) + return (new MailMessage()) ->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) diff --git a/app/Observers/ServerObserver.php b/app/Observers/ServerObserver.php index 00db4b334..c6a621204 100644 --- a/app/Observers/ServerObserver.php +++ b/app/Observers/ServerObserver.php @@ -19,8 +19,6 @@ class ServerObserver /** * Listen to the Server creating event. - * - * @param \Pterodactyl\Models\Server $server */ public function creating(Server $server) { @@ -29,8 +27,6 @@ class ServerObserver /** * Listen to the Server created event. - * - * @param \Pterodactyl\Models\Server $server */ public function created(Server $server) { @@ -39,8 +35,6 @@ class ServerObserver /** * Listen to the Server deleting event. - * - * @param \Pterodactyl\Models\Server $server */ public function deleting(Server $server) { @@ -49,8 +43,6 @@ class ServerObserver /** * Listen to the Server deleted event. - * - * @param \Pterodactyl\Models\Server $server */ public function deleted(Server $server) { @@ -59,8 +51,6 @@ class ServerObserver /** * Listen to the Server saving event. - * - * @param \Pterodactyl\Models\Server $server */ public function saving(Server $server) { @@ -69,8 +59,6 @@ class ServerObserver /** * Listen to the Server saved event. - * - * @param \Pterodactyl\Models\Server $server */ public function saved(Server $server) { @@ -79,8 +67,6 @@ class ServerObserver /** * Listen to the Server updating event. - * - * @param \Pterodactyl\Models\Server $server */ public function updating(Server $server) { @@ -89,8 +75,6 @@ class ServerObserver /** * Listen to the Server saved event. - * - * @param \Pterodactyl\Models\Server $server */ public function updated(Server $server) { diff --git a/app/Observers/SubuserObserver.php b/app/Observers/SubuserObserver.php index 009e65290..128de77fb 100644 --- a/app/Observers/SubuserObserver.php +++ b/app/Observers/SubuserObserver.php @@ -18,8 +18,6 @@ class SubuserObserver { /** * Listen to the Subuser creating event. - * - * @param \Pterodactyl\Models\Subuser $subuser */ public function creating(Subuser $subuser) { @@ -28,8 +26,6 @@ class SubuserObserver /** * Listen to the Subuser created event. - * - * @param \Pterodactyl\Models\Subuser $subuser */ public function created(Subuser $subuser) { @@ -44,8 +40,6 @@ class SubuserObserver /** * Listen to the Subuser deleting event. - * - * @param \Pterodactyl\Models\Subuser $subuser */ public function deleting(Subuser $subuser) { @@ -54,8 +48,6 @@ class SubuserObserver /** * Listen to the Subuser deleted event. - * - * @param \Pterodactyl\Models\Subuser $subuser */ public function deleted(Subuser $subuser) { diff --git a/app/Observers/UserObserver.php b/app/Observers/UserObserver.php index dd29d908b..18d73bc10 100644 --- a/app/Observers/UserObserver.php +++ b/app/Observers/UserObserver.php @@ -11,8 +11,6 @@ class UserObserver /** * Listen to the User creating event. - * - * @param \Pterodactyl\Models\User $user */ public function creating(User $user) { @@ -21,8 +19,6 @@ class UserObserver /** * Listen to the User created event. - * - * @param \Pterodactyl\Models\User $user */ public function created(User $user) { @@ -31,8 +27,6 @@ class UserObserver /** * Listen to the User deleting event. - * - * @param \Pterodactyl\Models\User $user */ public function deleting(User $user) { @@ -41,8 +35,6 @@ class UserObserver /** * Listen to the User deleted event. - * - * @param \Pterodactyl\Models\User $user */ public function deleted(User $user) { diff --git a/app/Policies/ServerPolicy.php b/app/Policies/ServerPolicy.php index bc3fa7aca..311f0a4a8 100644 --- a/app/Policies/ServerPolicy.php +++ b/app/Policies/ServerPolicy.php @@ -16,8 +16,6 @@ class ServerPolicy /** * ServerPolicy constructor. - * - * @param \Illuminate\Contracts\Cache\Repository $cache */ public function __construct(CacheRepository $cache) { @@ -27,9 +25,8 @@ class ServerPolicy /** * Checks if the user has the given permission on/for the server. * - * @param \Pterodactyl\Models\User $user - * @param \Pterodactyl\Models\Server $server * @param string $permission + * * @return bool */ protected function checkPermission(User $user, Server $server, $permission) @@ -49,9 +46,8 @@ class ServerPolicy /** * Runs before any of the functions are called. Used to determine if user is root admin, if so, ignore permissions. * - * @param \Pterodactyl\Models\User $user * @param string $ability - * @param \Pterodactyl\Models\Server $server + * * @return bool */ public function before(User $user, $ability, Server $server) @@ -69,7 +65,7 @@ class ServerPolicy * policy permission. * * @param string $name - * @param mixed $arguments + * @param mixed $arguments */ public function __call($name, $arguments) { diff --git a/app/Providers/BladeServiceProvider.php b/app/Providers/BladeServiceProvider.php index 97b0df48e..16a17a373 100644 --- a/app/Providers/BladeServiceProvider.php +++ b/app/Providers/BladeServiceProvider.php @@ -13,7 +13,7 @@ class BladeServiceProvider extends ServiceProvider { $this->app->make('blade.compiler') ->directive('datetimeHuman', function ($expression) { - return "setTimezone(config('app.timezone'))->toDateTimeString(); ?>"; + return "setTimezone(config('app.timezone'))->toDateTimeString(); ?>"; }); } } diff --git a/app/Providers/SettingsServiceProvider.php b/app/Providers/SettingsServiceProvider.php index 5cbcec105..71fda215e 100644 --- a/app/Providers/SettingsServiceProvider.php +++ b/app/Providers/SettingsServiceProvider.php @@ -63,11 +63,6 @@ class SettingsServiceProvider extends ServiceProvider /** * Boot the service provider. - * - * @param \Illuminate\Contracts\Config\Repository $config - * @param \Illuminate\Contracts\Encryption\Encrypter $encrypter - * @param \Psr\Log\LoggerInterface $log - * @param \Pterodactyl\Contracts\Repository\SettingsRepositoryInterface $settings */ public function boot(ConfigRepository $config, Encrypter $encrypter, Log $log, SettingsRepositoryInterface $settings) { @@ -118,9 +113,6 @@ class SettingsServiceProvider extends ServiceProvider } } - /** - * @return array - */ public static function getEncryptedKeys(): array { return self::$encrypted; diff --git a/app/Repositories/Eloquent/AllocationRepository.php b/app/Repositories/Eloquent/AllocationRepository.php index 15a5db81b..3723c1d1f 100644 --- a/app/Repositories/Eloquent/AllocationRepository.php +++ b/app/Repositories/Eloquent/AllocationRepository.php @@ -21,9 +21,6 @@ class AllocationRepository extends EloquentRepository implements AllocationRepos /** * Return all of the allocations that exist for a node that are not currently * allocated. - * - * @param int $node - * @return array */ public function getUnassignedAllocationIds(int $node): array { @@ -42,15 +39,12 @@ class AllocationRepository extends EloquentRepository implements AllocationRepos * * If an array of nodes is passed the results will be limited to allocations * in those nodes. - * - * @param array $nodes - * @return array */ protected function getDiscardableDedicatedAllocations(array $nodes = []): array { $query = Allocation::query()->selectRaw('CONCAT_WS("-", node_id, ip) as result'); - if (! empty($nodes)) { + if (!empty($nodes)) { $query->whereIn('node_id', $nodes); } @@ -64,20 +58,17 @@ class AllocationRepository extends EloquentRepository implements AllocationRepos /** * Return a single allocation from those meeting the requirements. * - * @param array $nodes - * @param array $ports - * @param bool $dedicated * @return \Pterodactyl\Models\Allocation|null */ public function getRandomAllocation(array $nodes, array $ports, bool $dedicated = false) { $query = Allocation::query()->whereNull('server_id'); - if (! empty($nodes)) { + if (!empty($nodes)) { $query->whereIn('node_id', $nodes); } - if (! empty($ports)) { + if (!empty($ports)) { $query->where(function (Builder $inner) use ($ports) { $whereIn = []; foreach ($ports as $port) { @@ -89,7 +80,7 @@ class AllocationRepository extends EloquentRepository implements AllocationRepos $whereIn[] = $port; } - if (! empty($whereIn)) { + if (!empty($whereIn)) { $inner->orWhereIn('port', $whereIn); } }); @@ -100,9 +91,10 @@ class AllocationRepository extends EloquentRepository implements AllocationRepos if ($dedicated) { $discard = $this->getDiscardableDedicatedAllocations($nodes); - if (! empty($discard)) { + if (!empty($discard)) { $query->whereNotIn( - $this->getBuilder()->raw('CONCAT_WS("-", node_id, ip)'), $discard + $this->getBuilder()->raw('CONCAT_WS("-", node_id, ip)'), + $discard ); } } diff --git a/app/Repositories/Eloquent/ApiKeyRepository.php b/app/Repositories/Eloquent/ApiKeyRepository.php index 55d559544..67a7e6e6e 100644 --- a/app/Repositories/Eloquent/ApiKeyRepository.php +++ b/app/Repositories/Eloquent/ApiKeyRepository.php @@ -21,9 +21,6 @@ class ApiKeyRepository extends EloquentRepository implements ApiKeyRepositoryInt /** * Get all of the account API keys that exist for a specific user. - * - * @param \Pterodactyl\Models\User $user - * @return \Illuminate\Support\Collection */ public function getAccountKeys(User $user): Collection { @@ -34,9 +31,6 @@ class ApiKeyRepository extends EloquentRepository implements ApiKeyRepositoryInt /** * Get all of the application API keys that exist for a specific user. - * - * @param \Pterodactyl\Models\User $user - * @return \Illuminate\Support\Collection */ public function getApplicationKeys(User $user): Collection { @@ -47,10 +41,6 @@ class ApiKeyRepository extends EloquentRepository implements ApiKeyRepositoryInt /** * Delete an account API key from the panel for a specific user. - * - * @param \Pterodactyl\Models\User $user - * @param string $identifier - * @return int */ public function deleteAccountKey(User $user, string $identifier): int { @@ -62,10 +52,6 @@ class ApiKeyRepository extends EloquentRepository implements ApiKeyRepositoryInt /** * Delete an application API key from the panel for a specific user. - * - * @param \Pterodactyl\Models\User $user - * @param string $identifier - * @return int */ public function deleteApplicationKey(User $user, string $identifier): int { diff --git a/app/Repositories/Eloquent/BackupRepository.php b/app/Repositories/Eloquent/BackupRepository.php index 46e400142..b53547e44 100644 --- a/app/Repositories/Eloquent/BackupRepository.php +++ b/app/Repositories/Eloquent/BackupRepository.php @@ -18,8 +18,6 @@ class BackupRepository extends EloquentRepository /** * Determines if too many backups have been generated by the server. * - * @param int $server - * @param int $seconds * @return \Pterodactyl\Models\Backup[]|\Illuminate\Support\Collection */ public function getBackupsGeneratedDuringTimespan(int $server, int $seconds = 600) diff --git a/app/Repositories/Eloquent/DatabaseHostRepository.php b/app/Repositories/Eloquent/DatabaseHostRepository.php index 4ed4d411e..c55b03232 100644 --- a/app/Repositories/Eloquent/DatabaseHostRepository.php +++ b/app/Repositories/Eloquent/DatabaseHostRepository.php @@ -21,8 +21,6 @@ class DatabaseHostRepository extends EloquentRepository implements DatabaseHostR /** * Return database hosts with a count of databases and the node * information for which it is attached. - * - * @return \Illuminate\Support\Collection */ public function getWithViewDetails(): Collection { diff --git a/app/Repositories/Eloquent/DatabaseRepository.php b/app/Repositories/Eloquent/DatabaseRepository.php index 46b3916da..4e421df4d 100644 --- a/app/Repositories/Eloquent/DatabaseRepository.php +++ b/app/Repositories/Eloquent/DatabaseRepository.php @@ -8,7 +8,6 @@ use Illuminate\Foundation\Application; use Illuminate\Database\DatabaseManager; use Illuminate\Contracts\Pagination\LengthAwarePaginator; use Pterodactyl\Contracts\Repository\DatabaseRepositoryInterface; -use Pterodactyl\Exceptions\Repository\DuplicateDatabaseNameException; class DatabaseRepository extends EloquentRepository implements DatabaseRepositoryInterface { @@ -24,9 +23,6 @@ class DatabaseRepository extends EloquentRepository implements DatabaseRepositor /** * DatabaseRepository constructor. - * - * @param \Illuminate\Foundation\Application $application - * @param \Illuminate\Database\DatabaseManager $database */ public function __construct(Application $application, DatabaseManager $database) { @@ -48,7 +44,6 @@ class DatabaseRepository extends EloquentRepository implements DatabaseRepositor /** * Set the connection name to execute statements against. * - * @param string $connection * @return $this */ public function setConnection(string $connection) @@ -60,8 +55,6 @@ class DatabaseRepository extends EloquentRepository implements DatabaseRepositor /** * Return the connection to execute statements against. - * - * @return string */ public function getConnection(): string { @@ -70,9 +63,6 @@ class DatabaseRepository extends EloquentRepository implements DatabaseRepositor /** * Return all of the databases belonging to a server. - * - * @param int $server - * @return \Illuminate\Support\Collection */ public function getDatabasesForServer(int $server): Collection { @@ -81,10 +71,6 @@ class DatabaseRepository extends EloquentRepository implements DatabaseRepositor /** * Return all of the databases for a given host with the server relationship loaded. - * - * @param int $host - * @param int $count - * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator */ public function getDatabasesForHost(int $host, int $count = 25): LengthAwarePaginator { @@ -95,9 +81,6 @@ class DatabaseRepository extends EloquentRepository implements DatabaseRepositor /** * Create a new database on a given connection. - * - * @param string $database - * @return bool */ public function createDatabase(string $database): bool { @@ -107,15 +90,11 @@ class DatabaseRepository extends EloquentRepository implements DatabaseRepositor /** * Create a new database user on a given connection. * - * @param string $username - * @param string $remote - * @param string $password * @param $max_connections - * @return bool */ public function createUser(string $username, string $remote, string $password, $max_connections): bool { - if (! $max_connections) { + if (!$max_connections) { return $this->run(sprintf('CREATE USER `%s`@`%s` IDENTIFIED BY \'%s\'', $username, $remote, $password)); } else { return $this->run(sprintf('CREATE USER `%s`@`%s` IDENTIFIED BY \'%s\' WITH MAX_USER_CONNECTIONS %s', $username, $remote, $password, $max_connections)); @@ -124,11 +103,6 @@ class DatabaseRepository extends EloquentRepository implements DatabaseRepositor /** * Give a specific user access to a given database. - * - * @param string $database - * @param string $username - * @param string $remote - * @return bool */ public function assignUserToDatabase(string $database, string $username, string $remote): bool { @@ -142,8 +116,6 @@ class DatabaseRepository extends EloquentRepository implements DatabaseRepositor /** * Flush the privileges for a given connection. - * - * @return bool */ public function flush(): bool { @@ -152,9 +124,6 @@ class DatabaseRepository extends EloquentRepository implements DatabaseRepositor /** * Drop a given database on a specific connection. - * - * @param string $database - * @return bool */ public function dropDatabase(string $database): bool { @@ -164,8 +133,6 @@ class DatabaseRepository extends EloquentRepository implements DatabaseRepositor /** * Drop a given user on a specific connection. * - * @param string $username - * @param string $remote * @return mixed */ public function dropUser(string $username, string $remote): bool @@ -175,9 +142,6 @@ class DatabaseRepository extends EloquentRepository implements DatabaseRepositor /** * Run the provided statement against the database on a given connection. - * - * @param string $statement - * @return bool */ private function run(string $statement): bool { diff --git a/app/Repositories/Eloquent/EggRepository.php b/app/Repositories/Eloquent/EggRepository.php index a716a5ec9..98b7db453 100644 --- a/app/Repositories/Eloquent/EggRepository.php +++ b/app/Repositories/Eloquent/EggRepository.php @@ -24,9 +24,6 @@ class EggRepository extends EloquentRepository implements EggRepositoryInterface /** * Return an egg with the variables relation attached. * - * @param int $id - * @return \Pterodactyl\Models\Egg - * * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ public function getWithVariables(int $id): Egg @@ -34,14 +31,12 @@ class EggRepository extends EloquentRepository implements EggRepositoryInterface try { return $this->getBuilder()->with('variables')->findOrFail($id, $this->getColumns()); } catch (ModelNotFoundException $exception) { - throw new RecordNotFoundException; + throw new RecordNotFoundException(); } } /** * Return all eggs and their relations to be used in the daemon API. - * - * @return \Illuminate\Database\Eloquent\Collection */ public function getAllWithCopyAttributes(): Collection { @@ -52,8 +47,6 @@ class EggRepository extends EloquentRepository implements EggRepositoryInterface * Return an egg with the scriptFrom and configFrom relations loaded onto the model. * * @param int|string $value - * @param string $column - * @return \Pterodactyl\Models\Egg * * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ @@ -64,16 +57,13 @@ class EggRepository extends EloquentRepository implements EggRepositoryInterface try { return $this->getBuilder()->with('scriptFrom', 'configFrom')->where($column, '=', $value)->firstOrFail($this->getColumns()); } catch (ModelNotFoundException $exception) { - throw new RecordNotFoundException; + throw new RecordNotFoundException(); } } /** * Return all of the data needed to export a service. * - * @param int $id - * @return \Pterodactyl\Models\Egg - * * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ public function getWithExportAttributes(int $id): Egg @@ -81,16 +71,12 @@ class EggRepository extends EloquentRepository implements EggRepositoryInterface try { return $this->getBuilder()->with('scriptFrom', 'configFrom', 'variables')->findOrFail($id, $this->getColumns()); } catch (ModelNotFoundException $exception) { - throw new RecordNotFoundException; + throw new RecordNotFoundException(); } } /** * Confirm a copy script belongs to the same nest as the item trying to use it. - * - * @param int $copyFromId - * @param int $service - * @return bool */ public function isCopyableScript(int $copyFromId, int $service): bool { diff --git a/app/Repositories/Eloquent/EggVariableRepository.php b/app/Repositories/Eloquent/EggVariableRepository.php index 9d84b9db1..ce79a65f6 100644 --- a/app/Repositories/Eloquent/EggVariableRepository.php +++ b/app/Repositories/Eloquent/EggVariableRepository.php @@ -21,9 +21,6 @@ class EggVariableRepository extends EloquentRepository implements EggVariableRep /** * Return editable variables for a given egg. Editable variables must be set to * user viewable in order to be picked up by this function. - * - * @param int $egg - * @return \Illuminate\Support\Collection */ public function getEditableVariables(int $egg): Collection { diff --git a/app/Repositories/Eloquent/EloquentRepository.php b/app/Repositories/Eloquent/EloquentRepository.php index bd8133022..3d3e09cdc 100644 --- a/app/Repositories/Eloquent/EloquentRepository.php +++ b/app/Repositories/Eloquent/EloquentRepository.php @@ -13,7 +13,6 @@ use Illuminate\Contracts\Pagination\LengthAwarePaginator; use Pterodactyl\Contracts\Repository\RepositoryInterface; use Pterodactyl\Exceptions\Model\DataValidationException; use Pterodactyl\Exceptions\Repository\RecordNotFoundException; -use Pterodactyl\Contracts\Repository\Attributes\SearchableInterface; abstract class EloquentRepository extends Repository implements RepositoryInterface { @@ -28,6 +27,7 @@ abstract class EloquentRepository extends Repository implements RepositoryInterf * context's such that we can pass through ?filter[name]=Dane&sort=desc for example. * * @param bool $usingFilters + * * @return $this */ public function usingRequestFilters($usingFilters = true) @@ -50,14 +50,11 @@ abstract class EloquentRepository extends Repository implements RepositoryInterf /** * Paginate the response data based on the page para. * - * @param \Illuminate\Database\Eloquent\Builder $instance - * @param int $default - * * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator */ protected function paginate(Builder $instance, int $default = 50) { - if (! $this->useRequestFilters) { + if (!$this->useRequestFilters) { return $instance->paginate($default); } @@ -88,9 +85,6 @@ abstract class EloquentRepository extends Repository implements RepositoryInterf /** * Create a new record in the database and return the associated model. * - * @param array $fields - * @param bool $validate - * @param bool $force * @return \Illuminate\Database\Eloquent\Model|bool * * @throws \Pterodactyl\Exceptions\Model\DataValidationException @@ -100,10 +94,10 @@ abstract class EloquentRepository extends Repository implements RepositoryInterf $instance = $this->getBuilder()->newModelInstance(); ($force) ? $instance->forceFill($fields) : $instance->fill($fields); - if (! $validate) { + if (!$validate) { $saved = $instance->skipValidation()->save(); } else { - if (! $saved = $instance->save()) { + if (!$saved = $instance->save()) { throw new DataValidationException($instance->getValidator()); } } @@ -114,7 +108,6 @@ abstract class EloquentRepository extends Repository implements RepositoryInterf /** * Find a model that has the specific ID passed. * - * @param int $id * @return \Illuminate\Database\Eloquent\Model * * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException @@ -124,15 +117,12 @@ abstract class EloquentRepository extends Repository implements RepositoryInterf try { return $this->getBuilder()->findOrFail($id, $this->getColumns()); } catch (ModelNotFoundException $exception) { - throw new RecordNotFoundException; + throw new RecordNotFoundException(); } } /** * Find a model matching an array of where clauses. - * - * @param array $fields - * @return \Illuminate\Support\Collection */ public function findWhere(array $fields): Collection { @@ -142,7 +132,6 @@ abstract class EloquentRepository extends Repository implements RepositoryInterf /** * Find and return the first matching instance for the given fields. * - * @param array $fields * @return \Illuminate\Database\Eloquent\Model * * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException @@ -152,15 +141,12 @@ abstract class EloquentRepository extends Repository implements RepositoryInterf try { return $this->getBuilder()->where($fields)->firstOrFail($this->getColumns()); } catch (ModelNotFoundException $exception) { - throw new RecordNotFoundException; + throw new RecordNotFoundException(); } } /** * Return a count of records matching the passed arguments. - * - * @param array $fields - * @return int */ public function findCountWhere(array $fields): int { @@ -169,10 +155,6 @@ abstract class EloquentRepository extends Repository implements RepositoryInterf /** * Delete a given record from the database. - * - * @param int $id - * @param bool $destroy - * @return int */ public function delete(int $id, bool $destroy = false): int { @@ -181,10 +163,6 @@ abstract class EloquentRepository extends Repository implements RepositoryInterf /** * Delete records matching the given attributes. - * - * @param array $attributes - * @param bool $force - * @return int */ public function deleteWhere(array $attributes, bool $force = false): int { @@ -197,9 +175,7 @@ abstract class EloquentRepository extends Repository implements RepositoryInterf * Update a given ID with the passed array of fields. * * @param int $id - * @param array $fields - * @param bool $validate - * @param bool $force + * * @return \Illuminate\Database\Eloquent\Model|bool * * @throws \Pterodactyl\Exceptions\Model\DataValidationException @@ -210,15 +186,15 @@ abstract class EloquentRepository extends Repository implements RepositoryInterf try { $instance = $this->getBuilder()->where('id', $id)->firstOrFail(); } catch (ModelNotFoundException $exception) { - throw new RecordNotFoundException; + throw new RecordNotFoundException(); } ($force) ? $instance->forceFill($fields) : $instance->fill($fields); - if (! $validate) { + if (!$validate) { $saved = $instance->skipValidation()->save(); } else { - if (! $saved = $instance->save()) { + if (!$saved = $instance->save()) { throw new DataValidationException($instance->getValidator()); } } @@ -230,7 +206,7 @@ abstract class EloquentRepository extends Repository implements RepositoryInterf * Update a model using the attributes passed. * * @param array|\Closure $attributes - * @param array $values + * * @return int */ public function updateWhere($attributes, array $values) @@ -241,11 +217,6 @@ abstract class EloquentRepository extends Repository implements RepositoryInterf /** * Perform a mass update where matching records are updated using whereIn. * This does not perform any model data validation. - * - * @param string $column - * @param array $values - * @param array $fields - * @return int */ public function updateWhereIn(string $column, array $values, array $fields): int { @@ -257,10 +228,6 @@ abstract class EloquentRepository extends Repository implements RepositoryInterf /** * Update a record if it exists in the database, otherwise create it. * - * @param array $where - * @param array $fields - * @param bool $validate - * @param bool $force * @return \Illuminate\Database\Eloquent\Model * * @throws \Pterodactyl\Exceptions\Model\DataValidationException @@ -284,7 +251,6 @@ abstract class EloquentRepository extends Repository implements RepositoryInterf /** * Return all records associated with the given model. * - * @return \Illuminate\Support\Collection * @deprecated Just use the model */ public function all(): Collection @@ -294,9 +260,6 @@ abstract class EloquentRepository extends Repository implements RepositoryInterf /** * Return a paginated result set using a search term if set on the repository. - * - * @param int $perPage - * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator */ public function paginated(int $perPage): LengthAwarePaginator { @@ -306,9 +269,6 @@ abstract class EloquentRepository extends Repository implements RepositoryInterf /** * Insert a single or multiple records into the database at once skipping * validation and mass assignment checking. - * - * @param array $data - * @return bool */ public function insert(array $data): bool { @@ -317,9 +277,6 @@ abstract class EloquentRepository extends Repository implements RepositoryInterf /** * Insert multiple records into the database and ignore duplicates. - * - * @param array $values - * @return bool */ public function insertIgnore(array $values): bool { @@ -333,7 +290,7 @@ abstract class EloquentRepository extends Repository implements RepositoryInterf } $bindings = array_values(array_filter(array_flatten($values, 1), function ($binding) { - return ! $binding instanceof Expression; + return !$binding instanceof Expression; })); $grammar = $this->getBuilder()->toBase()->getGrammar(); @@ -352,7 +309,6 @@ abstract class EloquentRepository extends Repository implements RepositoryInterf /** * Get the amount of entries in the database. * - * @return int * @deprecated just use the count method off a model */ public function count(): int diff --git a/app/Repositories/Eloquent/LocationRepository.php b/app/Repositories/Eloquent/LocationRepository.php index 6d14d5aa6..c06d10a9f 100644 --- a/app/Repositories/Eloquent/LocationRepository.php +++ b/app/Repositories/Eloquent/LocationRepository.php @@ -22,8 +22,6 @@ class LocationRepository extends EloquentRepository implements LocationRepositor /** * Return locations with a count of nodes and servers attached to it. - * - * @return \Illuminate\Support\Collection */ public function getAllWithDetails(): Collection { @@ -32,8 +30,6 @@ class LocationRepository extends EloquentRepository implements LocationRepositor /** * Return all of the available locations with the nodes as a relationship. - * - * @return \Illuminate\Support\Collection */ public function getAllWithNodes(): Collection { @@ -43,7 +39,6 @@ class LocationRepository extends EloquentRepository implements LocationRepositor /** * Return all of the nodes and their respective count of servers for a location. * - * @param int $id * @return mixed * * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException @@ -53,14 +48,13 @@ class LocationRepository extends EloquentRepository implements LocationRepositor try { return $this->getBuilder()->with('nodes.servers')->findOrFail($id, $this->getColumns()); } catch (ModelNotFoundException $exception) { - throw new RecordNotFoundException; + throw new RecordNotFoundException(); } } /** * Return a location and the count of nodes in that location. * - * @param int $id * @return mixed * * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException @@ -70,7 +64,7 @@ class LocationRepository extends EloquentRepository implements LocationRepositor try { return $this->getBuilder()->withCount('nodes')->findOrFail($id, $this->getColumns()); } catch (ModelNotFoundException $exception) { - throw new RecordNotFoundException; + throw new RecordNotFoundException(); } } } diff --git a/app/Repositories/Eloquent/MountRepository.php b/app/Repositories/Eloquent/MountRepository.php index 286e07913..490f76b64 100644 --- a/app/Repositories/Eloquent/MountRepository.php +++ b/app/Repositories/Eloquent/MountRepository.php @@ -22,8 +22,6 @@ class MountRepository extends EloquentRepository /** * Return mounts with a count of eggs, nodes, and servers attached to it. - * - * @return \Illuminate\Support\Collection */ public function getAllWithDetails(): Collection { @@ -33,7 +31,6 @@ class MountRepository extends EloquentRepository /** * Return all of the mounts and their respective relations. * - * @param string $id * @return mixed * * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException @@ -43,15 +40,12 @@ class MountRepository extends EloquentRepository try { return $this->getBuilder()->with('eggs', 'nodes')->findOrFail($id, $this->getColumns()); } catch (ModelNotFoundException $exception) { - throw new RecordNotFoundException; + throw new RecordNotFoundException(); } } /** * Return mounts available to a server (ignoring if they are or are not mounted). - * - * @param Server $server - * @return \Illuminate\Support\Collection */ public function getMountListForServer(Server $server): Collection { diff --git a/app/Repositories/Eloquent/NestRepository.php b/app/Repositories/Eloquent/NestRepository.php index cc3926805..89b9c9800 100644 --- a/app/Repositories/Eloquent/NestRepository.php +++ b/app/Repositories/Eloquent/NestRepository.php @@ -38,10 +38,10 @@ class NestRepository extends EloquentRepository implements NestRepositoryInterfa { $instance = $this->getBuilder()->with('eggs', 'eggs.variables'); - if (! is_null($id)) { + if (!is_null($id)) { $instance = $instance->find($id, $this->getColumns()); - if (! $instance) { - throw new RecordNotFoundException; + if (!$instance) { + throw new RecordNotFoundException(); } return $instance; @@ -53,7 +53,6 @@ class NestRepository extends EloquentRepository implements NestRepositoryInterfa /** * Return a nest or all nests and the count of eggs and servers for that nest. * - * @param int|null $id * @return \Pterodactyl\Models\Nest|\Illuminate\Database\Eloquent\Collection * * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException @@ -62,10 +61,10 @@ class NestRepository extends EloquentRepository implements NestRepositoryInterfa { $instance = $this->getBuilder()->withCount(['eggs', 'servers']); - if (! is_null($id)) { + if (!is_null($id)) { $instance = $instance->find($id, $this->getColumns()); - if (! $instance) { - throw new RecordNotFoundException; + if (!$instance) { + throw new RecordNotFoundException(); } return $instance; @@ -77,16 +76,13 @@ class NestRepository extends EloquentRepository implements NestRepositoryInterfa /** * Return a nest along with its associated eggs and the servers relation on those eggs. * - * @param int $id - * @return \Pterodactyl\Models\Nest - * * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ public function getWithEggServers(int $id): Nest { $instance = $this->getBuilder()->with('eggs.servers')->find($id, $this->getColumns()); - if (! $instance) { - throw new RecordNotFoundException; + if (!$instance) { + throw new RecordNotFoundException(); } /* @var Nest $instance */ diff --git a/app/Repositories/Eloquent/NodeRepository.php b/app/Repositories/Eloquent/NodeRepository.php index 9c852fb56..5d1a8bcac 100644 --- a/app/Repositories/Eloquent/NodeRepository.php +++ b/app/Repositories/Eloquent/NodeRepository.php @@ -4,8 +4,6 @@ namespace Pterodactyl\Repositories\Eloquent; use Pterodactyl\Models\Node; use Illuminate\Support\Collection; -use Illuminate\Support\LazyCollection; -use Illuminate\Contracts\Pagination\LengthAwarePaginator; use Pterodactyl\Contracts\Repository\NodeRepositoryInterface; class NodeRepository extends EloquentRepository implements NodeRepositoryInterface @@ -22,9 +20,6 @@ class NodeRepository extends EloquentRepository implements NodeRepositoryInterfa /** * Return the usage stats for a single node. - * - * @param \Pterodactyl\Models\Node $node - * @return array */ public function getUsageStats(Node $node): array { @@ -57,9 +52,6 @@ class NodeRepository extends EloquentRepository implements NodeRepositoryInterfa /** * Return the usage stats for a single node. - * - * @param \Pterodactyl\Models\Node $node - * @return array */ public function getUsageStatsRaw(Node $node): array { @@ -84,14 +76,10 @@ class NodeRepository extends EloquentRepository implements NodeRepositoryInterfa /** * Return a single node with location and server information. - * - * @param \Pterodactyl\Models\Node $node - * @param bool $refresh - * @return \Pterodactyl\Models\Node */ public function loadLocationAndServerCount(Node $node, bool $refresh = false): Node { - if (! $node->relationLoaded('location') || $refresh) { + if (!$node->relationLoaded('location') || $refresh) { $node->load('location'); } @@ -109,14 +97,11 @@ class NodeRepository extends EloquentRepository implements NodeRepositoryInterfa /** * Attach a paginated set of allocations to a node mode including * any servers that are also attached to those allocations. - * - * @param \Pterodactyl\Models\Node $node - * @param bool $refresh - * @return \Pterodactyl\Models\Node */ public function loadNodeAllocations(Node $node, bool $refresh = false): Node { - $node->setRelation('allocations', + $node->setRelation( + 'allocations', $node->allocations() ->orderByRaw('server_id IS NOT NULL DESC, server_id IS NULL') ->orderByRaw('INET_ATON(ip) ASC') @@ -130,8 +115,6 @@ class NodeRepository extends EloquentRepository implements NodeRepositoryInterfa /** * Return a collection of nodes for all locations to use in server creation UI. - * - * @return \Illuminate\Support\Collection */ public function getNodesForServerCreation(): Collection { @@ -157,9 +140,6 @@ class NodeRepository extends EloquentRepository implements NodeRepositoryInterfa /** * Returns a node with the given id with the Node's resource usage. - * - * @param int $node_id - * @return Node */ public function getNodeWithResourceUsage(int $node_id): Node { diff --git a/app/Repositories/Eloquent/PermissionRepository.php b/app/Repositories/Eloquent/PermissionRepository.php index e2d0b8cb5..bcd971408 100644 --- a/app/Repositories/Eloquent/PermissionRepository.php +++ b/app/Repositories/Eloquent/PermissionRepository.php @@ -11,6 +11,7 @@ class PermissionRepository extends EloquentRepository implements PermissionRepos * Return the model backing this repository. * * @return string + * * @throws \Exception */ public function model() diff --git a/app/Repositories/Eloquent/ScheduleRepository.php b/app/Repositories/Eloquent/ScheduleRepository.php index cb1b2cbf0..5c999df87 100644 --- a/app/Repositories/Eloquent/ScheduleRepository.php +++ b/app/Repositories/Eloquent/ScheduleRepository.php @@ -22,9 +22,6 @@ class ScheduleRepository extends EloquentRepository implements ScheduleRepositor /** * Return all of the schedules for a given server. - * - * @param int $server - * @return \Illuminate\Support\Collection */ public function findServerSchedules(int $server): Collection { @@ -34,9 +31,6 @@ class ScheduleRepository extends EloquentRepository implements ScheduleRepositor /** * Return a schedule model with all of the associated tasks as a relationship. * - * @param int $schedule - * @return \Pterodactyl\Models\Schedule - * * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ public function getScheduleWithTasks(int $schedule): Schedule @@ -44,7 +38,7 @@ class ScheduleRepository extends EloquentRepository implements ScheduleRepositor try { return $this->getBuilder()->with('tasks')->findOrFail($schedule, $this->getColumns()); } catch (ModelNotFoundException $exception) { - throw new RecordNotFoundException; + throw new RecordNotFoundException(); } } } diff --git a/app/Repositories/Eloquent/ServerRepository.php b/app/Repositories/Eloquent/ServerRepository.php index 5c16664b6..2e308ce17 100644 --- a/app/Repositories/Eloquent/ServerRepository.php +++ b/app/Repositories/Eloquent/ServerRepository.php @@ -24,14 +24,10 @@ class ServerRepository extends EloquentRepository implements ServerRepositoryInt /** * Load the egg relations onto the server model. - * - * @param \Pterodactyl\Models\Server $server - * @param bool $refresh - * @return \Pterodactyl\Models\Server */ public function loadEggRelations(Server $server, bool $refresh = false): Server { - if (! $server->relationLoaded('egg') || $refresh) { + if (!$server->relationLoaded('egg') || $refresh) { $server->load('egg.scriptFrom'); } @@ -40,18 +36,14 @@ class ServerRepository extends EloquentRepository implements ServerRepositoryInt /** * Return a collection of servers with their associated data for rebuild operations. - * - * @param int|null $server - * @param int|null $node - * @return \Illuminate\Support\Collection */ public function getDataForRebuild(int $server = null, int $node = null): Collection { $instance = $this->getBuilder()->with(['allocation', 'allocations', 'egg', 'node']); - if (! is_null($server) && is_null($node)) { + if (!is_null($server) && is_null($node)) { $instance = $instance->where('id', '=', $server); - } else if (is_null($server) && ! is_null($node)) { + } elseif (is_null($server) && !is_null($node)) { $instance = $instance->where('node_id', '=', $node); } @@ -60,18 +52,14 @@ class ServerRepository extends EloquentRepository implements ServerRepositoryInt /** * Return a collection of servers with their associated data for reinstall operations. - * - * @param int|null $server - * @param int|null $node - * @return \Illuminate\Support\Collection */ public function getDataForReinstall(int $server = null, int $node = null): Collection { $instance = $this->getBuilder()->with(['allocation', 'allocations', 'egg', 'node']); - if (! is_null($server) && is_null($node)) { + if (!is_null($server) && is_null($node)) { $instance = $instance->where('id', '=', $server); - } else if (is_null($server) && ! is_null($node)) { + } elseif (is_null($server) && !is_null($node)) { $instance = $instance->where('node_id', '=', $node); } @@ -81,9 +69,6 @@ class ServerRepository extends EloquentRepository implements ServerRepositoryInt /** * Return a server model and all variables associated with the server. * - * @param int $id - * @return \Pterodactyl\Models\Server - * * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ public function findWithVariables(int $id): Server @@ -93,7 +78,7 @@ class ServerRepository extends EloquentRepository implements ServerRepositoryInt ->where($this->getModel()->getKeyName(), '=', $id) ->firstOrFail($this->getColumns()); } catch (ModelNotFoundException $exception) { - throw new RecordNotFoundException; + throw new RecordNotFoundException(); } } @@ -101,14 +86,10 @@ class ServerRepository extends EloquentRepository implements ServerRepositoryInt * Get the primary allocation for a given server. If a model is passed into * the function, load the allocation relationship onto it. Otherwise, find and * return the server from the database. - * - * @param \Pterodactyl\Models\Server $server - * @param bool $refresh - * @return \Pterodactyl\Models\Server */ public function getPrimaryAllocation(Server $server, bool $refresh = false): Server { - if (! $server->relationLoaded('allocation') || $refresh) { + if (!$server->relationLoaded('allocation') || $refresh) { $server->load('allocation'); } @@ -117,15 +98,11 @@ class ServerRepository extends EloquentRepository implements ServerRepositoryInt /** * Return enough data to be used for the creation of a server via the daemon. - * - * @param \Pterodactyl\Models\Server $server - * @param bool $refresh - * @return \Pterodactyl\Models\Server */ public function getDataForCreation(Server $server, bool $refresh = false): Server { foreach (['allocation', 'allocations', 'egg'] as $relation) { - if (! $server->relationLoaded($relation) || $refresh) { + if (!$server->relationLoaded($relation) || $refresh) { $server->load($relation); } } @@ -135,14 +112,10 @@ class ServerRepository extends EloquentRepository implements ServerRepositoryInt /** * Load associated databases onto the server model. - * - * @param \Pterodactyl\Models\Server $server - * @param bool $refresh - * @return \Pterodactyl\Models\Server */ public function loadDatabaseRelations(Server $server, bool $refresh = false): Server { - if (! $server->relationLoaded('databases') || $refresh) { + if (!$server->relationLoaded('databases') || $refresh) { $server->load('databases.host'); } @@ -153,14 +126,10 @@ class ServerRepository extends EloquentRepository implements ServerRepositoryInt * Get data for use when updating a server on the Daemon. Returns an array of * the egg which is used for build and rebuild. Only loads relations * if they are missing, or refresh is set to true. - * - * @param \Pterodactyl\Models\Server $server - * @param bool $refresh - * @return array */ public function getDaemonServiceData(Server $server, bool $refresh = false): array { - if (! $server->relationLoaded('egg') || $refresh) { + if (!$server->relationLoaded('egg') || $refresh) { $server->load('egg'); } @@ -172,9 +141,6 @@ class ServerRepository extends EloquentRepository implements ServerRepositoryInt /** * Return a server by UUID. * - * @param string $uuid - * @return \Pterodactyl\Models\Server - * * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ public function getByUuid(string $uuid): Server @@ -190,26 +156,20 @@ class ServerRepository extends EloquentRepository implements ServerRepositoryInt return $model; } catch (ModelNotFoundException $exception) { - throw new RecordNotFoundException; + throw new RecordNotFoundException(); } } /** * Check if a given UUID and UUID-Short string are unique to a server. - * - * @param string $uuid - * @param string $short - * @return bool */ public function isUniqueUuidCombo(string $uuid, string $short): bool { - return ! $this->getBuilder()->where('uuid', '=', $uuid)->orWhere('uuidShort', '=', $short)->exists(); + return !$this->getBuilder()->where('uuid', '=', $uuid)->orWhere('uuidShort', '=', $short)->exists(); } /** * Get the amount of servers that are suspended. - * - * @return int */ public function getSuspendedServersCount(): int { @@ -218,11 +178,6 @@ class ServerRepository extends EloquentRepository implements ServerRepositoryInt /** * Returns all of the servers that exist for a given node in a paginated response. - * - * @param int $node - * @param int $limit - * - * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator */ public function loadAllServersForNode(int $node, int $limit): LengthAwarePaginator { diff --git a/app/Repositories/Eloquent/SessionRepository.php b/app/Repositories/Eloquent/SessionRepository.php index 54c4ff629..ad069abb8 100644 --- a/app/Repositories/Eloquent/SessionRepository.php +++ b/app/Repositories/Eloquent/SessionRepository.php @@ -20,9 +20,6 @@ class SessionRepository extends EloquentRepository implements SessionRepositoryI /** * Return all of the active sessions for a user. - * - * @param int $user - * @return \Illuminate\Support\Collection */ public function getUserSessions(int $user): Collection { @@ -32,8 +29,6 @@ class SessionRepository extends EloquentRepository implements SessionRepositoryI /** * Delete a session for a given user. * - * @param int $user - * @param string $session * @return int|null */ public function deleteUserSession(int $user, string $session) diff --git a/app/Repositories/Eloquent/SettingsRepository.php b/app/Repositories/Eloquent/SettingsRepository.php index 42cc7efed..b39d3a2e1 100644 --- a/app/Repositories/Eloquent/SettingsRepository.php +++ b/app/Repositories/Eloquent/SettingsRepository.php @@ -30,9 +30,6 @@ class SettingsRepository extends EloquentRepository implements SettingsRepositor /** * Store a new persistent setting in the database. * - * @param string $key - * @param string|null $value - * * @throws \Pterodactyl\Exceptions\Model\DataValidationException * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ @@ -48,8 +45,8 @@ class SettingsRepository extends EloquentRepository implements SettingsRepositor /** * Retrieve a persistent setting from the database. * - * @param string $key * @param mixed $default + * * @return mixed */ public function get(string $key, $default = null) @@ -74,8 +71,6 @@ class SettingsRepository extends EloquentRepository implements SettingsRepositor /** * Remove a key from the database cache. - * - * @param string $key */ public function forget(string $key) { @@ -85,8 +80,6 @@ class SettingsRepository extends EloquentRepository implements SettingsRepositor /** * Remove a key from the cache. - * - * @param string $key */ private function clearCache(string $key) { diff --git a/app/Repositories/Eloquent/SubuserRepository.php b/app/Repositories/Eloquent/SubuserRepository.php index c0fb930a6..d40ed9fda 100644 --- a/app/Repositories/Eloquent/SubuserRepository.php +++ b/app/Repositories/Eloquent/SubuserRepository.php @@ -20,18 +20,14 @@ class SubuserRepository extends EloquentRepository implements SubuserRepositoryI /** * Return a subuser with the associated server relationship. - * - * @param \Pterodactyl\Models\Subuser $subuser - * @param bool $refresh - * @return \Pterodactyl\Models\Subuser */ public function loadServerAndUserRelations(Subuser $subuser, bool $refresh = false): Subuser { - if (! $subuser->relationLoaded('server') || $refresh) { + if (!$subuser->relationLoaded('server') || $refresh) { $subuser->load('server'); } - if (! $subuser->relationLoaded('user') || $refresh) { + if (!$subuser->relationLoaded('user') || $refresh) { $subuser->load('user'); } @@ -40,18 +36,14 @@ class SubuserRepository extends EloquentRepository implements SubuserRepositoryI /** * Return a subuser with the associated permissions relationship. - * - * @param \Pterodactyl\Models\Subuser $subuser - * @param bool $refresh - * @return \Pterodactyl\Models\Subuser */ public function getWithPermissions(Subuser $subuser, bool $refresh = false): Subuser { - if (! $subuser->relationLoaded('permissions') || $refresh) { + if (!$subuser->relationLoaded('permissions') || $refresh) { $subuser->load('permissions'); } - if (! $subuser->relationLoaded('user') || $refresh) { + if (!$subuser->relationLoaded('user') || $refresh) { $subuser->load('user'); } @@ -61,10 +53,6 @@ class SubuserRepository extends EloquentRepository implements SubuserRepositoryI /** * Return a subuser and associated permissions given a user_id and server_id. * - * @param int $user - * @param int $server - * @return \Pterodactyl\Models\Subuser - * * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ public function getWithPermissionsUsingUserAndServer(int $user, int $server): Subuser @@ -75,7 +63,7 @@ class SubuserRepository extends EloquentRepository implements SubuserRepositoryI ])->first(); if (is_null($instance)) { - throw new RecordNotFoundException; + throw new RecordNotFoundException(); } return $instance; diff --git a/app/Repositories/Eloquent/TaskRepository.php b/app/Repositories/Eloquent/TaskRepository.php index 3b43221e8..718f99490 100644 --- a/app/Repositories/Eloquent/TaskRepository.php +++ b/app/Repositories/Eloquent/TaskRepository.php @@ -22,9 +22,6 @@ class TaskRepository extends EloquentRepository implements TaskRepositoryInterfa /** * Get a task and the server relationship for that task. * - * @param int $id - * @return \Pterodactyl\Models\Task - * * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ public function getTaskForJobProcess(int $id): Task @@ -32,15 +29,13 @@ class TaskRepository extends EloquentRepository implements TaskRepositoryInterfa try { return $this->getBuilder()->with('server.user', 'schedule')->findOrFail($id, $this->getColumns()); } catch (ModelNotFoundException $exception) { - throw new RecordNotFoundException; + throw new RecordNotFoundException(); } } /** * Returns the next task in a schedule. * - * @param int $schedule - * @param int $index * @return \Pterodactyl\Models\Task|null */ public function getNextTask(int $schedule, int $index) diff --git a/app/Repositories/Repository.php b/app/Repositories/Repository.php index c209e33ba..a80051942 100644 --- a/app/Repositories/Repository.php +++ b/app/Repositories/Repository.php @@ -30,8 +30,6 @@ abstract class Repository implements RepositoryInterface /** * Repository constructor. - * - * @param \Illuminate\Foundation\Application $application */ public function __construct(Application $application) { @@ -61,6 +59,7 @@ abstract class Repository implements RepositoryInterface * Setup column selection functionality. * * @param array|string $columns + * * @return $this */ public function setColumns($columns = ['*']) @@ -106,7 +105,6 @@ abstract class Repository implements RepositoryInterface * Set whether or not the repository should return a fresh model * when changes are committed. * - * @param bool $fresh * @return $this */ public function setFreshModel(bool $fresh = true) @@ -121,6 +119,7 @@ abstract class Repository implements RepositoryInterface * Take the provided model and make it accessible to the rest of the repository. * * @param array $model + * * @return mixed */ protected function initializeModel(...$model) diff --git a/app/Repositories/Wings/DaemonBackupRepository.php b/app/Repositories/Wings/DaemonBackupRepository.php index 37156f213..9b320e1b2 100644 --- a/app/Repositories/Wings/DaemonBackupRepository.php +++ b/app/Repositories/Wings/DaemonBackupRepository.php @@ -2,7 +2,6 @@ namespace Pterodactyl\Repositories\Wings; -use Illuminate\Support\Arr; use Webmozart\Assert\Assert; use Pterodactyl\Models\Backup; use Pterodactyl\Models\Server; @@ -20,7 +19,6 @@ class DaemonBackupRepository extends DaemonRepository /** * Sets the backup adapter for this execution instance. * - * @param string $adapter * @return $this */ public function setBackupAdapter(string $adapter) @@ -33,9 +31,6 @@ class DaemonBackupRepository extends DaemonRepository /** * Tells the remote Daemon to begin generating a backup for the server. * - * @param \Pterodactyl\Models\Backup $backup - * @return \Psr\Http\Message\ResponseInterface - * * @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException */ public function backup(Backup $backup): ResponseInterface @@ -61,8 +56,6 @@ class DaemonBackupRepository extends DaemonRepository /** * Deletes a backup from the daemon. * - * @param \Pterodactyl\Models\Backup $backup - * @return \Psr\Http\Message\ResponseInterface * @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException */ public function delete(Backup $backup): ResponseInterface diff --git a/app/Repositories/Wings/DaemonCommandRepository.php b/app/Repositories/Wings/DaemonCommandRepository.php index 38f2fb475..390434bff 100644 --- a/app/Repositories/Wings/DaemonCommandRepository.php +++ b/app/Repositories/Wings/DaemonCommandRepository.php @@ -14,7 +14,6 @@ class DaemonCommandRepository extends DaemonRepository * Sends a command or multiple commands to a running server instance. * * @param string|string[] $command - * @return \Psr\Http\Message\ResponseInterface * * @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException */ diff --git a/app/Repositories/Wings/DaemonConfigurationRepository.php b/app/Repositories/Wings/DaemonConfigurationRepository.php index ffd498cbc..f2672ddfa 100644 --- a/app/Repositories/Wings/DaemonConfigurationRepository.php +++ b/app/Repositories/Wings/DaemonConfigurationRepository.php @@ -11,7 +11,6 @@ class DaemonConfigurationRepository extends DaemonRepository /** * Returns system information from the wings instance. * - * @return array * @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException */ public function getSystemInformation(): array @@ -30,15 +29,16 @@ class DaemonConfigurationRepository extends DaemonRepository * this instance using a passed-in model. This allows us to change plenty of information * in the model, and still use the old, pre-update model to actually make the HTTP request. * - * @param \Pterodactyl\Models\Node $node * @return \Psr\Http\Message\ResponseInterface + * * @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException */ public function update(Node $node) { try { return $this->getHttpClient()->post( - '/api/update', ['json' => $node->getConfiguration()] + '/api/update', + ['json' => $node->getConfiguration()] ); } catch (TransferException $exception) { throw new DaemonConnectionException($exception); diff --git a/app/Repositories/Wings/DaemonFileRepository.php b/app/Repositories/Wings/DaemonFileRepository.php index da6cb7ae2..f1acdc7de 100644 --- a/app/Repositories/Wings/DaemonFileRepository.php +++ b/app/Repositories/Wings/DaemonFileRepository.php @@ -14,9 +14,7 @@ class DaemonFileRepository extends DaemonRepository /** * Return the contents of a given file. * - * @param string $path * @param int|null $notLargerThan the maximum content length in bytes - * @return string * * @throws \GuzzleHttp\Exception\TransferException * @throws \Pterodactyl\Exceptions\Http\Server\FileSizeTooLargeException @@ -37,10 +35,10 @@ class DaemonFileRepository extends DaemonRepository throw new DaemonConnectionException($exception); } - $length = (int)$response->getHeader('Content-Length')[0] ?? 0; + $length = (int) $response->getHeader('Content-Length')[0] ?? 0; if ($notLargerThan && $length > $notLargerThan) { - throw new FileSizeTooLargeException; + throw new FileSizeTooLargeException(); } return $response->getBody()->__toString(); @@ -50,10 +48,6 @@ class DaemonFileRepository extends DaemonRepository * Save new contents to a given file. This works for both creating and updating * a file. * - * @param string $path - * @param string $content - * @return \Psr\Http\Message\ResponseInterface - * * @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException */ public function putContent(string $path, string $content): ResponseInterface @@ -76,9 +70,6 @@ class DaemonFileRepository extends DaemonRepository /** * Return a directory listing for a given path. * - * @param string $path - * @return array - * * @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException */ public function getDirectory(string $path): array @@ -102,10 +93,6 @@ class DaemonFileRepository extends DaemonRepository /** * Creates a new directory for the server in the given $path. * - * @param string $name - * @param string $path - * @return \Psr\Http\Message\ResponseInterface - * * @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException */ public function createDirectory(string $name, string $path): ResponseInterface @@ -130,10 +117,6 @@ class DaemonFileRepository extends DaemonRepository /** * Renames or moves a file on the remote machine. * - * @param string|null $root - * @param array $files - * @return \Psr\Http\Message\ResponseInterface - * * @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException */ public function renameFiles(?string $root, array $files): ResponseInterface @@ -158,9 +141,6 @@ class DaemonFileRepository extends DaemonRepository /** * Copy a given file and give it a unique name. * - * @param string $location - * @return \Psr\Http\Message\ResponseInterface - * * @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException */ public function copyFile(string $location): ResponseInterface @@ -184,10 +164,6 @@ class DaemonFileRepository extends DaemonRepository /** * Delete a file or folder for the server. * - * @param string|null $root - * @param array $files - * @return \Psr\Http\Message\ResponseInterface - * * @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException */ public function deleteFiles(?string $root, array $files): ResponseInterface @@ -212,10 +188,6 @@ class DaemonFileRepository extends DaemonRepository /** * Compress the given files or folders in the given root. * - * @param string|null $root - * @param array $files - * @return array - * * @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException */ public function compressFiles(?string $root, array $files): array @@ -245,10 +217,6 @@ class DaemonFileRepository extends DaemonRepository /** * Decompresses a given archive file. * - * @param string|null $root - * @param string $file - * @return \Psr\Http\Message\ResponseInterface - * * @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException */ public function decompressFile(?string $root, string $file): ResponseInterface @@ -273,10 +241,6 @@ class DaemonFileRepository extends DaemonRepository /** * Chmods the given files. * - * @param string|null $root - * @param array $files - * @return \Psr\Http\Message\ResponseInterface - * * @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException */ public function chmodFiles(?string $root, array $files): ResponseInterface @@ -301,10 +265,6 @@ class DaemonFileRepository extends DaemonRepository /** * Pulls a file from the given URL and saves it to the disk. * - * @param string $url - * @param string|null $directory - * @return \Psr\Http\Message\ResponseInterface - * * @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException */ public function pull(string $url, ?string $directory): ResponseInterface diff --git a/app/Repositories/Wings/DaemonPowerRepository.php b/app/Repositories/Wings/DaemonPowerRepository.php index ccbf169ff..4e290cfc9 100644 --- a/app/Repositories/Wings/DaemonPowerRepository.php +++ b/app/Repositories/Wings/DaemonPowerRepository.php @@ -13,9 +13,6 @@ class DaemonPowerRepository extends DaemonRepository /** * Sends a power action to the server instance. * - * @param string $action - * @return \Psr\Http\Message\ResponseInterface - * * @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException */ public function send(string $action): ResponseInterface diff --git a/app/Repositories/Wings/DaemonRepository.php b/app/Repositories/Wings/DaemonRepository.php index 4ebe249cf..268a4a213 100644 --- a/app/Repositories/Wings/DaemonRepository.php +++ b/app/Repositories/Wings/DaemonRepository.php @@ -27,8 +27,6 @@ abstract class DaemonRepository /** * BaseWingsRepository constructor. - * - * @param \Illuminate\Contracts\Foundation\Application $application */ public function __construct(Application $application) { @@ -38,7 +36,6 @@ abstract class DaemonRepository /** * Set the server model this request is stemming from. * - * @param \Pterodactyl\Models\Server $server * @return $this */ public function setServer(Server $server) @@ -53,7 +50,6 @@ abstract class DaemonRepository /** * Set the node model this request is stemming from. * - * @param \Pterodactyl\Models\Node $node * @return $this */ public function setNode(Node $node) @@ -65,9 +61,6 @@ abstract class DaemonRepository /** * Return an instance of the Guzzle HTTP Client to be used for requests. - * - * @param array $headers - * @return \GuzzleHttp\Client */ public function getHttpClient(array $headers = []): Client { diff --git a/app/Repositories/Wings/DaemonServerRepository.php b/app/Repositories/Wings/DaemonServerRepository.php index f8af0c034..35df86d84 100644 --- a/app/Repositories/Wings/DaemonServerRepository.php +++ b/app/Repositories/Wings/DaemonServerRepository.php @@ -3,7 +3,6 @@ namespace Pterodactyl\Repositories\Wings; use Webmozart\Assert\Assert; -use Pterodactyl\Models\User; use Pterodactyl\Models\Server; use GuzzleHttp\Exception\TransferException; use Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException; @@ -33,8 +32,6 @@ class DaemonServerRepository extends DaemonRepository /** * Creates a new server on the Wings daemon. * - * @param array $data - * * @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException */ public function create(array $data): void @@ -43,7 +40,8 @@ class DaemonServerRepository extends DaemonRepository try { $this->getHttpClient()->post( - '/api/servers', [ + '/api/servers', + [ 'json' => $data, ] ); @@ -55,8 +53,6 @@ class DaemonServerRepository extends DaemonRepository /** * Updates details about a server on the Daemon. * - * @param array $data - * * @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException */ public function update(array $data): void @@ -97,7 +93,8 @@ class DaemonServerRepository extends DaemonRepository try { $this->getHttpClient()->post(sprintf( - '/api/servers/%s/reinstall', $this->server->uuid + '/api/servers/%s/reinstall', + $this->server->uuid )); } catch (TransferException $exception) { throw new DaemonConnectionException($exception); @@ -108,8 +105,6 @@ class DaemonServerRepository extends DaemonRepository * By default this function will suspend a server instance on the daemon. However, passing * "true" as the first argument will unsuspend the server. * - * @param bool $unsuspend - * * @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException */ public function suspend(bool $unsuspend = false): void @@ -119,7 +114,7 @@ class DaemonServerRepository extends DaemonRepository try { $this->getHttpClient()->patch( '/api/servers/' . $this->server->uuid, - ['json' => ['suspended' => ! $unsuspend]] + ['json' => ['suspended' => !$unsuspend]] ); } catch (TransferException $exception) { throw new DaemonConnectionException($exception); @@ -138,7 +133,8 @@ class DaemonServerRepository extends DaemonRepository try { $this->getHttpClient()->post(sprintf( - '/api/servers/%s/archive', $this->server->uuid + '/api/servers/%s/archive', + $this->server->uuid )); } catch (TransferException $exception) { throw new DaemonConnectionException($exception); @@ -150,21 +146,19 @@ class DaemonServerRepository extends DaemonRepository * make it easier to revoke tokens on the fly. This ensures that the JTI key is formatted * correctly and avoids any costly mistakes in the codebase. * - * @param int $id * @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException */ public function revokeUserJTI(int $id): void { Assert::isInstanceOf($this->server, Server::class); - $this->revokeJTIs([ md5($id . $this->server->uuid) ]); + $this->revokeJTIs([md5($id . $this->server->uuid)]); } /** * Revokes an array of JWT JTI's by marking any token generated before the current time on * the Wings instance as being invalid. * - * @param array $jtis * @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException */ protected function revokeJTIs(array $jtis): void diff --git a/app/Repositories/Wings/DaemonTransferRepository.php b/app/Repositories/Wings/DaemonTransferRepository.php index e8a514196..74a1e3dc7 100644 --- a/app/Repositories/Wings/DaemonTransferRepository.php +++ b/app/Repositories/Wings/DaemonTransferRepository.php @@ -10,11 +10,6 @@ use Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException; class DaemonTransferRepository extends DaemonRepository { /** - * @param Server $server - * @param array $data - * @param Node $node - * @param string $token - * * @throws DaemonConnectionException */ public function notify(Server $server, array $data, Node $node, string $token): void diff --git a/app/Rules/Username.php b/app/Rules/Username.php index 1cceae5f9..8d1373ea0 100644 --- a/app/Rules/Username.php +++ b/app/Rules/Username.php @@ -18,8 +18,7 @@ class Username implements Rule * Allowed characters: a-z0-9_-. * * @param string $attribute - * @param mixed $value - * @return bool + * @param mixed $value */ public function passes($attribute, $value): bool { @@ -28,8 +27,6 @@ class Username implements Rule /** * Return a validation message for use when this rule fails. - * - * @return string */ public function message(): string { diff --git a/app/Services/Acl/Api/AdminAcl.php b/app/Services/Acl/Api/AdminAcl.php index f0e649248..99c2d344f 100644 --- a/app/Services/Acl/Api/AdminAcl.php +++ b/app/Services/Acl/Api/AdminAcl.php @@ -11,31 +11,31 @@ class AdminAcl * Resource permission columns in the api_keys table begin * with this identifier. */ - const COLUMN_IDENTIFIER = 'r_'; + public const COLUMN_IDENTIFIER = 'r_'; /** * The different types of permissions available for API keys. This * implements a read/write/none permissions scheme for all endpoints. */ - const NONE = 0; - const READ = 1; - const WRITE = 2; + public const NONE = 0; + public const READ = 1; + public const WRITE = 2; /** * Resources that are available on the API and can contain a permissions * set for each key. These are stored in the database as r_{resource}. */ - const RESOURCE_SERVERS = 'servers'; - const RESOURCE_NODES = 'nodes'; - const RESOURCE_ALLOCATIONS = 'allocations'; - const RESOURCE_USERS = 'users'; - const RESOURCE_LOCATIONS = 'locations'; - const RESOURCE_NESTS = 'nests'; - const RESOURCE_EGGS = 'eggs'; - const RESOURCE_DATABASE_HOSTS = 'database_hosts'; - const RESOURCE_SERVER_DATABASES = 'server_databases'; - const RESOURCE_ROLES = 'roles'; - const RESOURCE_MOUNTS = 'mounts'; + public const RESOURCE_SERVERS = 'servers'; + public const RESOURCE_NODES = 'nodes'; + public const RESOURCE_ALLOCATIONS = 'allocations'; + public const RESOURCE_USERS = 'users'; + public const RESOURCE_LOCATIONS = 'locations'; + public const RESOURCE_NESTS = 'nests'; + public const RESOURCE_EGGS = 'eggs'; + public const RESOURCE_DATABASE_HOSTS = 'database_hosts'; + public const RESOURCE_SERVER_DATABASES = 'server_databases'; + public const RESOURCE_ROLES = 'roles'; + public const RESOURCE_MOUNTS = 'mounts'; /** * Determine if an API key has permission to perform a specific read/write operation. diff --git a/app/Services/Allocations/AllocationDeletionService.php b/app/Services/Allocations/AllocationDeletionService.php index 5e81a1d2f..4b1bfec3b 100644 --- a/app/Services/Allocations/AllocationDeletionService.php +++ b/app/Services/Allocations/AllocationDeletionService.php @@ -15,8 +15,6 @@ class AllocationDeletionService /** * AllocationDeletionService constructor. - * - * @param \Pterodactyl\Contracts\Repository\AllocationRepositoryInterface $repository */ public function __construct(AllocationRepositoryInterface $repository) { @@ -27,14 +25,13 @@ class AllocationDeletionService * Delete an allocation from the database only if it does not have a server * that is actively attached to it. * - * @param \Pterodactyl\Models\Allocation $allocation * @return int * * @throws \Pterodactyl\Exceptions\Service\Allocation\ServerUsingAllocationException */ public function handle(Allocation $allocation) { - if (! is_null($allocation->server_id)) { + if (!is_null($allocation->server_id)) { throw new ServerUsingAllocationException(trans('exceptions.allocations.server_using')); } diff --git a/app/Services/Allocations/AssignmentService.php b/app/Services/Allocations/AssignmentService.php index 99ae40f29..09313e4c9 100644 --- a/app/Services/Allocations/AssignmentService.php +++ b/app/Services/Allocations/AssignmentService.php @@ -13,12 +13,12 @@ use Pterodactyl\Exceptions\Service\Allocation\TooManyPortsInRangeException; class AssignmentService { - const CIDR_MAX_BITS = 27; - const CIDR_MIN_BITS = 32; - const PORT_FLOOR = 1024; - const PORT_CEIL = 65535; - const PORT_RANGE_LIMIT = 1000; - const PORT_RANGE_REGEX = '/^(\d{4,5})-(\d{4,5})$/'; + public const CIDR_MAX_BITS = 27; + 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})$/'; /** * @var \Illuminate\Database\ConnectionInterface @@ -32,9 +32,6 @@ class AssignmentService /** * AssignmentService constructor. - * - * @param \Pterodactyl\Contracts\Repository\AllocationRepositoryInterface $repository - * @param \Illuminate\Database\ConnectionInterface $connection */ public function __construct(AllocationRepositoryInterface $repository, ConnectionInterface $connection) { @@ -45,9 +42,6 @@ class AssignmentService /** * Insert allocations into the database and link them to a specific node. * - * @param \Pterodactyl\Models\Node $node - * @param array $data - * * @throws \Pterodactyl\Exceptions\Service\Allocation\CidrOutOfRangeException * @throws \Pterodactyl\Exceptions\Service\Allocation\PortOutOfRangeException * @throws \Pterodactyl\Exceptions\Service\Allocation\InvalidPortMappingException @@ -57,15 +51,15 @@ class AssignmentService { $explode = explode('/', $data['allocation_ip']); if (count($explode) !== 1) { - if (! ctype_digit($explode[1]) || ($explode[1] > self::CIDR_MIN_BITS || $explode[1] < self::CIDR_MAX_BITS)) { - throw new CidrOutOfRangeException; + if (!ctype_digit($explode[1]) || ($explode[1] > self::CIDR_MIN_BITS || $explode[1] < self::CIDR_MAX_BITS)) { + throw new CidrOutOfRangeException(); } } $this->connection->beginTransaction(); foreach (Network::parse(gethostbyname($data['allocation_ip'])) as $ip) { foreach ($data['allocation_ports'] as $port) { - if (! is_digit($port) && ! preg_match(self::PORT_RANGE_REGEX, $port)) { + if (!is_digit($port) && !preg_match(self::PORT_RANGE_REGEX, $port)) { throw new InvalidPortMappingException($port); } @@ -74,11 +68,11 @@ class AssignmentService $block = range($matches[1], $matches[2]); if (count($block) > self::PORT_RANGE_LIMIT) { - throw new TooManyPortsInRangeException; + throw new TooManyPortsInRangeException(); } if ((int) $matches[1] <= self::PORT_FLOOR || (int) $matches[2] > self::PORT_CEIL) { - throw new PortOutOfRangeException; + throw new PortOutOfRangeException(); } foreach ($block as $unit) { @@ -92,7 +86,7 @@ class AssignmentService } } else { if ((int) $port <= self::PORT_FLOOR || (int) $port > self::PORT_CEIL) { - throw new PortOutOfRangeException; + throw new PortOutOfRangeException(); } $insertData[] = [ diff --git a/app/Services/Allocations/FindAssignableAllocationService.php b/app/Services/Allocations/FindAssignableAllocationService.php index 6f523663a..29c37123f 100644 --- a/app/Services/Allocations/FindAssignableAllocationService.php +++ b/app/Services/Allocations/FindAssignableAllocationService.php @@ -30,7 +30,6 @@ class FindAssignableAllocationService * no allocation can be found, a new one will be created with a random port between the defined * range from the configuration. * - * @param \Pterodactyl\Models\Server $server * @return \Pterodactyl\Models\Allocation * * @throws \Pterodactyl\Exceptions\DisplayException @@ -41,8 +40,8 @@ class FindAssignableAllocationService */ public function handle(Server $server) { - if (! config('pterodactyl.client_features.allocations.enabled')) { - throw new AutoAllocationNotEnabledException; + if (!config('pterodactyl.client_features.allocations.enabled')) { + throw new AutoAllocationNotEnabledException(); } // Attempt to find a given available allocation for a server. If one cannot be found @@ -67,9 +66,6 @@ class FindAssignableAllocationService * in the settings. If there are no matches in that range, or something is wrong with the * range information provided an exception will be raised. * - * @param \Pterodactyl\Models\Server $server - * @return \Pterodactyl\Models\Allocation - * * @throws \Pterodactyl\Exceptions\DisplayException * @throws \Pterodactyl\Exceptions\Service\Allocation\CidrOutOfRangeException * @throws \Pterodactyl\Exceptions\Service\Allocation\InvalidPortMappingException @@ -81,8 +77,8 @@ class FindAssignableAllocationService $start = config('pterodactyl.client_features.allocations.range_start', null); $end = config('pterodactyl.client_features.allocations.range_end', null); - if (! $start || ! $end) { - throw new NoAutoAllocationSpaceAvailableException; + if (!$start || !$end) { + throw new NoAutoAllocationSpaceAvailableException(); } Assert::integerish($start); @@ -102,7 +98,7 @@ class FindAssignableAllocationService // If we've already allocated all of the ports, just abort. if (empty($available)) { - throw new NoAutoAllocationSpaceAvailableException; + throw new NoAutoAllocationSpaceAvailableException(); } // Pick a random port out of the remaining available ports. diff --git a/app/Services/Api/KeyCreationService.php b/app/Services/Api/KeyCreationService.php index a1547897e..20a11add0 100644 --- a/app/Services/Api/KeyCreationService.php +++ b/app/Services/Api/KeyCreationService.php @@ -25,9 +25,6 @@ class KeyCreationService /** * ApiKeyService constructor. - * - * @param \Pterodactyl\Contracts\Repository\ApiKeyRepositoryInterface $repository - * @param \Illuminate\Contracts\Encryption\Encrypter $encrypter */ public function __construct(ApiKeyRepositoryInterface $repository, Encrypter $encrypter) { @@ -39,7 +36,6 @@ class KeyCreationService * Set the type of key that should be created. By default an orphaned key will be * created. These keys cannot be used for anything, and will not render in the UI. * - * @param int $type * @return \Pterodactyl\Services\Api\KeyCreationService */ public function setKeyType(int $type) @@ -54,10 +50,6 @@ class KeyCreationService * This will automatically generate an identifier and an encrypted token that are * stored in the database. * - * @param array $data - * @param array $permissions - * @return \Pterodactyl\Models\ApiKey - * * @throws \Pterodactyl\Exceptions\Model\DataValidationException */ public function handle(array $data, array $permissions = []): ApiKey diff --git a/app/Services/Backups/DeleteBackupService.php b/app/Services/Backups/DeleteBackupService.php index cdb61844b..6c612e048 100644 --- a/app/Services/Backups/DeleteBackupService.php +++ b/app/Services/Backups/DeleteBackupService.php @@ -35,11 +35,6 @@ class DeleteBackupService /** * DeleteBackupService constructor. - * - * @param \Illuminate\Database\ConnectionInterface $connection - * @param \Pterodactyl\Repositories\Eloquent\BackupRepository $repository - * @param \Pterodactyl\Extensions\Backups\BackupManager $manager - * @param \Pterodactyl\Repositories\Wings\DaemonBackupRepository $daemonBackupRepository */ public function __construct( ConnectionInterface $connection, @@ -56,7 +51,6 @@ class DeleteBackupService /** * Deletes a backup from the system. * - * @param \Pterodactyl\Models\Backup $backup * @throws \Throwable */ public function handle(Backup $backup) @@ -74,7 +68,7 @@ class DeleteBackupService $previous = $exception->getPrevious(); // Don't fail the request if the Daemon responds with a 404, just assume the backup // doesn't actually exist and remove it's reference from the Panel as well. - if (! $previous instanceof ClientException || $previous->getResponse()->getStatusCode() !== Response::HTTP_NOT_FOUND) { + if (!$previous instanceof ClientException || $previous->getResponse()->getStatusCode() !== Response::HTTP_NOT_FOUND) { throw $exception; } } @@ -86,7 +80,6 @@ class DeleteBackupService /** * Deletes a backup from an S3 disk. * - * @param \Pterodactyl\Models\Backup $backup * @throws \Throwable */ protected function deleteFromS3(Backup $backup) diff --git a/app/Services/Backups/InitiateBackupService.php b/app/Services/Backups/InitiateBackupService.php index 0aa7ae4ed..b55f0f8ce 100644 --- a/app/Services/Backups/InitiateBackupService.php +++ b/app/Services/Backups/InitiateBackupService.php @@ -49,11 +49,7 @@ class InitiateBackupService /** * InitiateBackupService constructor. * - * @param \Pterodactyl\Repositories\Eloquent\BackupRepository $repository - * @param \Illuminate\Database\ConnectionInterface $connection - * @param \Pterodactyl\Repositories\Wings\DaemonBackupRepository $daemonBackupRepository * @param \Pterodactyl\Services\Backups\DeleteBackupService $deleteBackupService - * @param \Pterodactyl\Extensions\Backups\BackupManager $backupManager */ public function __construct( BackupRepository $repository, @@ -73,6 +69,7 @@ class InitiateBackupService * Sets the files to be ignored by this backup. * * @param string[]|null $ignored + * * @return $this */ public function setIgnoredFiles(?array $ignored) @@ -96,12 +93,6 @@ class InitiateBackupService /** * Initiates the backup process for a server on the daemon. * - * @param \Pterodactyl\Models\Server $server - * @param string|null $name - * @param bool $override - * - * @return \Pterodactyl\Models\Backup - * * @throws \Throwable * @throws \Pterodactyl\Exceptions\Service\Backup\TooManyBackupsException * @throws \Symfony\Component\HttpKernel\Exception\TooManyRequestsHttpException @@ -113,17 +104,14 @@ class InitiateBackupService if ($period > 0) { $previous = $this->repository->getBackupsGeneratedDuringTimespan($server->id, $period); if ($previous->count() >= $limit) { - throw new TooManyRequestsHttpException( - CarbonImmutable::now()->diffInSeconds($previous->last()->created_at->addSeconds($period)), - sprintf('Only %d backups may be generated within a %d second span of time.', $limit, $period) - ); + throw new TooManyRequestsHttpException(CarbonImmutable::now()->diffInSeconds($previous->last()->created_at->addSeconds($period)), sprintf('Only %d backups may be generated within a %d second span of time.', $limit, $period)); } } // Check if the server has reached or exceeded it's backup limit - if (! $server->backup_limit || $server->backups()->where('is_successful', true)->count() >= $server->backup_limit) { + if (!$server->backup_limit || $server->backups()->where('is_successful', true)->count() >= $server->backup_limit) { // Do not allow the user to continue if this server is already at its limit and can't override. - if (! $override || $server->backup_limit <= 0) { + if (!$override || $server->backup_limit <= 0) { throw new TooManyBackupsException($server->backup_limit); } diff --git a/app/Services/Databases/DatabaseManagementService.php b/app/Services/Databases/DatabaseManagementService.php index 832e4bdf1..a10b22719 100644 --- a/app/Services/Databases/DatabaseManagementService.php +++ b/app/Services/Databases/DatabaseManagementService.php @@ -8,7 +8,6 @@ use Pterodactyl\Models\Server; use Pterodactyl\Models\Database; use Pterodactyl\Helpers\Utilities; use Illuminate\Database\ConnectionInterface; -use Symfony\Component\VarDumper\Cloner\Data; use Illuminate\Contracts\Encryption\Encrypter; use Pterodactyl\Extensions\DynamicDatabaseConnection; use Pterodactyl\Repositories\Eloquent\DatabaseRepository; @@ -58,11 +57,6 @@ class DatabaseManagementService /** * CreationService constructor. - * - * @param \Illuminate\Database\ConnectionInterface $connection - * @param \Pterodactyl\Extensions\DynamicDatabaseConnection $dynamic - * @param \Pterodactyl\Repositories\Eloquent\DatabaseRepository $repository - * @param \Illuminate\Contracts\Encryption\Encrypter $encrypter */ public function __construct( ConnectionInterface $connection, @@ -80,10 +74,6 @@ class DatabaseManagementService * Generates a unique database name for the given server. This name should be passed through when * calling this handle function for this service, otherwise the database will be created with * whatever name is provided. - * - * @param string $name - * @param int $serverId - * @return string */ public static function generateUniqueDatabaseName(string $name, int $serverId): string { @@ -95,7 +85,6 @@ class DatabaseManagementService * Set wether or not this class should validate that the server has enough slots * left before creating the new database. * - * @param bool $validate * @return $this */ public function setValidateDatabaseLimit(bool $validate): self @@ -108,8 +97,6 @@ class DatabaseManagementService /** * Create a new database that is linked to a specific host. * - * @param \Pterodactyl\Models\Server $server - * @param array $data * @return \Pterodactyl\Models\Database * * @throws \Throwable @@ -118,23 +105,21 @@ class DatabaseManagementService */ public function create(Server $server, array $data) { - if (! config('pterodactyl.client_features.databases.enabled')) { - throw new DatabaseClientFeatureNotEnabledException; + if (!config('pterodactyl.client_features.databases.enabled')) { + throw new DatabaseClientFeatureNotEnabledException(); } if ($this->validateDatabaseLimit) { // If the server has a limit assigned and we've already reached that limit, throw back // an exception and kill the process. - if (! is_null($server->database_limit) && $server->databases()->count() >= $server->database_limit) { - throw new TooManyDatabasesException; + if (!is_null($server->database_limit) && $server->databases()->count() >= $server->database_limit) { + throw new TooManyDatabasesException(); } } // Protect against developer mistakes... - if (empty($data['database']) || ! preg_match(self::MATCH_NAME_REGEX, $data['database'])) { - throw new InvalidArgumentException( - 'The database name passed to DatabaseManagementService::handle MUST be prefixed with "s{server_id}_".' - ); + if (empty($data['database']) || !preg_match(self::MATCH_NAME_REGEX, $data['database'])) { + throw new InvalidArgumentException('The database name passed to DatabaseManagementService::handle MUST be prefixed with "s{server_id}_".'); } $data = array_merge($data, [ @@ -155,7 +140,10 @@ class DatabaseManagementService $this->repository->createDatabase($database->database); $this->repository->createUser( - $database->username, $database->remote, $this->encrypter->decrypt($database->password), $database->max_connections + $database->username, + $database->remote, + $this->encrypter->decrypt($database->password), + $database->max_connections ); $this->repository->assignUserToDatabase($database->database, $database->username, $database->remote); $this->repository->flush(); @@ -181,7 +169,6 @@ class DatabaseManagementService /** * Delete a database from the given host server. * - * @param \Pterodactyl\Models\Database $database * @return bool|null * * @throws \Exception @@ -202,9 +189,6 @@ class DatabaseManagementService * have the same name across multiple hosts, for the sake of keeping this logic easy to understand * and avoiding user confusion we will ignore the specific host and just look across all hosts. * - * @param array $data - * @return \Pterodactyl\Models\Database - * * @throws \Pterodactyl\Exceptions\Repository\DuplicateDatabaseNameException * @throws \Throwable */ @@ -215,12 +199,10 @@ class DatabaseManagementService ->exists(); if ($exists) { - throw new DuplicateDatabaseNameException( - 'A database with that name already exists for this server.' - ); + throw new DuplicateDatabaseNameException('A database with that name already exists for this server.'); } - $database = (new Database)->forceFill($data); + $database = (new Database())->forceFill($data); $database->saveOrFail(); return $database; diff --git a/app/Services/Databases/DatabasePasswordService.php b/app/Services/Databases/DatabasePasswordService.php index 2a9ebcabe..aabe98388 100644 --- a/app/Services/Databases/DatabasePasswordService.php +++ b/app/Services/Databases/DatabasePasswordService.php @@ -33,11 +33,6 @@ class DatabasePasswordService /** * DatabasePasswordService constructor. - * - * @param \Illuminate\Database\ConnectionInterface $connection - * @param \Pterodactyl\Contracts\Repository\DatabaseRepositoryInterface $repository - * @param \Pterodactyl\Extensions\DynamicDatabaseConnection $dynamic - * @param \Illuminate\Contracts\Encryption\Encrypter $encrypter */ public function __construct( ConnectionInterface $connection, @@ -55,7 +50,6 @@ class DatabasePasswordService * Updates a password for a given database. * * @param \Pterodactyl\Models\Database|int $database - * @return string * * @throws \Throwable */ diff --git a/app/Services/Databases/DeployServerDatabaseService.php b/app/Services/Databases/DeployServerDatabaseService.php index 4bc72a1fd..3946cb83f 100644 --- a/app/Services/Databases/DeployServerDatabaseService.php +++ b/app/Services/Databases/DeployServerDatabaseService.php @@ -26,10 +26,6 @@ class DeployServerDatabaseService } /** - * @param \Pterodactyl\Models\Server $server - * @param array $data - * @return \Pterodactyl\Models\Database - * * @throws \Throwable * @throws \Pterodactyl\Exceptions\Service\Database\TooManyDatabasesException * @throws \Pterodactyl\Exceptions\Service\Database\DatabaseClientFeatureNotEnabledException @@ -41,12 +37,12 @@ class DeployServerDatabaseService $hosts = DatabaseHost::query()->get()->toBase(); if ($hosts->isEmpty()) { - throw new NoSuitableDatabaseHostException; + throw new NoSuitableDatabaseHostException(); } else { $nodeHosts = $hosts->where('node_id', $server->node_id)->toBase(); - if ($nodeHosts->isEmpty() && ! config('pterodactyl.client_features.databases.allow_random')) { - throw new NoSuitableDatabaseHostException; + if ($nodeHosts->isEmpty() && !config('pterodactyl.client_features.databases.allow_random')) { + throw new NoSuitableDatabaseHostException(); } } diff --git a/app/Services/Databases/Hosts/HostCreationService.php b/app/Services/Databases/Hosts/HostCreationService.php index cbe3024f6..275f4d294 100644 --- a/app/Services/Databases/Hosts/HostCreationService.php +++ b/app/Services/Databases/Hosts/HostCreationService.php @@ -38,12 +38,6 @@ class HostCreationService /** * HostCreationService constructor. - * - * @param \Illuminate\Database\ConnectionInterface $connection - * @param \Illuminate\Database\DatabaseManager $databaseManager - * @param \Pterodactyl\Contracts\Repository\DatabaseHostRepositoryInterface $repository - * @param \Pterodactyl\Extensions\DynamicDatabaseConnection $dynamic - * @param \Illuminate\Contracts\Encryption\Encrypter $encrypter */ public function __construct( ConnectionInterface $connection, @@ -62,9 +56,6 @@ class HostCreationService /** * Create a new database host on the Panel. * - * @param array $data - * @return \Pterodactyl\Models\DatabaseHost - * * @throws \Throwable */ public function handle(array $data): DatabaseHost diff --git a/app/Services/Databases/Hosts/HostDeletionService.php b/app/Services/Databases/Hosts/HostDeletionService.php index f366305cb..1538d4823 100644 --- a/app/Services/Databases/Hosts/HostDeletionService.php +++ b/app/Services/Databases/Hosts/HostDeletionService.php @@ -20,9 +20,6 @@ class HostDeletionService /** * HostDeletionService constructor. - * - * @param \Pterodactyl\Contracts\Repository\DatabaseRepositoryInterface $databaseRepository - * @param \Pterodactyl\Contracts\Repository\DatabaseHostRepositoryInterface $repository */ public function __construct( DatabaseRepositoryInterface $databaseRepository, @@ -36,9 +33,6 @@ class HostDeletionService * Delete a specified host from the Panel if no databases are * attached to it. * - * @param int $host - * @return int - * * @throws \Pterodactyl\Exceptions\Service\HasActiveServersException */ public function handle(int $host): int diff --git a/app/Services/Databases/Hosts/HostUpdateService.php b/app/Services/Databases/Hosts/HostUpdateService.php index 9965abd9c..4a281b851 100644 --- a/app/Services/Databases/Hosts/HostUpdateService.php +++ b/app/Services/Databases/Hosts/HostUpdateService.php @@ -45,12 +45,6 @@ class HostUpdateService /** * DatabaseHostService constructor. - * - * @param \Illuminate\Database\ConnectionInterface $connection - * @param \Illuminate\Database\DatabaseManager $databaseManager - * @param \Pterodactyl\Contracts\Repository\DatabaseHostRepositoryInterface $repository - * @param \Pterodactyl\Extensions\DynamicDatabaseConnection $dynamic - * @param \Illuminate\Contracts\Encryption\Encrypter $encrypter */ public function __construct( ConnectionInterface $connection, @@ -69,15 +63,11 @@ class HostUpdateService /** * Update a database host and persist to the database. * - * @param int $hostId - * @param array $data - * @return \Pterodactyl\Models\DatabaseHost - * * @throws \Throwable */ public function handle(int $hostId, array $data): DatabaseHost { - if (! empty(array_get($data, 'password'))) { + if (!empty(array_get($data, 'password'))) { $data['password'] = $this->encrypter->encrypt($data['password']); } else { unset($data['password']); diff --git a/app/Services/Deployment/AllocationSelectionService.php b/app/Services/Deployment/AllocationSelectionService.php index 633ba1f5e..d714700b5 100644 --- a/app/Services/Deployment/AllocationSelectionService.php +++ b/app/Services/Deployment/AllocationSelectionService.php @@ -32,8 +32,6 @@ class AllocationSelectionService /** * AllocationSelectionService constructor. - * - * @param \Pterodactyl\Contracts\Repository\AllocationRepositoryInterface $repository */ public function __construct(AllocationRepositoryInterface $repository) { @@ -45,7 +43,6 @@ class AllocationSelectionService * to the given IP address. If true an allocation will not be selected if an IP * already has another server set to use on if its allocations. * - * @param bool $dedicated * @return $this */ public function setDedicated(bool $dedicated) @@ -59,7 +56,6 @@ class AllocationSelectionService * A list of node IDs that should be used when selecting an allocation. If empty, all * nodes will be used to filter with. * - * @param array $nodes * @return $this */ public function setNodes(array $nodes) @@ -74,7 +70,6 @@ class AllocationSelectionService * empty, all ports will be considered when finding an allocation. If set, only ports appearing * in the array or range will be used. * - * @param array $ports * @return $this * * @throws \Pterodactyl\Exceptions\DisplayException @@ -106,8 +101,6 @@ class AllocationSelectionService /** * Return a single allocation that should be used as the default allocation for a server. * - * @return \Pterodactyl\Models\Allocation - * * @throws \Pterodactyl\Exceptions\Service\Deployment\NoViableAllocationException */ public function handle(): Allocation diff --git a/app/Services/Deployment/FindViableNodesService.php b/app/Services/Deployment/FindViableNodesService.php index 0963d88ea..76cb89abf 100644 --- a/app/Services/Deployment/FindViableNodesService.php +++ b/app/Services/Deployment/FindViableNodesService.php @@ -2,8 +2,8 @@ namespace Pterodactyl\Services\Deployment; -use Webmozart\Assert\Assert; use Pterodactyl\Models\Node; +use Webmozart\Assert\Assert; use Pterodactyl\Exceptions\Service\Deployment\NoViableNodeException; class FindViableNodesService @@ -26,7 +26,6 @@ class FindViableNodesService /** * Set the locations that should be searched through to locate available nodes. * - * @param array $locations * @return $this */ public function setLocations(array $locations): self @@ -43,7 +42,6 @@ class FindViableNodesService * filtered out if they do not have enough available free disk space for this server * to be placed on. * - * @param int $disk * @return $this */ public function setDisk(int $disk): self @@ -57,7 +55,6 @@ class FindViableNodesService * Set the amount of memory that this server will be using. As with disk space, nodes that * do not have enough free memory will be filtered out. * - * @param int $memory * @return $this */ public function setMemory(int $memory): self @@ -81,6 +78,7 @@ class FindViableNodesService * up to 50 nodes at a time starting at the provided page. * If "null" is provided as the value no pagination will * be used. + * * @return \Illuminate\Support\Collection|\Illuminate\Contracts\Pagination\LengthAwarePaginator * * @throws \Pterodactyl\Exceptions\Service\Deployment\NoViableNodeException @@ -96,7 +94,7 @@ class FindViableNodesService ->leftJoin('servers', 'servers.node_id', '=', 'nodes.id') ->where('nodes.public', 1); - if (! empty($this->locations)) { + if (!empty($this->locations)) { $query = $query->whereIn('nodes.location_id', $this->locations); } @@ -104,7 +102,7 @@ class FindViableNodesService ->havingRaw('(IFNULL(SUM(servers.memory), 0) + ?) <= (nodes.memory * (1 + (nodes.memory_overallocate / 100)))', [$this->memory]) ->havingRaw('(IFNULL(SUM(servers.disk), 0) + ?) <= (nodes.disk * (1 + (nodes.disk_overallocate / 100)))', [$this->disk]); - if (! is_null($page)) { + if (!is_null($page)) { $results = $results->paginate(50, ['*'], 'page', $page); } else { $results = $results->get()->toBase(); diff --git a/app/Services/Eggs/EggConfigurationService.php b/app/Services/Eggs/EggConfigurationService.php index 4d1db4e2e..3b3ca2d11 100644 --- a/app/Services/Eggs/EggConfigurationService.php +++ b/app/Services/Eggs/EggConfigurationService.php @@ -16,8 +16,6 @@ class EggConfigurationService /** * EggConfigurationService constructor. - * - * @param \Pterodactyl\Services\Servers\ServerConfigurationStructureService $configurationStructureService */ public function __construct(ServerConfigurationStructureService $configurationStructureService) { @@ -26,14 +24,12 @@ class EggConfigurationService /** * Return an Egg file to be used by the Daemon. - * - * @param \Pterodactyl\Models\Server $server - * @return array */ public function handle(Server $server): array { $configs = $this->replacePlaceholders( - $server, json_decode($server->egg->inherit_config_files) + $server, + json_decode($server->egg->inherit_config_files) ); return [ @@ -46,7 +42,6 @@ class EggConfigurationService /** * Convert the "done" variable into an array if it is not currently one. * - * @param array $startup * @return array */ protected function convertStartupToNewFormat(array $startup) @@ -66,13 +61,10 @@ class EggConfigurationService * For most eggs, this ends up just being a command sent to the server console, but * if the stop command is something starting with a caret (^), it will be converted * into the associated kill signal for the instance. - * - * @param string $stop - * @return array */ protected function convertStopToNewFormat(string $stop): array { - if (! Str::startsWith($stop, '^')) { + if (!Str::startsWith($stop, '^')) { return [ 'type' => 'command', 'value' => $stop, @@ -94,8 +86,6 @@ class EggConfigurationService } /** - * @param \Pterodactyl\Models\Server $server - * @param object $configs * @return array */ protected function replacePlaceholders(Server $server, object $configs) @@ -108,7 +98,7 @@ class EggConfigurationService // Normalize the output of the configuration for the new Wings Daemon to more // easily ingest, as well as make things more flexible down the road. foreach ($configs as $file => $data) { - $append = array_merge((array)$data, ['file' => $file, 'replace' => []]); + $append = array_merge((array) $data, ['file' => $file, 'replace' => []]); foreach ($this->iterate($data->find, $structure) as $find => $replace) { if (is_object($replace)) { @@ -142,10 +132,6 @@ class EggConfigurationService * set SERVER_MEMORY, SERVER_IP, and SERVER_PORT with their respective values on the Daemon * side. Ensure that anything referencing those properly replaces them with the matching config * value. - * - * @param string $key - * @param string $value - * @return string */ protected function replaceLegacyModifiers(string $key, string $value): string { @@ -175,7 +161,7 @@ class EggConfigurationService /** * @param mixed $value - * @param array $structure + * * @return mixed|null */ protected function matchAndReplaceKeys($value, array $structure) @@ -187,13 +173,13 @@ class EggConfigurationService // value from the server properties. // // The Daemon supports server.X, env.X, and config.X placeholders. - if (! Str::startsWith($key, ['server.', 'env.', 'config.'])) { + if (!Str::startsWith($key, ['server.', 'env.', 'config.'])) { continue; } // Don't do a replacement on anything that is not a string, we don't want to unintentionally // modify the resulting output. - if (! is_string($value)) { + if (!is_string($value)) { continue; } @@ -218,7 +204,9 @@ class EggConfigurationService // Finally, replace anything starting with env. with the expected environment // variable from the server configuration. $plucked = Arr::get( - $structure, preg_replace('/^env\./', 'build.env.', $key), '' + $structure, + preg_replace('/^env\./', 'build.env.', $key), + '' ); $value = str_replace("{{{$key}}}", $plucked, $value); @@ -233,12 +221,12 @@ class EggConfigurationService * a match & replace. * * @param mixed $data - * @param array $structure + * * @return mixed */ private function iterate($data, array $structure) { - if (! is_iterable($data) && ! is_object($data)) { + if (!is_iterable($data) && !is_object($data)) { return $data; } diff --git a/app/Services/Eggs/EggCreationService.php b/app/Services/Eggs/EggCreationService.php index 33a0a919d..d7b5bb42b 100644 --- a/app/Services/Eggs/EggCreationService.php +++ b/app/Services/Eggs/EggCreationService.php @@ -30,9 +30,6 @@ class EggCreationService /** * EggCreationService constructor. - * - * @param \Illuminate\Contracts\Config\Repository $config - * @param \Pterodactyl\Contracts\Repository\EggRepositoryInterface $repository */ public function __construct(ConfigRepository $config, EggRepositoryInterface $repository) { @@ -43,16 +40,13 @@ class EggCreationService /** * Create a new service option and assign it to the given service. * - * @param array $data - * @return \Pterodactyl\Models\Egg - * * @throws \Pterodactyl\Exceptions\Model\DataValidationException * @throws \Pterodactyl\Exceptions\Service\Egg\NoParentConfigurationFoundException */ public function handle(array $data): Egg { $data['config_from'] = array_get($data, 'config_from'); - if (! is_null($data['config_from'])) { + if (!is_null($data['config_from'])) { $results = $this->repository->findCountWhere([ ['nest_id', '=', array_get($data, 'nest_id')], ['id', '=', array_get($data, 'config_from')], diff --git a/app/Services/Eggs/EggDeletionService.php b/app/Services/Eggs/EggDeletionService.php index 7b30e4426..1c8f8cf66 100644 --- a/app/Services/Eggs/EggDeletionService.php +++ b/app/Services/Eggs/EggDeletionService.php @@ -28,9 +28,6 @@ class EggDeletionService /** * EggDeletionService constructor. - * - * @param \Pterodactyl\Contracts\Repository\ServerRepositoryInterface $serverRepository - * @param \Pterodactyl\Contracts\Repository\EggRepositoryInterface $repository */ public function __construct( ServerRepositoryInterface $serverRepository, @@ -43,9 +40,6 @@ class EggDeletionService /** * Delete an Egg from the database if it has no active servers attached to it. * - * @param int $egg - * @return int - * * @throws \Pterodactyl\Exceptions\Service\HasActiveServersException * @throws \Pterodactyl\Exceptions\Service\Egg\HasChildrenException */ diff --git a/app/Services/Eggs/EggUpdateService.php b/app/Services/Eggs/EggUpdateService.php index 697ed0599..e0cabbb05 100644 --- a/app/Services/Eggs/EggUpdateService.php +++ b/app/Services/Eggs/EggUpdateService.php @@ -22,8 +22,6 @@ class EggUpdateService /** * EggUpdateService constructor. - * - * @param \Pterodactyl\Contracts\Repository\EggRepositoryInterface $repository */ public function __construct(EggRepositoryInterface $repository) { @@ -33,16 +31,13 @@ class EggUpdateService /** * Update a service option. * - * @param \Pterodactyl\Models\Egg $egg - * @param array $data - * * @throws \Pterodactyl\Exceptions\Model\DataValidationException * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException * @throws \Pterodactyl\Exceptions\Service\Egg\NoParentConfigurationFoundException */ public function handle(Egg $egg, array $data) { - if (! is_null(array_get($data, 'config_from'))) { + if (!is_null(array_get($data, 'config_from'))) { $results = $this->repository->findCountWhere([ ['nest_id', '=', $egg->nest_id], ['id', '=', array_get($data, 'config_from')], diff --git a/app/Services/Eggs/Scripts/InstallScriptService.php b/app/Services/Eggs/Scripts/InstallScriptService.php index 70621c32b..ecd1dc1f3 100644 --- a/app/Services/Eggs/Scripts/InstallScriptService.php +++ b/app/Services/Eggs/Scripts/InstallScriptService.php @@ -15,8 +15,6 @@ class InstallScriptService /** * InstallScriptService constructor. - * - * @param \Pterodactyl\Contracts\Repository\EggRepositoryInterface $repository */ public function __construct(EggRepositoryInterface $repository) { @@ -27,7 +25,6 @@ class InstallScriptService * Modify the install script for a given Egg. * * @param int|\Pterodactyl\Models\Egg $egg - * @param array $data * * @throws \Pterodactyl\Exceptions\Model\DataValidationException * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException @@ -35,8 +32,8 @@ class InstallScriptService */ public function handle(Egg $egg, array $data) { - if (! is_null(array_get($data, 'copy_script_from'))) { - if (! $this->repository->isCopyableScript(array_get($data, 'copy_script_from'), $egg->nest_id)) { + if (!is_null(array_get($data, 'copy_script_from'))) { + if (!$this->repository->isCopyableScript(array_get($data, 'copy_script_from'), $egg->nest_id)) { throw new InvalidCopyFromException(trans('exceptions.nest.egg.invalid_copy_id')); } } diff --git a/app/Services/Eggs/Sharing/EggExporterService.php b/app/Services/Eggs/Sharing/EggExporterService.php index 7b0cb3a49..2cdbd9850 100644 --- a/app/Services/Eggs/Sharing/EggExporterService.php +++ b/app/Services/Eggs/Sharing/EggExporterService.php @@ -14,8 +14,6 @@ class EggExporterService /** * EggExporterService constructor. - * - * @param \Pterodactyl\Contracts\Repository\EggRepositoryInterface $repository */ public function __construct(EggRepositoryInterface $repository) { @@ -25,9 +23,6 @@ class EggExporterService /** * Return a JSON representation of an egg and its variables. * - * @param int $egg - * @return string - * * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ public function handle(int $egg): string diff --git a/app/Services/Eggs/Sharing/EggImporterService.php b/app/Services/Eggs/Sharing/EggImporterService.php index 19d1c7d2a..b3ea33c90 100644 --- a/app/Services/Eggs/Sharing/EggImporterService.php +++ b/app/Services/Eggs/Sharing/EggImporterService.php @@ -36,11 +36,6 @@ class EggImporterService /** * EggImporterService constructor. - * - * @param \Illuminate\Database\ConnectionInterface $connection - * @param \Pterodactyl\Contracts\Repository\EggRepositoryInterface $repository - * @param \Pterodactyl\Contracts\Repository\EggVariableRepositoryInterface $eggVariableRepository - * @param \Pterodactyl\Contracts\Repository\NestRepositoryInterface $nestRepository */ public function __construct( ConnectionInterface $connection, @@ -57,10 +52,6 @@ class EggImporterService /** * Take an uploaded JSON file and parse it into a new egg. * - * @param \Illuminate\Http\UploadedFile $file - * @param int $nest - * @return \Pterodactyl\Models\Egg - * * @throws \Pterodactyl\Exceptions\Model\DataValidationException * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException * @throws \Pterodactyl\Exceptions\Service\Egg\BadJsonFormatException @@ -68,24 +59,13 @@ class EggImporterService */ public function handle(UploadedFile $file, int $nest): Egg { - if ($file->getError() !== UPLOAD_ERR_OK || ! $file->isFile()) { - throw new InvalidFileUploadException( - sprintf( - 'The selected file ["%s"] was not in a valid format to import. (is_file: %s is_valid: %s err_code: %s err: %s)', - $file->getFilename(), - $file->isFile() ? 'true' : 'false', - $file->isValid() ? 'true' : 'false', - $file->getError(), - $file->getErrorMessage() - ) - ); + if ($file->getError() !== UPLOAD_ERR_OK || !$file->isFile()) { + throw new InvalidFileUploadException(sprintf('The selected file ["%s"] was not in a valid format to import. (is_file: %s is_valid: %s err_code: %s err: %s)', $file->getFilename(), $file->isFile() ? 'true' : 'false', $file->isValid() ? 'true' : 'false', $file->getError(), $file->getErrorMessage())); } $parsed = json_decode($file->openFile()->fread($file->getSize())); if (json_last_error() !== 0) { - throw new BadJsonFormatException(trans('exceptions.nest.importer.json_error', [ - 'error' => json_last_error_msg(), - ])); + throw new BadJsonFormatException(trans('exceptions.nest.importer.json_error', ['error' => json_last_error_msg()])); } if (object_get($parsed, 'meta.version') !== 'PTDL_v1') { @@ -119,7 +99,7 @@ class EggImporterService ], true, true); collect($parsed->variables)->each(function ($variable) use ($egg) { - $this->eggVariableRepository->create(array_merge((array)$variable, [ + $this->eggVariableRepository->create(array_merge((array) $variable, [ 'egg_id' => $egg->id, ])); }); diff --git a/app/Services/Eggs/Sharing/EggUpdateImporterService.php b/app/Services/Eggs/Sharing/EggUpdateImporterService.php index b4705d25e..205314314 100644 --- a/app/Services/Eggs/Sharing/EggUpdateImporterService.php +++ b/app/Services/Eggs/Sharing/EggUpdateImporterService.php @@ -29,10 +29,6 @@ class EggUpdateImporterService /** * EggUpdateImporterService constructor. - * - * @param \Illuminate\Database\ConnectionInterface $connection - * @param \Pterodactyl\Contracts\Repository\EggRepositoryInterface $repository - * @param \Pterodactyl\Contracts\Repository\EggVariableRepositoryInterface $variableRepository */ public function __construct( ConnectionInterface $connection, @@ -47,9 +43,6 @@ class EggUpdateImporterService /** * Update an existing Egg using an uploaded JSON file. * - * @param \Pterodactyl\Models\Egg $egg - * @param \Illuminate\Http\UploadedFile $file - * * @throws \Pterodactyl\Exceptions\Model\DataValidationException * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException * @throws \Pterodactyl\Exceptions\Service\Egg\BadJsonFormatException @@ -57,24 +50,13 @@ class EggUpdateImporterService */ public function handle(Egg $egg, UploadedFile $file) { - if ($file->getError() !== UPLOAD_ERR_OK || ! $file->isFile()) { - throw new InvalidFileUploadException( - sprintf( - 'The selected file ["%s"] was not in a valid format to import. (is_file: %s is_valid: %s err_code: %s err: %s)', - $file->getFilename(), - $file->isFile() ? 'true' : 'false', - $file->isValid() ? 'true' : 'false', - $file->getError(), - $file->getErrorMessage() - ) - ); + if ($file->getError() !== UPLOAD_ERR_OK || !$file->isFile()) { + throw new InvalidFileUploadException(sprintf('The selected file ["%s"] was not in a valid format to import. (is_file: %s is_valid: %s err_code: %s err: %s)', $file->getFilename(), $file->isFile() ? 'true' : 'false', $file->isValid() ? 'true' : 'false', $file->getError(), $file->getErrorMessage())); } $parsed = json_decode($file->openFile()->fread($file->getSize())); if (json_last_error() !== 0) { - throw new BadJsonFormatException(trans('exceptions.nest.importer.json_error', [ - 'error' => json_last_error_msg(), - ])); + throw new BadJsonFormatException(trans('exceptions.nest.importer.json_error', ['error' => json_last_error_msg()])); } if (object_get($parsed, 'meta.version') !== 'PTDL_v1') { @@ -113,7 +95,7 @@ class EggUpdateImporterService // Delete variables not present in the import. collect($existing)->each(function ($variable) use ($egg, $imported) { - if (! in_array($variable->env_variable, $imported)) { + if (!in_array($variable->env_variable, $imported)) { $this->variableRepository->deleteWhere([ ['egg_id', '=', $egg->id], ['env_variable', '=', $variable->env_variable], diff --git a/app/Services/Eggs/Variables/VariableCreationService.php b/app/Services/Eggs/Variables/VariableCreationService.php index ed7e72a4f..fa758265b 100644 --- a/app/Services/Eggs/Variables/VariableCreationService.php +++ b/app/Services/Eggs/Variables/VariableCreationService.php @@ -24,9 +24,6 @@ class VariableCreationService /** * VariableCreationService constructor. - * - * @param \Pterodactyl\Contracts\Repository\EggVariableRepositoryInterface $repository - * @param \Illuminate\Contracts\Validation\Factory $validator */ public function __construct(EggVariableRepositoryInterface $repository, Factory $validator) { @@ -37,8 +34,6 @@ class VariableCreationService /** * Return the validation factory instance to be used by rule validation * checking in the trait. - * - * @return \Illuminate\Contracts\Validation\Factory */ protected function getValidator(): Factory { @@ -48,10 +43,6 @@ class VariableCreationService /** * Create a new variable for a given Egg. * - * @param int $egg - * @param array $data - * @return \Pterodactyl\Models\EggVariable - * * @throws \Pterodactyl\Exceptions\Model\DataValidationException * @throws \Pterodactyl\Exceptions\Service\Egg\Variable\BadValidationRuleException * @throws \Pterodactyl\Exceptions\Service\Egg\Variable\ReservedVariableNameException @@ -59,13 +50,10 @@ class VariableCreationService public function handle(int $egg, array $data): EggVariable { if (in_array(strtoupper(array_get($data, 'env_variable')), explode(',', EggVariable::RESERVED_ENV_NAMES))) { - throw new ReservedVariableNameException(sprintf( - 'Cannot use the protected name %s for this environment variable.', - array_get($data, 'env_variable') - )); + throw new ReservedVariableNameException(sprintf('Cannot use the protected name %s for this environment variable.', array_get($data, 'env_variable'))); } - if (! empty($data['rules'] ?? '')) { + if (!empty($data['rules'] ?? '')) { $this->validateRules($data['rules']); } diff --git a/app/Services/Eggs/Variables/VariableUpdateService.php b/app/Services/Eggs/Variables/VariableUpdateService.php index da1a9e987..da4426c33 100644 --- a/app/Services/Eggs/Variables/VariableUpdateService.php +++ b/app/Services/Eggs/Variables/VariableUpdateService.php @@ -26,9 +26,6 @@ class VariableUpdateService /** * VariableUpdateService constructor. - * - * @param \Pterodactyl\Contracts\Repository\EggVariableRepositoryInterface $repository - * @param \Illuminate\Contracts\Validation\Factory $validator */ public function __construct(EggVariableRepositoryInterface $repository, Factory $validator) { @@ -39,8 +36,6 @@ class VariableUpdateService /** * Return the validation factory instance to be used by rule validation * checking in the trait. - * - * @return \Illuminate\Contracts\Validation\Factory */ protected function getValidator(): Factory { @@ -50,8 +45,6 @@ class VariableUpdateService /** * Update a specific egg variable. * - * @param \Pterodactyl\Models\EggVariable $variable - * @param array $data * @return mixed * * @throws \Pterodactyl\Exceptions\DisplayException @@ -61,11 +54,9 @@ class VariableUpdateService */ public function handle(EggVariable $variable, array $data) { - if (! is_null(array_get($data, 'env_variable'))) { + if (!is_null(array_get($data, 'env_variable'))) { if (in_array(strtoupper(array_get($data, 'env_variable')), explode(',', EggVariable::RESERVED_ENV_NAMES))) { - throw new ReservedVariableNameException(trans('exceptions.service.variables.reserved_name', [ - 'name' => array_get($data, 'env_variable'), - ])); + throw new ReservedVariableNameException(trans('exceptions.service.variables.reserved_name', ['name' => array_get($data, 'env_variable')])); } $search = $this->repository->setColumns('id')->findCountWhere([ @@ -75,13 +66,11 @@ class VariableUpdateService ]); if ($search > 0) { - throw new DisplayException(trans('exceptions.service.variables.env_not_unique', [ - 'name' => array_get($data, 'env_variable'), - ])); + throw new DisplayException(trans('exceptions.service.variables.env_not_unique', ['name' => array_get($data, 'env_variable')])); } } - if (! empty($data['rules'] ?? '')) { + if (!empty($data['rules'] ?? '')) { $this->validateRules( (is_string($data['rules']) && Str::contains($data['rules'], ';;')) ? explode(';;', $data['rules']) diff --git a/app/Services/Helpers/AssetHashService.php b/app/Services/Helpers/AssetHashService.php index 25aa3318b..4b1bf7e0b 100644 --- a/app/Services/Helpers/AssetHashService.php +++ b/app/Services/Helpers/AssetHashService.php @@ -30,9 +30,6 @@ class AssetHashService /** * AssetHashService constructor. - * - * @param \Illuminate\Contracts\Foundation\Application $application - * @param \Illuminate\Filesystem\FilesystemManager $filesystem */ public function __construct(Application $application, FilesystemManager $filesystem) { @@ -43,9 +40,6 @@ class AssetHashService /** * Modify a URL to append the asset hash. * - * @param string $resource - * @return string - * * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException */ public function url(string $resource): string @@ -59,9 +53,6 @@ class AssetHashService /** * Return the data integrity hash for a resource. * - * @param string $resource - * @return string - * * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException */ public function integrity(string $resource): string @@ -75,9 +66,6 @@ class AssetHashService /** * Return a built CSS import using the provided URL. * - * @param string $resource - * @return string - * * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException */ public function css(string $resource): string @@ -105,9 +93,6 @@ class AssetHashService /** * Return a built JS import using the provided URL. * - * @param string $resource - * @return string - * * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException */ public function js(string $resource): string @@ -132,14 +117,13 @@ class AssetHashService /** * Get the asset manifest and store it in the cache for quicker lookups. * - * @return array - * * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException */ protected function manifest(): array { return self::$manifest ?: self::$manifest = json_decode( - $this->filesystem->get(self::MANIFEST_PATH), true + $this->filesystem->get(self::MANIFEST_PATH), + true ); } } diff --git a/app/Services/Helpers/SoftwareVersionService.php b/app/Services/Helpers/SoftwareVersionService.php index 72daa2282..e6c768d19 100644 --- a/app/Services/Helpers/SoftwareVersionService.php +++ b/app/Services/Helpers/SoftwareVersionService.php @@ -6,34 +6,30 @@ use Exception; use GuzzleHttp\Client; use Carbon\CarbonImmutable; use Illuminate\Support\Arr; -use Illuminate\Support\Str; use Illuminate\Contracts\Cache\Repository as CacheRepository; use Pterodactyl\Exceptions\Service\Helper\CdnVersionFetchingException; class SoftwareVersionService { - const VERSION_CACHE_KEY = 'pterodactyl:versioning_data'; + public const VERSION_CACHE_KEY = 'pterodactyl:versioning_data'; /** * @var array */ - private static array $result; + private static $result; /** * @var \Illuminate\Contracts\Cache\Repository */ - protected CacheRepository $cache; + protected $cache; /** * @var \GuzzleHttp\Client */ - protected Client $client; + protected $client; /** * SoftwareVersionService constructor. - * - * @param \Illuminate\Contracts\Cache\Repository $cache - * @param \GuzzleHttp\Client $client */ public function __construct( CacheRepository $cache, @@ -118,11 +114,11 @@ class SoftwareVersionService try { $response = $this->client->request('GET', config()->get('pterodactyl.cdn.url')); - if ($response->getStatusCode() !== 200) { - throw new CdnVersionFetchingException; + if ($response->getStatusCode() === 200) { + return json_decode($response->getBody(), true); } - return json_decode($response->getBody(), true); + throw new CdnVersionFetchingException(); } catch (Exception $exception) { return []; } diff --git a/app/Services/Locations/LocationCreationService.php b/app/Services/Locations/LocationCreationService.php index cd2a97572..cff493a8b 100644 --- a/app/Services/Locations/LocationCreationService.php +++ b/app/Services/Locations/LocationCreationService.php @@ -20,8 +20,6 @@ class LocationCreationService /** * LocationCreationService constructor. - * - * @param \Pterodactyl\Contracts\Repository\LocationRepositoryInterface $repository */ public function __construct(LocationRepositoryInterface $repository) { @@ -31,7 +29,6 @@ class LocationCreationService /** * Create a new location. * - * @param array $data * @return \Pterodactyl\Models\Location * * @throws \Pterodactyl\Exceptions\Model\DataValidationException diff --git a/app/Services/Locations/LocationDeletionService.php b/app/Services/Locations/LocationDeletionService.php index 5fc528ead..2ffd38187 100644 --- a/app/Services/Locations/LocationDeletionService.php +++ b/app/Services/Locations/LocationDeletionService.php @@ -29,9 +29,6 @@ class LocationDeletionService /** * LocationDeletionService constructor. - * - * @param \Pterodactyl\Contracts\Repository\LocationRepositoryInterface $repository - * @param \Pterodactyl\Contracts\Repository\NodeRepositoryInterface $nodeRepository */ public function __construct( LocationRepositoryInterface $repository, @@ -45,6 +42,7 @@ class LocationDeletionService * Delete an existing location. * * @param int|\Pterodactyl\Models\Location $location + * * @return int|null * * @throws \Pterodactyl\Exceptions\Service\Location\HasActiveNodesException diff --git a/app/Services/Locations/LocationUpdateService.php b/app/Services/Locations/LocationUpdateService.php index dfb5bcc5f..87399201f 100644 --- a/app/Services/Locations/LocationUpdateService.php +++ b/app/Services/Locations/LocationUpdateService.php @@ -21,8 +21,6 @@ class LocationUpdateService /** * LocationUpdateService constructor. - * - * @param \Pterodactyl\Contracts\Repository\LocationRepositoryInterface $repository */ public function __construct(LocationRepositoryInterface $repository) { @@ -33,7 +31,7 @@ class LocationUpdateService * Update an existing location. * * @param int|\Pterodactyl\Models\Location $location - * @param array $data + * * @return \Pterodactyl\Models\Location * * @throws \Pterodactyl\Exceptions\Model\DataValidationException diff --git a/app/Services/Nests/NestCreationService.php b/app/Services/Nests/NestCreationService.php index 5cac1c11a..af56496d1 100644 --- a/app/Services/Nests/NestCreationService.php +++ b/app/Services/Nests/NestCreationService.php @@ -21,9 +21,6 @@ class NestCreationService /** * NestCreationService constructor. - * - * @param \Illuminate\Contracts\Config\Repository $config - * @param \Pterodactyl\Contracts\Repository\NestRepositoryInterface $repository */ public function __construct(ConfigRepository $config, NestRepositoryInterface $repository) { @@ -34,9 +31,6 @@ class NestCreationService /** * Create a new nest on the system. * - * @param array $data - * @param string|null $author - * @return \Pterodactyl\Models\Nest * @throws \Pterodactyl\Exceptions\Model\DataValidationException */ public function handle(array $data, string $author = null): Nest diff --git a/app/Services/Nests/NestDeletionService.php b/app/Services/Nests/NestDeletionService.php index 990bbc595..777a41b68 100644 --- a/app/Services/Nests/NestDeletionService.php +++ b/app/Services/Nests/NestDeletionService.php @@ -27,9 +27,6 @@ class NestDeletionService /** * NestDeletionService constructor. - * - * @param \Pterodactyl\Contracts\Repository\ServerRepositoryInterface $serverRepository - * @param \Pterodactyl\Contracts\Repository\NestRepositoryInterface $repository */ public function __construct( ServerRepositoryInterface $serverRepository, @@ -42,9 +39,6 @@ class NestDeletionService /** * Delete a nest from the system only if there are no servers attached to it. * - * @param int $nest - * @return int - * * @throws \Pterodactyl\Exceptions\Service\HasActiveServersException */ public function handle(int $nest): int diff --git a/app/Services/Nests/NestUpdateService.php b/app/Services/Nests/NestUpdateService.php index de04e7e2f..7772ff380 100644 --- a/app/Services/Nests/NestUpdateService.php +++ b/app/Services/Nests/NestUpdateService.php @@ -20,8 +20,6 @@ class NestUpdateService /** * NestUpdateService constructor. - * - * @param \Pterodactyl\Contracts\Repository\NestRepositoryInterface $repository */ public function __construct(NestRepositoryInterface $repository) { @@ -31,14 +29,12 @@ class NestUpdateService /** * Update a nest and prevent changing the author once it is set. * - * @param int $nest - * @param array $data * @throws \Pterodactyl\Exceptions\Model\DataValidationException * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ public function handle(int $nest, array $data) { - if (! is_null(array_get($data, 'author'))) { + if (!is_null(array_get($data, 'author'))) { unset($data['author']); } diff --git a/app/Services/Nodes/NodeCreationService.php b/app/Services/Nodes/NodeCreationService.php index a44c036bd..e8ea5b0d8 100644 --- a/app/Services/Nodes/NodeCreationService.php +++ b/app/Services/Nodes/NodeCreationService.php @@ -22,9 +22,6 @@ class NodeCreationService /** * CreationService constructor. - * - * @param \Illuminate\Contracts\Encryption\Encrypter $encrypter - * @param \Pterodactyl\Contracts\Repository\NodeRepositoryInterface $repository */ public function __construct(Encrypter $encrypter, NodeRepositoryInterface $repository) { @@ -35,7 +32,6 @@ class NodeCreationService /** * Create a new node on the panel. * - * @param array $data * @return \Pterodactyl\Models\Node * * @throws \Pterodactyl\Exceptions\Model\DataValidationException diff --git a/app/Services/Nodes/NodeDeletionService.php b/app/Services/Nodes/NodeDeletionService.php index 75118fa30..30483a826 100644 --- a/app/Services/Nodes/NodeDeletionService.php +++ b/app/Services/Nodes/NodeDeletionService.php @@ -34,10 +34,6 @@ class NodeDeletionService /** * DeletionService constructor. - * - * @param \Pterodactyl\Contracts\Repository\NodeRepositoryInterface $repository - * @param \Pterodactyl\Contracts\Repository\ServerRepositoryInterface $serverRepository - * @param \Illuminate\Contracts\Translation\Translator $translator */ public function __construct( NodeRepositoryInterface $repository, @@ -53,6 +49,7 @@ class NodeDeletionService * Delete a node from the panel if no servers are attached to it. * * @param int|\Pterodactyl\Models\Node $node + * * @return bool|null * * @throws \Pterodactyl\Exceptions\Service\HasActiveServersException diff --git a/app/Services/Nodes/NodeJWTService.php b/app/Services/Nodes/NodeJWTService.php index dbbf8a826..1b52479ba 100644 --- a/app/Services/Nodes/NodeJWTService.php +++ b/app/Services/Nodes/NodeJWTService.php @@ -3,12 +3,13 @@ namespace Pterodactyl\Services\Nodes; use DateTimeImmutable; -use Lcobucci\JWT\Builder; use Carbon\CarbonImmutable; use Illuminate\Support\Str; -use Lcobucci\JWT\Signer\Key; use Pterodactyl\Models\Node; +use Lcobucci\JWT\Configuration; use Lcobucci\JWT\Signer\Hmac\Sha256; +use Lcobucci\JWT\Signer\Key\InMemory; +use Pterodactyl\Extensions\Lcobucci\JWT\Encoding\TimestampDates; class NodeJWTService { @@ -30,7 +31,6 @@ class NodeJWTService /** * Set the claims to include in this JWT. * - * @param array $claims * @return $this */ public function setClaims(array $claims) @@ -41,7 +41,6 @@ class NodeJWTService } /** - * @param \DateTimeImmutable $date * @return $this */ public function setExpiresAt(DateTimeImmutable $date) @@ -52,7 +51,6 @@ class NodeJWTService } /** - * @param string $subject * @return $this */ public function setSubject(string $subject) @@ -65,31 +63,29 @@ class NodeJWTService /** * Generate a new JWT for a given node. * - * @param \Pterodactyl\Models\Node $node * @param string|null $identifiedBy - * @param string $algo - * @return \Lcobucci\JWT\Token + * + * @return \Lcobucci\JWT\Token\Plain */ public function handle(Node $node, string $identifiedBy, string $algo = 'md5') { - $signer = new Sha256; - $identifier = hash($algo, $identifiedBy); + $config = Configuration::forSymmetricSigner(new Sha256(), InMemory::plainText($node->getDecryptedKey())); - $builder = (new Builder)->issuedBy(config('app.url')) + $builder = $config->builder(new TimestampDates()) + ->issuedBy(config('app.url')) ->permittedFor($node->getConnectionAddress()) ->identifiedBy($identifier) ->withHeader('jti', $identifier) - ->issuedAt(CarbonImmutable::now()->toDateTimeImmutable()) - ->canOnlyBeUsedAfter(CarbonImmutable::now()->subMinutes(5)->toDateTimeImmutable()); + ->issuedAt(CarbonImmutable::now()) + ->canOnlyBeUsedAfter(CarbonImmutable::now()->subMinutes(5)); if ($this->expiresAt) { $builder = $builder->expiresAt($this->expiresAt); } - if (! empty($this->subject)) { - $builder = $builder->relatedTo($this->subject) - ->withHeader('sub', $this->subject); + if (!empty($this->subject)) { + $builder = $builder->relatedTo($this->subject)->withHeader('sub', $this->subject); } foreach ($this->claims as $key => $value) { @@ -98,6 +94,6 @@ class NodeJWTService return $builder ->withClaim('unique_id', Str::random(16)) - ->getToken($signer, new Key($node->getDecryptedKey())); + ->getToken($config->signer(), $config->signingKey()); } } diff --git a/app/Services/Nodes/NodeUpdateService.php b/app/Services/Nodes/NodeUpdateService.php index f684d1064..9ba56fb4e 100644 --- a/app/Services/Nodes/NodeUpdateService.php +++ b/app/Services/Nodes/NodeUpdateService.php @@ -5,11 +5,9 @@ namespace Pterodactyl\Services\Nodes; use Illuminate\Support\Str; use Pterodactyl\Models\Node; use Illuminate\Support\Facades\Log; -use GuzzleHttp\Exception\ConnectException; use Illuminate\Database\ConnectionInterface; use Illuminate\Contracts\Encryption\Encrypter; use Pterodactyl\Repositories\Eloquent\NodeRepository; -use Pterodactyl\Repositories\Daemon\ConfigurationRepository; use Pterodactyl\Repositories\Wings\DaemonConfigurationRepository; use Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException; use Pterodactyl\Exceptions\Service\Node\ConfigurationNotPersistedException; @@ -38,11 +36,6 @@ class NodeUpdateService /** * UpdateService constructor. - * - * @param \Illuminate\Database\ConnectionInterface $connection - * @param \Illuminate\Contracts\Encryption\Encrypter $encrypter - * @param \Pterodactyl\Repositories\Wings\DaemonConfigurationRepository $configurationRepository - * @param \Pterodactyl\Repositories\Eloquent\NodeRepository $repository */ public function __construct( ConnectionInterface $connection, @@ -59,11 +52,8 @@ class NodeUpdateService /** * Update the configuration values for a given node on the machine. * - * @param \Pterodactyl\Models\Node $node - * @param array $data - * @param bool $resetToken - * * @return \Pterodactyl\Models\Node + * * @throws \Throwable */ public function handle(Node $node, array $data, bool $resetToken = false) @@ -101,7 +91,7 @@ class NodeUpdateService // inject their own response pages, causing this logic to get fucked up. // // @see https://github.com/pterodactyl/panel/issues/2712 - return [ $updated, true ]; + return [$updated, true]; } return [$updated, false]; diff --git a/app/Services/Schedules/ProcessScheduleService.php b/app/Services/Schedules/ProcessScheduleService.php index 86775430b..23c9ea5e8 100644 --- a/app/Services/Schedules/ProcessScheduleService.php +++ b/app/Services/Schedules/ProcessScheduleService.php @@ -23,9 +23,6 @@ class ProcessScheduleService /** * ProcessScheduleService constructor. - * - * @param \Illuminate\Database\ConnectionInterface $connection - * @param \Illuminate\Contracts\Bus\Dispatcher $dispatcher */ public function __construct(ConnectionInterface $connection, Dispatcher $dispatcher) { @@ -36,9 +33,6 @@ class ProcessScheduleService /** * Process a schedule and push the first task onto the queue worker. * - * @param \Pterodactyl\Models\Schedule $schedule - * @param bool $now - * * @throws \Throwable */ public function handle(Schedule $schedule, bool $now = false) @@ -47,9 +41,7 @@ class ProcessScheduleService $task = $schedule->tasks()->orderBy('sequence_id', 'asc')->first(); if (is_null($task)) { - throw new DisplayException( - 'Cannot process schedule for task execution: no tasks are registered.' - ); + throw new DisplayException('Cannot process schedule for task execution: no tasks are registered.'); } $this->connection->transaction(function () use ($schedule, $task) { @@ -63,7 +55,7 @@ class ProcessScheduleService $job = new RunTaskJob($task); - if (! $now) { + if (!$now) { $this->dispatcher->dispatch($job->delay($task->time_offset)); } else { // When using dispatchNow the RunTaskJob::failed() function is not called automatically diff --git a/app/Services/Servers/BuildModificationService.php b/app/Services/Servers/BuildModificationService.php index 328e0e533..6a96075c5 100644 --- a/app/Services/Servers/BuildModificationService.php +++ b/app/Services/Servers/BuildModificationService.php @@ -31,8 +31,6 @@ class BuildModificationService * BuildModificationService constructor. * * @param \Pterodactyl\Services\Servers\ServerConfigurationStructureService $structureService - * @param \Illuminate\Database\ConnectionInterface $connection - * @param \Pterodactyl\Repositories\Wings\DaemonServerRepository $daemonServerRepository */ public function __construct( ServerConfigurationStructureService $structureService, @@ -47,8 +45,6 @@ class BuildModificationService /** * Change the build details for a specified server. * - * @param \Pterodactyl\Models\Server $server - * @param array $data * @return \Pterodactyl\Models\Server * * @throws \Throwable @@ -96,9 +92,6 @@ class BuildModificationService /** * Process the allocations being assigned in the data and ensure they are available for a server. * - * @param \Pterodactyl\Models\Server $server - * @param array $data - * * @throws \Pterodactyl\Exceptions\DisplayException */ private function processAllocations(Server $server, array &$data) @@ -109,7 +102,7 @@ class BuildModificationService // Handle the addition of allocations to this server. Only assign allocations that are not currently // assigned to a different server, and only allocations on the same node as the server. - if (! empty($data['add_allocations'])) { + if (!empty($data['add_allocations'])) { $query = Allocation::query() ->where('node_id', $server->node_id) ->whereIn('id', $data['add_allocations']) @@ -122,16 +115,14 @@ class BuildModificationService $query->update(['server_id' => $server->id, 'notes' => null]); } - if (! empty($data['remove_allocations'])) { + if (!empty($data['remove_allocations'])) { foreach ($data['remove_allocations'] as $allocation) { // If we are attempting to remove the default allocation for the server, see if we can reassign // to the first provided value in add_allocations. If there is no new first allocation then we // will throw an exception back. if ($allocation === ($data['allocation_id'] ?? $server->allocation_id)) { if (empty($freshlyAllocated)) { - throw new DisplayException( - 'You are attempting to delete the default allocation for this server but there is no fallback allocation to use.' - ); + throw new DisplayException('You are attempting to delete the default allocation for this server but there is no fallback allocation to use.'); } // Update the default allocation to be the first allocation that we are creating. diff --git a/app/Services/Servers/DetailsModificationService.php b/app/Services/Servers/DetailsModificationService.php index aa480a06a..cbe2a6ed9 100644 --- a/app/Services/Servers/DetailsModificationService.php +++ b/app/Services/Servers/DetailsModificationService.php @@ -25,9 +25,6 @@ class DetailsModificationService /** * DetailsModificationService constructor. - * - * @param \Illuminate\Database\ConnectionInterface $connection - * @param \Pterodactyl\Repositories\Wings\DaemonServerRepository $serverRepository */ public function __construct(ConnectionInterface $connection, DaemonServerRepository $serverRepository) { @@ -38,10 +35,6 @@ class DetailsModificationService /** * Update the details for a single server instance. * - * @param \Pterodactyl\Models\Server $server - * @param array $data - * @return \Pterodactyl\Models\Server - * * @throws \Throwable */ public function handle(Server $server, array $data): Server diff --git a/app/Services/Servers/EnvironmentService.php b/app/Services/Servers/EnvironmentService.php index 6f7b590f7..54b82bab3 100644 --- a/app/Services/Servers/EnvironmentService.php +++ b/app/Services/Servers/EnvironmentService.php @@ -15,9 +15,6 @@ class EnvironmentService /** * Dynamically configure additional environment variables to be assigned * with a specific server. - * - * @param string $key - * @param callable $closure */ public function setEnvironmentKey(string $key, callable $closure) { @@ -26,8 +23,6 @@ class EnvironmentService /** * Return the dynamically added additional keys. - * - * @return array */ public function getEnvironmentKeys(): array { @@ -37,9 +32,6 @@ class EnvironmentService /** * Take all of the environment variables configured for this server and return * them in an easy to process format. - * - * @param \Pterodactyl\Models\Server $server - * @return array */ public function handle(Server $server): array { @@ -57,7 +49,8 @@ class EnvironmentService // Process variables set in the configuration file. foreach (config('pterodactyl.environment_variables', []) as $key => $object) { $variables->put( - $key, is_callable($object) ? call_user_func($object, $server) : object_get($server, $object) + $key, + is_callable($object) ? call_user_func($object, $server) : object_get($server, $object) ); } @@ -71,8 +64,6 @@ class EnvironmentService /** * Return a mapping of Panel default environment variables. - * - * @return array */ private function getEnvironmentMappings(): array { diff --git a/app/Services/Servers/GetUserPermissionsService.php b/app/Services/Servers/GetUserPermissionsService.php index 80ce35b52..fdac03bfd 100644 --- a/app/Services/Servers/GetUserPermissionsService.php +++ b/app/Services/Servers/GetUserPermissionsService.php @@ -12,8 +12,6 @@ class GetUserPermissionsService * if they are an admin or a subuser for the server. If no permissions are * found, an empty array is returned. * - * @param \Pterodactyl\Models\Server $server - * @param \Pterodactyl\Models\User $user * @return string[] */ public function handle(Server $server, User $user) diff --git a/app/Services/Servers/ReinstallServerService.php b/app/Services/Servers/ReinstallServerService.php index 6f5b56083..cfb880455 100644 --- a/app/Services/Servers/ReinstallServerService.php +++ b/app/Services/Servers/ReinstallServerService.php @@ -4,7 +4,6 @@ namespace Pterodactyl\Services\Servers; use Pterodactyl\Models\Server; use Illuminate\Database\ConnectionInterface; -use Pterodactyl\Repositories\Eloquent\ServerRepository; use Pterodactyl\Repositories\Wings\DaemonServerRepository; class ReinstallServerService @@ -21,9 +20,6 @@ class ReinstallServerService /** * ReinstallService constructor. - * - * @param \Illuminate\Database\ConnectionInterface $connection - * @param \Pterodactyl\Repositories\Wings\DaemonServerRepository $daemonServerRepository */ public function __construct( ConnectionInterface $connection, @@ -36,7 +32,6 @@ class ReinstallServerService /** * Reinstall a server on the remote daemon. * - * @param \Pterodactyl\Models\Server $server * @return \Pterodactyl\Models\Server * * @throws \Throwable diff --git a/app/Services/Servers/ServerConfigurationStructureService.php b/app/Services/Servers/ServerConfigurationStructureService.php index b942a270a..0972a4180 100644 --- a/app/Services/Servers/ServerConfigurationStructureService.php +++ b/app/Services/Servers/ServerConfigurationStructureService.php @@ -28,10 +28,7 @@ class ServerConfigurationStructureService * DO NOT MODIFY THIS FUNCTION. This powers legacy code handling for the new Wings * daemon, if you modify the structure eggs will break unexpectedly. * - * @param \Pterodactyl\Models\Server $server - * @param array $override * @param bool $legacy deprecated - * @return array */ public function handle(Server $server, array $override = [], bool $legacy = false): array { @@ -53,7 +50,6 @@ class ServerConfigurationStructureService /** * Returns the new data format used for the Wings daemon. * - * @param \Pterodactyl\Models\Server $server * @return array */ protected function returnCurrentFormat(Server $server) @@ -95,10 +91,10 @@ class ServerConfigurationStructureService 'id' => $server->egg->uuid, 'file_denylist' => [ 'config.yml', - '**/*.json' - ] + '**/*.json', + ], // 'file_denylist' => explode(PHP_EOL, $server->egg->inherit_file_denylist), - ] + ], ]; } @@ -106,8 +102,8 @@ class ServerConfigurationStructureService * Returns the legacy server data format to continue support for old egg configurations * that have not yet been updated. * - * @param \Pterodactyl\Models\Server $server * @return array + * * @deprecated */ protected function returnLegacyFormat(Server $server) @@ -124,12 +120,12 @@ class ServerConfigurationStructureService })->toArray(), 'env' => $this->environment->handle($server), 'oom_disabled' => $server->oom_disabled, - 'memory' => (int)$server->memory, - 'swap' => (int)$server->swap, - 'io' => (int)$server->io, - 'cpu' => (int)$server->cpu, + 'memory' => (int) $server->memory, + 'swap' => (int) $server->swap, + 'io' => (int) $server->io, + 'cpu' => (int) $server->cpu, 'threads' => $server->threads, - 'disk' => (int)$server->disk, + 'disk' => (int) $server->disk, 'image' => $server->image, ], 'service' => [ @@ -137,7 +133,7 @@ class ServerConfigurationStructureService 'skip_scripts' => $server->skip_scripts, ], 'rebuild' => false, - 'suspended' => (int)$server->suspended, + 'suspended' => (int) $server->suspended, ]; } } diff --git a/app/Services/Servers/ServerCreationService.php b/app/Services/Servers/ServerCreationService.php index 76d371ab2..d7d533638 100644 --- a/app/Services/Servers/ServerCreationService.php +++ b/app/Services/Servers/ServerCreationService.php @@ -75,16 +75,9 @@ class ServerCreationService /** * CreationService constructor. * - * @param \Pterodactyl\Services\Deployment\AllocationSelectionService $allocationSelectionService - * @param \Illuminate\Database\ConnectionInterface $connection - * @param \Pterodactyl\Repositories\Wings\DaemonServerRepository $daemonServerRepository - * @param \Pterodactyl\Repositories\Eloquent\EggRepository $eggRepository - * @param \Pterodactyl\Services\Deployment\FindViableNodesService $findViableNodesService * @param \Pterodactyl\Services\Servers\ServerConfigurationStructureService $configurationStructureService - * @param \Pterodactyl\Services\Servers\ServerDeletionService $serverDeletionService - * @param \Pterodactyl\Repositories\Eloquent\ServerRepository $repository - * @param \Pterodactyl\Repositories\Eloquent\ServerVariableRepository $serverVariableRepository - * @param \Pterodactyl\Services\Servers\VariableValidatorService $validatorService + * @param \Pterodactyl\Services\Servers\ServerDeletionService $serverDeletionService + * @param \Pterodactyl\Services\Servers\VariableValidatorService $validatorService */ public function __construct( AllocationSelectionService $allocationSelectionService, @@ -116,10 +109,6 @@ class ServerCreationService * as possible given the input data. For example, if an allocation_id is passed with * no node_id the node_is will be picked from the allocation. * - * @param array $data - * @param \Pterodactyl\Models\Objects\DeploymentObject|null $deployment - * @return \Pterodactyl\Models\Server - * * @throws \Throwable * @throws \Pterodactyl\Exceptions\DisplayException * @throws \Illuminate\Validation\ValidationException @@ -187,10 +176,6 @@ class ServerCreationService /** * Gets an allocation to use for automatic deployment. * - * @param array $data - * @param \Pterodactyl\Models\Objects\DeploymentObject $deployment - * - * @return \Pterodactyl\Models\Allocation * @throws \Pterodactyl\Exceptions\DisplayException * @throws \Pterodactyl\Exceptions\Service\Deployment\NoViableAllocationException * @throws \Pterodactyl\Exceptions\Service\Deployment\NoViableNodeException @@ -212,9 +197,6 @@ class ServerCreationService /** * Store the server in the database and return the model. * - * @param array $data - * @return \Pterodactyl\Models\Server - * * @throws \Pterodactyl\Exceptions\Model\DataValidationException */ private function createModel(array $data): Server @@ -254,9 +236,6 @@ class ServerCreationService /** * Configure the allocations assigned to this server. - * - * @param \Pterodactyl\Models\Server $server - * @param array $data */ private function storeAssignedAllocations(Server $server, array $data) { @@ -272,9 +251,6 @@ class ServerCreationService /** * Process environment variables passed for this server and store them in the database. - * - * @param \Pterodactyl\Models\Server $server - * @param \Illuminate\Support\Collection $variables */ private function storeEggVariables(Server $server, Collection $variables) { @@ -286,21 +262,19 @@ class ServerCreationService ]; })->toArray(); - if (! empty($records)) { + if (!empty($records)) { $this->serverVariableRepository->insert($records); } } /** * Create a unique UUID and UUID-Short combo for a server. - * - * @return string */ private function generateUniqueUuidCombo(): string { $uuid = Uuid::uuid4()->toString(); - if (! $this->repository->isUniqueUuidCombo($uuid, substr($uuid, 0, 8))) { + if (!$this->repository->isUniqueUuidCombo($uuid, substr($uuid, 0, 8))) { return $this->generateUniqueUuidCombo(); } diff --git a/app/Services/Servers/ServerDeletionService.php b/app/Services/Servers/ServerDeletionService.php index 95585873b..cc973ff84 100644 --- a/app/Services/Servers/ServerDeletionService.php +++ b/app/Services/Servers/ServerDeletionService.php @@ -35,10 +35,6 @@ class ServerDeletionService /** * DeletionService constructor. - * - * @param \Illuminate\Database\ConnectionInterface $connection - * @param \Pterodactyl\Repositories\Wings\DaemonServerRepository $daemonServerRepository - * @param \Pterodactyl\Services\Databases\DatabaseManagementService $databaseManagementService */ public function __construct( ConnectionInterface $connection, @@ -54,6 +50,7 @@ class ServerDeletionService * Set if the server should be forcibly deleted from the panel (ignoring daemon errors) or not. * * @param bool $bool + * * @return $this */ public function withForce($bool = true) @@ -66,8 +63,6 @@ class ServerDeletionService /** * Delete a server from the panel and remove any associated databases from hosts. * - * @param \Pterodactyl\Models\Server $server - * * @throws \Throwable * @throws \Pterodactyl\Exceptions\DisplayException */ @@ -80,7 +75,7 @@ class ServerDeletionService // go ahead and bail out. We specifically ignore a 404 since that can be assumed // to be a safe error, meaning the server doesn't exist at all on Wings so there // is no reason we need to bail out from that. - if (! $this->force && $exception->getStatusCode() !== Response::HTTP_NOT_FOUND) { + if (!$this->force && $exception->getStatusCode() !== Response::HTTP_NOT_FOUND) { throw $exception; } diff --git a/app/Services/Servers/StartupCommandService.php b/app/Services/Servers/StartupCommandService.php index bf31763cc..efdbbc5c4 100644 --- a/app/Services/Servers/StartupCommandService.php +++ b/app/Services/Servers/StartupCommandService.php @@ -8,10 +8,6 @@ class StartupCommandService { /** * Generates a startup command for a given server instance. - * - * @param \Pterodactyl\Models\Server $server - * @param bool $hideAllValues - * @return string */ public function handle(Server $server, bool $hideAllValues = false): string { diff --git a/app/Services/Servers/StartupModificationService.php b/app/Services/Servers/StartupModificationService.php index f154c54bd..66645e4f2 100644 --- a/app/Services/Servers/StartupModificationService.php +++ b/app/Services/Servers/StartupModificationService.php @@ -27,7 +27,6 @@ class StartupModificationService /** * StartupModificationService constructor. * - * @param \Illuminate\Database\ConnectionInterface $connection * @param \Pterodactyl\Services\Servers\VariableValidatorService $validatorService */ public function __construct(ConnectionInterface $connection, VariableValidatorService $validatorService) @@ -39,16 +38,12 @@ class StartupModificationService /** * Process startup modification for a server. * - * @param \Pterodactyl\Models\Server $server - * @param array $data - * @return \Pterodactyl\Models\Server - * * @throws \Throwable */ public function handle(Server $server, array $data): Server { return $this->connection->transaction(function () use ($server, $data) { - if (! empty($data['environment'])) { + if (!empty($data['environment'])) { $egg = $this->isUserLevel(User::USER_LEVEL_ADMIN) ? ($data['egg_id'] ?? $server->egg_id) : $server->egg_id; $results = $this->validatorService @@ -83,15 +78,12 @@ class StartupModificationService /** * Update certain administrative settings for a server in the DB. - * - * @param array $data - * @param \Pterodactyl\Models\Server $server */ protected function updateAdministrativeSettings(array $data, Server &$server) { $eggId = Arr::get($data, 'egg_id'); - if (is_digit($eggId) && $server->egg_id !== (int)$eggId) { + if (is_digit($eggId) && $server->egg_id !== (int) $eggId) { /** @var \Pterodactyl\Models\Egg $egg */ $egg = Egg::query()->findOrFail($data['egg_id']); diff --git a/app/Services/Servers/SuspensionService.php b/app/Services/Servers/SuspensionService.php index 87fd0a334..f58fa098a 100644 --- a/app/Services/Servers/SuspensionService.php +++ b/app/Services/Servers/SuspensionService.php @@ -6,13 +6,12 @@ use Webmozart\Assert\Assert; use Pterodactyl\Models\Server; use Illuminate\Database\ConnectionInterface; use Pterodactyl\Repositories\Wings\DaemonServerRepository; -use Symfony\Component\HttpKernel\Exception\ConflictHttpException; use Pterodactyl\Exceptions\Http\Server\ServerTransferringException; class SuspensionService { - const ACTION_SUSPEND = 'suspend'; - const ACTION_UNSUSPEND = 'unsuspend'; + public const ACTION_SUSPEND = 'suspend'; + public const ACTION_UNSUSPEND = 'unsuspend'; /** * @var \Illuminate\Database\ConnectionInterface @@ -26,9 +25,6 @@ class SuspensionService /** * SuspensionService constructor. - * - * @param \Illuminate\Database\ConnectionInterface $connection - * @param \Pterodactyl\Repositories\Wings\DaemonServerRepository $daemonServerRepository */ public function __construct( ConnectionInterface $connection, @@ -41,7 +37,6 @@ class SuspensionService /** * Suspends a server on the system. * - * @param \Pterodactyl\Models\Server $server * @param string $action * * @throws \Throwable @@ -59,8 +54,8 @@ class SuspensionService } // Check if the server is currently being transferred. - if (! is_null($server->transfer)) { - throw new ServerTransferringException; + if (!is_null($server->transfer)) { + throw new ServerTransferringException(); } $this->connection->transaction(function () use ($action, $server) { diff --git a/app/Services/Servers/TransferService.php b/app/Services/Servers/TransferService.php index b45a78dc8..35aed0659 100644 --- a/app/Services/Servers/TransferService.php +++ b/app/Services/Servers/TransferService.php @@ -20,9 +20,6 @@ class TransferService /** * TransferService constructor. - * - * @param \Pterodactyl\Repositories\Wings\DaemonServerRepository $daemonServerRepository - * @param \Pterodactyl\Contracts\Repository\ServerRepositoryInterface $repository */ public function __construct( DaemonServerRepository $daemonServerRepository, diff --git a/app/Services/Servers/VariableValidatorService.php b/app/Services/Servers/VariableValidatorService.php index 7cb1aa427..2ac3879a5 100644 --- a/app/Services/Servers/VariableValidatorService.php +++ b/app/Services/Servers/VariableValidatorService.php @@ -27,8 +27,6 @@ class VariableValidatorService /** * VariableValidatorService constructor. - * - * @param \Illuminate\Contracts\Validation\Factory $validator */ public function __construct(ValidationFactory $validator) { @@ -38,15 +36,12 @@ class VariableValidatorService /** * Validate all of the passed data against the given service option variables. * - * @param int $egg - * @param array $fields - * @return \Illuminate\Support\Collection * @throws \Illuminate\Validation\ValidationException */ public function handle(int $egg, array $fields = []): Collection { $query = EggVariable::query()->where('egg_id', $egg); - if (! $this->isUserLevel(User::USER_LEVEL_ADMIN)) { + if (!$this->isUserLevel(User::USER_LEVEL_ADMIN)) { // Don't attempt to validate variables if they aren't user editable // and we're not running this at an admin level. $query = $query->where('user_editable', true)->where('user_viewable', true); @@ -68,7 +63,7 @@ class VariableValidatorService } return Collection::make($variables)->map(function ($item) use ($fields) { - return (object)[ + return (object) [ 'id' => $item->id, 'key' => $item->env_variable, 'value' => $fields[$item->env_variable] ?? null, diff --git a/app/Services/Subusers/SubuserCreationService.php b/app/Services/Subusers/SubuserCreationService.php index 5efc700fe..b1affd3f3 100644 --- a/app/Services/Subusers/SubuserCreationService.php +++ b/app/Services/Subusers/SubuserCreationService.php @@ -37,11 +37,6 @@ class SubuserCreationService /** * SubuserCreationService constructor. - * - * @param \Illuminate\Database\ConnectionInterface $connection - * @param \Pterodactyl\Repositories\Eloquent\SubuserRepository $subuserRepository - * @param \Pterodactyl\Services\Users\UserCreationService $userCreationService - * @param \Pterodactyl\Contracts\Repository\UserRepositoryInterface $userRepository */ public function __construct( ConnectionInterface $connection, @@ -60,11 +55,6 @@ class SubuserCreationService * If the email address already belongs to a user on the system a new user will not * be created. * - * @param \Pterodactyl\Models\Server $server - * @param string $email - * @param array $permissions - * @return \Pterodactyl\Models\Subuser - * * @throws \Pterodactyl\Exceptions\Model\DataValidationException * @throws \Pterodactyl\Exceptions\Service\Subuser\ServerSubuserExistsException * @throws \Pterodactyl\Exceptions\Service\Subuser\UserIsServerOwnerException diff --git a/app/Services/Users/ToggleTwoFactorService.php b/app/Services/Users/ToggleTwoFactorService.php index f8b41b454..908fc35d6 100644 --- a/app/Services/Users/ToggleTwoFactorService.php +++ b/app/Services/Users/ToggleTwoFactorService.php @@ -41,12 +41,6 @@ class ToggleTwoFactorService /** * ToggleTwoFactorService constructor. - * - * @param \Illuminate\Database\ConnectionInterface $connection - * @param \Illuminate\Contracts\Encryption\Encrypter $encrypter - * @param \PragmaRX\Google2FA\Google2FA $google2FA - * @param \Pterodactyl\Repositories\Eloquent\RecoveryTokenRepository $recoveryTokenRepository - * @param \Pterodactyl\Contracts\Repository\UserRepositoryInterface $repository */ public function __construct( ConnectionInterface $connection, @@ -65,9 +59,6 @@ class ToggleTwoFactorService /** * Toggle 2FA on an account only if the token provided is valid. * - * @param \Pterodactyl\Models\User $user - * @param string $token - * @param bool|null $toggleState * @return string[] * * @throws \Throwable @@ -82,7 +73,7 @@ class ToggleTwoFactorService $isValidToken = $this->google2FA->verifyKey($secret, $token, config()->get('pterodactyl.auth.2fa.window')); - if (! $isValidToken) { + if (!$isValidToken) { throw new TwoFactorAuthenticationTokenInvalid('The token provided is not valid.'); } @@ -95,9 +86,9 @@ class ToggleTwoFactorService // which will then be marked as deleted from the database and will also bypass 2FA protections // on their account. $tokens = []; - if ((! $toggleState && ! $user->use_totp) || $toggleState) { + if ((!$toggleState && !$user->use_totp) || $toggleState) { $inserts = []; - for ($i = 0; $i < 10; $i++) { + for ($i = 0; $i < 10; ++$i) { $token = Str::random(10); $inserts[] = [ @@ -118,7 +109,7 @@ class ToggleTwoFactorService $this->repository->withoutFreshModel()->update($user->id, [ 'totp_authenticated_at' => Carbon::now(), - 'use_totp' => (is_null($toggleState) ? ! $user->use_totp : $toggleState), + 'use_totp' => (is_null($toggleState) ? !$user->use_totp : $toggleState), ]); return $tokens; diff --git a/app/Services/Users/TwoFactorSetupService.php b/app/Services/Users/TwoFactorSetupService.php index 5dcb7879c..e3649634f 100644 --- a/app/Services/Users/TwoFactorSetupService.php +++ b/app/Services/Users/TwoFactorSetupService.php @@ -11,7 +11,7 @@ use Illuminate\Contracts\Config\Repository as ConfigRepository; class TwoFactorSetupService { - const VALID_BASE32_CHARACTERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567'; + public const VALID_BASE32_CHARACTERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567'; /** * @var \Illuminate\Contracts\Config\Repository @@ -30,10 +30,6 @@ class TwoFactorSetupService /** * TwoFactorSetupService constructor. - * - * @param \Illuminate\Contracts\Config\Repository $config - * @param \Illuminate\Contracts\Encryption\Encrypter $encrypter - * @param \Pterodactyl\Contracts\Repository\UserRepositoryInterface $repository */ public function __construct( ConfigRepository $config, @@ -50,9 +46,6 @@ class TwoFactorSetupService * QR code URL. This URL will need to be attached to a QR generating service in * order to function. * - * @param \Pterodactyl\Models\User $user - * @return string - * * @throws \Pterodactyl\Exceptions\Model\DataValidationException * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ @@ -60,7 +53,7 @@ class TwoFactorSetupService { $secret = ''; try { - for ($i = 0; $i < $this->config->get('pterodactyl.auth.2fa.bytes', 16); $i++) { + for ($i = 0; $i < $this->config->get('pterodactyl.auth.2fa.bytes', 16); ++$i) { $secret .= substr(self::VALID_BASE32_CHARACTERS, random_int(0, 31), 1); } } catch (Exception $exception) { diff --git a/app/Services/Users/UserCreationService.php b/app/Services/Users/UserCreationService.php index 5bc56dd40..2d0abcb9f 100644 --- a/app/Services/Users/UserCreationService.php +++ b/app/Services/Users/UserCreationService.php @@ -33,11 +33,6 @@ class UserCreationService /** * CreationService constructor. - * - * @param \Illuminate\Database\ConnectionInterface $connection - * @param \Illuminate\Contracts\Hashing\Hasher $hasher - * @param \Illuminate\Contracts\Auth\PasswordBroker $passwordBroker - * @param \Pterodactyl\Contracts\Repository\UserRepositoryInterface $repository */ public function __construct( ConnectionInterface $connection, @@ -54,7 +49,6 @@ class UserCreationService /** * Create a new user on the system. * - * @param array $data * @return \Pterodactyl\Models\User * * @throws \Exception @@ -62,12 +56,12 @@ class UserCreationService */ public function handle(array $data) { - if (array_key_exists('password', $data) && ! empty($data['password'])) { + if (array_key_exists('password', $data) && !empty($data['password'])) { $data['password'] = $this->hasher->make($data['password']); } $this->connection->beginTransaction(); - if (! isset($data['password']) || empty($data['password'])) { + if (!isset($data['password']) || empty($data['password'])) { $generateResetToken = true; $data['password'] = $this->hasher->make(str_random(30)); } diff --git a/app/Services/Users/UserDeletionService.php b/app/Services/Users/UserDeletionService.php index fd5196821..87459773e 100644 --- a/app/Services/Users/UserDeletionService.php +++ b/app/Services/Users/UserDeletionService.php @@ -34,10 +34,6 @@ class UserDeletionService /** * DeletionService constructor. - * - * @param \Pterodactyl\Contracts\Repository\ServerRepositoryInterface $serverRepository - * @param \Illuminate\Contracts\Translation\Translator $translator - * @param \Pterodactyl\Contracts\Repository\UserRepositoryInterface $repository */ public function __construct( ServerRepositoryInterface $serverRepository, @@ -53,6 +49,7 @@ class UserDeletionService * Delete a user from the panel only if they have no servers attached to their account. * * @param int|\Pterodactyl\Models\User $user + * * @return bool|null * * @throws \Pterodactyl\Exceptions\DisplayException diff --git a/app/Services/Users/UserUpdateService.php b/app/Services/Users/UserUpdateService.php index 4e1911a32..0c7e1c172 100644 --- a/app/Services/Users/UserUpdateService.php +++ b/app/Services/Users/UserUpdateService.php @@ -23,9 +23,6 @@ class UserUpdateService /** * UpdateService constructor. - * - * @param \Illuminate\Contracts\Hashing\Hasher $hasher - * @param \Pterodactyl\Repositories\Eloquent\UserRepository $repository */ public function __construct(Hasher $hasher, UserRepository $repository) { @@ -36,8 +33,6 @@ class UserUpdateService /** * Update the user model instance. * - * @param \Pterodactyl\Models\User $user - * @param array $data * @return \Pterodactyl\Models\User * * @throws \Pterodactyl\Exceptions\Model\DataValidationException @@ -45,7 +40,7 @@ class UserUpdateService */ public function handle(User $user, array $data) { - if (! empty(array_get($data, 'password'))) { + if (!empty(array_get($data, 'password'))) { $data['password'] = $this->hasher->make($data['password']); } else { unset($data['password']); diff --git a/app/Traits/Commands/EnvironmentWriterTrait.php b/app/Traits/Commands/EnvironmentWriterTrait.php index 6726e931f..10692a9a4 100644 --- a/app/Traits/Commands/EnvironmentWriterTrait.php +++ b/app/Traits/Commands/EnvironmentWriterTrait.php @@ -16,14 +16,12 @@ trait EnvironmentWriterTrait /** * Update the .env file for the application using the passed in values. * - * @param array $values - * * @throws \Pterodactyl\Exceptions\PterodactylException */ public function writeToEnvironment(array $values = []) { $path = base_path('.env'); - if (! file_exists($path)) { + if (!file_exists($path)) { throw new PterodactylException('Cannot locate .env file, was this software installed correctly?'); } @@ -33,7 +31,7 @@ trait EnvironmentWriterTrait // If the key value is not sorrounded by quotation marks, and contains anything that could reasonably // cause environment parsing issues, wrap it in quotes before writing it. This also adds slashes to the // value to ensure quotes within it don't cause us issues. - if (! preg_match('/^\"(.*)\"$/', $value) && preg_match('/([^\w.\-+\/])+/', $value)) { + if (!preg_match('/^\"(.*)\"$/', $value) && preg_match('/([^\w.\-+\/])+/', $value)) { $value = sprintf('"%s"', addslashes($value)); } diff --git a/app/Traits/Controllers/JavascriptInjection.php b/app/Traits/Controllers/JavascriptInjection.php index 556c99550..4e7e0a120 100644 --- a/app/Traits/Controllers/JavascriptInjection.php +++ b/app/Traits/Controllers/JavascriptInjection.php @@ -22,7 +22,6 @@ trait JavascriptInjection /** * Set the request object to use when injecting JS. * - * @param \Illuminate\Http\Request $request * @return $this */ public function setRequest(Request $request) @@ -36,6 +35,7 @@ trait JavascriptInjection * Injects the exact array passed in, nothing more. * * @param array $args + * * @return array */ public function plainInject($args = []) diff --git a/app/Traits/Helpers/AvailableLanguages.php b/app/Traits/Helpers/AvailableLanguages.php index f44771f6d..479722976 100644 --- a/app/Traits/Helpers/AvailableLanguages.php +++ b/app/Traits/Helpers/AvailableLanguages.php @@ -22,7 +22,6 @@ trait AvailableLanguages * that are present in the language folder. * * @param bool $localize - * @return array */ public function getAvailableLanguages($localize = false): array { @@ -36,8 +35,6 @@ trait AvailableLanguages /** * Return an instance of the filesystem for getting a folder listing. - * - * @return \Illuminate\Filesystem\Filesystem */ private function getFilesystemInstance(): Filesystem { @@ -46,8 +43,6 @@ trait AvailableLanguages /** * Return an instance of the ISO639 class for generating names. - * - * @return \Matriphe\ISO639\ISO639 */ private function getIsoInstance(): ISO639 { diff --git a/app/Traits/Services/HasUserLevels.php b/app/Traits/Services/HasUserLevels.php index 29e49e8e6..293e7fce7 100644 --- a/app/Traits/Services/HasUserLevels.php +++ b/app/Traits/Services/HasUserLevels.php @@ -14,7 +14,6 @@ trait HasUserLevels /** * Set the access level for running this function. * - * @param int $level * @return $this */ public function setUserLevel(int $level) @@ -26,8 +25,6 @@ trait HasUserLevels /** * Determine which level this function is running at. - * - * @return int */ public function getUserLevel(): int { @@ -36,9 +33,6 @@ trait HasUserLevels /** * Determine if the current user level is set to a specific level. - * - * @param int $level - * @return bool */ public function isUserLevel(int $level): bool { diff --git a/app/Traits/Services/ReturnsUpdatedModels.php b/app/Traits/Services/ReturnsUpdatedModels.php index 2d5ee64fd..07e4f4fde 100644 --- a/app/Traits/Services/ReturnsUpdatedModels.php +++ b/app/Traits/Services/ReturnsUpdatedModels.php @@ -22,8 +22,6 @@ trait ReturnsUpdatedModels * for API calls, but is unnecessary for UI based updates where the page is * being reloaded and a fresh model will be pulled anyways. * - * @param bool $toggle - * * @return $this */ public function returnUpdatedModel(bool $toggle = true) diff --git a/app/Traits/Services/ValidatesValidationRules.php b/app/Traits/Services/ValidatesValidationRules.php index d2010c828..f4c1ea188 100644 --- a/app/Traits/Services/ValidatesValidationRules.php +++ b/app/Traits/Services/ValidatesValidationRules.php @@ -9,9 +9,6 @@ use Pterodactyl\Exceptions\Service\Egg\Variable\BadValidationRuleException; trait ValidatesValidationRules { - /** - * @return \Illuminate\Contracts\Validation\Factory - */ abstract protected function getValidator(): Factory; /** @@ -29,9 +26,7 @@ trait ValidatesValidationRules } catch (BadMethodCallException $exception) { $matches = []; if (preg_match('/Method \[(.+)\] does not exist\./', $exception->getMessage(), $matches)) { - throw new BadValidationRuleException(trans('exceptions.nest.variables.bad_validation_rule', [ - 'rule' => Str::snake(str_replace('validate', '', array_get($matches, 1, 'unknownRule'))), - ]), $exception); + throw new BadValidationRuleException(trans('exceptions.nest.variables.bad_validation_rule', ['rule' => Str::snake(str_replace('validate', '', array_get($matches, 1, 'unknownRule')))]), $exception); } throw $exception; diff --git a/app/Transformers/Api/Application/BaseTransformer.php b/app/Transformers/Api/Application/BaseTransformer.php index 4e8d5f7ac..e6747b107 100644 --- a/app/Transformers/Api/Application/BaseTransformer.php +++ b/app/Transformers/Api/Application/BaseTransformer.php @@ -2,7 +2,7 @@ namespace Pterodactyl\Transformers\Api\Application; -use Cake\Chronos\Chronos; +use Carbon\CarbonImmutable; use Pterodactyl\Models\ApiKey; use Illuminate\Container\Container; use Illuminate\Database\Eloquent\Model; @@ -15,7 +15,7 @@ use Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException; */ abstract class BaseTransformer extends TransformerAbstract { - const RESPONSE_TIMEZONE = 'UTC'; + public const RESPONSE_TIMEZONE = 'UTC'; /** * @var \Pterodactyl\Models\ApiKey @@ -145,7 +145,7 @@ abstract class BaseTransformer extends TransformerAbstract */ protected function formatTimestamp(string $timestamp): string { - return Chronos::createFromFormat(Chronos::DEFAULT_TO_STRING_FORMAT, $timestamp) + return CarbonImmutable::createFromFormat(CarbonImmutable::DEFAULT_TO_STRING_FORMAT, $timestamp) ->setTimezone(self::RESPONSE_TIMEZONE) ->toIso8601String(); } diff --git a/app/Transformers/Api/Application/DatabaseHostTransformer.php b/app/Transformers/Api/Application/DatabaseHostTransformer.php index 2cabb0db6..46f0ab343 100644 --- a/app/Transformers/Api/Application/DatabaseHostTransformer.php +++ b/app/Transformers/Api/Application/DatabaseHostTransformer.php @@ -2,8 +2,6 @@ namespace Pterodactyl\Transformers\Api\Application; -use Cake\Chronos\Chronos; -use Pterodactyl\Models\Node; use Pterodactyl\Models\Database; use Pterodactyl\Models\DatabaseHost; use Pterodactyl\Services\Acl\Api\AdminAcl; @@ -13,7 +11,9 @@ class DatabaseHostTransformer extends BaseTransformer /** * @var array */ - protected $availableIncludes = ['databases', 'nodes']; + protected $availableIncludes = [ + 'databases', + ]; /** * Return the resource name for the JSONAPI output. @@ -29,7 +29,6 @@ class DatabaseHostTransformer extends BaseTransformer * Transform database host into a representation for the application API. * * @param \Pterodactyl\Models\DatabaseHost $model - * * @return array */ public function transform(DatabaseHost $model) @@ -41,62 +40,26 @@ class DatabaseHostTransformer extends BaseTransformer 'port' => $model->port, 'username' => $model->username, 'node' => $model->node_id, - 'created_at' => Chronos::createFromFormat(Chronos::DEFAULT_TO_STRING_FORMAT, $model->created_at) - ->setTimezone(config('app.timezone')) - ->toIso8601String(), - 'updated_at' => Chronos::createFromFormat(Chronos::DEFAULT_TO_STRING_FORMAT, $model->updated_at) - ->setTimezone(config('app.timezone')) - ->toIso8601String(), + 'created_at' => $model->created_at->toIso8601String(), + 'updated_at' => $model->updated_at->toIso8601String(), ]; } /** * Include the databases associated with this host. * - * @param \Pterodactyl\Models\DatabaseHost $model - * * @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource + * * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException - * @throws \Illuminate\Contracts\Container\BindingResolutionException */ public function includeDatabases(DatabaseHost $model) { - if (! $this->authorize(AdminAcl::RESOURCE_SERVER_DATABASES)) { + if (!$this->authorize(AdminAcl::RESOURCE_SERVER_DATABASES)) { return $this->null(); } $model->loadMissing('databases'); - return $this->collection( - $model->getRelation('databases'), - $this->makeTransformer(ServerDatabaseTransformer::class), - Database::RESOURCE_NAME - ); - } - - - - /** - * Return the nodes associated with this mount. - * - * @param \Pterodactyl\Models\Mount $mount - * - * @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource - * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException - * @throws \Illuminate\Contracts\Container\BindingResolutionException - */ - public function includeNodes(DatabaseHost $model) - { - if (!$this->authorize(AdminAcl::RESOURCE_NODES)) { - return $this->null(); - } - - $model->loadMissing('nodes'); - - return $this->collection( - $model->getRelation('nodes'), - $this->makeTransformer(NodeTransformer::class), - Node::RESOURCE_NAME - ); + return $this->collection($model->getRelation('databases'), $this->makeTransformer(ServerDatabaseTransformer::class), Database::RESOURCE_NAME); } } diff --git a/app/Transformers/Api/Application/EggTransformer.php b/app/Transformers/Api/Application/EggTransformer.php index 0e4c91d35..a4d3d6985 100644 --- a/app/Transformers/Api/Application/EggTransformer.php +++ b/app/Transformers/Api/Application/EggTransformer.php @@ -21,8 +21,6 @@ class EggTransformer extends BaseTransformer /** * Return the resource name for the JSONAPI output. - * - * @return string */ public function getResourceName(): string { @@ -33,8 +31,6 @@ class EggTransformer extends BaseTransformer * Transform an Egg model into a representation that can be consumed by * the application api. * - * @param \Pterodactyl\Models\Egg $model - * * @return array */ public function transform(Egg $model) @@ -75,15 +71,13 @@ class EggTransformer extends BaseTransformer /** * Include the Nest relationship for the given Egg in the transformation. * - * @param \Pterodactyl\Models\Egg $model - * * @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource + * * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException - * @throws \Illuminate\Contracts\Container\BindingResolutionException */ public function includeNest(Egg $model) { - if (! $this->authorize(AdminAcl::RESOURCE_NESTS)) { + if (!$this->authorize(AdminAcl::RESOURCE_NESTS)) { return $this->null(); } @@ -95,15 +89,13 @@ class EggTransformer extends BaseTransformer /** * Include the Servers relationship for the given Egg in the transformation. * - * @param \Pterodactyl\Models\Egg $model - * * @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource + * * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException - * @throws \Illuminate\Contracts\Container\BindingResolutionException */ public function includeServers(Egg $model) { - if (! $this->authorize(AdminAcl::RESOURCE_SERVERS)) { + if (!$this->authorize(AdminAcl::RESOURCE_SERVERS)) { return $this->null(); } @@ -116,8 +108,6 @@ class EggTransformer extends BaseTransformer * Include more detailed information about the configuration if this Egg is * extending another. * - * @param \Pterodactyl\Models\Egg $model - * * @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource */ public function includeConfig(Egg $model) @@ -142,8 +132,6 @@ class EggTransformer extends BaseTransformer * Include more detailed information about the script configuration if the * Egg is extending another. * - * @param \Pterodactyl\Models\Egg $model - * * @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource */ public function includeScript(Egg $model) @@ -167,15 +155,13 @@ class EggTransformer extends BaseTransformer /** * Include the variables that are defined for this Egg. * - * @param \Pterodactyl\Models\Egg $model - * * @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource + * * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException - * @throws \Illuminate\Contracts\Container\BindingResolutionException */ public function includeVariables(Egg $model) { - if (! $this->authorize(AdminAcl::RESOURCE_EGGS)) { + if (!$this->authorize(AdminAcl::RESOURCE_EGGS)) { return $this->null(); } diff --git a/app/Transformers/Api/Application/EggVariableTransformer.php b/app/Transformers/Api/Application/EggVariableTransformer.php index decb038ab..2088806d5 100644 --- a/app/Transformers/Api/Application/EggVariableTransformer.php +++ b/app/Transformers/Api/Application/EggVariableTransformer.php @@ -9,8 +9,6 @@ class EggVariableTransformer extends BaseTransformer { /** * Return the resource name for the JSONAPI output. - * - * @return string */ public function getResourceName(): string { diff --git a/app/Transformers/Api/Application/LocationTransformer.php b/app/Transformers/Api/Application/LocationTransformer.php index bd12916dc..c0ef249d7 100644 --- a/app/Transformers/Api/Application/LocationTransformer.php +++ b/app/Transformers/Api/Application/LocationTransformer.php @@ -16,8 +16,6 @@ class LocationTransformer extends BaseTransformer /** * Return the resource name for the JSONAPI output. - * - * @return string */ public function getResourceName(): string { @@ -26,9 +24,6 @@ class LocationTransformer extends BaseTransformer /** * Return a generic transformed location array. - * - * @param \Pterodactyl\Models\Location $model - * @return array */ public function transform(Location $model): array { @@ -44,14 +39,13 @@ class LocationTransformer extends BaseTransformer /** * Return the nodes associated with this location. * - * @param \Pterodactyl\Models\Location $location * @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource * * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException */ public function includeServers(Location $location) { - if (! $this->authorize(AdminAcl::RESOURCE_SERVERS)) { + if (!$this->authorize(AdminAcl::RESOURCE_SERVERS)) { return $this->null(); } @@ -63,14 +57,13 @@ class LocationTransformer extends BaseTransformer /** * Return the nodes associated with this location. * - * @param \Pterodactyl\Models\Location $location * @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource * * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException */ public function includeNodes(Location $location) { - if (! $this->authorize(AdminAcl::RESOURCE_NODES)) { + if (!$this->authorize(AdminAcl::RESOURCE_NODES)) { return $this->null(); } diff --git a/app/Transformers/Api/Application/NestTransformer.php b/app/Transformers/Api/Application/NestTransformer.php index 80154a682..506b0276b 100644 --- a/app/Transformers/Api/Application/NestTransformer.php +++ b/app/Transformers/Api/Application/NestTransformer.php @@ -20,8 +20,6 @@ class NestTransformer extends BaseTransformer /** * Return the resource name for the JSONAPI output. - * - * @return string */ public function getResourceName(): string { @@ -32,7 +30,6 @@ class NestTransformer extends BaseTransformer * Transform a Nest model into a representation that can be consumed by the * application API. * - * @param \Pterodactyl\Models\Nest $model * @return array */ public function transform(Nest $model) @@ -48,14 +45,13 @@ class NestTransformer extends BaseTransformer /** * Include the Eggs relationship on the given Nest model transformation. * - * @param \Pterodactyl\Models\Nest $model * @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource * * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException */ public function includeEggs(Nest $model) { - if (! $this->authorize(AdminAcl::RESOURCE_EGGS)) { + if (!$this->authorize(AdminAcl::RESOURCE_EGGS)) { return $this->null(); } @@ -67,14 +63,13 @@ class NestTransformer extends BaseTransformer /** * Include the servers relationship on the given Nest model. * - * @param \Pterodactyl\Models\Nest $model * @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource * * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException */ public function includeServers(Nest $model) { - if (! $this->authorize(AdminAcl::RESOURCE_SERVERS)) { + if (!$this->authorize(AdminAcl::RESOURCE_SERVERS)) { return $this->null(); } diff --git a/app/Transformers/Api/Application/NodeTransformer.php b/app/Transformers/Api/Application/NodeTransformer.php index 7fcea2b13..ec89b6202 100644 --- a/app/Transformers/Api/Application/NodeTransformer.php +++ b/app/Transformers/Api/Application/NodeTransformer.php @@ -16,8 +16,6 @@ class NodeTransformer extends BaseTransformer /** * Return the resource name for the JSONAPI output. - * - * @return string */ public function getResourceName(): string { @@ -27,10 +25,6 @@ class NodeTransformer extends BaseTransformer /** * Return a node transformed into a format that can be consumed by the * external administrative API. - * - * @param \Pterodactyl\Models\Node $model - * - * @return array */ public function transform(Node $model): array { @@ -58,66 +52,66 @@ class NodeTransformer extends BaseTransformer /** * Return the nodes associated with this location. * - * @param \Pterodactyl\Models\Node $node - * * @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource + * * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException - * @throws \Illuminate\Contracts\Container\BindingResolutionException */ public function includeAllocations(Node $node) { - if (! $this->authorize(AdminAcl::RESOURCE_ALLOCATIONS)) { + if (!$this->authorize(AdminAcl::RESOURCE_ALLOCATIONS)) { return $this->null(); } $node->loadMissing('allocations'); return $this->collection( - $node->getRelation('allocations'), $this->makeTransformer(AllocationTransformer::class), 'allocation' + $node->getRelation('allocations'), + $this->makeTransformer(AllocationTransformer::class), + 'allocation' ); } /** * Return the nodes associated with this location. * - * @param \Pterodactyl\Models\Node $node - * * @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource + * * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException - * @throws \Illuminate\Contracts\Container\BindingResolutionException */ public function includeLocation(Node $node) { - if (! $this->authorize(AdminAcl::RESOURCE_LOCATIONS)) { + if (!$this->authorize(AdminAcl::RESOURCE_LOCATIONS)) { return $this->null(); } $node->loadMissing('location'); return $this->item( - $node->getRelation('location'), $this->makeTransformer(LocationTransformer::class), 'location' + $node->getRelation('location'), + $this->makeTransformer(LocationTransformer::class), + 'location' ); } /** * Return the nodes associated with this location. * - * @param \Pterodactyl\Models\Node $node - * * @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource + * * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException - * @throws \Illuminate\Contracts\Container\BindingResolutionException */ public function includeServers(Node $node) { - if (! $this->authorize(AdminAcl::RESOURCE_SERVERS)) { + if (!$this->authorize(AdminAcl::RESOURCE_SERVERS)) { return $this->null(); } $node->loadMissing('servers'); return $this->collection( - $node->getRelation('servers'), $this->makeTransformer(ServerTransformer::class), 'server' + $node->getRelation('servers'), + $this->makeTransformer(ServerTransformer::class), + 'server' ); } } diff --git a/app/Transformers/Api/Application/ServerDatabaseTransformer.php b/app/Transformers/Api/Application/ServerDatabaseTransformer.php index dd238375d..95180e2d9 100644 --- a/app/Transformers/Api/Application/ServerDatabaseTransformer.php +++ b/app/Transformers/Api/Application/ServerDatabaseTransformer.php @@ -2,7 +2,6 @@ namespace Pterodactyl\Transformers\Api\Application; -use Cake\Chronos\Chronos; use Pterodactyl\Models\Database; use Pterodactyl\Models\DatabaseHost; use Pterodactyl\Services\Acl\Api\AdminAcl; @@ -22,8 +21,6 @@ class ServerDatabaseTransformer extends BaseTransformer /** * Perform dependency injection. - * - * @param \Illuminate\Contracts\Encryption\Encrypter $encrypter */ public function handle(Encrypter $encrypter) { @@ -32,8 +29,6 @@ class ServerDatabaseTransformer extends BaseTransformer /** * Return the resource name for the JSONAPI output. - * - * @return string */ public function getResourceName(): string { @@ -42,9 +37,6 @@ class ServerDatabaseTransformer extends BaseTransformer /** * Transform a database model in a representation for the application API. - * - * @param \Pterodactyl\Models\Database $model - * @return array */ public function transform(Database $model): array { @@ -56,19 +48,14 @@ class ServerDatabaseTransformer extends BaseTransformer 'username' => $model->username, 'remote' => $model->remote, 'max_connections' => $model->max_connections, - 'created_at' => Chronos::createFromFormat(Chronos::DEFAULT_TO_STRING_FORMAT, $model->created_at) - ->setTimezone(config('app.timezone')) - ->toIso8601String(), - 'updated_at' => Chronos::createFromFormat(Chronos::DEFAULT_TO_STRING_FORMAT, $model->updated_at) - ->setTimezone(config('app.timezone')) - ->toIso8601String(), + 'created_at' => $model->created_at->toIso8601String(), + 'updated_at' => $model->updated_at->toIso8601String(), ]; } /** * Include the database password in the request. * - * @param \Pterodactyl\Models\Database $model * @return \League\Fractal\Resource\Item */ public function includePassword(Database $model) @@ -83,13 +70,13 @@ class ServerDatabaseTransformer extends BaseTransformer /** * Return the database host relationship for this server database. * - * @param \Pterodactyl\Models\Database $model * @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource + * * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException */ public function includeHost(Database $model) { - if (! $this->authorize(AdminAcl::RESOURCE_DATABASE_HOSTS)) { + if (!$this->authorize(AdminAcl::RESOURCE_DATABASE_HOSTS)) { return $this->null(); } diff --git a/app/Transformers/Api/Application/ServerTransformer.php b/app/Transformers/Api/Application/ServerTransformer.php index 53e3483da..ff776504c 100644 --- a/app/Transformers/Api/Application/ServerTransformer.php +++ b/app/Transformers/Api/Application/ServerTransformer.php @@ -33,8 +33,6 @@ class ServerTransformer extends BaseTransformer /** * Perform dependency injection. - * - * @param \Pterodactyl\Services\Servers\EnvironmentService $environmentService */ public function handle(EnvironmentService $environmentService) { @@ -43,8 +41,6 @@ class ServerTransformer extends BaseTransformer /** * Return the resource name for the JSONAPI output. - * - * @return string */ public function getResourceName(): string { @@ -53,10 +49,6 @@ class ServerTransformer extends BaseTransformer /** * Return a generic transformed server array. - * - * @param \Pterodactyl\Models\Server $model - * - * @return array */ public function transform(Server $model): array { @@ -108,16 +100,13 @@ class ServerTransformer extends BaseTransformer /** * Return a generic array of allocations for this server. * - * @param \Pterodactyl\Models\Server $server - * * @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource * * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException - * @throws \Illuminate\Contracts\Container\BindingResolutionException */ public function includeAllocations(Server $server) { - if (! $this->authorize(AdminAcl::RESOURCE_ALLOCATIONS)) { + if (!$this->authorize(AdminAcl::RESOURCE_ALLOCATIONS)) { return $this->null(); } @@ -129,16 +118,13 @@ class ServerTransformer extends BaseTransformer /** * Return a generic array of data about subusers for this server. * - * @param \Pterodactyl\Models\Server $server - * * @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource * * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException - * @throws \Illuminate\Contracts\Container\BindingResolutionException */ public function includeSubusers(Server $server) { - if (! $this->authorize(AdminAcl::RESOURCE_USERS)) { + if (!$this->authorize(AdminAcl::RESOURCE_USERS)) { return $this->null(); } @@ -150,16 +136,13 @@ class ServerTransformer extends BaseTransformer /** * Return a generic array of data about subusers for this server. * - * @param \Pterodactyl\Models\Server $server - * * @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource * * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException - * @throws \Illuminate\Contracts\Container\BindingResolutionException */ public function includeUser(Server $server) { - if (! $this->authorize(AdminAcl::RESOURCE_USERS)) { + if (!$this->authorize(AdminAcl::RESOURCE_USERS)) { return $this->null(); } @@ -171,16 +154,13 @@ class ServerTransformer extends BaseTransformer /** * Return a generic array with nest information for this server. * - * @param \Pterodactyl\Models\Server $server - * * @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource * * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException - * @throws \Illuminate\Contracts\Container\BindingResolutionException */ public function includeNest(Server $server) { - if (! $this->authorize(AdminAcl::RESOURCE_NESTS)) { + if (!$this->authorize(AdminAcl::RESOURCE_NESTS)) { return $this->null(); } @@ -192,16 +172,13 @@ class ServerTransformer extends BaseTransformer /** * Return a generic array with egg information for this server. * - * @param \Pterodactyl\Models\Server $server - * * @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource * * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException - * @throws \Illuminate\Contracts\Container\BindingResolutionException */ public function includeEgg(Server $server) { - if (! $this->authorize(AdminAcl::RESOURCE_EGGS)) { + if (!$this->authorize(AdminAcl::RESOURCE_EGGS)) { return $this->null(); } @@ -213,16 +190,13 @@ class ServerTransformer extends BaseTransformer /** * Return a generic array of data about subusers for this server. * - * @param \Pterodactyl\Models\Server $server - * * @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource * * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException - * @throws \Illuminate\Contracts\Container\BindingResolutionException */ public function includeVariables(Server $server) { - if (! $this->authorize(AdminAcl::RESOURCE_SERVERS)) { + if (!$this->authorize(AdminAcl::RESOURCE_SERVERS)) { return $this->null(); } @@ -234,16 +208,13 @@ class ServerTransformer extends BaseTransformer /** * Return a generic array with location information for this server. * - * @param \Pterodactyl\Models\Server $server - * * @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource * * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException - * @throws \Illuminate\Contracts\Container\BindingResolutionException */ public function includeLocation(Server $server) { - if (! $this->authorize(AdminAcl::RESOURCE_LOCATIONS)) { + if (!$this->authorize(AdminAcl::RESOURCE_LOCATIONS)) { return $this->null(); } @@ -255,16 +226,13 @@ class ServerTransformer extends BaseTransformer /** * Return a generic array with node information for this server. * - * @param \Pterodactyl\Models\Server $server - * * @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource * * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException - * @throws \Illuminate\Contracts\Container\BindingResolutionException */ public function includeNode(Server $server) { - if (! $this->authorize(AdminAcl::RESOURCE_NODES)) { + if (!$this->authorize(AdminAcl::RESOURCE_NODES)) { return $this->null(); } @@ -276,16 +244,13 @@ class ServerTransformer extends BaseTransformer /** * Return a generic array with database information for this server. * - * @param \Pterodactyl\Models\Server $server - * * @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource * * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException - * @throws \Illuminate\Contracts\Container\BindingResolutionException */ public function includeDatabases(Server $server) { - if (! $this->authorize(AdminAcl::RESOURCE_SERVER_DATABASES)) { + if (!$this->authorize(AdminAcl::RESOURCE_SERVER_DATABASES)) { return $this->null(); } diff --git a/app/Transformers/Api/Application/ServerVariableTransformer.php b/app/Transformers/Api/Application/ServerVariableTransformer.php index 3f7eeac49..aefa318e2 100644 --- a/app/Transformers/Api/Application/ServerVariableTransformer.php +++ b/app/Transformers/Api/Application/ServerVariableTransformer.php @@ -16,8 +16,6 @@ class ServerVariableTransformer extends BaseTransformer /** * Return the resource name for the JSONAPI output. - * - * @return string */ public function getResourceName(): string { @@ -27,7 +25,6 @@ class ServerVariableTransformer extends BaseTransformer /** * Return a generic transformed server variable array. * - * @param \Pterodactyl\Models\EggVariable $variable * @return array */ public function transform(EggVariable $variable) @@ -38,13 +35,13 @@ class ServerVariableTransformer extends BaseTransformer /** * Return the parent service variable data. * - * @param \Pterodactyl\Models\EggVariable $variable * @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource + * * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException */ public function includeParent(EggVariable $variable) { - if (! $this->authorize(AdminAcl::RESOURCE_EGGS)) { + if (!$this->authorize(AdminAcl::RESOURCE_EGGS)) { return $this->null(); } diff --git a/app/Transformers/Api/Application/SubuserTransformer.php b/app/Transformers/Api/Application/SubuserTransformer.php index 265e2f9d0..08c622666 100644 --- a/app/Transformers/Api/Application/SubuserTransformer.php +++ b/app/Transformers/Api/Application/SubuserTransformer.php @@ -3,7 +3,6 @@ namespace Pterodactyl\Transformers\Api\Application; use Pterodactyl\Models\Subuser; -use Pterodactyl\Models\Permission; use Pterodactyl\Services\Acl\Api\AdminAcl; class SubuserTransformer extends BaseTransformer @@ -17,8 +16,6 @@ class SubuserTransformer extends BaseTransformer /** * Return the resource name for the JSONAPI output. - * - * @return string */ public function getResourceName(): string { @@ -27,9 +24,6 @@ class SubuserTransformer extends BaseTransformer /** * Return a transformed Subuser model that can be consumed by external services. - * - * @param \Pterodactyl\Models\Subuser $subuser - * @return array */ public function transform(Subuser $subuser): array { @@ -46,14 +40,13 @@ class SubuserTransformer extends BaseTransformer /** * Return a generic item of user for this subuser. * - * @param \Pterodactyl\Models\Subuser $subuser * @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource * * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException */ public function includeUser(Subuser $subuser) { - if (! $this->authorize(AdminAcl::RESOURCE_USERS)) { + if (!$this->authorize(AdminAcl::RESOURCE_USERS)) { return $this->null(); } @@ -65,14 +58,13 @@ class SubuserTransformer extends BaseTransformer /** * Return a generic item of server for this subuser. * - * @param \Pterodactyl\Models\Subuser $subuser * @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource * * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException */ public function includeServer(Subuser $subuser) { - if (! $this->authorize(AdminAcl::RESOURCE_SERVERS)) { + if (!$this->authorize(AdminAcl::RESOURCE_SERVERS)) { return $this->null(); } diff --git a/app/Transformers/Api/Application/UserTransformer.php b/app/Transformers/Api/Application/UserTransformer.php index 3a4c859d0..c97ffe49b 100644 --- a/app/Transformers/Api/Application/UserTransformer.php +++ b/app/Transformers/Api/Application/UserTransformer.php @@ -16,8 +16,6 @@ class UserTransformer extends BaseTransformer /** * Return the resource name for the JSONAPI output. - * - * @return string */ public function getResourceName(): string { @@ -26,9 +24,6 @@ class UserTransformer extends BaseTransformer /** * Return a transformed User model that can be consumed by external services. - * - * @param \Pterodactyl\Models\User $model - * @return array */ public function transform(User $model): array { @@ -53,8 +48,6 @@ class UserTransformer extends BaseTransformer /** * Return the servers associated with this user. * - * @param \Pterodactyl\Models\User $user - * * @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource * * @throws \Illuminate\Contracts\Container\BindingResolutionException @@ -62,7 +55,7 @@ class UserTransformer extends BaseTransformer */ public function includeServers(User $user) { - if (! $this->authorize(AdminAcl::RESOURCE_SERVERS)) { + if (!$this->authorize(AdminAcl::RESOURCE_SERVERS)) { return $this->null(); } diff --git a/app/Transformers/Api/Client/AccountTransformer.php b/app/Transformers/Api/Client/AccountTransformer.php index 2cdc92e34..405a4208a 100644 --- a/app/Transformers/Api/Client/AccountTransformer.php +++ b/app/Transformers/Api/Client/AccountTransformer.php @@ -8,8 +8,6 @@ class AccountTransformer extends BaseClientTransformer { /** * Return the resource name for the JSONAPI output. - * - * @return string */ public function getResourceName(): string { @@ -19,7 +17,6 @@ class AccountTransformer extends BaseClientTransformer /** * Return basic information about the currently logged in user. * - * @param \Pterodactyl\Models\User $model * @return array */ public function transform(User $model) diff --git a/app/Transformers/Api/Client/AllocationTransformer.php b/app/Transformers/Api/Client/AllocationTransformer.php index 57f72eaf3..0d9bfec7c 100644 --- a/app/Transformers/Api/Client/AllocationTransformer.php +++ b/app/Transformers/Api/Client/AllocationTransformer.php @@ -8,8 +8,6 @@ class AllocationTransformer extends BaseClientTransformer { /** * Return the resource name for the JSONAPI output. - * - * @return string */ public function getResourceName(): string { @@ -19,7 +17,6 @@ class AllocationTransformer extends BaseClientTransformer /** * Return basic information about the currently logged in user. * - * @param \Pterodactyl\Models\Allocation $model * @return array */ public function transform(Allocation $model) diff --git a/app/Transformers/Api/Client/ApiKeyTransformer.php b/app/Transformers/Api/Client/ApiKeyTransformer.php index 4c30ea3a6..c7c39c2b4 100644 --- a/app/Transformers/Api/Client/ApiKeyTransformer.php +++ b/app/Transformers/Api/Client/ApiKeyTransformer.php @@ -17,7 +17,6 @@ class ApiKeyTransformer extends BaseClientTransformer /** * Transform this model into a representation that can be consumed by a client. * - * @param \Pterodactyl\Models\ApiKey $model * @return array */ public function transform(ApiKey $model) diff --git a/app/Transformers/Api/Client/BackupTransformer.php b/app/Transformers/Api/Client/BackupTransformer.php index d5acd41fe..fe341ff16 100644 --- a/app/Transformers/Api/Client/BackupTransformer.php +++ b/app/Transformers/Api/Client/BackupTransformer.php @@ -6,16 +6,12 @@ use Pterodactyl\Models\Backup; class BackupTransformer extends BaseClientTransformer { - /** - * @return string - */ public function getResourceName(): string { return Backup::RESOURCE_NAME; } /** - * @param \Pterodactyl\Models\Backup $backup * @return array */ public function transform(Backup $backup) diff --git a/app/Transformers/Api/Client/BaseClientTransformer.php b/app/Transformers/Api/Client/BaseClientTransformer.php index c15e583ec..efe53276f 100644 --- a/app/Transformers/Api/Client/BaseClientTransformer.php +++ b/app/Transformers/Api/Client/BaseClientTransformer.php @@ -18,8 +18,6 @@ abstract class BaseClientTransformer extends BaseApplicationTransformer /** * Return the user model of the user requesting this transformation. - * - * @return \Pterodactyl\Models\User */ public function getUser(): User { @@ -28,8 +26,6 @@ abstract class BaseClientTransformer extends BaseApplicationTransformer /** * Set the user model of the user requesting this transformation. - * - * @param \Pterodactyl\Models\User $user */ public function setUser(User $user) { @@ -41,9 +37,7 @@ abstract class BaseClientTransformer extends BaseApplicationTransformer * to access a different resource. This is used when including other * models on a transformation request. * - * @param string $ability * @param \Pterodactyl\Models\Server $server - * @return bool */ protected function authorize(string $ability, Server $server = null): bool { @@ -56,8 +50,6 @@ abstract class BaseClientTransformer extends BaseApplicationTransformer * Create a new instance of the transformer and pass along the currently * set API key. * - * @param string $abstract - * @param array $parameters * @return self * * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException @@ -68,7 +60,7 @@ abstract class BaseClientTransformer extends BaseApplicationTransformer $transformer = Container::getInstance()->makeWith($abstract, $parameters); $transformer->setKey($this->getKey()); - if (! $transformer instanceof self) { + if (!$transformer instanceof self) { throw new InvalidTransformerLevelException('Calls to ' . __METHOD__ . ' must return a transformer that is an instance of ' . __CLASS__); } diff --git a/app/Transformers/Api/Client/DatabaseTransformer.php b/app/Transformers/Api/Client/DatabaseTransformer.php index e63583deb..9c5bd86d4 100644 --- a/app/Transformers/Api/Client/DatabaseTransformer.php +++ b/app/Transformers/Api/Client/DatabaseTransformer.php @@ -23,9 +23,6 @@ class DatabaseTransformer extends BaseClientTransformer /** * Handle dependency injection. - * - * @param \Illuminate\Contracts\Encryption\Encrypter $encrypter - * @param \Pterodactyl\Contracts\Extensions\HashidsInterface $hashids */ public function handle(Encrypter $encrypter, HashidsInterface $hashids) { @@ -33,18 +30,11 @@ class DatabaseTransformer extends BaseClientTransformer $this->hashids = $hashids; } - /** - * @return string - */ public function getResourceName(): string { return Database::RESOURCE_NAME; } - /** - * @param \Pterodactyl\Models\Database $model - * @return array - */ public function transform(Database $model): array { $model->loadMissing('host'); @@ -65,12 +55,11 @@ class DatabaseTransformer extends BaseClientTransformer /** * Include the database password in the request. * - * @param \Pterodactyl\Models\Database $database * @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource */ public function includePassword(Database $database) { - if (! $this->getUser()->can(Permission::ACTION_DATABASE_VIEW_PASSWORD, $database->server)) { + if (!$this->getUser()->can(Permission::ACTION_DATABASE_VIEW_PASSWORD, $database->server)) { return $this->null(); } diff --git a/app/Transformers/Api/Client/EggTransformer.php b/app/Transformers/Api/Client/EggTransformer.php index ed5b8c585..25e135007 100644 --- a/app/Transformers/Api/Client/EggTransformer.php +++ b/app/Transformers/Api/Client/EggTransformer.php @@ -8,8 +8,6 @@ class EggTransformer extends BaseClientTransformer { /** * Return the resource name for the JSONAPI output. - * - * @return string */ public function getResourceName(): string { @@ -17,7 +15,6 @@ class EggTransformer extends BaseClientTransformer } /** - * @param \Pterodactyl\Models\Egg $egg * @return array */ public function transform(Egg $egg) diff --git a/app/Transformers/Api/Client/EggVariableTransformer.php b/app/Transformers/Api/Client/EggVariableTransformer.php index 4f7e39658..c7725b978 100644 --- a/app/Transformers/Api/Client/EggVariableTransformer.php +++ b/app/Transformers/Api/Client/EggVariableTransformer.php @@ -3,21 +3,16 @@ namespace Pterodactyl\Transformers\Api\Client; use BadMethodCallException; -use InvalidArgumentException; use Pterodactyl\Models\EggVariable; class EggVariableTransformer extends BaseClientTransformer { - /** - * @return string - */ public function getResourceName(): string { return EggVariable::RESOURCE_NAME; } /** - * @param \Pterodactyl\Models\EggVariable $variable * @return array */ public function transform(EggVariable $variable) @@ -26,9 +21,7 @@ class EggVariableTransformer extends BaseClientTransformer // them into the transformer and along to the user. Just throw an exception and break the entire // pathway since you should never be exposing these types of variables to a client. if (!$variable->user_viewable) { - throw new BadMethodCallException( - 'Cannot transform a hidden egg variable in a client transformer.' - ); + throw new BadMethodCallException('Cannot transform a hidden egg variable in a client transformer.'); } return [ diff --git a/app/Transformers/Api/Client/ScheduleTransformer.php b/app/Transformers/Api/Client/ScheduleTransformer.php index 43e35ed42..44ea2c555 100644 --- a/app/Transformers/Api/Client/ScheduleTransformer.php +++ b/app/Transformers/Api/Client/ScheduleTransformer.php @@ -29,7 +29,6 @@ class ScheduleTransformer extends BaseClientTransformer /** * Returns a transformed schedule model such that a client can view the information. * - * @param \Pterodactyl\Models\Schedule $model * @return array */ public function transform(Schedule $model) @@ -40,6 +39,7 @@ class ScheduleTransformer extends BaseClientTransformer 'cron' => [ 'day_of_week' => $model->cron_day_of_week, 'day_of_month' => $model->cron_day_of_month, + 'month' => $model->cron_month, 'hour' => $model->cron_hour, 'minute' => $model->cron_minute, ], @@ -55,7 +55,6 @@ class ScheduleTransformer extends BaseClientTransformer /** * Allows attaching the tasks specific to the schedule in the response. * - * @param \Pterodactyl\Models\Schedule $model * @return \League\Fractal\Resource\Collection * * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException @@ -63,7 +62,9 @@ class ScheduleTransformer extends BaseClientTransformer public function includeTasks(Schedule $model) { return $this->collection( - $model->tasks, $this->makeTransformer(TaskTransformer::class), Task::RESOURCE_NAME + $model->tasks, + $this->makeTransformer(TaskTransformer::class), + Task::RESOURCE_NAME ); } } diff --git a/app/Transformers/Api/Client/ServerTransformer.php b/app/Transformers/Api/Client/ServerTransformer.php index 0673f9b57..03f853052 100644 --- a/app/Transformers/Api/Client/ServerTransformer.php +++ b/app/Transformers/Api/Client/ServerTransformer.php @@ -23,9 +23,6 @@ class ServerTransformer extends BaseClientTransformer */ protected $availableIncludes = ['egg', 'subusers']; - /** - * @return string - */ public function getResourceName(): string { return Server::RESOURCE_NAME; @@ -34,9 +31,6 @@ class ServerTransformer extends BaseClientTransformer /** * Transform a server model into a representation that can be returned * to a client. - * - * @param \Pterodactyl\Models\Server $server - * @return array */ public function transform(Server $server): array { @@ -62,7 +56,7 @@ class ServerTransformer extends BaseClientTransformer 'io' => $server->io, 'cpu' => $server->cpu, ], - 'invocation' => $service->handle($server, ! $this->getUser()->can(Permission::ACTION_STARTUP_READ, $server)), + 'invocation' => $service->handle($server, !$this->getUser()->can(Permission::ACTION_STARTUP_READ, $server)), 'docker_image' => $server->image, 'egg_features' => $server->egg->inherit_features, 'feature_limits' => [ @@ -72,14 +66,13 @@ class ServerTransformer extends BaseClientTransformer ], 'is_suspended' => $server->suspended, 'is_installing' => $server->installed !== 1, - 'is_transferring' => ! is_null($server->transfer), + 'is_transferring' => !is_null($server->transfer), ]; } /** * Returns the allocations associated with this server. * - * @param \Pterodactyl\Models\Server $server * @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource * * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException @@ -95,7 +88,7 @@ class ServerTransformer extends BaseClientTransformer // // This allows us to avoid too much permission regression, without also hiding information that // is generally needed for the frontend to make sense when browsing or searching results. - if (! $this->getUser()->can(Permission::ACTION_ALLOCATION_READ, $server)) { + if (!$this->getUser()->can(Permission::ACTION_ALLOCATION_READ, $server)) { $primary = clone $server->allocation; $primary->notes = null; @@ -106,14 +99,13 @@ class ServerTransformer extends BaseClientTransformer } /** - * @param \Pterodactyl\Models\Server $server * @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource * * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException */ public function includeVariables(Server $server) { - if (! $this->getUser()->can(Permission::ACTION_STARTUP_READ, $server)) { + if (!$this->getUser()->can(Permission::ACTION_STARTUP_READ, $server)) { return $this->null(); } @@ -127,8 +119,8 @@ class ServerTransformer extends BaseClientTransformer /** * Returns the egg associated with this server. * - * @param \Pterodactyl\Models\Server $server * @return \League\Fractal\Resource\Item + * * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException */ public function includeEgg(Server $server) @@ -139,14 +131,13 @@ class ServerTransformer extends BaseClientTransformer /** * Returns the subusers associated with this server. * - * @param \Pterodactyl\Models\Server $server * @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource * * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException */ public function includeSubusers(Server $server) { - if (! $this->getUser()->can(Permission::ACTION_USER_READ, $server)) { + if (!$this->getUser()->can(Permission::ACTION_USER_READ, $server)) { return $this->null(); } diff --git a/app/Transformers/Api/Client/StatsTransformer.php b/app/Transformers/Api/Client/StatsTransformer.php index 97989cc3a..8ca7bea07 100644 --- a/app/Transformers/Api/Client/StatsTransformer.php +++ b/app/Transformers/Api/Client/StatsTransformer.php @@ -6,9 +6,6 @@ use Illuminate\Support\Arr; class StatsTransformer extends BaseClientTransformer { - /** - * @return string - */ public function getResourceName(): string { return 'stats'; @@ -18,7 +15,6 @@ class StatsTransformer extends BaseClientTransformer * Transform stats from the daemon into a result set that can be used in * the client API. * - * @param array $data * @return array */ public function transform(array $data) diff --git a/app/Transformers/Api/Client/SubuserTransformer.php b/app/Transformers/Api/Client/SubuserTransformer.php index d2e7ce0ff..7a8bfde0e 100644 --- a/app/Transformers/Api/Client/SubuserTransformer.php +++ b/app/Transformers/Api/Client/SubuserTransformer.php @@ -8,8 +8,6 @@ class SubuserTransformer extends BaseClientTransformer { /** * Return the resource name for the JSONAPI output. - * - * @return string */ public function getResourceName(): string { @@ -19,8 +17,8 @@ class SubuserTransformer extends BaseClientTransformer /** * Transforms a subuser into a model that can be shown to a front-end user. * - * @param \Pterodactyl\Models\Subuser $model * @return array|void + * * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException */ public function transform(Subuser $model) diff --git a/app/Transformers/Api/Client/TaskTransformer.php b/app/Transformers/Api/Client/TaskTransformer.php index c215479ac..0b2956262 100644 --- a/app/Transformers/Api/Client/TaskTransformer.php +++ b/app/Transformers/Api/Client/TaskTransformer.php @@ -17,7 +17,6 @@ class TaskTransformer extends BaseClientTransformer /** * Transforms a schedule's task into a client viewable format. * - * @param \Pterodactyl\Models\Task $model * @return array */ public function transform(Task $model) diff --git a/app/Transformers/Api/Client/UserTransformer.php b/app/Transformers/Api/Client/UserTransformer.php index 65849f06d..468232f8d 100644 --- a/app/Transformers/Api/Client/UserTransformer.php +++ b/app/Transformers/Api/Client/UserTransformer.php @@ -9,8 +9,6 @@ class UserTransformer extends BaseClientTransformer { /** * Return the resource name for the JSONAPI output. - * - * @return string */ public function getResourceName(): string { @@ -21,7 +19,6 @@ class UserTransformer extends BaseClientTransformer * Transforms a User model into a representation that can be shown to regular * users of the API. * - * @param \Pterodactyl\Models\User $model * @return array */ public function transform(User $model) diff --git a/app/Transformers/Daemon/FileObjectTransformer.php b/app/Transformers/Daemon/FileObjectTransformer.php index f19d9028c..1ad86dce8 100644 --- a/app/Transformers/Daemon/FileObjectTransformer.php +++ b/app/Transformers/Daemon/FileObjectTransformer.php @@ -17,7 +17,6 @@ class FileObjectTransformer extends BaseDaemonTransformer /** * Transform a file object response from the daemon into a standardized response. * - * @param array $item * @return array */ public function transform(array $item) @@ -35,9 +34,6 @@ class FileObjectTransformer extends BaseDaemonTransformer ]; } - /** - * @return string - */ public function getResourceName(): string { return 'file_object'; diff --git a/app/helpers.php b/app/helpers.php index 0716fd214..ac099f923 100644 --- a/app/helpers.php +++ b/app/helpers.php @@ -1,11 +1,12 @@ make(Kernel::class); */ $kernel->bootstrap(); -$output = new ConsoleOutput; +// Register the collision service provider so that errors during the test +// setup process are output nicely. +(new Provider())->register(); + +$output = new ConsoleOutput(); if (config('database.default') !== 'testing') { $output->writeln(PHP_EOL . 'Cannot run test process against non-testing database.'); @@ -27,7 +32,7 @@ if (config('database.default') !== 'testing') { * Perform database migrations and reseeding before continuing with * running the tests. */ -if (! env('SKIP_MIGRATIONS')) { +if (!env('SKIP_MIGRATIONS')) { $output->writeln(PHP_EOL . 'Refreshing database for Integration tests...'); $kernel->call('migrate:fresh', ['--database' => 'testing']); diff --git a/composer.json b/composer.json index 2602cf9ba..987d7d05d 100644 --- a/composer.json +++ b/composer.json @@ -11,65 +11,60 @@ } ], "require": { - "php": "^7.4", + "php": "^7.4 || ^8.0", "ext-json": "*", "ext-mbstring": "*", "ext-pdo_mysql": "*", "ext-zip": "*", - "appstract/laravel-blade-directives": "^1.10", "aws/aws-sdk-php": "^3.171", - "cakephp/chronos": "^1.3", "doctrine/dbal": "^2.12", "fideloper/proxy": "^4.4", - "guzzlehttp/guzzle": "^6.5", + "guzzlehttp/guzzle": "^7.2", "hashids/hashids": "^4.1", "laracasts/utilities": "^3.2", - "laravel/framework": "^7.30", + "laravel/framework": "^8.22", "laravel/helpers": "^1.4", "laravel/tinker": "^2.5", - "laravel/ui": "^2.5", - "lcobucci/jwt": "^3.4", + "laravel/ui": "^3.0", + "lcobucci/jwt": "^4.0", "league/flysystem-aws-s3-v3": "^1.0", "league/flysystem-memory": "^1.0", "matriphe/iso-639": "^1.2", "pragmarx/google2fa": "^5.0", "predis/predis": "^1.1", "prologue/alerts": "^0.4", - "psy/psysh": "^0.10.5", "s1lentium/iptools": "^1.1", "spatie/laravel-fractal": "^5.8", - "spatie/laravel-query-builder": "^2.8", - "staudenmeir/belongs-to-through": "^2.10", + "spatie/laravel-query-builder": "^3.3", + "staudenmeir/belongs-to-through": "^2.11", "symfony/yaml": "^4.4", "webmozart/assert": "^1.9" }, "require-dev": { "barryvdh/laravel-debugbar": "^3.5", - "barryvdh/laravel-ide-helper": "^2.8", - "codedungeon/phpunit-result-printer": "^0.28.0", - "friendsofphp/php-cs-fixer": "^2.17.3", - "fzaninotto/faker": "^1.9", + "barryvdh/laravel-ide-helper": "^2.9", + "facade/ignition": "^2.5", + "fakerphp/faker": "^1.13", + "friendsofphp/php-cs-fixer": "^2.18", "laravel/dusk": "^6.11", "mockery/mockery": "^1.4", + "nunomaduro/collision": "^5.2", "php-mock/php-mock-phpunit": "^2.6", - "phpunit/phpunit": "^8.5" + "phpunit/phpunit": "^9.0" }, "autoload": { - "classmap": [ - "database" - ], "files": [ "app/helpers.php" ], "psr-4": { - "Pterodactyl\\": "app/" + "Pterodactyl\\": "app/", + "Database\\Factories\\": "database/Factories/", + "Database\\Seeders\\": "database/Seeders/" } }, "autoload-dev": { "psr-4": { - "Pterodactyl\\Tests\\Browser\\": "tests/Browser", - "Pterodactyl\\Tests\\Integration\\": "tests/Integration", - "Tests\\": "tests/" + "Pterodactyl\\Tests\\": "tests/" } }, "scripts": { diff --git a/composer.lock b/composer.lock index bf13e2afb..b710b41f1 100644 --- a/composer.lock +++ b/composer.lock @@ -4,78 +4,20 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "cf41509e18df363b4f25374ab97cfaf1", + "content-hash": "ff65a88dee023a86598a10a5178c0165", "packages": [ - { - "name": "appstract/laravel-blade-directives", - "version": "1.10.0", - "source": { - "type": "git", - "url": "https://github.com/appstract/laravel-blade-directives.git", - "reference": "9cff1f2db9718cb932b3b7df8141dcb97e1ab2fd" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/appstract/laravel-blade-directives/zipball/9cff1f2db9718cb932b3b7df8141dcb97e1ab2fd", - "reference": "9cff1f2db9718cb932b3b7df8141dcb97e1ab2fd", - "shasum": "" - }, - "require": { - "laravel/framework": "^5.7|^6.0|^7.0|^8.0", - "php": "^7.1.3" - }, - "require-dev": { - "orchestra/testbench": "~3.7|^4.0|^5.0|^6.0" - }, - "type": "library", - "extra": { - "laravel": { - "providers": [ - "Appstract\\BladeDirectives\\BladeDirectivesServiceProvider" - ] - } - }, - "autoload": { - "psr-4": { - "Appstract\\BladeDirectives\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Gijs Jorissen", - "email": "gijs@appstract.nl", - "homepage": "https://appstract.nl", - "role": "Developer" - } - ], - "description": "Handy Blade directives", - "homepage": "https://github.com/appstract/laravel-blade-directives", - "keywords": [ - "appstract", - "laravel-blade-directives" - ], - "support": { - "issues": "https://github.com/appstract/laravel-blade-directives/issues", - "source": "https://github.com/appstract/laravel-blade-directives/tree/1.10.0" - }, - "time": "2020-09-15T14:58:47+00:00" - }, { "name": "aws/aws-sdk-php", - "version": "3.171.12", + "version": "3.172.0", "source": { "type": "git", "url": "https://github.com/aws/aws-sdk-php.git", - "reference": "2a575d8336a6005fcd7b8c3d54783ee5ddc3ceac" + "reference": "5a5e66c4d54c392042820703eeb8a6bd3d222924" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/2a575d8336a6005fcd7b8c3d54783ee5ddc3ceac", - "reference": "2a575d8336a6005fcd7b8c3d54783ee5ddc3ceac", + "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/5a5e66c4d54c392042820703eeb8a6bd3d222924", + "reference": "5a5e66c4d54c392042820703eeb8a6bd3d222924", "shasum": "" }, "require": { @@ -150,32 +92,32 @@ "support": { "forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80", "issues": "https://github.com/aws/aws-sdk-php/issues", - "source": "https://github.com/aws/aws-sdk-php/tree/3.171.12" + "source": "https://github.com/aws/aws-sdk-php/tree/3.172.0" }, - "time": "2021-01-05T19:12:58+00:00" + "time": "2021-01-22T19:21:38+00:00" }, { "name": "brick/math", - "version": "0.9.1", + "version": "0.9.2", "source": { "type": "git", "url": "https://github.com/brick/math.git", - "reference": "283a40c901101e66de7061bd359252c013dcc43c" + "reference": "dff976c2f3487d42c1db75a3b180e2b9f0e72ce0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/brick/math/zipball/283a40c901101e66de7061bd359252c013dcc43c", - "reference": "283a40c901101e66de7061bd359252c013dcc43c", + "url": "https://api.github.com/repos/brick/math/zipball/dff976c2f3487d42c1db75a3b180e2b9f0e72ce0", + "reference": "dff976c2f3487d42c1db75a3b180e2b9f0e72ce0", "shasum": "" }, "require": { "ext-json": "*", - "php": "^7.1|^8.0" + "php": "^7.1 || ^8.0" }, "require-dev": { "php-coveralls/php-coveralls": "^2.2", - "phpunit/phpunit": "^7.5.15|^8.5", - "vimeo/psalm": "^3.5" + "phpunit/phpunit": "^7.5.15 || ^8.5 || ^9.0", + "vimeo/psalm": "4.3.2" }, "type": "library", "autoload": { @@ -200,7 +142,7 @@ ], "support": { "issues": "https://github.com/brick/math/issues", - "source": "https://github.com/brick/math/tree/master" + "source": "https://github.com/brick/math/tree/0.9.2" }, "funding": [ { @@ -208,68 +150,7 @@ "type": "tidelift" } ], - "time": "2020-08-18T23:57:15+00:00" - }, - { - "name": "cakephp/chronos", - "version": "1.3.0", - "source": { - "type": "git", - "url": "https://github.com/cakephp/chronos.git", - "reference": "ba2bab98849e7bf29b02dd634ada49ab36472959" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/cakephp/chronos/zipball/ba2bab98849e7bf29b02dd634ada49ab36472959", - "reference": "ba2bab98849e7bf29b02dd634ada49ab36472959", - "shasum": "" - }, - "require": { - "php": ">=5.6" - }, - "require-dev": { - "athletic/athletic": "~0.1", - "cakephp/cakephp-codesniffer": "^3.0", - "phpbench/phpbench": "@dev", - "phpunit/phpunit": "<6.0 || ^7.0" - }, - "type": "library", - "autoload": { - "psr-4": { - "Cake\\Chronos\\": "src/" - }, - "files": [ - "src/carbon_compat.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Brian Nesbitt", - "email": "brian@nesbot.com", - "homepage": "http://nesbot.com" - }, - { - "name": "The CakePHP Team", - "homepage": "http://cakephp.org" - } - ], - "description": "A simple API extension for DateTime.", - "homepage": "http://cakephp.org", - "keywords": [ - "date", - "datetime", - "time" - ], - "support": { - "irc": "irc://irc.freenode.org/cakephp", - "issues": "https://github.com/cakephp/chronos/issues", - "source": "https://github.com/cakephp/chronos" - }, - "time": "2019-11-30T02:33:19+00:00" + "time": "2021-01-20T22:51:39+00:00" }, { "name": "dnoegel/php-xdg-base-dir", @@ -790,30 +671,32 @@ }, { "name": "dragonmantank/cron-expression", - "version": "v2.3.1", + "version": "v3.1.0", "source": { "type": "git", "url": "https://github.com/dragonmantank/cron-expression.git", - "reference": "65b2d8ee1f10915efb3b55597da3404f096acba2" + "reference": "7a8c6e56ab3ffcc538d05e8155bb42269abf1a0c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/dragonmantank/cron-expression/zipball/65b2d8ee1f10915efb3b55597da3404f096acba2", - "reference": "65b2d8ee1f10915efb3b55597da3404f096acba2", + "url": "https://api.github.com/repos/dragonmantank/cron-expression/zipball/7a8c6e56ab3ffcc538d05e8155bb42269abf1a0c", + "reference": "7a8c6e56ab3ffcc538d05e8155bb42269abf1a0c", "shasum": "" }, "require": { - "php": "^7.0|^8.0" + "php": "^7.2|^8.0", + "webmozart/assert": "^1.7.0" + }, + "replace": { + "mtdowling/cron-expression": "^1.0" }, "require-dev": { - "phpunit/phpunit": "^6.4|^7.0|^8.0|^9.0" + "phpstan/extension-installer": "^1.0", + "phpstan/phpstan": "^0.12", + "phpstan/phpstan-webmozart-assert": "^0.12.7", + "phpunit/phpunit": "^7.0|^8.0|^9.0" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.3-dev" - } - }, "autoload": { "psr-4": { "Cron\\": "src/Cron/" @@ -824,11 +707,6 @@ "MIT" ], "authors": [ - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - }, { "name": "Chris Tankersley", "email": "chris@ctankersley.com", @@ -842,7 +720,7 @@ ], "support": { "issues": "https://github.com/dragonmantank/cron-expression/issues", - "source": "https://github.com/dragonmantank/cron-expression/tree/v2.3.1" + "source": "https://github.com/dragonmantank/cron-expression/tree/v3.1.0" }, "funding": [ { @@ -850,7 +728,7 @@ "type": "github" } ], - "time": "2020-10-13T00:52:37+00:00" + "time": "2020-11-24T19:55:57+00:00" }, { "name": "egulias/email-validator", @@ -979,38 +857,110 @@ "time": "2020-10-22T13:48:01+00:00" }, { - "name": "guzzlehttp/guzzle", - "version": "6.5.5", + "name": "graham-campbell/result-type", + "version": "v1.0.1", "source": { "type": "git", - "url": "https://github.com/guzzle/guzzle.git", - "reference": "9d4290de1cfd701f38099ef7e183b64b4b7b0c5e" + "url": "https://github.com/GrahamCampbell/Result-Type.git", + "reference": "7e279d2cd5d7fbb156ce46daada972355cea27bb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/9d4290de1cfd701f38099ef7e183b64b4b7b0c5e", - "reference": "9d4290de1cfd701f38099ef7e183b64b4b7b0c5e", + "url": "https://api.github.com/repos/GrahamCampbell/Result-Type/zipball/7e279d2cd5d7fbb156ce46daada972355cea27bb", + "reference": "7e279d2cd5d7fbb156ce46daada972355cea27bb", + "shasum": "" + }, + "require": { + "php": "^7.0|^8.0", + "phpoption/phpoption": "^1.7.3" + }, + "require-dev": { + "phpunit/phpunit": "^6.5|^7.5|^8.5|^9.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "psr-4": { + "GrahamCampbell\\ResultType\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "graham@alt-three.com" + } + ], + "description": "An Implementation Of The Result Type", + "keywords": [ + "Graham Campbell", + "GrahamCampbell", + "Result Type", + "Result-Type", + "result" + ], + "support": { + "issues": "https://github.com/GrahamCampbell/Result-Type/issues", + "source": "https://github.com/GrahamCampbell/Result-Type/tree/v1.0.1" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/graham-campbell/result-type", + "type": "tidelift" + } + ], + "time": "2020-04-13T13:17:36+00:00" + }, + { + "name": "guzzlehttp/guzzle", + "version": "7.2.0", + "source": { + "type": "git", + "url": "https://github.com/guzzle/guzzle.git", + "reference": "0aa74dfb41ae110835923ef10a9d803a22d50e79" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/0aa74dfb41ae110835923ef10a9d803a22d50e79", + "reference": "0aa74dfb41ae110835923ef10a9d803a22d50e79", "shasum": "" }, "require": { "ext-json": "*", - "guzzlehttp/promises": "^1.0", - "guzzlehttp/psr7": "^1.6.1", - "php": ">=5.5", - "symfony/polyfill-intl-idn": "^1.17.0" + "guzzlehttp/promises": "^1.4", + "guzzlehttp/psr7": "^1.7", + "php": "^7.2.5 || ^8.0", + "psr/http-client": "^1.0" + }, + "provide": { + "psr/http-client-implementation": "1.0" }, "require-dev": { "ext-curl": "*", - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.4 || ^7.0", + "php-http/client-integration-tests": "^3.0", + "phpunit/phpunit": "^8.5.5 || ^9.3.5", "psr/log": "^1.1" }, "suggest": { + "ext-curl": "Required for CURL handler support", + "ext-intl": "Required for Internationalized Domain Name (IDN) support", "psr/log": "Required for using the Log middleware" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "6.5-dev" + "dev-master": "7.1-dev" } }, "autoload": { @@ -1030,6 +980,11 @@ "name": "Michael Dowling", "email": "mtdowling@gmail.com", "homepage": "https://github.com/mtdowling" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://sagikazarmark.hu" } ], "description": "Guzzle is a PHP HTTP client library", @@ -1040,14 +995,34 @@ "framework", "http", "http client", + "psr-18", + "psr-7", "rest", "web service" ], "support": { "issues": "https://github.com/guzzle/guzzle/issues", - "source": "https://github.com/guzzle/guzzle/tree/6.5" + "source": "https://github.com/guzzle/guzzle/tree/7.2.0" }, - "time": "2020-06-16T21:01:06+00:00" + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://github.com/Nyholm", + "type": "github" + }, + { + "url": "https://github.com/alexeyshockov", + "type": "github" + }, + { + "url": "https://github.com/gmponos", + "type": "github" + } + ], + "time": "2020-10-10T11:47:56+00:00" }, { "name": "guzzlehttp/promises", @@ -1312,21 +1287,21 @@ }, { "name": "laravel/framework", - "version": "v7.30.1", + "version": "v8.24.0", "source": { "type": "git", "url": "https://github.com/laravel/framework.git", - "reference": "e73855b18dcfc645c36d2474f437e4e73dd3c11d" + "reference": "d16e9f875e4d7609a05d5007393e22ba95efd1fc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/framework/zipball/e73855b18dcfc645c36d2474f437e4e73dd3c11d", - "reference": "e73855b18dcfc645c36d2474f437e4e73dd3c11d", + "url": "https://api.github.com/repos/laravel/framework/zipball/d16e9f875e4d7609a05d5007393e22ba95efd1fc", + "reference": "d16e9f875e4d7609a05d5007393e22ba95efd1fc", "shasum": "" }, "require": { "doctrine/inflector": "^1.4|^2.0", - "dragonmantank/cron-expression": "^2.3.1", + "dragonmantank/cron-expression": "^3.0.2", "egulias/email-validator": "^2.1.10", "ext-json": "*", "ext-mbstring": "*", @@ -1336,23 +1311,22 @@ "monolog/monolog": "^2.0", "nesbot/carbon": "^2.31", "opis/closure": "^3.6", - "php": "^7.2.5|^8.0", + "php": "^7.3|^8.0", "psr/container": "^1.0", "psr/simple-cache": "^1.0", - "ramsey/uuid": "^3.7|^4.0", + "ramsey/uuid": "^4.0", "swiftmailer/swiftmailer": "^6.0", - "symfony/console": "^5.0", - "symfony/error-handler": "^5.0", - "symfony/finder": "^5.0", - "symfony/http-foundation": "^5.0", - "symfony/http-kernel": "^5.0", - "symfony/mime": "^5.0", - "symfony/polyfill-php73": "^1.17", - "symfony/process": "^5.0", - "symfony/routing": "^5.0", - "symfony/var-dumper": "^5.0", + "symfony/console": "^5.1.4", + "symfony/error-handler": "^5.1.4", + "symfony/finder": "^5.1.4", + "symfony/http-foundation": "^5.1.4", + "symfony/http-kernel": "^5.1.4", + "symfony/mime": "^5.1.4", + "symfony/process": "^5.1.4", + "symfony/routing": "^5.1.4", + "symfony/var-dumper": "^5.1.4", "tijsverkoyen/css-to-inline-styles": "^2.2.2", - "vlucas/phpdotenv": "^4.0", + "vlucas/phpdotenv": "^5.2", "voku/portable-ascii": "^1.4.8" }, "conflict": { @@ -1366,6 +1340,7 @@ "illuminate/broadcasting": "self.version", "illuminate/bus": "self.version", "illuminate/cache": "self.version", + "illuminate/collections": "self.version", "illuminate/config": "self.version", "illuminate/console": "self.version", "illuminate/container": "self.version", @@ -1378,6 +1353,7 @@ "illuminate/hashing": "self.version", "illuminate/http": "self.version", "illuminate/log": "self.version", + "illuminate/macroable": "self.version", "illuminate/mail": "self.version", "illuminate/notifications": "self.version", "illuminate/pagination": "self.version", @@ -1394,21 +1370,20 @@ }, "require-dev": { "aws/aws-sdk-php": "^3.155", - "doctrine/dbal": "^2.6", + "doctrine/dbal": "^2.6|^3.0", "filp/whoops": "^2.8", - "guzzlehttp/guzzle": "^6.3.1|^7.0.1", + "guzzlehttp/guzzle": "^6.5.5|^7.0.1", "league/flysystem-cached-adapter": "^1.0", - "mockery/mockery": "~1.3.3|^1.4.2", - "moontoast/math": "^1.1", - "orchestra/testbench-core": "^5.8", + "mockery/mockery": "^1.4.2", + "orchestra/testbench-core": "^6.8", "pda/pheanstalk": "^4.0", - "phpunit/phpunit": "^8.4|^9.3.3", + "phpunit/phpunit": "^8.5.8|^9.3.3", "predis/predis": "^1.1.1", - "symfony/cache": "^5.0" + "symfony/cache": "^5.1.4" }, "suggest": { "aws/aws-sdk-php": "Required to use the SQS queue driver, DynamoDb failed job storage and SES mail driver (^3.155).", - "doctrine/dbal": "Required to rename columns and drop SQLite columns (^2.6).", + "doctrine/dbal": "Required to rename columns and drop SQLite columns (^2.6|^3.0).", "ext-ftp": "Required to use the Flysystem FTP driver.", "ext-gd": "Required to use Illuminate\\Http\\Testing\\FileFactory::image().", "ext-memcached": "Required to use the memcache cache driver.", @@ -1417,37 +1392,42 @@ "ext-redis": "Required to use the Redis cache and queue drivers (^4.0|^5.0).", "fakerphp/faker": "Required to use the eloquent factory builder (^1.9.1).", "filp/whoops": "Required for friendly error pages in development (^2.8).", - "guzzlehttp/guzzle": "Required to use the HTTP Client, Mailgun mail driver and the ping methods on schedules (^6.3.1|^7.0.1).", + "guzzlehttp/guzzle": "Required to use the HTTP Client, Mailgun mail driver and the ping methods on schedules (^6.5.5|^7.0.1).", "laravel/tinker": "Required to use the tinker console command (^2.0).", "league/flysystem-aws-s3-v3": "Required to use the Flysystem S3 driver (^1.0).", "league/flysystem-cached-adapter": "Required to use the Flysystem cache (^1.0).", "league/flysystem-sftp": "Required to use the Flysystem SFTP driver (^1.0).", - "mockery/mockery": "Required to use mocking (~1.3.3|^1.4.2).", - "moontoast/math": "Required to use ordered UUIDs (^1.1).", + "mockery/mockery": "Required to use mocking (^1.4.2).", "nyholm/psr7": "Required to use PSR-7 bridging features (^1.2).", "pda/pheanstalk": "Required to use the beanstalk queue driver (^4.0).", - "phpunit/phpunit": "Required to use assertions and run tests (^8.4|^9.3.3).", + "phpunit/phpunit": "Required to use assertions and run tests (^8.5.8|^9.3.3).", "predis/predis": "Required to use the predis connector (^1.1.2).", "psr/http-message": "Required to allow Storage::put to accept a StreamInterface (^1.0).", "pusher/pusher-php-server": "Required to use the Pusher broadcast driver (^4.0).", - "symfony/cache": "Required to PSR-6 cache bridge (^5.0).", - "symfony/filesystem": "Required to create relative storage directory symbolic links (^5.0).", + "symfony/cache": "Required to PSR-6 cache bridge (^5.1.4).", + "symfony/filesystem": "Required to enable support for relative symbolic links (^5.1.4).", "symfony/psr-http-message-bridge": "Required to use PSR-7 bridging features (^2.0).", "wildbit/swiftmailer-postmark": "Required to use Postmark mail driver (^3.0)." }, "type": "library", "extra": { "branch-alias": { - "dev-master": "7.x-dev" + "dev-master": "8.x-dev" } }, "autoload": { "files": [ + "src/Illuminate/Collections/helpers.php", + "src/Illuminate/Events/functions.php", "src/Illuminate/Foundation/helpers.php", "src/Illuminate/Support/helpers.php" ], "psr-4": { - "Illuminate\\": "src/Illuminate/" + "Illuminate\\": "src/Illuminate/", + "Illuminate\\Support\\": [ + "src/Illuminate/Macroable/", + "src/Illuminate/Collections/" + ] } }, "notification-url": "https://packagist.org/downloads/", @@ -1470,7 +1450,7 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2020-12-22T17:00:45+00:00" + "time": "2021-01-21T14:19:29+00:00" }, { "name": "laravel/helpers", @@ -1598,26 +1578,29 @@ }, { "name": "laravel/ui", - "version": "v2.5.0", + "version": "v3.2.0", "source": { "type": "git", "url": "https://github.com/laravel/ui.git", - "reference": "d01a705763c243b07be795e9d1bb47f89260f73d" + "reference": "a1f82c6283c8373ea1958b8a27c3d5c98cade351" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/ui/zipball/d01a705763c243b07be795e9d1bb47f89260f73d", - "reference": "d01a705763c243b07be795e9d1bb47f89260f73d", + "url": "https://api.github.com/repos/laravel/ui/zipball/a1f82c6283c8373ea1958b8a27c3d5c98cade351", + "reference": "a1f82c6283c8373ea1958b8a27c3d5c98cade351", "shasum": "" }, "require": { - "illuminate/console": "^7.0", - "illuminate/filesystem": "^7.0", - "illuminate/support": "^7.0", - "php": "^7.2.5|^8.0" + "illuminate/console": "^8.0", + "illuminate/filesystem": "^8.0", + "illuminate/support": "^8.0", + "php": "^7.3|^8.0" }, "type": "library", "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + }, "laravel": { "providers": [ "Laravel\\Ui\\UiServiceProvider" @@ -1647,74 +1630,58 @@ ], "support": { "issues": "https://github.com/laravel/ui/issues", - "source": "https://github.com/laravel/ui/tree/v2.5.0" + "source": "https://github.com/laravel/ui/tree/v3.2.0" }, - "time": "2020-11-03T19:45:19+00:00" + "time": "2021-01-06T19:20:22+00:00" }, { - "name": "lcobucci/jwt", - "version": "3.4.2", + "name": "lcobucci/clock", + "version": "2.0.0", "source": { "type": "git", - "url": "https://github.com/lcobucci/jwt.git", - "reference": "17cb82dd625ccb17c74bf8f38563d3b260306483" + "url": "https://github.com/lcobucci/clock.git", + "reference": "353d83fe2e6ae95745b16b3d911813df6a05bfb3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/lcobucci/jwt/zipball/17cb82dd625ccb17c74bf8f38563d3b260306483", - "reference": "17cb82dd625ccb17c74bf8f38563d3b260306483", + "url": "https://api.github.com/repos/lcobucci/clock/zipball/353d83fe2e6ae95745b16b3d911813df6a05bfb3", + "reference": "353d83fe2e6ae95745b16b3d911813df6a05bfb3", "shasum": "" }, "require": { - "ext-mbstring": "*", - "ext-openssl": "*", - "php": "^5.6 || ^7.0" + "php": "^7.4 || ^8.0" }, "require-dev": { - "mikey179/vfsstream": "~1.5", - "phpmd/phpmd": "~2.2", - "phpunit/php-invoker": "~1.1", - "phpunit/phpunit": "^5.7 || ^7.3", - "squizlabs/php_codesniffer": "~2.3" - }, - "suggest": { - "lcobucci/clock": "*" + "infection/infection": "^0.17", + "lcobucci/coding-standard": "^6.0", + "phpstan/extension-installer": "^1.0", + "phpstan/phpstan": "^0.12", + "phpstan/phpstan-deprecation-rules": "^0.12", + "phpstan/phpstan-phpunit": "^0.12", + "phpstan/phpstan-strict-rules": "^0.12", + "phpunit/php-code-coverage": "9.1.4", + "phpunit/phpunit": "9.3.7" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.1-dev" - } - }, "autoload": { "psr-4": { - "Lcobucci\\JWT\\": "src" - }, - "files": [ - "compat/class-aliases.php", - "compat/json-exception-polyfill.php", - "compat/lcobucci-clock-polyfill.php" - ] + "Lcobucci\\Clock\\": "src" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ - "BSD-3-Clause" + "MIT" ], "authors": [ { - "name": "Luís Otávio Cobucci Oblonczyk", - "email": "lcobucci@gmail.com", - "role": "Developer" + "name": "Luís Cobucci", + "email": "lcobucci@gmail.com" } ], - "description": "A simple library to work with JSON Web Token and JSON Web Signature", - "keywords": [ - "JWS", - "jwt" - ], + "description": "Yet another clock abstraction", "support": { - "issues": "https://github.com/lcobucci/jwt/issues", - "source": "https://github.com/lcobucci/jwt/tree/3.4.2" + "issues": "https://github.com/lcobucci/clock/issues", + "source": "https://github.com/lcobucci/clock/tree/2.0.x" }, "funding": [ { @@ -1726,7 +1693,83 @@ "type": "patreon" } ], - "time": "2020-12-03T13:43:45+00:00" + "time": "2020-08-27T18:56:02+00:00" + }, + { + "name": "lcobucci/jwt", + "version": "4.0.0", + "source": { + "type": "git", + "url": "https://github.com/lcobucci/jwt.git", + "reference": "6d8665ccd924dc076a9b65d1ea8abe21d68f6958" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/lcobucci/jwt/zipball/6d8665ccd924dc076a9b65d1ea8abe21d68f6958", + "reference": "6d8665ccd924dc076a9b65d1ea8abe21d68f6958", + "shasum": "" + }, + "require": { + "ext-mbstring": "*", + "ext-openssl": "*", + "lcobucci/clock": "^2.0", + "php": "^7.4 || ^8.0" + }, + "require-dev": { + "infection/infection": "^0.20", + "lcobucci/coding-standard": "^6.0", + "mikey179/vfsstream": "^1.6", + "phpbench/phpbench": "^0.17", + "phpstan/extension-installer": "^1.0", + "phpstan/phpstan": "^0.12", + "phpstan/phpstan-deprecation-rules": "^0.12", + "phpstan/phpstan-phpunit": "^0.12", + "phpstan/phpstan-strict-rules": "^0.12", + "phpunit/php-invoker": "^3.1", + "phpunit/phpunit": "^9.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "psr-4": { + "Lcobucci\\JWT\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Luís Cobucci", + "email": "lcobucci@gmail.com", + "role": "Developer" + } + ], + "description": "A simple library to work with JSON Web Token and JSON Web Signature", + "keywords": [ + "JWS", + "jwt" + ], + "support": { + "issues": "https://github.com/lcobucci/jwt/issues", + "source": "https://github.com/lcobucci/jwt/tree/4.0.0" + }, + "funding": [ + { + "url": "https://github.com/lcobucci", + "type": "github" + }, + { + "url": "https://www.patreon.com/lcobucci", + "type": "patreon" + } + ], + "time": "2020-11-25T02:06:12+00:00" }, { "name": "league/commonmark", @@ -2100,16 +2143,16 @@ }, { "name": "league/mime-type-detection", - "version": "1.5.1", + "version": "1.7.0", "source": { "type": "git", "url": "https://github.com/thephpleague/mime-type-detection.git", - "reference": "353f66d7555d8a90781f6f5e7091932f9a4250aa" + "reference": "3b9dff8aaf7323590c1d2e443db701eb1f9aa0d3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/mime-type-detection/zipball/353f66d7555d8a90781f6f5e7091932f9a4250aa", - "reference": "353f66d7555d8a90781f6f5e7091932f9a4250aa", + "url": "https://api.github.com/repos/thephpleague/mime-type-detection/zipball/3b9dff8aaf7323590c1d2e443db701eb1f9aa0d3", + "reference": "3b9dff8aaf7323590c1d2e443db701eb1f9aa0d3", "shasum": "" }, "require": { @@ -2117,8 +2160,9 @@ "php": "^7.2 || ^8.0" }, "require-dev": { - "phpstan/phpstan": "^0.12.36", - "phpunit/phpunit": "^8.5.8" + "friendsofphp/php-cs-fixer": "^2.18", + "phpstan/phpstan": "^0.12.68", + "phpunit/phpunit": "^8.5.8 || ^9.3" }, "type": "library", "autoload": { @@ -2139,7 +2183,7 @@ "description": "Mime-type detection for Flysystem", "support": { "issues": "https://github.com/thephpleague/mime-type-detection/issues", - "source": "https://github.com/thephpleague/mime-type-detection/tree/1.5.1" + "source": "https://github.com/thephpleague/mime-type-detection/tree/1.7.0" }, "funding": [ { @@ -2151,7 +2195,7 @@ "type": "tidelift" } ], - "time": "2020-10-18T11:50:25+00:00" + "time": "2021-01-18T20:58:21+00:00" }, { "name": "matriphe/iso-639", @@ -3070,6 +3114,58 @@ }, "time": "2019-01-08T18:20:26+00:00" }, + { + "name": "psr/http-client", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-client.git", + "reference": "2dfb5f6c5eff0e91e20e913f8c5452ed95b86621" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-client/zipball/2dfb5f6c5eff0e91e20e913f8c5452ed95b86621", + "reference": "2dfb5f6c5eff0e91e20e913f8c5452ed95b86621", + "shasum": "" + }, + "require": { + "php": "^7.0 || ^8.0", + "psr/http-message": "^1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Client\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP clients", + "homepage": "https://github.com/php-fig/http-client", + "keywords": [ + "http", + "http-client", + "psr", + "psr-18" + ], + "support": { + "source": "https://github.com/php-fig/http-client/tree/master" + }, + "time": "2020-06-29T06:28:15+00:00" + }, { "name": "psr/http-message", "version": "1.0.1", @@ -3226,16 +3322,16 @@ }, { "name": "psy/psysh", - "version": "v0.10.5", + "version": "v0.10.6", "source": { "type": "git", "url": "https://github.com/bobthecow/psysh.git", - "reference": "7c710551d4a2653afa259c544508dc18a9098956" + "reference": "6f990c19f91729de8b31e639d6e204ea59f19cf3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/bobthecow/psysh/zipball/7c710551d4a2653afa259c544508dc18a9098956", - "reference": "7c710551d4a2653afa259c544508dc18a9098956", + "url": "https://api.github.com/repos/bobthecow/psysh/zipball/6f990c19f91729de8b31e639d6e204ea59f19cf3", + "reference": "6f990c19f91729de8b31e639d6e204ea59f19cf3", "shasum": "" }, "require": { @@ -3264,7 +3360,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "0.10.x-dev" + "dev-main": "0.10.x-dev" } }, "autoload": { @@ -3296,9 +3392,9 @@ ], "support": { "issues": "https://github.com/bobthecow/psysh/issues", - "source": "https://github.com/bobthecow/psysh/tree/v0.10.5" + "source": "https://github.com/bobthecow/psysh/tree/v0.10.6" }, - "time": "2020-12-04T02:51:30+00:00" + "time": "2021-01-18T15:53:43+00:00" }, { "name": "ralouphie/getallheaders", @@ -3346,16 +3442,16 @@ }, { "name": "ramsey/collection", - "version": "1.1.1", + "version": "1.1.3", "source": { "type": "git", "url": "https://github.com/ramsey/collection.git", - "reference": "24d93aefb2cd786b7edd9f45b554aea20b28b9b1" + "reference": "28a5c4ab2f5111db6a60b2b4ec84057e0f43b9c1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ramsey/collection/zipball/24d93aefb2cd786b7edd9f45b554aea20b28b9b1", - "reference": "24d93aefb2cd786b7edd9f45b554aea20b28b9b1", + "url": "https://api.github.com/repos/ramsey/collection/zipball/28a5c4ab2f5111db6a60b2b4ec84057e0f43b9c1", + "reference": "28a5c4ab2f5111db6a60b2b4ec84057e0f43b9c1", "shasum": "" }, "require": { @@ -3365,19 +3461,19 @@ "captainhook/captainhook": "^5.3", "dealerdirect/phpcodesniffer-composer-installer": "^0.7.0", "ergebnis/composer-normalize": "^2.6", - "fzaninotto/faker": "^1.5", + "fakerphp/faker": "^1.5", "hamcrest/hamcrest-php": "^2", - "jangregor/phpstan-prophecy": "^0.6", + "jangregor/phpstan-prophecy": "^0.8", "mockery/mockery": "^1.3", "phpstan/extension-installer": "^1", "phpstan/phpstan": "^0.12.32", "phpstan/phpstan-mockery": "^0.12.5", "phpstan/phpstan-phpunit": "^0.12.11", - "phpunit/phpunit": "^8.5", + "phpunit/phpunit": "^8.5 || ^9", "psy/psysh": "^0.10.4", "slevomat/coding-standard": "^6.3", "squizlabs/php_codesniffer": "^3.5", - "vimeo/psalm": "^3.12.2" + "vimeo/psalm": "^4.4" }, "type": "library", "autoload": { @@ -3407,15 +3503,19 @@ ], "support": { "issues": "https://github.com/ramsey/collection/issues", - "source": "https://github.com/ramsey/collection/tree/1.1.1" + "source": "https://github.com/ramsey/collection/tree/1.1.3" }, "funding": [ { "url": "https://github.com/ramsey", "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/ramsey/collection", + "type": "tidelift" } ], - "time": "2020-09-10T20:58:17+00:00" + "time": "2021-01-21T17:40:04+00:00" }, { "name": "ramsey/uuid", @@ -3705,28 +3805,30 @@ }, { "name": "spatie/laravel-query-builder", - "version": "2.8.4", + "version": "3.3.4", "source": { "type": "git", "url": "https://github.com/spatie/laravel-query-builder.git", - "reference": "377cdd397a0d424146c39b92a36a851f95587842" + "reference": "2e131b0c8ae600b6e3aabb5a1501c721862a0b8f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/spatie/laravel-query-builder/zipball/377cdd397a0d424146c39b92a36a851f95587842", - "reference": "377cdd397a0d424146c39b92a36a851f95587842", + "url": "https://api.github.com/repos/spatie/laravel-query-builder/zipball/2e131b0c8ae600b6e3aabb5a1501c721862a0b8f", + "reference": "2e131b0c8ae600b6e3aabb5a1501c721862a0b8f", "shasum": "" }, "require": { - "illuminate/database": "~5.6.34|~5.7.0|~5.8.0|^6.0|^7.0|^8.0", - "illuminate/http": "~5.6.34|~5.7.0|~5.8.0|^6.0|^7.0|^8.0", - "illuminate/support": "~5.6.34|~5.7.0|~5.8.0|^6.0|^7.0|^8.0", - "php": "^7.1" + "illuminate/database": "^6.0|^7.0|^8.0", + "illuminate/http": "^6.0|^7.0|^8.0", + "illuminate/support": "^6.0|^7.0|^8.0", + "php": "^7.3|^8.0" }, "require-dev": { "ext-json": "*", - "orchestra/testbench": "~3.6.0|~3.7.0|~3.8.0|^4.0|^5.0|^6.0", - "phpunit/phpunit": "^7.0|^8.0|^9.0" + "laravel/legacy-factories": "^1.0.4", + "mockery/mockery": "^1.4", + "orchestra/testbench": "^4.9|^5.8|^6.3", + "phpunit/phpunit": "^9.0" }, "type": "library", "extra": { @@ -3769,28 +3871,28 @@ "type": "custom" } ], - "time": "2020-09-08T22:41:35+00:00" + "time": "2020-11-26T14:51:30+00:00" }, { "name": "staudenmeir/belongs-to-through", - "version": "v2.10.1", + "version": "v2.11.1", "source": { "type": "git", "url": "https://github.com/staudenmeir/belongs-to-through.git", - "reference": "91451e8f90834807f5dc439a8124e40071f062f4" + "reference": "d300afa1045e6541b79af2291336312613b5cd02" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/staudenmeir/belongs-to-through/zipball/91451e8f90834807f5dc439a8124e40071f062f4", - "reference": "91451e8f90834807f5dc439a8124e40071f062f4", + "url": "https://api.github.com/repos/staudenmeir/belongs-to-through/zipball/d300afa1045e6541b79af2291336312613b5cd02", + "reference": "d300afa1045e6541b79af2291336312613b5cd02", "shasum": "" }, "require": { - "illuminate/database": "^7.0", - "php": "^7.2.5|^8.0" + "illuminate/database": "^8.0", + "php": "^7.3|^8.0" }, "require-dev": { - "phpunit/phpunit": "^8.5|^9.3" + "phpunit/phpunit": "^9.3" }, "type": "library", "autoload": { @@ -3815,7 +3917,7 @@ "description": "Laravel Eloquent BelongsToThrough relationships", "support": { "issues": "https://github.com/staudenmeir/belongs-to-through/issues", - "source": "https://github.com/staudenmeir/belongs-to-through/tree/v2.10.1" + "source": "https://github.com/staudenmeir/belongs-to-through/tree/v2.11.1" }, "funding": [ { @@ -3823,20 +3925,20 @@ "type": "custom" } ], - "time": "2020-11-16T19:48:36+00:00" + "time": "2020-11-16T19:39:09+00:00" }, { "name": "swiftmailer/swiftmailer", - "version": "v6.2.4", + "version": "v6.2.5", "source": { "type": "git", "url": "https://github.com/swiftmailer/swiftmailer.git", - "reference": "56f0ab23f54c4ccbb0d5dcc67ff8552e0c98d59e" + "reference": "698a6a9f54d7eb321274de3ad19863802c879fb7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/swiftmailer/swiftmailer/zipball/56f0ab23f54c4ccbb0d5dcc67ff8552e0c98d59e", - "reference": "56f0ab23f54c4ccbb0d5dcc67ff8552e0c98d59e", + "url": "https://api.github.com/repos/swiftmailer/swiftmailer/zipball/698a6a9f54d7eb321274de3ad19863802c879fb7", + "reference": "698a6a9f54d7eb321274de3ad19863802c879fb7", "shasum": "" }, "require": { @@ -3886,7 +3988,7 @@ ], "support": { "issues": "https://github.com/swiftmailer/swiftmailer/issues", - "source": "https://github.com/swiftmailer/swiftmailer/tree/v6.2.4" + "source": "https://github.com/swiftmailer/swiftmailer/tree/v6.2.5" }, "funding": [ { @@ -3898,7 +4000,7 @@ "type": "tidelift" } ], - "time": "2020-12-08T18:02:06+00:00" + "time": "2021-01-12T09:35:59+00:00" }, { "name": "symfony/console", @@ -4769,16 +4871,16 @@ }, { "name": "symfony/polyfill-ctype", - "version": "v1.20.0", + "version": "v1.22.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "f4ba089a5b6366e453971d3aad5fe8e897b37f41" + "reference": "c6c942b1ac76c82448322025e084cadc56048b4e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/f4ba089a5b6366e453971d3aad5fe8e897b37f41", - "reference": "f4ba089a5b6366e453971d3aad5fe8e897b37f41", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/c6c942b1ac76c82448322025e084cadc56048b4e", + "reference": "c6c942b1ac76c82448322025e084cadc56048b4e", "shasum": "" }, "require": { @@ -4790,7 +4892,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.20-dev" + "dev-main": "1.22-dev" }, "thanks": { "name": "symfony/polyfill", @@ -4828,7 +4930,7 @@ "portable" ], "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.20.0" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.22.0" }, "funding": [ { @@ -4844,20 +4946,20 @@ "type": "tidelift" } ], - "time": "2020-10-23T14:02:19+00:00" + "time": "2021-01-07T16:49:33+00:00" }, { "name": "symfony/polyfill-iconv", - "version": "v1.20.0", + "version": "v1.22.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-iconv.git", - "reference": "c536646fdb4f29104dd26effc2fdcb9a5b085024" + "reference": "b34bfb8c4c22650ac080d2662ae3502e5f2f4ae6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-iconv/zipball/c536646fdb4f29104dd26effc2fdcb9a5b085024", - "reference": "c536646fdb4f29104dd26effc2fdcb9a5b085024", + "url": "https://api.github.com/repos/symfony/polyfill-iconv/zipball/b34bfb8c4c22650ac080d2662ae3502e5f2f4ae6", + "reference": "b34bfb8c4c22650ac080d2662ae3502e5f2f4ae6", "shasum": "" }, "require": { @@ -4869,7 +4971,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.20-dev" + "dev-main": "1.22-dev" }, "thanks": { "name": "symfony/polyfill", @@ -4908,7 +5010,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-iconv/tree/v1.20.0" + "source": "https://github.com/symfony/polyfill-iconv/tree/v1.22.0" }, "funding": [ { @@ -4924,20 +5026,20 @@ "type": "tidelift" } ], - "time": "2020-10-23T14:02:19+00:00" + "time": "2021-01-07T16:49:33+00:00" }, { "name": "symfony/polyfill-intl-grapheme", - "version": "v1.20.0", + "version": "v1.22.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-grapheme.git", - "reference": "c7cf3f858ec7d70b89559d6e6eb1f7c2517d479c" + "reference": "267a9adeb8ecb8071040a740930e077cdfb987af" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/c7cf3f858ec7d70b89559d6e6eb1f7c2517d479c", - "reference": "c7cf3f858ec7d70b89559d6e6eb1f7c2517d479c", + "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/267a9adeb8ecb8071040a740930e077cdfb987af", + "reference": "267a9adeb8ecb8071040a740930e077cdfb987af", "shasum": "" }, "require": { @@ -4949,7 +5051,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.20-dev" + "dev-main": "1.22-dev" }, "thanks": { "name": "symfony/polyfill", @@ -4989,7 +5091,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.20.0" + "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.22.0" }, "funding": [ { @@ -5005,20 +5107,20 @@ "type": "tidelift" } ], - "time": "2020-10-23T14:02:19+00:00" + "time": "2021-01-07T16:49:33+00:00" }, { "name": "symfony/polyfill-intl-idn", - "version": "v1.20.0", + "version": "v1.22.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-idn.git", - "reference": "3b75acd829741c768bc8b1f84eb33265e7cc5117" + "reference": "0eb8293dbbcd6ef6bf81404c9ce7d95bcdf34f44" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/3b75acd829741c768bc8b1f84eb33265e7cc5117", - "reference": "3b75acd829741c768bc8b1f84eb33265e7cc5117", + "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/0eb8293dbbcd6ef6bf81404c9ce7d95bcdf34f44", + "reference": "0eb8293dbbcd6ef6bf81404c9ce7d95bcdf34f44", "shasum": "" }, "require": { @@ -5032,7 +5134,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.20-dev" + "dev-main": "1.22-dev" }, "thanks": { "name": "symfony/polyfill", @@ -5076,7 +5178,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-idn/tree/v1.20.0" + "source": "https://github.com/symfony/polyfill-intl-idn/tree/v1.22.0" }, "funding": [ { @@ -5092,20 +5194,20 @@ "type": "tidelift" } ], - "time": "2020-10-23T14:02:19+00:00" + "time": "2021-01-07T16:49:33+00:00" }, { "name": "symfony/polyfill-intl-normalizer", - "version": "v1.20.0", + "version": "v1.22.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-normalizer.git", - "reference": "727d1096295d807c309fb01a851577302394c897" + "reference": "6e971c891537eb617a00bb07a43d182a6915faba" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/727d1096295d807c309fb01a851577302394c897", - "reference": "727d1096295d807c309fb01a851577302394c897", + "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/6e971c891537eb617a00bb07a43d182a6915faba", + "reference": "6e971c891537eb617a00bb07a43d182a6915faba", "shasum": "" }, "require": { @@ -5117,7 +5219,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.20-dev" + "dev-main": "1.22-dev" }, "thanks": { "name": "symfony/polyfill", @@ -5160,7 +5262,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.20.0" + "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.22.0" }, "funding": [ { @@ -5176,20 +5278,20 @@ "type": "tidelift" } ], - "time": "2020-10-23T14:02:19+00:00" + "time": "2021-01-07T17:09:11+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.20.0", + "version": "v1.22.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "39d483bdf39be819deabf04ec872eb0b2410b531" + "reference": "f377a3dd1fde44d37b9831d68dc8dea3ffd28e13" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/39d483bdf39be819deabf04ec872eb0b2410b531", - "reference": "39d483bdf39be819deabf04ec872eb0b2410b531", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/f377a3dd1fde44d37b9831d68dc8dea3ffd28e13", + "reference": "f377a3dd1fde44d37b9831d68dc8dea3ffd28e13", "shasum": "" }, "require": { @@ -5201,7 +5303,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.20-dev" + "dev-main": "1.22-dev" }, "thanks": { "name": "symfony/polyfill", @@ -5240,7 +5342,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.20.0" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.22.0" }, "funding": [ { @@ -5256,7 +5358,7 @@ "type": "tidelift" } ], - "time": "2020-10-23T14:02:19+00:00" + "time": "2021-01-07T16:49:33+00:00" }, { "name": "symfony/polyfill-php56", @@ -5328,16 +5430,16 @@ }, { "name": "symfony/polyfill-php72", - "version": "v1.20.0", + "version": "v1.22.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php72.git", - "reference": "cede45fcdfabdd6043b3592e83678e42ec69e930" + "reference": "cc6e6f9b39fe8075b3dabfbaf5b5f645ae1340c9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/cede45fcdfabdd6043b3592e83678e42ec69e930", - "reference": "cede45fcdfabdd6043b3592e83678e42ec69e930", + "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/cc6e6f9b39fe8075b3dabfbaf5b5f645ae1340c9", + "reference": "cc6e6f9b39fe8075b3dabfbaf5b5f645ae1340c9", "shasum": "" }, "require": { @@ -5346,7 +5448,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.20-dev" + "dev-main": "1.22-dev" }, "thanks": { "name": "symfony/polyfill", @@ -5384,7 +5486,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php72/tree/v1.20.0" + "source": "https://github.com/symfony/polyfill-php72/tree/v1.22.0" }, "funding": [ { @@ -5400,20 +5502,20 @@ "type": "tidelift" } ], - "time": "2020-10-23T14:02:19+00:00" + "time": "2021-01-07T16:49:33+00:00" }, { "name": "symfony/polyfill-php73", - "version": "v1.20.0", + "version": "v1.22.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php73.git", - "reference": "8ff431c517be11c78c48a39a66d37431e26a6bed" + "reference": "a678b42e92f86eca04b7fa4c0f6f19d097fb69e2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/8ff431c517be11c78c48a39a66d37431e26a6bed", - "reference": "8ff431c517be11c78c48a39a66d37431e26a6bed", + "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/a678b42e92f86eca04b7fa4c0f6f19d097fb69e2", + "reference": "a678b42e92f86eca04b7fa4c0f6f19d097fb69e2", "shasum": "" }, "require": { @@ -5422,7 +5524,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.20-dev" + "dev-main": "1.22-dev" }, "thanks": { "name": "symfony/polyfill", @@ -5463,7 +5565,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php73/tree/v1.20.0" + "source": "https://github.com/symfony/polyfill-php73/tree/v1.22.0" }, "funding": [ { @@ -5479,20 +5581,20 @@ "type": "tidelift" } ], - "time": "2020-10-23T14:02:19+00:00" + "time": "2021-01-07T16:49:33+00:00" }, { "name": "symfony/polyfill-php80", - "version": "v1.20.0", + "version": "v1.22.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "e70aa8b064c5b72d3df2abd5ab1e90464ad009de" + "reference": "dc3063ba22c2a1fd2f45ed856374d79114998f91" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/e70aa8b064c5b72d3df2abd5ab1e90464ad009de", - "reference": "e70aa8b064c5b72d3df2abd5ab1e90464ad009de", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/dc3063ba22c2a1fd2f45ed856374d79114998f91", + "reference": "dc3063ba22c2a1fd2f45ed856374d79114998f91", "shasum": "" }, "require": { @@ -5501,7 +5603,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.20-dev" + "dev-main": "1.22-dev" }, "thanks": { "name": "symfony/polyfill", @@ -5546,7 +5648,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.20.0" + "source": "https://github.com/symfony/polyfill-php80/tree/v1.22.0" }, "funding": [ { @@ -5562,7 +5664,7 @@ "type": "tidelift" } ], - "time": "2020-10-23T14:02:19+00:00" + "time": "2021-01-07T16:49:33+00:00" }, { "name": "symfony/process", @@ -6263,37 +6365,39 @@ }, { "name": "vlucas/phpdotenv", - "version": "v4.1.8", + "version": "v5.3.0", "source": { "type": "git", "url": "https://github.com/vlucas/phpdotenv.git", - "reference": "572af79d913627a9d70374d27a6f5d689a35de32" + "reference": "b3eac5c7ac896e52deab4a99068e3f4ab12d9e56" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/572af79d913627a9d70374d27a6f5d689a35de32", - "reference": "572af79d913627a9d70374d27a6f5d689a35de32", + "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/b3eac5c7ac896e52deab4a99068e3f4ab12d9e56", + "reference": "b3eac5c7ac896e52deab4a99068e3f4ab12d9e56", "shasum": "" }, "require": { - "php": "^5.5.9 || ^7.0 || ^8.0", - "phpoption/phpoption": "^1.7.3", - "symfony/polyfill-ctype": "^1.17" + "ext-pcre": "*", + "graham-campbell/result-type": "^1.0.1", + "php": "^7.1.3 || ^8.0", + "phpoption/phpoption": "^1.7.4", + "symfony/polyfill-ctype": "^1.17", + "symfony/polyfill-mbstring": "^1.17", + "symfony/polyfill-php80": "^1.17" }, "require-dev": { "bamarni/composer-bin-plugin": "^1.4.1", "ext-filter": "*", - "ext-pcre": "*", - "phpunit/phpunit": "^4.8.35 || ^5.7.27 || ^6.5.6 || ^7.0" + "phpunit/phpunit": "^7.5.20 || ^8.5.14 || ^9.5.1" }, "suggest": { - "ext-filter": "Required to use the boolean validator.", - "ext-pcre": "Required to use most of the library." + "ext-filter": "Required to use the boolean validator." }, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.1-dev" + "dev-master": "5.3-dev" } }, "autoload": { @@ -6325,7 +6429,7 @@ ], "support": { "issues": "https://github.com/vlucas/phpdotenv/issues", - "source": "https://github.com/vlucas/phpdotenv/tree/4.1" + "source": "https://github.com/vlucas/phpdotenv/tree/v5.3.0" }, "funding": [ { @@ -6337,7 +6441,7 @@ "type": "tidelift" } ], - "time": "2020-07-14T19:22:52+00:00" + "time": "2021-01-20T15:23:13+00:00" }, { "name": "voku/portable-ascii", @@ -6418,12 +6522,12 @@ "version": "1.9.1", "source": { "type": "git", - "url": "https://github.com/webmozart/assert.git", + "url": "https://github.com/webmozarts/assert.git", "reference": "bafc69caeb4d49c39fd0779086c03a3738cbb389" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webmozart/assert/zipball/bafc69caeb4d49c39fd0779086c03a3738cbb389", + "url": "https://api.github.com/repos/webmozarts/assert/zipball/bafc69caeb4d49c39fd0779086c03a3738cbb389", "reference": "bafc69caeb4d49c39fd0779086c03a3738cbb389", "shasum": "" }, @@ -6461,74 +6565,25 @@ "validate" ], "support": { - "issues": "https://github.com/webmozart/assert/issues", - "source": "https://github.com/webmozart/assert/tree/master" + "issues": "https://github.com/webmozarts/assert/issues", + "source": "https://github.com/webmozarts/assert/tree/1.9.1" }, "time": "2020-07-08T17:02:28+00:00" } ], "packages-dev": [ - { - "name": "2bj/phanybar", - "version": "v1.0.0", - "source": { - "type": "git", - "url": "https://github.com/2bj/Phanybar.git", - "reference": "88ff671e18f30c2047a34f8cf2465a7ff93c819b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/2bj/Phanybar/zipball/88ff671e18f30c2047a34f8cf2465a7ff93c819b", - "reference": "88ff671e18f30c2047a34f8cf2465a7ff93c819b", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "bin": [ - "bin/phanybar" - ], - "type": "library", - "autoload": { - "psr-4": { - "Bakyt\\": [ - "src/" - ] - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Bakyt Turgumbaev", - "email": "dev2bj@gmail.com" - } - ], - "description": "Control AnyBar from your php", - "keywords": [ - "anybar", - "phanybar" - ], - "support": { - "issues": "https://github.com/2bj/Phanybar/issues", - "source": "https://github.com/2bj/Phanybar/tree/master" - }, - "time": "2015-03-06T12:14:28+00:00" - }, { "name": "barryvdh/laravel-debugbar", - "version": "v3.5.1", + "version": "v3.5.2", "source": { "type": "git", "url": "https://github.com/barryvdh/laravel-debugbar.git", - "reference": "233c10688f4c1a6e66ed2ef123038b1363d1bedc" + "reference": "cae0a8d1cb89b0f0522f65e60465e16d738e069b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/barryvdh/laravel-debugbar/zipball/233c10688f4c1a6e66ed2ef123038b1363d1bedc", - "reference": "233c10688f4c1a6e66ed2ef123038b1363d1bedc", + "url": "https://api.github.com/repos/barryvdh/laravel-debugbar/zipball/cae0a8d1cb89b0f0522f65e60465e16d738e069b", + "reference": "cae0a8d1cb89b0f0522f65e60465e16d738e069b", "shasum": "" }, "require": { @@ -6541,6 +6596,7 @@ "symfony/finder": "^4.3|^5" }, "require-dev": { + "mockery/mockery": "^1.3.3", "orchestra/testbench-dusk": "^4|^5|^6", "phpunit/phpunit": "^8.5|^9.0", "squizlabs/php_codesniffer": "^3.5" @@ -6587,7 +6643,7 @@ ], "support": { "issues": "https://github.com/barryvdh/laravel-debugbar/issues", - "source": "https://github.com/barryvdh/laravel-debugbar/tree/v3.5.1" + "source": "https://github.com/barryvdh/laravel-debugbar/tree/v3.5.2" }, "funding": [ { @@ -6595,48 +6651,48 @@ "type": "github" } ], - "time": "2020-09-07T19:32:39+00:00" + "time": "2021-01-06T14:21:44+00:00" }, { "name": "barryvdh/laravel-ide-helper", - "version": "v2.8.2", + "version": "v2.9.0", "source": { "type": "git", "url": "https://github.com/barryvdh/laravel-ide-helper.git", - "reference": "5515cabea39b9cf55f98980d0f269dc9d85cfcca" + "reference": "64a6b902583802c162cdccf7e76dc8619368bf1a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/barryvdh/laravel-ide-helper/zipball/5515cabea39b9cf55f98980d0f269dc9d85cfcca", - "reference": "5515cabea39b9cf55f98980d0f269dc9d85cfcca", + "url": "https://api.github.com/repos/barryvdh/laravel-ide-helper/zipball/64a6b902583802c162cdccf7e76dc8619368bf1a", + "reference": "64a6b902583802c162cdccf7e76dc8619368bf1a", "shasum": "" }, "require": { "barryvdh/reflection-docblock": "^2.0.6", "composer/composer": "^1.6 || ^2", - "doctrine/dbal": "~2.3", + "doctrine/dbal": "^2.6 || ^3", "ext-json": "*", - "illuminate/console": "^6 || ^7 || ^8", - "illuminate/filesystem": "^6 || ^7 || ^8", - "illuminate/support": "^6 || ^7 || ^8", - "php": ">=7.2", + "illuminate/console": "^8", + "illuminate/filesystem": "^8", + "illuminate/support": "^8", + "php": "^7.3 || ^8.0", "phpdocumentor/type-resolver": "^1.1.0" }, "require-dev": { "ext-pdo_sqlite": "*", "friendsofphp/php-cs-fixer": "^2", - "illuminate/config": "^6 || ^7 || ^8", - "illuminate/view": "^6 || ^7 || ^8", - "mockery/mockery": "^1.3.3", - "orchestra/testbench": "^4 || ^5 || ^6", + "illuminate/config": "^8", + "illuminate/view": "^8", + "mockery/mockery": "^1.4", + "orchestra/testbench": "^6", "phpunit/phpunit": "^8.5 || ^9", - "spatie/phpunit-snapshot-assertions": "^1.4 || ^2.2 || ^3 || ^4", + "spatie/phpunit-snapshot-assertions": "^3 || ^4", "vimeo/psalm": "^3.12" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.8-dev" + "dev-master": "2.9-dev" }, "laravel": { "providers": [ @@ -6673,7 +6729,7 @@ ], "support": { "issues": "https://github.com/barryvdh/laravel-ide-helper/issues", - "source": "https://github.com/barryvdh/laravel-ide-helper/tree/v2.8.2" + "source": "https://github.com/barryvdh/laravel-ide-helper/tree/v2.9.0" }, "funding": [ { @@ -6681,7 +6737,7 @@ "type": "github" } ], - "time": "2020-12-06T08:55:05+00:00" + "time": "2020-12-29T10:11:05+00:00" }, { "name": "barryvdh/reflection-docblock", @@ -6735,122 +6791,18 @@ }, "time": "2018-12-13T10:34:14+00:00" }, - { - "name": "codedungeon/php-cli-colors", - "version": "1.12.2", - "source": { - "type": "git", - "url": "https://github.com/mikeerickson/php-cli-colors.git", - "reference": "e346156f75717140a3dd622124d2ec686aa7ff8e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/mikeerickson/php-cli-colors/zipball/e346156f75717140a3dd622124d2ec686aa7ff8e", - "reference": "e346156f75717140a3dd622124d2ec686aa7ff8e", - "shasum": "" - }, - "require-dev": { - "phpunit/phpunit": ">=5.2" - }, - "type": "library", - "autoload": { - "psr-4": { - "Codedungeon\\PHPCliColors\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Mike Erickson", - "email": "codedungeon@gmail.com" - } - ], - "description": "Liven up you PHP Console Apps with standard colors", - "homepage": "https://github.com/mikeerickson/php-cli-colors", - "keywords": [ - "color", - "colors", - "composer", - "package", - "php" - ], - "support": { - "issues": "https://github.com/mikeerickson/php-cli-colors/issues", - "source": "https://github.com/mikeerickson/php-cli-colors/tree/1.12.2" - }, - "time": "2021-01-05T04:48:27+00:00" - }, - { - "name": "codedungeon/phpunit-result-printer", - "version": "0.28.0", - "source": { - "type": "git", - "url": "https://github.com/mikeerickson/phpunit-pretty-result-printer.git", - "reference": "bc023b0311589bee19047425083163ffa3f0cf88" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/mikeerickson/phpunit-pretty-result-printer/zipball/bc023b0311589bee19047425083163ffa3f0cf88", - "reference": "bc023b0311589bee19047425083163ffa3f0cf88", - "shasum": "" - }, - "require": { - "2bj/phanybar": "^1.0", - "codedungeon/php-cli-colors": "^1.10.2", - "hassankhan/config": "^0.11.2", - "php": "^7.1", - "symfony/yaml": "^2.7|^3.0|^4.0|^5.0" - }, - "require-dev": { - "spatie/phpunit-watcher": "^1.6" - }, - "type": "library", - "autoload": { - "psr-4": { - "Codedungeon\\PHPUnitPrettyResultPrinter\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Mike Erickson", - "email": "codedungeon@gmail.com" - } - ], - "description": "PHPUnit Pretty Result Printer", - "keywords": [ - "TDD", - "composer", - "package", - "phpunit", - "printer", - "result-printer", - "testing" - ], - "support": { - "issues": "https://github.com/mikeerickson/phpunit-pretty-result-printer/issues", - "source": "https://github.com/mikeerickson/phpunit-pretty-result-printer/tree/master" - }, - "time": "2020-06-24T00:16:05+00:00" - }, { "name": "composer/ca-bundle", - "version": "1.2.8", + "version": "1.2.9", "source": { "type": "git", "url": "https://github.com/composer/ca-bundle.git", - "reference": "8a7ecad675253e4654ea05505233285377405215" + "reference": "78a0e288fdcebf92aa2318a8d3656168da6ac1a5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/ca-bundle/zipball/8a7ecad675253e4654ea05505233285377405215", - "reference": "8a7ecad675253e4654ea05505233285377405215", + "url": "https://api.github.com/repos/composer/ca-bundle/zipball/78a0e288fdcebf92aa2318a8d3656168da6ac1a5", + "reference": "78a0e288fdcebf92aa2318a8d3656168da6ac1a5", "shasum": "" }, "require": { @@ -6859,14 +6811,15 @@ "php": "^5.3.2 || ^7.0 || ^8.0" }, "require-dev": { - "phpunit/phpunit": "^4.8.35 || ^5.7 || 6.5 - 8", + "phpstan/phpstan": "^0.12.55", "psr/log": "^1.0", + "symfony/phpunit-bridge": "^4.2 || ^5", "symfony/process": "^2.5 || ^3.0 || ^4.0 || ^5.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.x-dev" + "dev-main": "1.x-dev" } }, "autoload": { @@ -6896,7 +6849,7 @@ "support": { "irc": "irc://irc.freenode.org/composer", "issues": "https://github.com/composer/ca-bundle/issues", - "source": "https://github.com/composer/ca-bundle/tree/1.2.8" + "source": "https://github.com/composer/ca-bundle/tree/1.2.9" }, "funding": [ { @@ -6912,7 +6865,7 @@ "type": "tidelift" } ], - "time": "2020-08-23T12:54:47+00:00" + "time": "2021-01-12T12:10:35+00:00" }, { "name": "composer/composer", @@ -7379,17 +7332,329 @@ "time": "2020-11-10T18:47:58+00:00" }, { - "name": "friendsofphp/php-cs-fixer", - "version": "v2.17.3", + "name": "facade/flare-client-php", + "version": "1.3.7", "source": { "type": "git", - "url": "https://github.com/FriendsOfPHP/PHP-CS-Fixer.git", - "reference": "bd32f5dd72cdfc7b53f54077f980e144bfa2f595" + "url": "https://github.com/facade/flare-client-php.git", + "reference": "fd688d3c06658f2b3b5f7bb19f051ee4ddf02492" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/bd32f5dd72cdfc7b53f54077f980e144bfa2f595", - "reference": "bd32f5dd72cdfc7b53f54077f980e144bfa2f595", + "url": "https://api.github.com/repos/facade/flare-client-php/zipball/fd688d3c06658f2b3b5f7bb19f051ee4ddf02492", + "reference": "fd688d3c06658f2b3b5f7bb19f051ee4ddf02492", + "shasum": "" + }, + "require": { + "facade/ignition-contracts": "~1.0", + "illuminate/pipeline": "^5.5|^6.0|^7.0|^8.0", + "php": "^7.1|^8.0", + "symfony/http-foundation": "^3.3|^4.1|^5.0", + "symfony/mime": "^3.4|^4.0|^5.1", + "symfony/var-dumper": "^3.4|^4.0|^5.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^2.14", + "phpunit/phpunit": "^7.5.16", + "spatie/phpunit-snapshot-assertions": "^2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "psr-4": { + "Facade\\FlareClient\\": "src" + }, + "files": [ + "src/helpers.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Send PHP errors to Flare", + "homepage": "https://github.com/facade/flare-client-php", + "keywords": [ + "exception", + "facade", + "flare", + "reporting" + ], + "support": { + "issues": "https://github.com/facade/flare-client-php/issues", + "source": "https://github.com/facade/flare-client-php/tree/1.3.7" + }, + "funding": [ + { + "url": "https://github.com/spatie", + "type": "github" + } + ], + "time": "2020-10-21T16:02:39+00:00" + }, + { + "name": "facade/ignition", + "version": "2.5.8", + "source": { + "type": "git", + "url": "https://github.com/facade/ignition.git", + "reference": "8e907d81244649c5ea746e2ec30c32c5f59df472" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/facade/ignition/zipball/8e907d81244649c5ea746e2ec30c32c5f59df472", + "reference": "8e907d81244649c5ea746e2ec30c32c5f59df472", + "shasum": "" + }, + "require": { + "ext-json": "*", + "ext-mbstring": "*", + "facade/flare-client-php": "^1.3.7", + "facade/ignition-contracts": "^1.0.2", + "filp/whoops": "^2.4", + "illuminate/support": "^7.0|^8.0", + "monolog/monolog": "^2.0", + "php": "^7.2.5|^8.0", + "symfony/console": "^5.0", + "symfony/var-dumper": "^5.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^2.14", + "mockery/mockery": "^1.3", + "orchestra/testbench": "^5.0|^6.0", + "psalm/plugin-laravel": "^1.2" + }, + "suggest": { + "laravel/telescope": "^3.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.x-dev" + }, + "laravel": { + "providers": [ + "Facade\\Ignition\\IgnitionServiceProvider" + ], + "aliases": { + "Flare": "Facade\\Ignition\\Facades\\Flare" + } + } + }, + "autoload": { + "psr-4": { + "Facade\\Ignition\\": "src" + }, + "files": [ + "src/helpers.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "A beautiful error page for Laravel applications.", + "homepage": "https://github.com/facade/ignition", + "keywords": [ + "error", + "flare", + "laravel", + "page" + ], + "support": { + "docs": "https://flareapp.io/docs/ignition-for-laravel/introduction", + "forum": "https://twitter.com/flareappio", + "issues": "https://github.com/facade/ignition/issues", + "source": "https://github.com/facade/ignition" + }, + "time": "2020-12-29T09:12:55+00:00" + }, + { + "name": "facade/ignition-contracts", + "version": "1.0.2", + "source": { + "type": "git", + "url": "https://github.com/facade/ignition-contracts.git", + "reference": "3c921a1cdba35b68a7f0ccffc6dffc1995b18267" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/facade/ignition-contracts/zipball/3c921a1cdba35b68a7f0ccffc6dffc1995b18267", + "reference": "3c921a1cdba35b68a7f0ccffc6dffc1995b18267", + "shasum": "" + }, + "require": { + "php": "^7.3|^8.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^v2.15.8", + "phpunit/phpunit": "^9.3.11", + "vimeo/psalm": "^3.17.1" + }, + "type": "library", + "autoload": { + "psr-4": { + "Facade\\IgnitionContracts\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Freek Van der Herten", + "email": "freek@spatie.be", + "homepage": "https://flareapp.io", + "role": "Developer" + } + ], + "description": "Solution contracts for Ignition", + "homepage": "https://github.com/facade/ignition-contracts", + "keywords": [ + "contracts", + "flare", + "ignition" + ], + "support": { + "issues": "https://github.com/facade/ignition-contracts/issues", + "source": "https://github.com/facade/ignition-contracts/tree/1.0.2" + }, + "time": "2020-10-16T08:27:54+00:00" + }, + { + "name": "fakerphp/faker", + "version": "v1.13.0", + "source": { + "type": "git", + "url": "https://github.com/FakerPHP/Faker.git", + "reference": "ab3f5364d01f2c2c16113442fb987d26e4004913" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/FakerPHP/Faker/zipball/ab3f5364d01f2c2c16113442fb987d26e4004913", + "reference": "ab3f5364d01f2c2c16113442fb987d26e4004913", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "conflict": { + "fzaninotto/faker": "*" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.4.1", + "ext-intl": "*", + "phpunit/phpunit": "^7.5.20 || ^8.5.8 || ^9.4.2" + }, + "type": "library", + "autoload": { + "psr-4": { + "Faker\\": "src/Faker/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "François Zaninotto" + } + ], + "description": "Faker is a PHP library that generates fake data for you.", + "keywords": [ + "data", + "faker", + "fixtures" + ], + "support": { + "issues": "https://github.com/FakerPHP/Faker/issues", + "source": "https://github.com/FakerPHP/Faker/tree/v1.13.0" + }, + "time": "2020-12-18T16:50:48+00:00" + }, + { + "name": "filp/whoops", + "version": "2.9.1", + "source": { + "type": "git", + "url": "https://github.com/filp/whoops.git", + "reference": "307fb34a5ab697461ec4c9db865b20ff2fd40771" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/filp/whoops/zipball/307fb34a5ab697461ec4c9db865b20ff2fd40771", + "reference": "307fb34a5ab697461ec4c9db865b20ff2fd40771", + "shasum": "" + }, + "require": { + "php": "^5.5.9 || ^7.0 || ^8.0", + "psr/log": "^1.0.1" + }, + "require-dev": { + "mockery/mockery": "^0.9 || ^1.0", + "phpunit/phpunit": "^4.8.36 || ^5.7.27 || ^6.5.14 || ^7.5.20 || ^8.5.8 || ^9.3.3", + "symfony/var-dumper": "^2.6 || ^3.0 || ^4.0 || ^5.0" + }, + "suggest": { + "symfony/var-dumper": "Pretty print complex values better with var-dumper available", + "whoops/soap": "Formats errors as SOAP responses" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.7-dev" + } + }, + "autoload": { + "psr-4": { + "Whoops\\": "src/Whoops/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Filipe Dobreira", + "homepage": "https://github.com/filp", + "role": "Developer" + } + ], + "description": "php error handling for cool kids", + "homepage": "https://filp.github.io/whoops/", + "keywords": [ + "error", + "exception", + "handling", + "library", + "throwable", + "whoops" + ], + "support": { + "issues": "https://github.com/filp/whoops/issues", + "source": "https://github.com/filp/whoops/tree/2.9.1" + }, + "time": "2020-11-01T12:00:00+00:00" + }, + { + "name": "friendsofphp/php-cs-fixer", + "version": "v2.18.1", + "source": { + "type": "git", + "url": "https://github.com/FriendsOfPHP/PHP-CS-Fixer.git", + "reference": "c68ff6231adb276857761e43b7ed082f164dce0b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/c68ff6231adb276857761e43b7ed082f164dce0b", + "reference": "c68ff6231adb276857761e43b7ed082f164dce0b", "shasum": "" }, "require": { @@ -7411,7 +7676,6 @@ "symfony/stopwatch": "^3.0 || ^4.0 || ^5.0" }, "require-dev": { - "johnkary/phpunit-speedtrap": "^1.1 || ^2.0 || ^3.0", "justinrainbow/json-schema": "^5.0", "keradus/cli-executor": "^1.4", "mikey179/vfsstream": "^1.6", @@ -7420,11 +7684,11 @@ "php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.2", "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.2.1", "phpspec/prophecy-phpunit": "^1.1 || ^2.0", - "phpunit/phpunit": "^5.7.27 || ^6.5.14 || ^7.5.20 || ^8.5.13 || ^9.4.4 <9.5", + "phpunit/phpunit": "^5.7.27 || ^6.5.14 || ^7.5.20 || ^8.5.13 || ^9.5", "phpunitgoodpractices/polyfill": "^1.5", "phpunitgoodpractices/traits": "^1.9.1", "sanmai/phpunit-legacy-adapter": "^6.4 || ^8.2.1", - "symfony/phpunit-bridge": "^5.1", + "symfony/phpunit-bridge": "^5.2.1", "symfony/yaml": "^3.0 || ^4.0 || ^5.0" }, "suggest": { @@ -7472,7 +7736,7 @@ "description": "A tool to automatically fix PHP code style", "support": { "issues": "https://github.com/FriendsOfPHP/PHP-CS-Fixer/issues", - "source": "https://github.com/FriendsOfPHP/PHP-CS-Fixer/tree/v2.17.3" + "source": "https://github.com/FriendsOfPHP/PHP-CS-Fixer/tree/v2.18.1" }, "funding": [ { @@ -7480,62 +7744,7 @@ "type": "github" } ], - "time": "2020-12-24T11:14:44+00:00" - }, - { - "name": "fzaninotto/faker", - "version": "v1.9.2", - "source": { - "type": "git", - "url": "https://github.com/fzaninotto/Faker.git", - "reference": "848d8125239d7dbf8ab25cb7f054f1a630e68c2e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/fzaninotto/Faker/zipball/848d8125239d7dbf8ab25cb7f054f1a630e68c2e", - "reference": "848d8125239d7dbf8ab25cb7f054f1a630e68c2e", - "shasum": "" - }, - "require": { - "php": "^5.3.3 || ^7.0" - }, - "require-dev": { - "ext-intl": "*", - "phpunit/phpunit": "^4.8.35 || ^5.7", - "squizlabs/php_codesniffer": "^2.9.2" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.9-dev" - } - }, - "autoload": { - "psr-4": { - "Faker\\": "src/Faker/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "François Zaninotto" - } - ], - "description": "Faker is a PHP library that generates fake data for you.", - "keywords": [ - "data", - "faker", - "fixtures" - ], - "support": { - "issues": "https://github.com/fzaninotto/Faker/issues", - "source": "https://github.com/fzaninotto/Faker/tree/v1.9.2" - }, - "abandoned": true, - "time": "2020-12-11T09:56:16+00:00" + "time": "2021-01-21T18:50:42+00:00" }, { "name": "hamcrest/hamcrest-php", @@ -7588,67 +7797,6 @@ }, "time": "2020-07-09T08:09:16+00:00" }, - { - "name": "hassankhan/config", - "version": "0.11.2", - "source": { - "type": "git", - "url": "https://github.com/hassankhan/config.git", - "reference": "7fbc236c32dc6cc53a7b00992a2739cf8b41c085" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/hassankhan/config/zipball/7fbc236c32dc6cc53a7b00992a2739cf8b41c085", - "reference": "7fbc236c32dc6cc53a7b00992a2739cf8b41c085", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "require-dev": { - "phpunit/phpunit": "~4.0", - "scrutinizer/ocular": "~1.1", - "squizlabs/php_codesniffer": "~2.2" - }, - "suggest": { - "symfony/yaml": "~2.5" - }, - "type": "library", - "autoload": { - "psr-4": { - "Noodlehaus\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Hassan Khan", - "homepage": "http://hassankhan.me/", - "role": "Developer" - } - ], - "description": "Lightweight configuration file loader that supports PHP, INI, XML, JSON, and YAML files", - "homepage": "http://hassankhan.me/config/", - "keywords": [ - "config", - "configuration", - "ini", - "json", - "microphp", - "unframework", - "xml", - "yaml", - "yml" - ], - "support": { - "issues": "https://github.com/hassankhan/config/issues", - "source": "https://github.com/hassankhan/config/tree/0.11.2" - }, - "time": "2017-11-07T22:49:43+00:00" - }, { "name": "justinrainbow/json-schema", "version": "5.2.10", @@ -7721,16 +7869,16 @@ }, { "name": "laravel/dusk", - "version": "v6.11.0", + "version": "v6.11.1", "source": { "type": "git", "url": "https://github.com/laravel/dusk.git", - "reference": "7e05b3ca4f17afcba528c4c5a2390a2dd9949b38" + "reference": "2fb73c87b5805ced07e8ab4487b3c1ace0b65ae9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/dusk/zipball/7e05b3ca4f17afcba528c4c5a2390a2dd9949b38", - "reference": "7e05b3ca4f17afcba528c4c5a2390a2dd9949b38", + "url": "https://api.github.com/repos/laravel/dusk/zipball/2fb73c87b5805ced07e8ab4487b3c1ace0b65ae9", + "reference": "2fb73c87b5805ced07e8ab4487b3c1ace0b65ae9", "shasum": "" }, "require": { @@ -7787,22 +7935,22 @@ ], "support": { "issues": "https://github.com/laravel/dusk/issues", - "source": "https://github.com/laravel/dusk/tree/v6.11.0" + "source": "https://github.com/laravel/dusk/tree/v6.11.1" }, - "time": "2020-12-22T16:57:45+00:00" + "time": "2021-01-19T14:58:07+00:00" }, { "name": "maximebf/debugbar", - "version": "v1.16.4", + "version": "v1.16.5", "source": { "type": "git", "url": "https://github.com/maximebf/php-debugbar.git", - "reference": "c86c717e4bf3c6d98422da5c38bfa7b0f494b04c" + "reference": "6d51ee9e94cff14412783785e79a4e7ef97b9d62" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/maximebf/php-debugbar/zipball/c86c717e4bf3c6d98422da5c38bfa7b0f494b04c", - "reference": "c86c717e4bf3c6d98422da5c38bfa7b0f494b04c", + "url": "https://api.github.com/repos/maximebf/php-debugbar/zipball/6d51ee9e94cff14412783785e79a4e7ef97b9d62", + "reference": "6d51ee9e94cff14412783785e79a4e7ef97b9d62", "shasum": "" }, "require": { @@ -7852,9 +8000,9 @@ ], "support": { "issues": "https://github.com/maximebf/php-debugbar/issues", - "source": "https://github.com/maximebf/php-debugbar/tree/v1.16.4" + "source": "https://github.com/maximebf/php-debugbar/tree/v1.16.5" }, - "time": "2020-12-07T10:48:48+00:00" + "time": "2020-12-07T11:07:24+00:00" }, { "name": "mockery/mockery", @@ -7986,6 +8134,94 @@ ], "time": "2020-11-13T09:40:50+00:00" }, + { + "name": "nunomaduro/collision", + "version": "v5.2.0", + "source": { + "type": "git", + "url": "https://github.com/nunomaduro/collision.git", + "reference": "aca954fd03414ba0dd85d7d8e42ba9b251893d1f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nunomaduro/collision/zipball/aca954fd03414ba0dd85d7d8e42ba9b251893d1f", + "reference": "aca954fd03414ba0dd85d7d8e42ba9b251893d1f", + "shasum": "" + }, + "require": { + "facade/ignition-contracts": "^1.0", + "filp/whoops": "^2.7.2", + "php": "^7.3 || ^8.0", + "symfony/console": "^5.0" + }, + "require-dev": { + "brianium/paratest": "^6.1", + "fideloper/proxy": "^4.4.1", + "friendsofphp/php-cs-fixer": "^2.17.3", + "fruitcake/laravel-cors": "^2.0.3", + "laravel/framework": "^9.0", + "nunomaduro/larastan": "^0.6.2", + "nunomaduro/mock-final-classes": "^1.0", + "orchestra/testbench": "^7.0", + "phpstan/phpstan": "^0.12.64", + "phpunit/phpunit": "^9.5.0" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "NunoMaduro\\Collision\\Adapters\\Laravel\\CollisionServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "NunoMaduro\\Collision\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nuno Maduro", + "email": "enunomaduro@gmail.com" + } + ], + "description": "Cli error handling for console/command-line PHP applications.", + "keywords": [ + "artisan", + "cli", + "command-line", + "console", + "error", + "handling", + "laravel", + "laravel-zero", + "php", + "symfony" + ], + "support": { + "issues": "https://github.com/nunomaduro/collision/issues", + "source": "https://github.com/nunomaduro/collision" + }, + "funding": [ + { + "url": "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=66BYDWAT92N6L", + "type": "custom" + }, + { + "url": "https://github.com/nunomaduro", + "type": "github" + }, + { + "url": "https://www.patreon.com/nunomaduro", + "type": "patreon" + } + ], + "time": "2021-01-13T10:00:08+00:00" + }, { "name": "phar-io/manifest", "version": "2.0.1", @@ -8640,40 +8876,44 @@ }, { "name": "phpunit/php-code-coverage", - "version": "7.0.14", + "version": "9.2.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "bb7c9a210c72e4709cdde67f8b7362f672f2225c" + "reference": "f3e026641cc91909d421802dd3ac7827ebfd97e1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/bb7c9a210c72e4709cdde67f8b7362f672f2225c", - "reference": "bb7c9a210c72e4709cdde67f8b7362f672f2225c", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/f3e026641cc91909d421802dd3ac7827ebfd97e1", + "reference": "f3e026641cc91909d421802dd3ac7827ebfd97e1", "shasum": "" }, "require": { "ext-dom": "*", + "ext-libxml": "*", "ext-xmlwriter": "*", - "php": ">=7.2", - "phpunit/php-file-iterator": "^2.0.2", - "phpunit/php-text-template": "^1.2.1", - "phpunit/php-token-stream": "^3.1.1 || ^4.0", - "sebastian/code-unit-reverse-lookup": "^1.0.1", - "sebastian/environment": "^4.2.2", - "sebastian/version": "^2.0.1", - "theseer/tokenizer": "^1.1.3" + "nikic/php-parser": "^4.10.2", + "php": ">=7.3", + "phpunit/php-file-iterator": "^3.0.3", + "phpunit/php-text-template": "^2.0.2", + "sebastian/code-unit-reverse-lookup": "^2.0.2", + "sebastian/complexity": "^2.0", + "sebastian/environment": "^5.1.2", + "sebastian/lines-of-code": "^1.0.3", + "sebastian/version": "^3.0.1", + "theseer/tokenizer": "^1.2.0" }, "require-dev": { - "phpunit/phpunit": "^8.2.2" + "phpunit/phpunit": "^9.3" }, "suggest": { - "ext-xdebug": "^2.7.2" + "ext-pcov": "*", + "ext-xdebug": "*" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "7.0-dev" + "dev-master": "9.2-dev" } }, "autoload": { @@ -8701,7 +8941,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/7.0.14" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.5" }, "funding": [ { @@ -8709,32 +8949,32 @@ "type": "github" } ], - "time": "2020-12-02T13:39:03+00:00" + "time": "2020-11-28T06:44:49+00:00" }, { "name": "phpunit/php-file-iterator", - "version": "2.0.3", + "version": "3.0.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "4b49fb70f067272b659ef0174ff9ca40fdaa6357" + "reference": "aa4be8575f26070b100fccb67faabb28f21f66f8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/4b49fb70f067272b659ef0174ff9ca40fdaa6357", - "reference": "4b49fb70f067272b659ef0174ff9ca40fdaa6357", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/aa4be8575f26070b100fccb67faabb28f21f66f8", + "reference": "aa4be8575f26070b100fccb67faabb28f21f66f8", "shasum": "" }, "require": { - "php": ">=7.1" + "php": ">=7.3" }, "require-dev": { - "phpunit/phpunit": "^8.5" + "phpunit/phpunit": "^9.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0.x-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -8761,7 +9001,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-file-iterator/issues", - "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/2.0.3" + "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/3.0.5" }, "funding": [ { @@ -8769,26 +9009,97 @@ "type": "github" } ], - "time": "2020-11-30T08:25:21+00:00" + "time": "2020-09-28T05:57:25+00:00" }, { - "name": "phpunit/php-text-template", - "version": "1.2.1", + "name": "phpunit/php-invoker", + "version": "3.1.1", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/php-text-template.git", - "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686" + "url": "https://github.com/sebastianbergmann/php-invoker.git", + "reference": "5a10147d0aaf65b58940a0b72f71c9ac0423cc67" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/31f8b717e51d9a2afca6c9f046f5d69fc27c8686", - "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686", + "url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/5a10147d0aaf65b58940a0b72f71c9ac0423cc67", + "reference": "5a10147d0aaf65b58940a0b72f71c9ac0423cc67", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": ">=7.3" + }, + "require-dev": { + "ext-pcntl": "*", + "phpunit/phpunit": "^9.3" + }, + "suggest": { + "ext-pcntl": "*" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.1-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Invoke callables with a timeout", + "homepage": "https://github.com/sebastianbergmann/php-invoker/", + "keywords": [ + "process" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-invoker/issues", + "source": "https://github.com/sebastianbergmann/php-invoker/tree/3.1.1" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-09-28T05:58:55+00:00" + }, + { + "name": "phpunit/php-text-template", + "version": "2.0.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-text-template.git", + "reference": "5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28", + "reference": "5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, "autoload": { "classmap": [ "src/" @@ -8812,34 +9123,40 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-text-template/issues", - "source": "https://github.com/sebastianbergmann/php-text-template/tree/1.2.1" + "source": "https://github.com/sebastianbergmann/php-text-template/tree/2.0.4" }, - "time": "2015-06-21T13:50:34+00:00" + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T05:33:50+00:00" }, { "name": "phpunit/php-timer", - "version": "2.1.3", + "version": "5.0.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "2454ae1765516d20c4ffe103d85a58a9a3bd5662" + "reference": "5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/2454ae1765516d20c4ffe103d85a58a9a3bd5662", - "reference": "2454ae1765516d20c4ffe103d85a58a9a3bd5662", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2", + "reference": "5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2", "shasum": "" }, "require": { - "php": ">=7.1" + "php": ">=7.3" }, "require-dev": { - "phpunit/phpunit": "^8.5" + "phpunit/phpunit": "^9.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.1-dev" + "dev-master": "5.0-dev" } }, "autoload": { @@ -8865,7 +9182,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-timer/issues", - "source": "https://github.com/sebastianbergmann/php-timer/tree/2.1.3" + "source": "https://github.com/sebastianbergmann/php-timer/tree/5.0.3" }, "funding": [ { @@ -8873,80 +9190,20 @@ "type": "github" } ], - "time": "2020-11-30T08:20:02+00:00" - }, - { - "name": "phpunit/php-token-stream", - "version": "4.0.4", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "a853a0e183b9db7eed023d7933a858fa1c8d25a3" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/a853a0e183b9db7eed023d7933a858fa1c8d25a3", - "reference": "a853a0e183b9db7eed023d7933a858fa1c8d25a3", - "shasum": "" - }, - "require": { - "ext-tokenizer": "*", - "php": "^7.3 || ^8.0" - }, - "require-dev": { - "phpunit/phpunit": "^9.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Wrapper around PHP's tokenizer extension.", - "homepage": "https://github.com/sebastianbergmann/php-token-stream/", - "keywords": [ - "tokenizer" - ], - "support": { - "issues": "https://github.com/sebastianbergmann/php-token-stream/issues", - "source": "https://github.com/sebastianbergmann/php-token-stream/tree/master" - }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "abandoned": true, - "time": "2020-08-04T08:28:15+00:00" + "time": "2020-10-26T13:16:10+00:00" }, { "name": "phpunit/phpunit", - "version": "8.5.13", + "version": "9.5.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "8e86be391a58104ef86037ba8a846524528d784e" + "reference": "e7bdf4085de85a825f4424eae52c99a1cec2f360" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/8e86be391a58104ef86037ba8a846524528d784e", - "reference": "8e86be391a58104ef86037ba8a846524528d784e", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/e7bdf4085de85a825f4424eae52c99a1cec2f360", + "reference": "e7bdf4085de85a825f4424eae52c99a1cec2f360", "shasum": "" }, "require": { @@ -8957,32 +9214,35 @@ "ext-mbstring": "*", "ext-xml": "*", "ext-xmlwriter": "*", - "myclabs/deep-copy": "^1.10.0", + "myclabs/deep-copy": "^1.10.1", "phar-io/manifest": "^2.0.1", "phar-io/version": "^3.0.2", - "php": ">=7.2", - "phpspec/prophecy": "^1.10.3", - "phpunit/php-code-coverage": "^7.0.12", - "phpunit/php-file-iterator": "^2.0.2", - "phpunit/php-text-template": "^1.2.1", - "phpunit/php-timer": "^2.1.2", - "sebastian/comparator": "^3.0.2", - "sebastian/diff": "^3.0.2", - "sebastian/environment": "^4.2.3", - "sebastian/exporter": "^3.1.2", - "sebastian/global-state": "^3.0.0", - "sebastian/object-enumerator": "^3.0.3", - "sebastian/resource-operations": "^2.0.1", - "sebastian/type": "^1.1.3", - "sebastian/version": "^2.0.1" + "php": ">=7.3", + "phpspec/prophecy": "^1.12.1", + "phpunit/php-code-coverage": "^9.2.3", + "phpunit/php-file-iterator": "^3.0.5", + "phpunit/php-invoker": "^3.1.1", + "phpunit/php-text-template": "^2.0.3", + "phpunit/php-timer": "^5.0.2", + "sebastian/cli-parser": "^1.0.1", + "sebastian/code-unit": "^1.0.6", + "sebastian/comparator": "^4.0.5", + "sebastian/diff": "^4.0.3", + "sebastian/environment": "^5.1.3", + "sebastian/exporter": "^4.0.3", + "sebastian/global-state": "^5.0.1", + "sebastian/object-enumerator": "^4.0.3", + "sebastian/resource-operations": "^3.0.3", + "sebastian/type": "^2.3", + "sebastian/version": "^3.0.2" }, "require-dev": { - "ext-pdo": "*" + "ext-pdo": "*", + "phpspec/prophecy-phpunit": "^2.0.1" }, "suggest": { "ext-soap": "*", - "ext-xdebug": "*", - "phpunit/php-invoker": "^2.0.0" + "ext-xdebug": "*" }, "bin": [ "phpunit" @@ -8990,12 +9250,15 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "8.5-dev" + "dev-master": "9.5-dev" } }, "autoload": { "classmap": [ "src/" + ], + "files": [ + "src/Framework/Assert/Functions.php" ] }, "notification-url": "https://packagist.org/downloads/", @@ -9018,7 +9281,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", - "source": "https://github.com/sebastianbergmann/phpunit/tree/8.5.13" + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.1" }, "funding": [ { @@ -9030,7 +9293,7 @@ "type": "github" } ], - "time": "2020-12-01T04:53:52+00:00" + "time": "2021-01-17T07:42:25+00:00" }, { "name": "react/promise", @@ -9083,29 +9346,141 @@ "time": "2020-05-12T15:16:56+00:00" }, { - "name": "sebastian/code-unit-reverse-lookup", - "version": "1.0.2", + "name": "sebastian/cli-parser", + "version": "1.0.1", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", - "reference": "1de8cd5c010cb153fcd68b8d0f64606f523f7619" + "url": "https://github.com/sebastianbergmann/cli-parser.git", + "reference": "442e7c7e687e42adc03470c7b668bc4b2402c0b2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/1de8cd5c010cb153fcd68b8d0f64606f523f7619", - "reference": "1de8cd5c010cb153fcd68b8d0f64606f523f7619", + "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/442e7c7e687e42adc03470c7b668bc4b2402c0b2", + "reference": "442e7c7e687e42adc03470c7b668bc4b2402c0b2", "shasum": "" }, "require": { - "php": ">=5.6" + "php": ">=7.3" }, "require-dev": { - "phpunit/phpunit": "^8.5" + "phpunit/phpunit": "^9.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "1.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library for parsing CLI options", + "homepage": "https://github.com/sebastianbergmann/cli-parser", + "support": { + "issues": "https://github.com/sebastianbergmann/cli-parser/issues", + "source": "https://github.com/sebastianbergmann/cli-parser/tree/1.0.1" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-09-28T06:08:49+00:00" + }, + { + "name": "sebastian/code-unit", + "version": "1.0.8", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/code-unit.git", + "reference": "1fc9f64c0927627ef78ba436c9b17d967e68e120" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit/zipball/1fc9f64c0927627ef78ba436c9b17d967e68e120", + "reference": "1fc9f64c0927627ef78ba436c9b17d967e68e120", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Collection of value objects that represent the PHP code units", + "homepage": "https://github.com/sebastianbergmann/code-unit", + "support": { + "issues": "https://github.com/sebastianbergmann/code-unit/issues", + "source": "https://github.com/sebastianbergmann/code-unit/tree/1.0.8" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T13:08:54+00:00" + }, + { + "name": "sebastian/code-unit-reverse-lookup", + "version": "2.0.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", + "reference": "ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5", + "reference": "ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" } }, "autoload": { @@ -9127,7 +9502,7 @@ "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", "support": { "issues": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/issues", - "source": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/tree/1.0.2" + "source": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/tree/2.0.3" }, "funding": [ { @@ -9135,34 +9510,34 @@ "type": "github" } ], - "time": "2020-11-30T08:15:22+00:00" + "time": "2020-09-28T05:30:19+00:00" }, { "name": "sebastian/comparator", - "version": "3.0.3", + "version": "4.0.6", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "1071dfcef776a57013124ff35e1fc41ccd294758" + "reference": "55f4261989e546dc112258c7a75935a81a7ce382" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/1071dfcef776a57013124ff35e1fc41ccd294758", - "reference": "1071dfcef776a57013124ff35e1fc41ccd294758", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/55f4261989e546dc112258c7a75935a81a7ce382", + "reference": "55f4261989e546dc112258c7a75935a81a7ce382", "shasum": "" }, "require": { - "php": ">=7.1", - "sebastian/diff": "^3.0", - "sebastian/exporter": "^3.1" + "php": ">=7.3", + "sebastian/diff": "^4.0", + "sebastian/exporter": "^4.0" }, "require-dev": { - "phpunit/phpunit": "^8.5" + "phpunit/phpunit": "^9.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "4.0-dev" } }, "autoload": { @@ -9201,7 +9576,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/comparator/issues", - "source": "https://github.com/sebastianbergmann/comparator/tree/3.0.3" + "source": "https://github.com/sebastianbergmann/comparator/tree/4.0.6" }, "funding": [ { @@ -9209,33 +9584,90 @@ "type": "github" } ], - "time": "2020-11-30T08:04:30+00:00" + "time": "2020-10-26T15:49:45+00:00" }, { - "name": "sebastian/diff", - "version": "3.0.3", + "name": "sebastian/complexity", + "version": "2.0.2", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "14f72dd46eaf2f2293cbe79c93cc0bc43161a211" + "url": "https://github.com/sebastianbergmann/complexity.git", + "reference": "739b35e53379900cc9ac327b2147867b8b6efd88" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/14f72dd46eaf2f2293cbe79c93cc0bc43161a211", - "reference": "14f72dd46eaf2f2293cbe79c93cc0bc43161a211", + "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/739b35e53379900cc9ac327b2147867b8b6efd88", + "reference": "739b35e53379900cc9ac327b2147867b8b6efd88", "shasum": "" }, "require": { - "php": ">=7.1" + "nikic/php-parser": "^4.7", + "php": ">=7.3" }, "require-dev": { - "phpunit/phpunit": "^7.5 || ^8.0", - "symfony/process": "^2 || ^3.3 || ^4" + "phpunit/phpunit": "^9.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library for calculating the complexity of PHP code units", + "homepage": "https://github.com/sebastianbergmann/complexity", + "support": { + "issues": "https://github.com/sebastianbergmann/complexity/issues", + "source": "https://github.com/sebastianbergmann/complexity/tree/2.0.2" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T15:52:27+00:00" + }, + { + "name": "sebastian/diff", + "version": "4.0.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/diff.git", + "reference": "3461e3fccc7cfdfc2720be910d3bd73c69be590d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/3461e3fccc7cfdfc2720be910d3bd73c69be590d", + "reference": "3461e3fccc7cfdfc2720be910d3bd73c69be590d", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3", + "symfony/process": "^4.2 || ^5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" } }, "autoload": { @@ -9267,7 +9699,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/diff/issues", - "source": "https://github.com/sebastianbergmann/diff/tree/3.0.3" + "source": "https://github.com/sebastianbergmann/diff/tree/4.0.4" }, "funding": [ { @@ -9275,27 +9707,27 @@ "type": "github" } ], - "time": "2020-11-30T07:59:04+00:00" + "time": "2020-10-26T13:10:38+00:00" }, { "name": "sebastian/environment", - "version": "4.2.4", + "version": "5.1.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "d47bbbad83711771f167c72d4e3f25f7fcc1f8b0" + "reference": "388b6ced16caa751030f6a69e588299fa09200ac" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/d47bbbad83711771f167c72d4e3f25f7fcc1f8b0", - "reference": "d47bbbad83711771f167c72d4e3f25f7fcc1f8b0", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/388b6ced16caa751030f6a69e588299fa09200ac", + "reference": "388b6ced16caa751030f6a69e588299fa09200ac", "shasum": "" }, "require": { - "php": ">=7.1" + "php": ">=7.3" }, "require-dev": { - "phpunit/phpunit": "^7.5" + "phpunit/phpunit": "^9.3" }, "suggest": { "ext-posix": "*" @@ -9303,7 +9735,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.2-dev" + "dev-master": "5.1-dev" } }, "autoload": { @@ -9330,7 +9762,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/environment/issues", - "source": "https://github.com/sebastianbergmann/environment/tree/4.2.4" + "source": "https://github.com/sebastianbergmann/environment/tree/5.1.3" }, "funding": [ { @@ -9338,34 +9770,34 @@ "type": "github" } ], - "time": "2020-11-30T07:53:42+00:00" + "time": "2020-09-28T05:52:38+00:00" }, { "name": "sebastian/exporter", - "version": "3.1.3", + "version": "4.0.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "6b853149eab67d4da22291d36f5b0631c0fd856e" + "reference": "d89cc98761b8cb5a1a235a6b703ae50d34080e65" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/6b853149eab67d4da22291d36f5b0631c0fd856e", - "reference": "6b853149eab67d4da22291d36f5b0631c0fd856e", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/d89cc98761b8cb5a1a235a6b703ae50d34080e65", + "reference": "d89cc98761b8cb5a1a235a6b703ae50d34080e65", "shasum": "" }, "require": { - "php": ">=7.0", - "sebastian/recursion-context": "^3.0" + "php": ">=7.3", + "sebastian/recursion-context": "^4.0" }, "require-dev": { "ext-mbstring": "*", - "phpunit/phpunit": "^6.0" + "phpunit/phpunit": "^9.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.1.x-dev" + "dev-master": "4.0-dev" } }, "autoload": { @@ -9407,7 +9839,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/exporter/issues", - "source": "https://github.com/sebastianbergmann/exporter/tree/3.1.3" + "source": "https://github.com/sebastianbergmann/exporter/tree/4.0.3" }, "funding": [ { @@ -9415,30 +9847,30 @@ "type": "github" } ], - "time": "2020-11-30T07:47:53+00:00" + "time": "2020-09-28T05:24:23+00:00" }, { "name": "sebastian/global-state", - "version": "3.0.1", + "version": "5.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "474fb9edb7ab891665d3bfc6317f42a0a150454b" + "reference": "a90ccbddffa067b51f574dea6eb25d5680839455" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/474fb9edb7ab891665d3bfc6317f42a0a150454b", - "reference": "474fb9edb7ab891665d3bfc6317f42a0a150454b", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/a90ccbddffa067b51f574dea6eb25d5680839455", + "reference": "a90ccbddffa067b51f574dea6eb25d5680839455", "shasum": "" }, "require": { - "php": ">=7.2", - "sebastian/object-reflector": "^1.1.1", - "sebastian/recursion-context": "^3.0" + "php": ">=7.3", + "sebastian/object-reflector": "^2.0", + "sebastian/recursion-context": "^4.0" }, "require-dev": { "ext-dom": "*", - "phpunit/phpunit": "^8.0" + "phpunit/phpunit": "^9.3" }, "suggest": { "ext-uopz": "*" @@ -9446,7 +9878,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "5.0-dev" } }, "autoload": { @@ -9471,7 +9903,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/global-state/issues", - "source": "https://github.com/sebastianbergmann/global-state/tree/3.0.1" + "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.2" }, "funding": [ { @@ -9479,34 +9911,91 @@ "type": "github" } ], - "time": "2020-11-30T07:43:24+00:00" + "time": "2020-10-26T15:55:19+00:00" }, { - "name": "sebastian/object-enumerator", - "version": "3.0.4", + "name": "sebastian/lines-of-code", + "version": "1.0.3", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/object-enumerator.git", - "reference": "e67f6d32ebd0c749cf9d1dbd9f226c727043cdf2" + "url": "https://github.com/sebastianbergmann/lines-of-code.git", + "reference": "c1c2e997aa3146983ed888ad08b15470a2e22ecc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/e67f6d32ebd0c749cf9d1dbd9f226c727043cdf2", - "reference": "e67f6d32ebd0c749cf9d1dbd9f226c727043cdf2", + "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/c1c2e997aa3146983ed888ad08b15470a2e22ecc", + "reference": "c1c2e997aa3146983ed888ad08b15470a2e22ecc", "shasum": "" }, "require": { - "php": ">=7.0", - "sebastian/object-reflector": "^1.1.1", - "sebastian/recursion-context": "^3.0" + "nikic/php-parser": "^4.6", + "php": ">=7.3" }, "require-dev": { - "phpunit/phpunit": "^6.0" + "phpunit/phpunit": "^9.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0.x-dev" + "dev-master": "1.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library for counting the lines of code in PHP source code", + "homepage": "https://github.com/sebastianbergmann/lines-of-code", + "support": { + "issues": "https://github.com/sebastianbergmann/lines-of-code/issues", + "source": "https://github.com/sebastianbergmann/lines-of-code/tree/1.0.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-11-28T06:42:11+00:00" + }, + { + "name": "sebastian/object-enumerator", + "version": "4.0.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/object-enumerator.git", + "reference": "5c9eeac41b290a3712d88851518825ad78f45c71" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/5c9eeac41b290a3712d88851518825ad78f45c71", + "reference": "5c9eeac41b290a3712d88851518825ad78f45c71", + "shasum": "" + }, + "require": { + "php": ">=7.3", + "sebastian/object-reflector": "^2.0", + "sebastian/recursion-context": "^4.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" } }, "autoload": { @@ -9528,7 +10017,7 @@ "homepage": "https://github.com/sebastianbergmann/object-enumerator/", "support": { "issues": "https://github.com/sebastianbergmann/object-enumerator/issues", - "source": "https://github.com/sebastianbergmann/object-enumerator/tree/3.0.4" + "source": "https://github.com/sebastianbergmann/object-enumerator/tree/4.0.4" }, "funding": [ { @@ -9536,32 +10025,32 @@ "type": "github" } ], - "time": "2020-11-30T07:40:27+00:00" + "time": "2020-10-26T13:12:34+00:00" }, { "name": "sebastian/object-reflector", - "version": "1.1.2", + "version": "2.0.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/object-reflector.git", - "reference": "9b8772b9cbd456ab45d4a598d2dd1a1bced6363d" + "reference": "b4f479ebdbf63ac605d183ece17d8d7fe49c15c7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/9b8772b9cbd456ab45d4a598d2dd1a1bced6363d", - "reference": "9b8772b9cbd456ab45d4a598d2dd1a1bced6363d", + "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/b4f479ebdbf63ac605d183ece17d8d7fe49c15c7", + "reference": "b4f479ebdbf63ac605d183ece17d8d7fe49c15c7", "shasum": "" }, "require": { - "php": ">=7.0" + "php": ">=7.3" }, "require-dev": { - "phpunit/phpunit": "^6.0" + "phpunit/phpunit": "^9.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.1-dev" + "dev-master": "2.0-dev" } }, "autoload": { @@ -9583,7 +10072,7 @@ "homepage": "https://github.com/sebastianbergmann/object-reflector/", "support": { "issues": "https://github.com/sebastianbergmann/object-reflector/issues", - "source": "https://github.com/sebastianbergmann/object-reflector/tree/1.1.2" + "source": "https://github.com/sebastianbergmann/object-reflector/tree/2.0.4" }, "funding": [ { @@ -9591,32 +10080,32 @@ "type": "github" } ], - "time": "2020-11-30T07:37:18+00:00" + "time": "2020-10-26T13:14:26+00:00" }, { "name": "sebastian/recursion-context", - "version": "3.0.1", + "version": "4.0.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "367dcba38d6e1977be014dc4b22f47a484dac7fb" + "reference": "cd9d8cf3c5804de4341c283ed787f099f5506172" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/367dcba38d6e1977be014dc4b22f47a484dac7fb", - "reference": "367dcba38d6e1977be014dc4b22f47a484dac7fb", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/cd9d8cf3c5804de4341c283ed787f099f5506172", + "reference": "cd9d8cf3c5804de4341c283ed787f099f5506172", "shasum": "" }, "require": { - "php": ">=7.0" + "php": ">=7.3" }, "require-dev": { - "phpunit/phpunit": "^6.0" + "phpunit/phpunit": "^9.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0.x-dev" + "dev-master": "4.0-dev" } }, "autoload": { @@ -9646,7 +10135,7 @@ "homepage": "http://www.github.com/sebastianbergmann/recursion-context", "support": { "issues": "https://github.com/sebastianbergmann/recursion-context/issues", - "source": "https://github.com/sebastianbergmann/recursion-context/tree/3.0.1" + "source": "https://github.com/sebastianbergmann/recursion-context/tree/4.0.4" }, "funding": [ { @@ -9654,29 +10143,32 @@ "type": "github" } ], - "time": "2020-11-30T07:34:24+00:00" + "time": "2020-10-26T13:17:30+00:00" }, { "name": "sebastian/resource-operations", - "version": "2.0.2", + "version": "3.0.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/resource-operations.git", - "reference": "31d35ca87926450c44eae7e2611d45a7a65ea8b3" + "reference": "0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/31d35ca87926450c44eae7e2611d45a7a65ea8b3", - "reference": "31d35ca87926450c44eae7e2611d45a7a65ea8b3", + "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8", + "reference": "0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8", "shasum": "" }, "require": { - "php": ">=7.1" + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -9698,7 +10190,7 @@ "homepage": "https://www.github.com/sebastianbergmann/resource-operations", "support": { "issues": "https://github.com/sebastianbergmann/resource-operations/issues", - "source": "https://github.com/sebastianbergmann/resource-operations/tree/2.0.2" + "source": "https://github.com/sebastianbergmann/resource-operations/tree/3.0.3" }, "funding": [ { @@ -9706,32 +10198,32 @@ "type": "github" } ], - "time": "2020-11-30T07:30:19+00:00" + "time": "2020-09-28T06:45:17+00:00" }, { "name": "sebastian/type", - "version": "1.1.4", + "version": "2.3.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/type.git", - "reference": "0150cfbc4495ed2df3872fb31b26781e4e077eb4" + "reference": "81cd61ab7bbf2de744aba0ea61fae32f721df3d2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/0150cfbc4495ed2df3872fb31b26781e4e077eb4", - "reference": "0150cfbc4495ed2df3872fb31b26781e4e077eb4", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/81cd61ab7bbf2de744aba0ea61fae32f721df3d2", + "reference": "81cd61ab7bbf2de744aba0ea61fae32f721df3d2", "shasum": "" }, "require": { - "php": ">=7.2" + "php": ">=7.3" }, "require-dev": { - "phpunit/phpunit": "^8.2" + "phpunit/phpunit": "^9.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.1-dev" + "dev-master": "2.3-dev" } }, "autoload": { @@ -9754,7 +10246,7 @@ "homepage": "https://github.com/sebastianbergmann/type", "support": { "issues": "https://github.com/sebastianbergmann/type/issues", - "source": "https://github.com/sebastianbergmann/type/tree/1.1.4" + "source": "https://github.com/sebastianbergmann/type/tree/2.3.1" }, "funding": [ { @@ -9762,29 +10254,29 @@ "type": "github" } ], - "time": "2020-11-30T07:25:11+00:00" + "time": "2020-10-26T13:18:59+00:00" }, { "name": "sebastian/version", - "version": "2.0.1", + "version": "3.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/version.git", - "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019" + "reference": "c6c1022351a901512170118436c764e473f6de8c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/99732be0ddb3361e16ad77b68ba41efc8e979019", - "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/c6c1022351a901512170118436c764e473f6de8c", + "reference": "c6c1022351a901512170118436c764e473f6de8c", "shasum": "" }, "require": { - "php": ">=5.6" + "php": ">=7.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0.x-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -9807,9 +10299,15 @@ "homepage": "https://github.com/sebastianbergmann/version", "support": { "issues": "https://github.com/sebastianbergmann/version/issues", - "source": "https://github.com/sebastianbergmann/version/tree/master" + "source": "https://github.com/sebastianbergmann/version/tree/3.0.2" }, - "time": "2016-10-03T07:35:21+00:00" + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-09-28T06:39:44+00:00" }, { "name": "seld/jsonlint", @@ -10309,7 +10807,7 @@ "prefer-stable": true, "prefer-lowest": false, "platform": { - "php": "^7.4", + "php": "^7.4 || ^8.0", "ext-json": "*", "ext-mbstring": "*", "ext-pdo_mysql": "*", diff --git a/config/database.php b/config/database.php index e69e19ed0..d404a37fe 100644 --- a/config/database.php +++ b/config/database.php @@ -45,7 +45,7 @@ return [ 'collation' => 'utf8mb4_unicode_ci', 'prefix' => env('DB_PREFIX', ''), 'strict' => env('DB_STRICT_MODE', false), - 'timezone' => env('DB_TIMEZONE', Time::getMySQLTimezoneOffset(env('APP_TIMEZONE', 'UTC'))) + 'timezone' => env('DB_TIMEZONE', Time::getMySQLTimezoneOffset(env('APP_TIMEZONE', 'UTC'))), ], /* @@ -68,7 +68,7 @@ return [ 'collation' => 'utf8mb4_unicode_ci', 'prefix' => '', 'strict' => false, - 'timezone' => env('DB_TIMEZONE', Time::getMySQLTimezoneOffset(env('APP_TIMEZONE', 'UTC'))) + 'timezone' => env('DB_TIMEZONE', Time::getMySQLTimezoneOffset(env('APP_TIMEZONE', 'UTC'))), ], ], diff --git a/config/pterodactyl.php b/config/pterodactyl.php index 404f7aa34..db08688d3 100644 --- a/config/pterodactyl.php +++ b/config/pterodactyl.php @@ -10,7 +10,7 @@ return [ | setup on the panel. When set to true, configurations stored in the | database will not be applied. */ - 'load_environment_only' => (bool)env('APP_ENVIRONMENT_ONLY', false), + 'load_environment_only' => (bool) env('APP_ENVIRONMENT_ONLY', false), /* |-------------------------------------------------------------------------- diff --git a/database/Factories/AllocationFactory.php b/database/Factories/AllocationFactory.php new file mode 100644 index 000000000..e7a5f7e67 --- /dev/null +++ b/database/Factories/AllocationFactory.php @@ -0,0 +1,27 @@ + $this->faker->ipv4, + 'port' => $this->faker->randomNumber(5), + ]; + } +} diff --git a/database/Factories/ApiKeyFactory.php b/database/Factories/ApiKeyFactory.php new file mode 100644 index 000000000..9da4bbf75 --- /dev/null +++ b/database/Factories/ApiKeyFactory.php @@ -0,0 +1,36 @@ + ApiKey::TYPE_APPLICATION, + 'identifier' => Str::random(\Pterodactyl\Models\ApiKey::IDENTIFIER_LENGTH), + 'token' => $token ?: $token = encrypt(Str::random(\Pterodactyl\Models\ApiKey::KEY_LENGTH)), + 'allowed_ips' => null, + 'memo' => 'Test Function Key', + 'created_at' => Carbon::now(), + 'updated_at' => Carbon::now(), + ]; + } +} diff --git a/database/Factories/BackupFactory.php b/database/Factories/BackupFactory.php new file mode 100644 index 000000000..de9a1d923 --- /dev/null +++ b/database/Factories/BackupFactory.php @@ -0,0 +1,30 @@ + Uuid::uuid4()->toString(), + 'is_successful' => true, + 'name' => $this->faker->sentence, + 'disk' => Backup::ADAPTER_WINGS, + ]; + } +} diff --git a/database/Factories/DatabaseFactory.php b/database/Factories/DatabaseFactory.php new file mode 100644 index 000000000..d3c6f2a57 --- /dev/null +++ b/database/Factories/DatabaseFactory.php @@ -0,0 +1,35 @@ + Str::random(10), + 'username' => Str::random(10), + 'remote' => '%', + 'password' => $password ?: encrypt('test123'), + 'created_at' => Carbon::now(), + 'updated_at' => Carbon::now(), + ]; + } +} diff --git a/database/Factories/DatabaseHostFactory.php b/database/Factories/DatabaseHostFactory.php new file mode 100644 index 000000000..b65e856ea --- /dev/null +++ b/database/Factories/DatabaseHostFactory.php @@ -0,0 +1,31 @@ + $this->faker->colorName, + 'host' => $this->faker->unique()->ipv4, + 'port' => 3306, + 'username' => $this->faker->colorName, + 'password' => Crypt::encrypt($this->faker->word), + ]; + } +} diff --git a/database/Factories/EggFactory.php b/database/Factories/EggFactory.php new file mode 100644 index 000000000..4085b70e5 --- /dev/null +++ b/database/Factories/EggFactory.php @@ -0,0 +1,30 @@ + Uuid::uuid4()->toString(), + 'name' => $this->faker->name, + 'description' => implode(' ', $this->faker->sentences()), + 'startup' => 'java -jar test.jar', + ]; + } +} diff --git a/database/Factories/EggVariableFactory.php b/database/Factories/EggVariableFactory.php new file mode 100644 index 000000000..d288b4ee9 --- /dev/null +++ b/database/Factories/EggVariableFactory.php @@ -0,0 +1,57 @@ + $this->faker->firstName, + 'description' => $this->faker->sentence(), + 'env_variable' => Str::upper(Str::replaceArray(' ', ['_'], $this->faker->words(2, true))), + 'default_value' => $this->faker->colorName, + 'user_viewable' => 0, + 'user_editable' => 0, + 'rules' => 'required|string', + ]; + } + + /** + * Indicate that the egg variable is viewable. + */ + public function viewable(): Factory + { + return $this->state(function (array $attributes) { + return [ + 'user_viewable' => 1, + ]; + }); + } + + /** + * Indicate that the egg variable is editable. + */ + public function editable(): Factory + { + return $this->state(function (array $attributes) { + return [ + 'user_editable' => 1, + ]; + }); + } +} diff --git a/database/Factories/LocationFactory.php b/database/Factories/LocationFactory.php new file mode 100644 index 000000000..9e0af5dca --- /dev/null +++ b/database/Factories/LocationFactory.php @@ -0,0 +1,28 @@ + Str::random(8), + 'long' => Str::random(32), + ]; + } +} diff --git a/database/Factories/NestFactory.php b/database/Factories/NestFactory.php new file mode 100644 index 000000000..9a5755ba1 --- /dev/null +++ b/database/Factories/NestFactory.php @@ -0,0 +1,30 @@ + Uuid::uuid4()->toString(), + 'author' => 'testauthor@example.com', + 'name' => $this->faker->word, + 'description' => null, + ]; + } +} diff --git a/database/Factories/NodeFactory.php b/database/Factories/NodeFactory.php new file mode 100644 index 000000000..683d8a482 --- /dev/null +++ b/database/Factories/NodeFactory.php @@ -0,0 +1,44 @@ + Uuid::uuid4()->toString(), + 'public' => true, + 'name' => $this->faker->firstName, + 'fqdn' => $this->faker->ipv4, + 'scheme' => 'http', + 'behind_proxy' => false, + 'memory' => 1024, + 'memory_overallocate' => 0, + 'disk' => 10240, + 'disk_overallocate' => 0, + 'upload_size' => 100, + 'daemon_token_id' => Str::random(Node::DAEMON_TOKEN_ID_LENGTH), + 'daemon_token' => Crypt::encrypt(Str::random(Node::DAEMON_TOKEN_LENGTH)), + 'daemonListen' => 8080, + 'daemonSFTP' => 2022, + 'daemonBase' => '/var/lib/pterodactyl/volumes', + ]; + } +} diff --git a/database/Factories/ScheduleFactory.php b/database/Factories/ScheduleFactory.php new file mode 100644 index 000000000..0a28f4c41 --- /dev/null +++ b/database/Factories/ScheduleFactory.php @@ -0,0 +1,26 @@ + $this->faker->firstName(), + ]; + } +} diff --git a/database/Factories/ServerFactory.php b/database/Factories/ServerFactory.php new file mode 100644 index 000000000..c56b66863 --- /dev/null +++ b/database/Factories/ServerFactory.php @@ -0,0 +1,48 @@ + Uuid::uuid4()->toString(), + 'uuidShort' => Str::lower(Str::random(8)), + 'name' => $this->faker->firstName, + 'description' => implode(' ', $this->faker->sentences()), + 'skip_scripts' => 0, + 'suspended' => 0, + 'memory' => 512, + 'swap' => 0, + 'disk' => 512, + 'io' => 500, + 'cpu' => 0, + 'threads' => null, + 'oom_disabled' => 0, + 'installed' => 1, + 'allocation_limit' => null, + 'database_limit' => null, + 'created_at' => Carbon::now(), + 'updated_at' => Carbon::now(), + ]; + } +} diff --git a/database/Factories/SubuserFactory.php b/database/Factories/SubuserFactory.php new file mode 100644 index 000000000..7db93d4d1 --- /dev/null +++ b/database/Factories/SubuserFactory.php @@ -0,0 +1,29 @@ + [ + Permission::ACTION_WEBSOCKET_CONNECT, + ], + ]; + } +} diff --git a/database/Factories/TaskFactory.php b/database/Factories/TaskFactory.php new file mode 100644 index 000000000..f04ebbe8b --- /dev/null +++ b/database/Factories/TaskFactory.php @@ -0,0 +1,30 @@ + $this->faker->randomNumber(1), + 'action' => 'command', + 'payload' => 'test command', + 'time_offset' => 120, + 'is_queued' => false, + ]; + } +} diff --git a/database/Factories/UserFactory.php b/database/Factories/UserFactory.php new file mode 100644 index 000000000..b9e6062f3 --- /dev/null +++ b/database/Factories/UserFactory.php @@ -0,0 +1,53 @@ + $this->faker->unique()->isbn10, + 'uuid' => Uuid::uuid4()->toString(), + 'username' => $this->faker->userName, + 'email' => $this->faker->safeEmail, + 'name_first' => $this->faker->firstName, + 'name_last' => $this->faker->lastName, + 'password' => $password ?: $password = bcrypt('password'), + 'language' => 'en', + 'root_admin' => false, + 'use_totp' => false, + 'created_at' => Carbon::now(), + 'updated_at' => Carbon::now(), + ]; + } + + /** + * Indicate that the user is an admin. + */ + public function admin(): Factory + { + return $this->state(function (array $attributes) { + return [ + 'root_admin' => true, + ]; + }); + } +} diff --git a/database/seeds/.gitkeep b/database/Seeders/.gitkeep similarity index 100% rename from database/seeds/.gitkeep rename to database/Seeders/.gitkeep diff --git a/database/seeds/DatabaseSeeder.php b/database/Seeders/DatabaseSeeder.php similarity index 89% rename from database/seeds/DatabaseSeeder.php rename to database/Seeders/DatabaseSeeder.php index fa426deae..ae534fe6a 100644 --- a/database/seeds/DatabaseSeeder.php +++ b/database/Seeders/DatabaseSeeder.php @@ -1,5 +1,7 @@ filesystem->allFiles(database_path('seeds/eggs/' . kebab_case($nest->name))); + $files = $this->filesystem->allFiles(database_path('seeders/eggs/' . kebab_case($nest->name))); $this->command->alert('Updating Eggs for Nest: ' . $nest->name); Collection::make($files)->each(function ($file) use ($nest) { diff --git a/database/seeds/NestSeeder.php b/database/Seeders/NestSeeder.php similarity index 90% rename from database/seeds/NestSeeder.php rename to database/Seeders/NestSeeder.php index fdd775645..eae7ae21b 100644 --- a/database/seeds/NestSeeder.php +++ b/database/Seeders/NestSeeder.php @@ -1,5 +1,7 @@ define(Pterodactyl\Models\Server::class, function (Faker $faker) { - return [ - 'uuid' => Uuid::uuid4()->toString(), - 'uuidShort' => str_random(8), - 'name' => $faker->firstName, - 'description' => implode(' ', $faker->sentences()), - 'skip_scripts' => 0, - 'suspended' => 0, - 'memory' => 512, - 'swap' => 0, - 'disk' => 512, - 'io' => 500, - 'cpu' => 0, - 'oom_disabled' => 0, - 'installed' => 1, - 'database_limit' => null, - 'allocation_limit' => null, - 'created_at' => Carbon::now(), - 'updated_at' => Carbon::now(), - ]; -}); - -$factory->define(Pterodactyl\Models\User::class, function (Faker $faker) { - static $password; - - return [ - 'external_id' => $faker->unique()->isbn10, - 'uuid' => $faker->uuid, - 'username' => $faker->userName, - 'email' => $faker->safeEmail, - 'name_first' => $faker->firstName, - 'name_last' => $faker->lastName, - 'password' => $password ?: $password = bcrypt('password'), - 'language' => 'en', - 'root_admin' => false, - 'use_totp' => false, - 'created_at' => Chronos::now(), - 'updated_at' => Chronos::now(), - ]; -}); - -$factory->state(Pterodactyl\Models\User::class, 'admin', function () { - return [ - 'root_admin' => true, - ]; -}); - -$factory->define(Pterodactyl\Models\Location::class, function (Faker $faker) { - return [ - 'short' => Str::random(8), - 'long' => $faker->catchPhrase, - ]; -}); - -$factory->define(Pterodactyl\Models\Node::class, function (Faker $faker) { - return [ - 'uuid' => Uuid::uuid4()->toString(), - 'public' => true, - 'name' => $faker->firstName, - 'fqdn' => $faker->ipv4, - 'scheme' => 'http', - 'behind_proxy' => false, - 'memory' => 1024, - 'memory_overallocate' => 0, - 'disk' => 10240, - 'disk_overallocate' => 0, - 'upload_size' => 100, - 'daemon_token_id' => Str::random(Node::DAEMON_TOKEN_ID_LENGTH), - 'daemon_token' => encrypt(Str::random(Node::DAEMON_TOKEN_LENGTH)), - 'daemonListen' => 8080, - 'daemonSFTP' => 2022, - 'daemonBase' => '/var/lib/pterodactyl/volumes', - ]; -}); - -$factory->define(Pterodactyl\Models\Nest::class, function (Faker $faker) { - return [ - 'uuid' => $faker->unique()->uuid, - 'author' => 'testauthor@example.com', - 'name' => $faker->word, - 'description' => null, - ]; -}); - -$factory->define(Pterodactyl\Models\Egg::class, function (Faker $faker) { - return [ - 'uuid' => $faker->unique()->uuid, - 'name' => $faker->name, - 'description' => implode(' ', $faker->sentences(3)), - 'startup' => 'java -jar test.jar', - ]; -}); - -$factory->define(Pterodactyl\Models\EggVariable::class, function (Faker $faker) { - return [ - 'name' => $faker->firstName, - 'description' => $faker->sentence(), - 'env_variable' => strtoupper(str_replace(' ', '_', $faker->words(2, true))), - 'default_value' => $faker->colorName, - 'user_viewable' => 0, - 'user_editable' => 0, - 'rules' => 'required|string', - ]; -}); - -$factory->state(Pterodactyl\Models\EggVariable::class, 'viewable', function () { - return ['user_viewable' => 1]; -}); - -$factory->state(Pterodactyl\Models\EggVariable::class, 'editable', function () { - return ['user_editable' => 1]; -}); - -$factory->define(Pterodactyl\Models\Subuser::class, function (Faker $faker) { - return []; -}); - -$factory->define(Pterodactyl\Models\Allocation::class, function (Faker $faker) { - return [ - 'ip' => $faker->ipv4, - 'port' => $faker->randomNumber(5), - ]; -}); - -$factory->define(Pterodactyl\Models\DatabaseHost::class, function (Faker $faker) { - return [ - 'name' => $faker->colorName, - 'host' => $faker->unique()->ipv4, - 'port' => 3306, - 'username' => $faker->colorName, - 'password' => Crypt::encrypt($faker->word), - ]; -}); - -$factory->define(Pterodactyl\Models\Database::class, function (Faker $faker) { - static $password; - - return [ - 'database' => str_random(10), - 'username' => str_random(10), - 'remote' => '%', - 'password' => $password ?: bcrypt('test123'), - 'created_at' => Carbon::now()->toDateTimeString(), - 'updated_at' => Carbon::now()->toDateTimeString(), - ]; -}); - -$factory->define(Pterodactyl\Models\Schedule::class, function (Faker $faker) { - return [ - 'name' => $faker->firstName(), - ]; -}); - -$factory->define(Pterodactyl\Models\Task::class, function (Faker $faker) { - return [ - 'sequence_id' => $faker->randomNumber(1), - 'action' => 'command', - 'payload' => 'test command', - 'time_offset' => 120, - 'is_queued' => false, - ]; -}); - -$factory->define(Pterodactyl\Models\ApiKey::class, function (Faker $faker) { - static $token; - - return [ - 'key_type' => ApiKey::TYPE_APPLICATION, - 'identifier' => str_random(Pterodactyl\Models\ApiKey::IDENTIFIER_LENGTH), - 'token' => $token ?: $token = encrypt(str_random(Pterodactyl\Models\ApiKey::KEY_LENGTH)), - 'allowed_ips' => null, - 'memo' => 'Test Function Key', - 'created_at' => Carbon::now()->toDateTimeString(), - 'updated_at' => Carbon::now()->toDateTimeString(), - ]; -}); diff --git a/database/migrations/2016_11_04_000949_add_ark_service_option_fixed.php b/database/migrations/2016_11_04_000949_add_ark_service_option_fixed.php index 4383c11cd..1547e32cc 100644 --- a/database/migrations/2016_11_04_000949_add_ark_service_option_fixed.php +++ b/database/migrations/2016_11_04_000949_add_ark_service_option_fixed.php @@ -13,7 +13,7 @@ class AddArkServiceOptionFixed extends Migration $service = DB::table('services')->select('id')->where('author', 'ptrdctyl-v040-11e6-8b77-86f30ca893d3')->where('name', 'Source Engine')->first(); // No SRCDS Service, Skipping - if (! $service) { + if (!$service) { return; } diff --git a/database/migrations/2017_03_05_212803_DeleteServiceExecutableOption.php b/database/migrations/2017_03_05_212803_DeleteServiceExecutableOption.php index 2918e1afd..6792f265a 100644 --- a/database/migrations/2017_03_05_212803_DeleteServiceExecutableOption.php +++ b/database/migrations/2017_03_05_212803_DeleteServiceExecutableOption.php @@ -11,13 +11,11 @@ class DeleteServiceExecutableOption extends Migration */ public function up() { - DB::transaction(function () { - Schema::table('services', function (Blueprint $table) { - $table->renameColumn('file', 'folder'); - $table->dropColumn('executable'); - $table->text('description')->nullable()->change(); - $table->text('startup')->nullable()->change(); - }); + Schema::table('services', function (Blueprint $table) { + $table->renameColumn('file', 'folder'); + $table->dropColumn('executable'); + $table->text('description')->nullable()->change(); + $table->text('startup')->nullable()->change(); }); } diff --git a/database/migrations/2017_03_10_173607_MigrateToNewServiceSystem.php b/database/migrations/2017_03_10_173607_MigrateToNewServiceSystem.php index 039976352..c786ab468 100644 --- a/database/migrations/2017_03_10_173607_MigrateToNewServiceSystem.php +++ b/database/migrations/2017_03_10_173607_MigrateToNewServiceSystem.php @@ -17,12 +17,12 @@ class MigrateToNewServiceSystem extends Migration { DB::transaction(function () { $service = DB::table('services')->where('author', config('pterodactyl.service.core'))->where('folder', 'srcds')->first(); - if (! $service) { + if (!$service) { return; } $options = DB::table('service_options')->where('service_id', $service->id)->get(); - $options->each(function ($item) use ($options) { + $options->each(function ($item) { if ($item->tag === 'srcds' && $item->name === 'Insurgency') { $item->tag = 'insurgency'; } elseif ($item->tag === 'srcds' && $item->name === 'Team Fortress 2') { diff --git a/database/migrations/2017_09_13_211810_UpdateOldPermissionsToPointToNewScheduleSystem.php b/database/migrations/2017_09_13_211810_UpdateOldPermissionsToPointToNewScheduleSystem.php index b7c361f13..ba3a8bac0 100644 --- a/database/migrations/2017_09_13_211810_UpdateOldPermissionsToPointToNewScheduleSystem.php +++ b/database/migrations/2017_09_13_211810_UpdateOldPermissionsToPointToNewScheduleSystem.php @@ -13,7 +13,7 @@ class UpdateOldPermissionsToPointToNewScheduleSystem extends Migration $permissions = DB::table('permissions')->where('permission', 'like', '%-task%')->get(); foreach ($permissions as $record) { $parts = explode('-', $record->permission); - if (! in_array(array_get($parts, 1), ['tasks', 'task']) || count($parts) !== 2) { + if (!in_array(array_get($parts, 1), ['tasks', 'task']) || count($parts) !== 2) { continue; } @@ -31,7 +31,7 @@ class UpdateOldPermissionsToPointToNewScheduleSystem extends Migration $permissions = DB::table('permissions')->where('permission', 'like', '%-schedule%')->get(); foreach ($permissions as $record) { $parts = explode('-', $record->permission); - if (! in_array(array_get($parts, 1), ['schedules', 'schedule']) || count($parts) !== 2) { + if (!in_array(array_get($parts, 1), ['schedules', 'schedule']) || count($parts) !== 2) { continue; } diff --git a/database/migrations/2018_01_13_142012_SetupTableForKeyEncryption.php b/database/migrations/2018_01_13_142012_SetupTableForKeyEncryption.php index 5dba9c113..1d36b3648 100644 --- a/database/migrations/2018_01_13_142012_SetupTableForKeyEncryption.php +++ b/database/migrations/2018_01_13_142012_SetupTableForKeyEncryption.php @@ -10,6 +10,7 @@ class SetupTableForKeyEncryption extends Migration * Run the migrations. * * @return void + * * @throws \Exception * @throws \Throwable */ @@ -29,6 +30,7 @@ class SetupTableForKeyEncryption extends Migration * Reverse the migrations. * * @return void + * * @throws \Exception * @throws \Throwable */ 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 b40f4f55d..27d26674f 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 @@ -1,7 +1,7 @@ map(function ($value) { return self::$permissionsMap[$value] ?? null; })->filter(function ($value) { - return ! is_null($value) && $value !== Permission::ACTION_WEBSOCKET_CONNECT; + return !is_null($value) && $value !== Permission::ACTION_WEBSOCKET_CONNECT; }) // All subusers get this permission, so make sure it gets pushed into the array. ->merge([Permission::ACTION_WEBSOCKET_CONNECT]) @@ -109,13 +109,13 @@ class MergePermissionsTableIntoSubusers extends Migration $values = []; foreach (json_decode($datum->permissions, true) as $permission) { $v = $flipped[$permission] ?? null; - if (! empty($v)) { + if (!empty($v)) { $values[] = $datum->id; $values[] = $v; } } - if (! empty($values)) { + if (!empty($values)) { $string = 'VALUES ' . implode(', ', array_fill(0, count($values) / 2, '(?, ?)')); DB::insert('INSERT INTO permissions(`subuser_id`, `permission`) ' . $string, $values); diff --git a/database/migrations/2020_04_03_230614_create_backups_table.php b/database/migrations/2020_04_03_230614_create_backups_table.php index 68eeee2ce..daa35dd3b 100644 --- a/database/migrations/2020_04_03_230614_create_backups_table.php +++ b/database/migrations/2020_04_03_230614_create_backups_table.php @@ -20,13 +20,13 @@ class CreateBackupsTable extends Migration // to use. For now, just rename them to maintain the data. $results = DB::select('SELECT TABLE_NAME FROM information_schema.tables WHERE table_schema = ? AND table_name LIKE ? AND table_name NOT LIKE \'%_plugin_bak\'', [ config("database.connections.{$db}.database"), - 'backup%' + 'backup%', ]); // Take any of the results, most likely "backups" and "backup_logs" and rename them to have a // suffix so data isn't completely lost, but they're no longer in the way of this migration... foreach ($results as $result) { - Schema::rename($result->TABLE_NAME, $result->TABLE_NAME. '_plugin_bak'); + Schema::rename($result->TABLE_NAME, $result->TABLE_NAME . '_plugin_bak'); } Schema::create('backups', function (Blueprint $table) { 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 ff81f863d..b3d94af89 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 @@ -14,6 +14,7 @@ class StoreNodeTokensAsEncryptedValue extends Migration * Run the migrations. * * @return void + * * @throws \Exception */ public function up() diff --git a/database/migrations/2020_04_26_111208_add_backup_limit_to_servers.php b/database/migrations/2020_04_26_111208_add_backup_limit_to_servers.php index 92121b7df..b0f859c9f 100644 --- a/database/migrations/2020_04_26_111208_add_backup_limit_to_servers.php +++ b/database/migrations/2020_04_26_111208_add_backup_limit_to_servers.php @@ -19,7 +19,7 @@ class AddBackupLimitToServers extends Migration // here. If we find a result we'll actually keep the column around since we can maintain that backup // limit, but we need to correct the column definition a bit. $results = DB::select('SELECT * FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = ? AND TABLE_NAME = \'servers\' AND COLUMN_NAME = \'backup_limit\'', [ - config("database.connections.{$db}.database") + config("database.connections.{$db}.database"), ]); if (count($results) === 1) { diff --git a/database/migrations/2020_07_02_213612_create_user_recovery_tokens_table.php b/database/migrations/2020_07_02_213612_create_user_recovery_tokens_table.php index df0f34919..9b0743af2 100644 --- a/database/migrations/2020_07_02_213612_create_user_recovery_tokens_table.php +++ b/database/migrations/2020_07_02_213612_create_user_recovery_tokens_table.php @@ -1,8 +1,8 @@ unique(['database_host_id', 'database']); }); - } } diff --git a/database/migrations/2020_10_26_194904_remove_nullable_from_schedule_name_field.php b/database/migrations/2020_10_26_194904_remove_nullable_from_schedule_name_field.php index fc1f01baa..69593e656 100644 --- a/database/migrations/2020_10_26_194904_remove_nullable_from_schedule_name_field.php +++ b/database/migrations/2020_10_26_194904_remove_nullable_from_schedule_name_field.php @@ -1,9 +1,9 @@ string('cron_month')->after('cron_day_of_week'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('schedules', function (Blueprint $table) { + $table->dropColumn('cron_month'); + }); + } +} diff --git a/phpunit.xml b/phpunit.xml index e4e18e417..227dadb9e 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,14 +1,23 @@ - + + + + ./app + + ./tests/Browser/Processes @@ -20,11 +29,6 @@ ./tests/Unit - - - ./app - - diff --git a/public/index.php b/public/index.php index 233cba743..796d29022 100644 --- a/public/index.php +++ b/public/index.php @@ -7,6 +7,21 @@ */ define('LARAVEL_START', microtime(true)); +/* +|-------------------------------------------------------------------------- +| Check If Application Is Under Maintenance +|-------------------------------------------------------------------------- +| +| If the application is maintenance / demo mode via the "down" command we +| will require this file so that any pre-rendered template can be shown +| instead of starting the framework, which could cause an exception. +| +*/ + +if (file_exists(__DIR__ . '/../storage/framework/maintenance.php')) { + require __DIR__ . '/../storage/framework/maintenance.php'; +} + /* |-------------------------------------------------------------------------- | Register The Auto Loader diff --git a/resources/scripts/api/server/schedules/createOrUpdateSchedule.ts b/resources/scripts/api/server/schedules/createOrUpdateSchedule.ts index 0545650be..481cea777 100644 --- a/resources/scripts/api/server/schedules/createOrUpdateSchedule.ts +++ b/resources/scripts/api/server/schedules/createOrUpdateSchedule.ts @@ -11,6 +11,7 @@ export default (uuid: string, schedule: Data): Promise => { minute: schedule.cron.minute, hour: schedule.cron.hour, day_of_month: schedule.cron.dayOfMonth, + month: schedule.cron.month, day_of_week: schedule.cron.dayOfWeek, }) .then(({ data }) => resolve(rawDataToServerSchedule(data.attributes))) diff --git a/resources/scripts/api/server/schedules/getServerSchedules.ts b/resources/scripts/api/server/schedules/getServerSchedules.ts index 42514582a..f7a07617c 100644 --- a/resources/scripts/api/server/schedules/getServerSchedules.ts +++ b/resources/scripts/api/server/schedules/getServerSchedules.ts @@ -5,6 +5,7 @@ export interface Schedule { name: string; cron: { dayOfWeek: string; + month: string; dayOfMonth: string; hour: string; minute: string; @@ -46,6 +47,7 @@ export const rawDataToServerSchedule = (data: any): Schedule => ({ name: data.name, cron: { dayOfWeek: data.cron.day_of_week, + month: data.cron.month, dayOfMonth: data.cron.day_of_month, hour: data.cron.hour, minute: data.cron.minute, diff --git a/resources/scripts/components/dashboard/DashboardContainer.tsx b/resources/scripts/components/dashboard/DashboardContainer.tsx index b4cb4c290..2edc06056 100644 --- a/resources/scripts/components/dashboard/DashboardContainer.tsx +++ b/resources/scripts/components/dashboard/DashboardContainer.tsx @@ -16,8 +16,9 @@ import Pagination from '@/components/elements/Pagination'; export default () => { const { clearFlashes, clearAndAddHttpError } = useFlash(); const [ page, setPage ] = useState(1); - const { rootAdmin } = useStoreState(state => state.user.data!); - const [ showOnlyAdmin, setShowOnlyAdmin ] = usePersistedState('show_all_servers', false); + const uuid = useStoreState(state => state.user.data!.uuid); + const rootAdmin = useStoreState(state => state.user.data!.rootAdmin); + const [ showOnlyAdmin, setShowOnlyAdmin ] = usePersistedState(`${uuid}:show_all_servers`, false); const { data: servers, error } = useSWR>( [ '/api/client/servers', showOnlyAdmin, page ], diff --git a/resources/scripts/components/server/schedules/EditScheduleModal.tsx b/resources/scripts/components/server/schedules/EditScheduleModal.tsx index 73f74f2cf..e0df9e981 100644 --- a/resources/scripts/components/server/schedules/EditScheduleModal.tsx +++ b/resources/scripts/components/server/schedules/EditScheduleModal.tsx @@ -19,6 +19,7 @@ type Props = { interface Values { name: string; dayOfWeek: string; + month: string; dayOfMonth: string; hour: string; minute: string; @@ -38,7 +39,7 @@ const EditScheduleModal = ({ schedule, ...props }: Omit -
+
@@ -48,6 +49,9 @@ const EditScheduleModal = ({ schedule, ...props }: Omit
+
+ +
@@ -94,6 +98,7 @@ export default ({ schedule, visible, ...props }: Props) => { minute: values.minute, hour: values.hour, dayOfWeek: values.dayOfWeek, + month: values.month, dayOfMonth: values.dayOfMonth, }, isActive: values.enabled, @@ -116,10 +121,11 @@ export default ({ schedule, visible, ...props }: Props) => { onSubmit={submit} initialValues={{ name: schedule?.name || '', - dayOfWeek: schedule?.cron.dayOfWeek || '*', - dayOfMonth: schedule?.cron.dayOfMonth || '*', - hour: schedule?.cron.hour || '*', minute: schedule?.cron.minute || '*/5', + hour: schedule?.cron.hour || '*', + dayOfMonth: schedule?.cron.dayOfMonth || '*', + month: schedule?.cron.month || '*', + dayOfWeek: schedule?.cron.dayOfWeek || '*', enabled: schedule ? schedule.isActive : true, } as Values} validationSchema={null} diff --git a/resources/scripts/components/server/schedules/ScheduleCronRow.tsx b/resources/scripts/components/server/schedules/ScheduleCronRow.tsx index e7918a132..2a733b2d4 100644 --- a/resources/scripts/components/server/schedules/ScheduleCronRow.tsx +++ b/resources/scripts/components/server/schedules/ScheduleCronRow.tsx @@ -22,7 +22,7 @@ const ScheduleCronRow = ({ cron, className }: Props) => (

Day (Month)

-

*

+

{cron.month}

Month

diff --git a/resources/scripts/components/server/schedules/ScheduleEditContainer.tsx b/resources/scripts/components/server/schedules/ScheduleEditContainer.tsx index 17d58ac4e..8fcb91af0 100644 --- a/resources/scripts/components/server/schedules/ScheduleEditContainer.tsx +++ b/resources/scripts/components/server/schedules/ScheduleEditContainer.tsx @@ -28,9 +28,9 @@ interface State { } const CronBox = ({ title, value }: { title: string; value: string }) => ( -
+

{title}

-

{value}

+

{value}

); @@ -88,13 +88,6 @@ export default () => { : <> -
- - - - - -
@@ -143,6 +136,13 @@ export default () => {
+
+ + + + + +
{schedule.tasks.length > 0 ? schedule.tasks.map(task => ( diff --git a/resources/scripts/plugins/usePersistedState.ts b/resources/scripts/plugins/usePersistedState.ts index f31985558..007e3fcde 100644 --- a/resources/scripts/plugins/usePersistedState.ts +++ b/resources/scripts/plugins/usePersistedState.ts @@ -1,6 +1,6 @@ import { Dispatch, SetStateAction, useEffect, useState } from 'react'; -export function usePersistedState (key: string, defaultValue: S): [S | undefined, Dispatch>] { +export function usePersistedState (key: string, defaultValue: S): [ S | undefined, Dispatch> ] { const [ state, setState ] = useState( () => { try { @@ -12,7 +12,7 @@ export function usePersistedState (key: string, defaultValue: S): return defaultValue; } - } + }, ); useEffect(() => { diff --git a/routes/api-client.php b/routes/api-client.php index a00938f55..b0b314cc2 100644 --- a/routes/api-client.php +++ b/routes/api-client.php @@ -2,9 +2,8 @@ use Illuminate\Support\Facades\Route; use Pterodactyl\Http\Middleware\RequireTwoFactorAuthentication; -use Pterodactyl\Http\Middleware\Api\Client\Server\SubuserBelongsToServer; +use Pterodactyl\Http\Middleware\Api\Client\Server\ResourceBelongsToServer; use Pterodactyl\Http\Middleware\Api\Client\Server\AuthenticateServerAccess; -use Pterodactyl\Http\Middleware\Api\Client\Server\AllocationBelongsToServer; /* |-------------------------------------------------------------------------- @@ -39,7 +38,7 @@ Route::group(['prefix' => '/account'], function () { | Endpoint: /api/client/servers/{server} | */ -Route::group(['prefix' => '/servers/{server}', 'middleware' => [AuthenticateServerAccess::class]], function () { +Route::group(['prefix' => '/servers/{server}', 'middleware' => [AuthenticateServerAccess::class, ResourceBelongsToServer::class]], function () { Route::get('/', 'Servers\ServerController@index')->name('api:client:server.view'); Route::get('/websocket', 'Servers\WebsocketController')->name('api:client:server.ws'); Route::get('/resources', 'Servers\ResourceUtilizationController')->name('api:client:server.resources'); @@ -83,7 +82,7 @@ Route::group(['prefix' => '/servers/{server}', 'middleware' => [AuthenticateServ Route::delete('/{schedule}/tasks/{task}', 'Servers\ScheduleTaskController@delete'); }); - Route::group(['prefix' => '/network', 'middleware' => [AllocationBelongsToServer::class]], function () { + Route::group(['prefix' => '/network'], function () { Route::get('/allocations', 'Servers\NetworkAllocationController@index'); Route::post('/allocations', 'Servers\NetworkAllocationController@store'); Route::post('/allocations/{allocation}', 'Servers\NetworkAllocationController@update'); @@ -91,7 +90,7 @@ Route::group(['prefix' => '/servers/{server}', 'middleware' => [AuthenticateServ Route::delete('/allocations/{allocation}', 'Servers\NetworkAllocationController@delete'); }); - Route::group(['prefix' => '/users', 'middleware' => [SubuserBelongsToServer::class]], function () { + Route::group(['prefix' => '/users'], function () { Route::get('/', 'Servers\SubuserController@index'); Route::post('/', 'Servers\SubuserController@store'); Route::get('/{user}', 'Servers\SubuserController@view'); diff --git a/tests/Assertions/CommandAssertionsTrait.php b/tests/Assertions/CommandAssertionsTrait.php deleted file mode 100644 index bf88daa9f..000000000 --- a/tests/Assertions/CommandAssertionsTrait.php +++ /dev/null @@ -1,26 +0,0 @@ -. - * - * This software is licensed under the terms of the MIT license. - * https://opensource.org/licenses/MIT - */ - -namespace Tests\Assertions; - -use PHPUnit\Framework\Assert; - -trait CommandAssertionsTrait -{ - /** - * Assert that an output table contains a value. - * - * @param mixed $string - * @param string $display - */ - public function assertTableContains($string, $display) - { - Assert::assertRegExp('/\|(\s+)' . preg_quote($string) . '(\s+)\|/', $display, 'Assert that a response table contains a value.'); - } -} diff --git a/tests/Assertions/ControllerAssertionsTrait.php b/tests/Assertions/ControllerAssertionsTrait.php deleted file mode 100644 index 16cfcdd93..000000000 --- a/tests/Assertions/ControllerAssertionsTrait.php +++ /dev/null @@ -1,207 +0,0 @@ -. - * - * This software is licensed under the terms of the MIT license. - * https://opensource.org/licenses/MIT - */ - -namespace Tests\Assertions; - -use Illuminate\View\View; -use Illuminate\Http\Response; -use PHPUnit\Framework\Assert; -use Illuminate\Http\JsonResponse; -use Illuminate\Http\RedirectResponse; - -trait ControllerAssertionsTrait -{ - /** - * Assert that a response is an instance of Illuminate View. - * - * @param mixed $response - */ - public function assertIsViewResponse($response) - { - Assert::assertInstanceOf(View::class, $response); - } - - /** - * Assert that a response is an instance of Illuminate Redirect Response. - * - * @param mixed $response - */ - public function assertIsRedirectResponse($response) - { - Assert::assertInstanceOf(RedirectResponse::class, $response); - } - - /** - * Assert that a response is an instance of Illuminate Json Response. - * - * @param mixed $response - */ - public function assertIsJsonResponse($response) - { - Assert::assertInstanceOf(JsonResponse::class, $response); - } - - /** - * Assert that a response is an instance of Illuminate Response. - * - * @param mixed $response - */ - public function assertIsResponse($response) - { - Assert::assertInstanceOf(Response::class, $response); - } - - /** - * Assert that a view name equals the passed name. - * - * @param string $name - * @param mixed $view - */ - public function assertViewNameEquals($name, $view) - { - Assert::assertEquals($name, $view->getName()); - } - - /** - * Assert that a view name does not equal a provided name. - * - * @param string $name - * @param mixed $view - */ - public function assertViewNameNotEquals($name, $view) - { - Assert::assertNotEquals($name, $view->getName()); - } - - /** - * Assert that a view has an attribute passed into it. - * - * @param string $attribute - * @param mixed $view - */ - public function assertViewHasKey($attribute, $view) - { - if (str_contains($attribute, '.')) { - Assert::assertNotEquals( - '__TEST__FAIL', - array_get($view->getData(), $attribute, '__TEST__FAIL') - ); - } else { - Assert::assertArrayHasKey($attribute, $view->getData()); - } - } - - /** - * Assert that a view does not have a specific attribute passed in. - * - * @param string $attribute - * @param mixed $view - */ - public function assertViewNotHasKey($attribute, $view) - { - if (str_contains($attribute, '.')) { - Assert::assertEquals( - '__TEST__PASS', - array_get($view->getData(), $attribute, '__TEST__PASS') - ); - } else { - Assert::assertArrayNotHasKey($attribute, $view->getData()); - } - } - - /** - * Assert that a view attribute equals a given parameter. - * - * @param string $attribute - * @param mixed $value - * @param mixed $view - */ - public function assertViewKeyEquals($attribute, $value, $view) - { - Assert::assertEquals($value, array_get($view->getData(), $attribute, '__TEST__FAIL')); - } - - /** - * Assert that a view attribute does not equal a given parameter. - * - * @param string $attribute - * @param mixed $value - * @param mixed $view - */ - public function assertViewKeyNotEquals($attribute, $value, $view) - { - Assert::assertNotEquals($value, array_get($view->getData(), $attribute, '__TEST__FAIL')); - } - - /** - * Assert that a route redirect equals a given route name. - * - * @param string $route - * @param mixed $response - * @param array $args - */ - public function assertRedirectRouteEquals($route, $response, array $args = []) - { - Assert::assertEquals(route($route, $args), $response->getTargetUrl()); - } - - /** - * Assert that a route redirect URL equals as passed URL. - * - * @param string $url - * @param mixed $response - */ - public function assertRedirectUrlEquals($url, $response) - { - Assert::assertEquals($url, $response->getTargetUrl()); - } - - /** - * Assert that a response code equals a given code. - * - * @param int $code - * @param mixed $response - */ - public function assertResponseCodeEquals($code, $response) - { - Assert::assertEquals($code, $response->getStatusCode()); - } - - /** - * Assert that a response code does not equal a given code. - * - * @param int $code - * @param mixed $response - */ - public function assertResponseCodeNotEquals($code, $response) - { - Assert::assertNotEquals($code, $response->getStatusCode()); - } - - /** - * Assert that a response is in a JSON format. - * - * @param mixed $response - */ - public function assertResponseHasJsonHeaders($response) - { - Assert::assertEquals('application/json', $response->headers->get('content-type')); - } - - /** - * Assert that response JSON matches a given JSON string. - * - * @param array|string $json - * @param mixed $response - */ - public function assertResponseJsonEquals($json, $response) - { - Assert::assertEquals(is_array($json) ? json_encode($json) : $json, $response->getContent()); - } -} diff --git a/tests/Assertions/MiddlewareAttributeAssertionsTrait.php b/tests/Assertions/MiddlewareAttributeAssertionsTrait.php index fb8f70086..bd5ec0d1d 100644 --- a/tests/Assertions/MiddlewareAttributeAssertionsTrait.php +++ b/tests/Assertions/MiddlewareAttributeAssertionsTrait.php @@ -1,6 +1,6 @@ . - * - * This software is licensed under the terms of the MIT license. - * https://opensource.org/licenses/MIT - */ - -namespace Tests\Assertions; - -use PHPUnit\Framework\Assert; -use PHPUnit_Util_InvalidArgumentHelper; - -trait NestedObjectAssertionsTrait -{ - /** - * Assert that an object value matches an expected value. - * - * @param string $key - * @param mixed $expected - * @param object $object - */ - public function assertObjectNestedValueEquals(string $key, $expected, $object) - { - if (! is_object($object)) { - throw PHPUnit_Util_InvalidArgumentHelper::factory(3, 'object'); - } - - Assert::assertEquals($expected, object_get_strict($object, $key, '__TEST_FAILURE'), 'Assert that an object value equals a provided value.'); - } - - /** - * Assert that an object contains a nested key. - * - * @param string $key - * @param object $object - */ - public function assertObjectHasNestedAttribute(string $key, $object) - { - if (! is_object($object)) { - throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'object'); - } - - Assert::assertNotEquals('__TEST_FAILURE', object_get_strict($object, $key, '__TEST_FAILURE'), 'Assert that an object contains a nested key.'); - } -} diff --git a/tests/Browser/BrowserTestCase.php b/tests/Browser/BrowserTestCase.php index 6972a41dc..68a6ddc1b 100644 --- a/tests/Browser/BrowserTestCase.php +++ b/tests/Browser/BrowserTestCase.php @@ -5,10 +5,10 @@ namespace Pterodactyl\Tests\Browser; use Laravel\Dusk\TestCase; use BadMethodCallException; use Pterodactyl\Models\User; -use Tests\CreatesApplication; use Pterodactyl\Console\Kernel; use Illuminate\Support\Facades\Hash; use Illuminate\Database\Eloquent\Model; +use Pterodactyl\Tests\CreatesApplication; use Facebook\WebDriver\Chrome\ChromeOptions; use Facebook\WebDriver\Remote\RemoteWebDriver; use Facebook\WebDriver\Remote\DesiredCapabilities; @@ -70,14 +70,16 @@ abstract class BrowserTestCase extends TestCase */ protected function driver() { - $options = (new ChromeOptions)->addArguments([ + $options = (new ChromeOptions())->addArguments([ '--disable-gpu', '--disable-infobars', ]); return RemoteWebDriver::create( - 'http://host.pterodactyl.local:4444/wd/hub', DesiredCapabilities::chrome()->setCapability( - ChromeOptions::CAPABILITY, $options + 'http://host.pterodactyl.local:4444/wd/hub', + DesiredCapabilities::chrome()->setCapability( + ChromeOptions::CAPABILITY, + $options ) ); } @@ -86,6 +88,7 @@ abstract class BrowserTestCase extends TestCase * Return an instance of the browser to be used for tests. * * @param \Facebook\WebDriver\Remote\RemoteWebDriver $driver + * * @return \Pterodactyl\Tests\Browser\PterodactylBrowser */ protected function newBrowser($driver): PterodactylBrowser @@ -109,13 +112,10 @@ abstract class BrowserTestCase extends TestCase /** * Return a user model to authenticate aganist and use in the tests. - * - * @param array $attributes - * @return \Pterodactyl\Models\User */ protected function user(array $attributes = []): User { - return factory(User::class)->create(array_merge([ + return User::factory()->create(array_merge([ 'password' => Hash::make(static::$userPassword), ], $attributes)); } diff --git a/tests/Browser/Pages/LoginPage.php b/tests/Browser/Pages/LoginPage.php index 5fd42cbf6..ea60b0580 100644 --- a/tests/Browser/Pages/LoginPage.php +++ b/tests/Browser/Pages/LoginPage.php @@ -4,9 +4,6 @@ namespace Pterodactyl\Tests\Browser\Pages; class LoginPage extends BasePage { - /** - * @return string - */ public function url(): string { return '/auth/login'; diff --git a/tests/Browser/Processes/Authentication/ForgotPasswordProcessTest.php b/tests/Browser/Processes/Authentication/ForgotPasswordProcessTest.php index ab8c9bc8a..f6cef86c4 100644 --- a/tests/Browser/Processes/Authentication/ForgotPasswordProcessTest.php +++ b/tests/Browser/Processes/Authentication/ForgotPasswordProcessTest.php @@ -15,7 +15,7 @@ class ForgotPasswordProcessTest extends BrowserTestCase public function testResetPasswordWithInvalidAccount() { $this->browse(function (PterodactylBrowser $browser) { - $browser->visit(new LoginPage) + $browser->visit(new LoginPage()) ->assertSee(trans('auth.forgot_password.label')) ->click('@forgotPassword') ->waitForLocation('/auth/password') @@ -39,7 +39,7 @@ class ForgotPasswordProcessTest extends BrowserTestCase public function testEmailCarryover() { $this->browse(function (PterodactylBrowser $browser) { - $browser->visit(new LoginPage) + $browser->visit(new LoginPage()) ->type('@username', 'dane@example.com') ->click('@forgotPassword') ->waitForLocation('/auth/password') diff --git a/tests/Browser/Processes/Authentication/LoginProcessTest.php b/tests/Browser/Processes/Authentication/LoginProcessTest.php index bf10fde56..0806cd789 100644 --- a/tests/Browser/Processes/Authentication/LoginProcessTest.php +++ b/tests/Browser/Processes/Authentication/LoginProcessTest.php @@ -27,7 +27,7 @@ class LoginProcessTest extends BrowserTestCase public function testLoginUsingEmail() { $this->browse(function (PterodactylBrowser $browser) { - $browser->visit(new LoginPage) + $browser->visit(new LoginPage()) ->waitFor('@username') ->type('@username', $this->user->email) ->type('@password', self::$userPassword) @@ -44,7 +44,7 @@ class LoginProcessTest extends BrowserTestCase public function testLoginUsingUsername() { $this->browse(function (PterodactylBrowser $browser) { - $browser->visit(new LoginPage) + $browser->visit(new LoginPage()) ->waitFor('@username') ->type('@username', $this->user->username) ->type('@password', self::$userPassword) diff --git a/tests/Browser/Processes/Dashboard/AccountEmailProcessTest.php b/tests/Browser/Processes/Dashboard/AccountEmailProcessTest.php index 311312b21..6efe4ee03 100644 --- a/tests/Browser/Processes/Dashboard/AccountEmailProcessTest.php +++ b/tests/Browser/Processes/Dashboard/AccountEmailProcessTest.php @@ -14,7 +14,7 @@ class AccountEmailProcessTest extends DashboardTestCase { $this->browse(function (PterodactylBrowser $browser) { $browser->loginAs($this->user) - ->visit(new AccountPage) + ->visit(new AccountPage()) ->assertValue('@email', $this->user->email) ->type('@email', 'new.email@example.com') ->type('@password', 'Password123') @@ -34,7 +34,7 @@ class AccountEmailProcessTest extends DashboardTestCase { $this->browse(function (PterodactylBrowser $browser) { $browser->loginAs($this->user) - ->visit(new AccountPage) + ->visit(new AccountPage()) ->assertMissing('@email ~ .input-help.error') ->type('@email', 'admin') ->assertVisible('@email ~ .input-help.error') @@ -51,7 +51,7 @@ class AccountEmailProcessTest extends DashboardTestCase { $this->browse(function (PterodactylBrowser $browser) { $browser->loginAs($this->user) - ->visit(new AccountPage) + ->visit(new AccountPage()) ->type('@email', 'new.email@example.com') ->click('@submit') ->assertFocused('@password') diff --git a/tests/Browser/Processes/Dashboard/AccountPasswordProcessTest.php b/tests/Browser/Processes/Dashboard/AccountPasswordProcessTest.php index 0b5e48786..4b8a5a3b6 100644 --- a/tests/Browser/Processes/Dashboard/AccountPasswordProcessTest.php +++ b/tests/Browser/Processes/Dashboard/AccountPasswordProcessTest.php @@ -14,7 +14,7 @@ class AccountPasswordProcessTest extends DashboardTestCase { $this->browse(function (PterodactylBrowser $browser) { $browser->loginAs($this->user) - ->visit(new AccountPage) + ->visit(new AccountPage()) ->type('@current_password', self::$userPassword) ->assertMissing('@new_password ~ .input-help.error') ->type('@new_password', 'test') @@ -42,7 +42,7 @@ class AccountPasswordProcessTest extends DashboardTestCase { $this->browse(function (PterodactylBrowser $browser) { $browser->loginAs($this->user) - ->visit(new AccountPage) + ->visit(new AccountPage()) ->type('@current_password', 'badpassword') ->type('@new_password', 'testtest') ->type('@confirm_password', 'testtest') diff --git a/tests/Browser/Processes/Dashboard/TwoFactorAuthenticationProcessTest.php b/tests/Browser/Processes/Dashboard/TwoFactorAuthenticationProcessTest.php index 26a13048e..463286ddb 100644 --- a/tests/Browser/Processes/Dashboard/TwoFactorAuthenticationProcessTest.php +++ b/tests/Browser/Processes/Dashboard/TwoFactorAuthenticationProcessTest.php @@ -17,7 +17,7 @@ class TwoFactorAuthenticationProcessTest extends DashboardTestCase { $this->browse(function (PterodactylBrowser $browser) { $browser->loginAs($this->user) - ->visit(new AccountPage) + ->visit(new AccountPage()) ->assertMissing('.modal-mask') ->click('@2fa_button') ->waitFor('@2fa_modal') @@ -42,7 +42,7 @@ class TwoFactorAuthenticationProcessTest extends DashboardTestCase { $this->browse(function (PterodactylBrowser $browser) { $browser->loginAs($this->user) - ->visit(new AccountPage) + ->visit(new AccountPage()) ->click('@2fa_button') ->waitForText(trans('dashboard/account.two_factor.setup.title')) ->assertFocused('@2fa_token') @@ -76,7 +76,7 @@ class TwoFactorAuthenticationProcessTest extends DashboardTestCase */ public function testTwoFactorCanBeDisabled() { - $secret = (new Google2FA)->generateSecretKey(16); + $secret = (new Google2FA())->generateSecretKey(16); $this->user->update([ 'use_totp' => true, @@ -85,7 +85,7 @@ class TwoFactorAuthenticationProcessTest extends DashboardTestCase $this->browse(function (PterodactylBrowser $browser) use ($secret) { $browser->loginAs($this->user) - ->visit(new AccountPage) + ->visit(new AccountPage()) ->click('@2fa_button') ->waitForText(trans('dashboard/account.two_factor.disable.title')) ->click('@2fa_cancel') diff --git a/tests/Browser/PterodactylBrowser.php b/tests/Browser/PterodactylBrowser.php index c7465ff3e..9136a6a65 100644 --- a/tests/Browser/PterodactylBrowser.php +++ b/tests/Browser/PterodactylBrowser.php @@ -11,8 +11,6 @@ class PterodactylBrowser extends Browser /** * Move the mouse to a specific location and then perform a left click action. * - * @param int $x - * @param int $y * @return $this */ public function clickPosition(int $x, int $y) @@ -26,6 +24,7 @@ class PterodactylBrowser extends Browser * Perform a case insensitive search for a string in the body. * * @param string $text + * * @return \Pterodactyl\Tests\Browser\PterodactylBrowser */ public function assertSee($text) @@ -38,6 +37,7 @@ class PterodactylBrowser extends Browser * * @param string $selector * @param string $text + * * @return \Pterodactyl\Tests\Browser\PterodactylBrowser */ public function assertSeeIn($selector, $text) diff --git a/tests/CreatesApplication.php b/tests/CreatesApplication.php index ab9240255..b7ff2256c 100644 --- a/tests/CreatesApplication.php +++ b/tests/CreatesApplication.php @@ -1,6 +1,6 @@ create([ + return User::factory()->create([ 'root_admin' => true, ]); } @@ -108,7 +110,7 @@ abstract class ApplicationApiIntegrationTestCase extends IntegrationTestCase */ protected function createApiKey(User $user, array $permissions = []): ApiKey { - return factory(ApiKey::class)->create(array_merge([ + return ApiKey::factory()->create(array_merge([ 'user_id' => $user->id, 'key_type' => ApiKey::TYPE_APPLICATION, 'r_servers' => AdminAcl::READ | AdminAcl::WRITE, diff --git a/tests/Integration/Api/Application/Location/LocationControllerTest.php b/tests/Integration/Api/Application/Location/LocationControllerTest.php index 222dc2847..150e01bea 100644 --- a/tests/Integration/Api/Application/Location/LocationControllerTest.php +++ b/tests/Integration/Api/Application/Location/LocationControllerTest.php @@ -16,7 +16,7 @@ class LocationControllerTest extends ApplicationApiIntegrationTestCase */ public function testGetLocations() { - $locations = factory(Location::class)->times(2)->create(); + $locations = Location::factory()->times(2)->create(); $response = $this->getJson('/api/application/locations'); $response->assertStatus(Response::HTTP_OK); @@ -70,7 +70,7 @@ class LocationControllerTest extends ApplicationApiIntegrationTestCase */ public function testGetSingleLocation() { - $location = factory(Location::class)->create(); + $location = Location::factory()->create(); $response = $this->getJson('/api/application/locations/' . $location->id); $response->assertStatus(Response::HTTP_OK); @@ -93,7 +93,7 @@ class LocationControllerTest extends ApplicationApiIntegrationTestCase */ public function testRelationshipsCanBeLoaded() { - $location = factory(Location::class)->create(); + $location = Location::factory()->create(); $server = $this->createServerModel(['user_id' => $this->getApiUser()->id, 'location_id' => $location->id]); $response = $this->getJson('/api/application/locations/' . $location->id . '?include=servers,nodes'); @@ -143,8 +143,8 @@ class LocationControllerTest extends ApplicationApiIntegrationTestCase { $this->createNewDefaultApiKey($this->getApiUser(), ['r_nodes' => 0]); - $location = factory(Location::class)->create(); - factory(Node::class)->create(['location_id' => $location->id]); + $location = Location::factory()->create(); + Node::factory()->create(['location_id' => $location->id]); $response = $this->getJson('/api/application/locations/' . $location->id . '?include=nodes'); $response->assertStatus(Response::HTTP_OK); @@ -187,7 +187,7 @@ class LocationControllerTest extends ApplicationApiIntegrationTestCase */ public function testErrorReturnedIfNoPermission() { - $location = factory(Location::class)->create(); + $location = Location::factory()->create(); $this->createNewDefaultApiKey($this->getApiUser(), ['r_locations' => 0]); $response = $this->getJson('/api/application/locations/' . $location->id); diff --git a/tests/Integration/Api/Application/Nests/EggControllerTest.php b/tests/Integration/Api/Application/Nests/EggControllerTest.php index f9b42dae0..584a64521 100644 --- a/tests/Integration/Api/Application/Nests/EggControllerTest.php +++ b/tests/Integration/Api/Application/Nests/EggControllerTest.php @@ -61,7 +61,9 @@ class EggControllerTest extends ApplicationApiIntegrationTestCase $expected = json_encode(Arr::sortRecursive($datum['attributes'])); $actual = json_encode(Arr::sortRecursive($this->getTransformer(EggTransformer::class)->transform($egg))); - $this->assertSame($expected, $actual, + $this->assertSame( + $expected, + $actual, 'Unable to find JSON fragment: ' . PHP_EOL . PHP_EOL . "[{$expected}]" . PHP_EOL . PHP_EOL . 'within' . PHP_EOL . PHP_EOL . "[{$actual}]." ); } diff --git a/tests/Integration/Api/Application/Users/ExternalUserControllerTest.php b/tests/Integration/Api/Application/Users/ExternalUserControllerTest.php index f28e15a93..983710b16 100644 --- a/tests/Integration/Api/Application/Users/ExternalUserControllerTest.php +++ b/tests/Integration/Api/Application/Users/ExternalUserControllerTest.php @@ -13,7 +13,7 @@ class ExternalUserControllerTest extends ApplicationApiIntegrationTestCase */ public function testGetRemoteUser() { - $user = factory(User::class)->create(); + $user = User::factory()->create(); $response = $this->getJson('/api/application/users/external/' . $user->external_id); $response->assertStatus(Response::HTTP_OK); @@ -60,7 +60,7 @@ class ExternalUserControllerTest extends ApplicationApiIntegrationTestCase */ public function testErrorReturnedIfNoPermission() { - $user = factory(User::class)->create(); + $user = User::factory()->create(); $this->createNewDefaultApiKey($this->getApiUser(), ['r_users' => 0]); $response = $this->getJson('/api/application/users/external/' . $user->external_id); diff --git a/tests/Integration/Api/Application/Users/UserControllerTest.php b/tests/Integration/Api/Application/Users/UserControllerTest.php index 128d9b607..00b091589 100644 --- a/tests/Integration/Api/Application/Users/UserControllerTest.php +++ b/tests/Integration/Api/Application/Users/UserControllerTest.php @@ -16,7 +16,7 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase */ public function testGetUsers() { - $user = factory(User::class)->create(); + $user = User::factory()->create(); $response = $this->getJson('/api/application/users'); $response->assertStatus(Response::HTTP_OK); @@ -85,7 +85,7 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase */ public function testGetSingleUser() { - $user = factory(User::class)->create(); + $user = User::factory()->create(); $response = $this->getJson('/api/application/users/' . $user->id); $response->assertStatus(Response::HTTP_OK); @@ -119,7 +119,7 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase */ public function testRelationshipsCanBeLoaded() { - $user = factory(User::class)->create(); + $user = User::factory()->create(); $server = $this->createServerModel(['user_id' => $user->id]); $response = $this->getJson('/api/application/users/' . $user->id . '?include=servers'); @@ -152,7 +152,7 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase { $this->createNewDefaultApiKey($this->getApiUser(), ['r_servers' => 0]); - $user = factory(User::class)->create(); + $user = User::factory()->create(); $this->createServerModel(['user_id' => $user->id]); $response = $this->getJson('/api/application/users/' . $user->id . '?include=servers'); @@ -194,7 +194,7 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase */ public function testErrorReturnedIfNoPermission() { - $user = factory(User::class)->create(); + $user = User::factory()->create(); $this->createNewDefaultApiKey($this->getApiUser(), ['r_users' => 0]); $response = $this->getJson('/api/application/users/' . $user->id); @@ -250,7 +250,7 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase */ public function testUpdateUser() { - $user = factory(User::class)->create(); + $user = User::factory()->create(); $response = $this->patchJson('/api/application/users/' . $user->id, [ 'username' => 'new.test.name', @@ -279,7 +279,7 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase */ public function testDeleteUser() { - $user = factory(User::class)->create(); + $user = User::factory()->create(); $this->assertDatabaseHas('users', ['id' => $user->id]); $response = $this->delete('/api/application/users/' . $user->id); @@ -292,9 +292,6 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase * Test that an API key without write permissions cannot create, update, or * delete a user model. * - * @param string $method - * @param string $url - * * @dataProvider userWriteEndpointsDataProvider */ public function testApiKeyWithoutWritePermissions(string $method, string $url) @@ -302,7 +299,7 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase $this->createNewDefaultApiKey($this->getApiUser(), ['r_users' => AdminAcl::READ]); if (str_contains($url, '{id}')) { - $user = factory(User::class)->create(); + $user = User::factory()->create(); $url = str_replace('{id}', $user->id, $url); } @@ -313,8 +310,6 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase /** * Endpoints that should return a 403 error when the key does not have write * permissions for user management. - * - * @return array */ public function userWriteEndpointsDataProvider(): array { diff --git a/tests/Integration/Api/Client/AccountControllerTest.php b/tests/Integration/Api/Client/AccountControllerTest.php index 6534bd508..3ed689ef9 100644 --- a/tests/Integration/Api/Client/AccountControllerTest.php +++ b/tests/Integration/Api/Client/AccountControllerTest.php @@ -15,7 +15,7 @@ class AccountControllerTest extends ClientApiIntegrationTestCase public function testAccountDetailsAreReturned() { /** @var \Pterodactyl\Models\User $user */ - $user = factory(User::class)->create(); + $user = User::factory()->create(); $response = $this->actingAs($user)->get('/api/client/account'); @@ -39,7 +39,7 @@ class AccountControllerTest extends ClientApiIntegrationTestCase public function testEmailIsUpdated() { /** @var \Pterodactyl\Models\User $user */ - $user = factory(User::class)->create(); + $user = User::factory()->create(); $response = $this->actingAs($user)->putJson('/api/client/account/email', [ 'email' => 'hodor@example.com', @@ -58,7 +58,7 @@ class AccountControllerTest extends ClientApiIntegrationTestCase public function testEmailIsNotUpdatedWhenPasswordIsInvalid() { /** @var \Pterodactyl\Models\User $user */ - $user = factory(User::class)->create(); + $user = User::factory()->create(); $response = $this->actingAs($user)->putJson('/api/client/account/email', [ 'email' => 'hodor@example.com', @@ -77,7 +77,7 @@ class AccountControllerTest extends ClientApiIntegrationTestCase public function testEmailIsNotUpdatedWhenNotValid() { /** @var \Pterodactyl\Models\User $user */ - $user = factory(User::class)->create(); + $user = User::factory()->create(); $response = $this->actingAs($user)->putJson('/api/client/account/email', [ 'email' => '', @@ -104,7 +104,7 @@ class AccountControllerTest extends ClientApiIntegrationTestCase public function testPasswordIsUpdated() { /** @var \Pterodactyl\Models\User $user */ - $user = factory(User::class)->create(); + $user = User::factory()->create(); $mock = Mockery::mock(AuthManager::class); $mock->expects('logoutOtherDevices')->with('New_Password1'); @@ -127,7 +127,7 @@ class AccountControllerTest extends ClientApiIntegrationTestCase public function testPasswordIsNotUpdatedIfCurrentPasswordIsInvalid() { /** @var \Pterodactyl\Models\User $user */ - $user = factory(User::class)->create(); + $user = User::factory()->create(); $response = $this->actingAs($user)->putJson('/api/client/account/password', [ 'current_password' => 'invalid', @@ -146,7 +146,7 @@ class AccountControllerTest extends ClientApiIntegrationTestCase */ public function testErrorIsReturnedForInvalidRequestData() { - $user = factory(User::class)->create(); + $user = User::factory()->create(); $this->actingAs($user)->putJson('/api/client/account/password', [ 'current_password' => 'password', @@ -170,7 +170,7 @@ class AccountControllerTest extends ClientApiIntegrationTestCase public function testErrorIsReturnedIfPasswordIsNotConfirmed() { /** @var \Pterodactyl\Models\User $user */ - $user = factory(User::class)->create(); + $user = User::factory()->create(); $response = $this->actingAs($user)->putJson('/api/client/account/password', [ 'current_password' => 'password', diff --git a/tests/Integration/Api/Client/ApiKeyControllerTest.php b/tests/Integration/Api/Client/ApiKeyControllerTest.php index f4c19f4f2..77bb8e1a6 100644 --- a/tests/Integration/Api/Client/ApiKeyControllerTest.php +++ b/tests/Integration/Api/Client/ApiKeyControllerTest.php @@ -24,9 +24,9 @@ class ApiKeyControllerTest extends ClientApiIntegrationTestCase public function testApiKeysAreReturned() { /** @var \Pterodactyl\Models\User $user */ - $user = factory(User::class)->create(); + $user = User::factory()->create(); /** @var \Pterodactyl\Models\ApiKey $key */ - $key = factory(ApiKey::class)->create([ + $key = ApiKey::factory()->create([ 'user_id' => $user->id, 'key_type' => ApiKey::TYPE_ACCOUNT, ]); @@ -59,13 +59,13 @@ class ApiKeyControllerTest extends ClientApiIntegrationTestCase public function testApiKeyCanBeCreatedForAccount() { /** @var \Pterodactyl\Models\User $user */ - $user = factory(User::class)->create(); + $user = User::factory()->create(); // Small sub-test to ensure we're always comparing the number of keys to the // specific logged in account, and not just the total number of keys stored in // the database. - factory(ApiKey::class)->times(10)->create([ - 'user_id' => factory(User::class)->create()->id, + ApiKey::factory()->times(10)->create([ + 'user_id' => User::factory()->create()->id, 'key_type' => ApiKey::TYPE_ACCOUNT, ]); @@ -103,8 +103,8 @@ class ApiKeyControllerTest extends ClientApiIntegrationTestCase public function testNoMoreThanFiveApiKeysCanBeCreatedForAnAccount() { /** @var \Pterodactyl\Models\User $user */ - $user = factory(User::class)->create(); - factory(ApiKey::class)->times(5)->create([ + $user = User::factory()->create(); + ApiKey::factory()->times(5)->create([ 'user_id' => $user->id, 'key_type' => ApiKey::TYPE_ACCOUNT, ]); @@ -127,7 +127,7 @@ class ApiKeyControllerTest extends ClientApiIntegrationTestCase public function testValidationErrorIsReturnedForBadRequests() { /** @var \Pterodactyl\Models\User $user */ - $user = factory(User::class)->create(); + $user = User::factory()->create(); $response = $this->actingAs($user)->postJson('/api/client/account/api-keys', [ 'description' => '', @@ -154,9 +154,9 @@ class ApiKeyControllerTest extends ClientApiIntegrationTestCase public function testApiKeyCanBeDeleted() { /** @var \Pterodactyl\Models\User $user */ - $user = factory(User::class)->create(); + $user = User::factory()->create(); /** @var \Pterodactyl\Models\ApiKey $key */ - $key = factory(ApiKey::class)->create([ + $key = ApiKey::factory()->create([ 'user_id' => $user->id, 'key_type' => ApiKey::TYPE_ACCOUNT, ]); @@ -173,9 +173,9 @@ class ApiKeyControllerTest extends ClientApiIntegrationTestCase public function testNonExistentApiKeyDeletionReturns404Error() { /** @var \Pterodactyl\Models\User $user */ - $user = factory(User::class)->create(); + $user = User::factory()->create(); /** @var \Pterodactyl\Models\ApiKey $key */ - $key = factory(ApiKey::class)->create([ + $key = ApiKey::factory()->create([ 'user_id' => $user->id, 'key_type' => ApiKey::TYPE_ACCOUNT, ]); @@ -193,11 +193,11 @@ class ApiKeyControllerTest extends ClientApiIntegrationTestCase public function testApiKeyBelongingToAnotherUserCannotBeDeleted() { /** @var \Pterodactyl\Models\User $user */ - $user = factory(User::class)->create(); + $user = User::factory()->create(); /** @var \Pterodactyl\Models\User $user2 */ - $user2 = factory(User::class)->create(); + $user2 = User::factory()->create(); /** @var \Pterodactyl\Models\ApiKey $key */ - $key = factory(ApiKey::class)->create([ + $key = ApiKey::factory()->create([ 'user_id' => $user2->id, 'key_type' => ApiKey::TYPE_ACCOUNT, ]); @@ -215,9 +215,9 @@ class ApiKeyControllerTest extends ClientApiIntegrationTestCase public function testApplicationApiKeyCannotBeDeleted() { /** @var \Pterodactyl\Models\User $user */ - $user = factory(User::class)->create(); + $user = User::factory()->create(); /** @var \Pterodactyl\Models\ApiKey $key */ - $key = factory(ApiKey::class)->create([ + $key = ApiKey::factory()->create([ 'user_id' => $user->id, 'key_type' => ApiKey::TYPE_APPLICATION, ]); diff --git a/tests/Integration/Api/Client/ClientApiIntegrationTestCase.php b/tests/Integration/Api/Client/ClientApiIntegrationTestCase.php index b77959058..30667d51e 100644 --- a/tests/Integration/Api/Client/ClientApiIntegrationTestCase.php +++ b/tests/Integration/Api/Client/ClientApiIntegrationTestCase.php @@ -2,19 +2,21 @@ namespace Pterodactyl\Tests\Integration\Api\Client; -use Carbon\Carbon; use ReflectionClass; -use Carbon\CarbonImmutable; use Pterodactyl\Models\Node; use Pterodactyl\Models\Task; use Pterodactyl\Models\User; use Webmozart\Assert\Assert; +use Pterodactyl\Models\Backup; use Pterodactyl\Models\Server; use Pterodactyl\Models\Subuser; +use Pterodactyl\Models\Database; use Pterodactyl\Models\Location; use Pterodactyl\Models\Schedule; use Illuminate\Support\Collection; use Pterodactyl\Models\Allocation; +use Pterodactyl\Models\DatabaseHost; +use Pterodactyl\Tests\Integration\TestResponse; use Pterodactyl\Tests\Integration\IntegrationTestCase; use Pterodactyl\Transformers\Api\Client\BaseClientTransformer; @@ -25,6 +27,9 @@ abstract class ClientApiIntegrationTestCase extends IntegrationTestCase */ protected function tearDown(): void { + Database::query()->forceDelete(); + DatabaseHost::query()->forceDelete(); + Backup::query()->forceDelete(); Server::query()->forceDelete(); Node::query()->forceDelete(); Location::query()->forceDelete(); @@ -34,22 +39,24 @@ abstract class ClientApiIntegrationTestCase extends IntegrationTestCase } /** - * Setup tests and ensure all of the times are always the same. + * Override the default createTestResponse from Illuminate so that we can + * just dump 500-level errors to the screen in the tests without having + * to keep re-assigning variables. + * + * @param \Illuminate\Http\Response $response + * + * @return \Illuminate\Testing\TestResponse */ - public function setUp(): void + protected function createTestResponse($response) { - parent::setUp(); - - Carbon::setTestNow(Carbon::now()); - CarbonImmutable::setTestNow(Carbon::now()); + return TestResponse::fromBaseResponse($response); } /** * Returns a link to the specific resource using the client API. * - * @param mixed $model + * @param mixed $model * @param string|null $append - * @return string */ protected function link($model, $append = null): string { @@ -79,17 +86,17 @@ abstract class ClientApiIntegrationTestCase extends IntegrationTestCase * is assumed that the user is actually a subuser of the server. * * @param string[] $permissions - * @return array */ protected function generateTestAccount(array $permissions = []): array { /** @var \Pterodactyl\Models\User $user */ - $user = factory(User::class)->create(); + $user = User::factory()->create(); if (empty($permissions)) { return [$user, $this->createServerModel(['user_id' => $user->id])]; } + /** @var \Pterodactyl\Models\Server $server */ $server = $this->createServerModel(); Subuser::query()->create([ @@ -105,7 +112,6 @@ abstract class ClientApiIntegrationTestCase extends IntegrationTestCase * Asserts that the data passed through matches the output of the data from the transformer. This * will remove the "relationships" key when performing the comparison. * - * @param array $data * @param \Pterodactyl\Models\Model|\Illuminate\Database\Eloquent\Model $model */ protected function assertJsonTransformedWith(array $data, $model) @@ -113,7 +119,7 @@ abstract class ClientApiIntegrationTestCase extends IntegrationTestCase $reflect = new ReflectionClass($model); $transformer = sprintf('\\Pterodactyl\\Transformers\\Api\\Client\\%sTransformer', $reflect->getShortName()); - $transformer = new $transformer; + $transformer = new $transformer(); $this->assertInstanceOf(BaseClientTransformer::class, $transformer); $this->assertSame( diff --git a/tests/Integration/Api/Client/ClientControllerTest.php b/tests/Integration/Api/Client/ClientControllerTest.php index fc8c2c1e1..3ab6b1912 100644 --- a/tests/Integration/Api/Client/ClientControllerTest.php +++ b/tests/Integration/Api/Client/ClientControllerTest.php @@ -5,8 +5,8 @@ namespace Pterodactyl\Tests\Integration\Api\Client; use Pterodactyl\Models\User; use Pterodactyl\Models\Server; use Pterodactyl\Models\Subuser; -use Pterodactyl\Models\Permission; use Pterodactyl\Models\Allocation; +use Pterodactyl\Models\Permission; class ClientControllerTest extends ClientApiIntegrationTestCase { @@ -19,7 +19,7 @@ class ClientControllerTest extends ClientApiIntegrationTestCase public function testOnlyLoggedInUsersServersAreReturned() { /** @var \Pterodactyl\Models\User[] $users */ - $users = factory(User::class)->times(3)->create(); + $users = User::factory()->times(3)->create(); /** @var \Pterodactyl\Models\Server[] $servers */ $servers = [ @@ -46,7 +46,7 @@ class ClientControllerTest extends ClientApiIntegrationTestCase public function testServersAreFilteredUsingNameAndUuidInformation() { /** @var \Pterodactyl\Models\User[] $users */ - $users = factory(User::class)->times(2)->create(); + $users = User::factory()->times(2)->create(); $users[0]->update(['root_admin' => true]); /** @var \Pterodactyl\Models\Server[] $servers */ @@ -106,8 +106,8 @@ class ClientControllerTest extends ClientApiIntegrationTestCase [$user, $server] = $this->generateTestAccount(); $server2 = $this->createServerModel(['user_id' => $user->id, 'node_id' => $server->node_id]); - $allocation = factory(Allocation::class)->create(['node_id' => $server->node_id, 'server_id' => $server->id, 'ip' => '192.168.1.1', 'port' => 25565]); - $allocation2 = factory(Allocation::class)->create(['node_id' => $server->node_id, 'server_id' => $server2->id, 'ip' => '192.168.1.1', 'port' => 25570]); + $allocation = Allocation::factory()->create(['node_id' => $server->node_id, 'server_id' => $server->id, 'ip' => '192.168.1.1', 'port' => 25565]); + $allocation2 = Allocation::factory()->create(['node_id' => $server->node_id, 'server_id' => $server2->id, 'ip' => '192.168.1.1', 'port' => 25570]); $server->update(['allocation_id' => $allocation->id]); $server2->update(['allocation_id' => $allocation2->id]); @@ -144,7 +144,7 @@ class ClientControllerTest extends ClientApiIntegrationTestCase public function testServersUserIsASubuserOfAreReturned() { /** @var \Pterodactyl\Models\User[] $users */ - $users = factory(User::class)->times(3)->create(); + $users = User::factory()->times(3)->create(); $servers = [ $this->createServerModel(['user_id' => $users[0]->id]), $this->createServerModel(['user_id' => $users[1]->id]), @@ -175,7 +175,7 @@ class ClientControllerTest extends ClientApiIntegrationTestCase public function testFilterOnlyOwnerServers() { /** @var \Pterodactyl\Models\User[] $users */ - $users = factory(User::class)->times(3)->create(); + $users = User::factory()->times(3)->create(); $servers = [ $this->createServerModel(['user_id' => $users[0]->id]), $this->createServerModel(['user_id' => $users[1]->id]), @@ -204,7 +204,7 @@ class ClientControllerTest extends ClientApiIntegrationTestCase public function testPermissionsAreReturned() { /** @var \Pterodactyl\Models\User $user */ - $user = factory(User::class)->create(); + $user = User::factory()->create(); $this->actingAs($user) ->getJson('/api/client/permissions') @@ -224,7 +224,7 @@ class ClientControllerTest extends ClientApiIntegrationTestCase public function testOnlyAdminLevelServersAreReturned() { /** @var \Pterodactyl\Models\User[] $users */ - $users = factory(User::class)->times(4)->create(); + $users = User::factory()->times(4)->create(); $users[0]->update(['root_admin' => true]); $servers = [ @@ -259,7 +259,7 @@ class ClientControllerTest extends ClientApiIntegrationTestCase public function testAllServersAreReturnedToAdmin() { /** @var \Pterodactyl\Models\User[] $users */ - $users = factory(User::class)->times(4)->create(); + $users = User::factory()->times(4)->create(); $users[0]->update(['root_admin' => true]); $servers = [ @@ -292,7 +292,7 @@ class ClientControllerTest extends ClientApiIntegrationTestCase public function testNoServersAreReturnedIfAdminFilterIsPassedByRegularUser($type) { /** @var \Pterodactyl\Models\User[] $users */ - $users = factory(User::class)->times(3)->create(); + $users = User::factory()->times(3)->create(); $this->createServerModel(['user_id' => $users[0]->id]); $this->createServerModel(['user_id' => $users[1]->id]); @@ -315,7 +315,7 @@ class ClientControllerTest extends ClientApiIntegrationTestCase $server->allocation->notes = 'Test notes'; $server->allocation->save(); - factory(Allocation::class)->times(2)->create([ + Allocation::factory()->times(2)->create([ 'node_id' => $server->node_id, 'server_id' => $server->id, ]); diff --git a/tests/Integration/Api/Client/Server/Allocation/AllocationAuthorizationTest.php b/tests/Integration/Api/Client/Server/Allocation/AllocationAuthorizationTest.php new file mode 100644 index 000000000..b698d8c7e --- /dev/null +++ b/tests/Integration/Api/Client/Server/Allocation/AllocationAuthorizationTest.php @@ -0,0 +1,60 @@ +generateTestAccount(); + // Will be a subuser of $server2. + $server2 = $this->createServerModel(); + // And as no access to $server3. + $server3 = $this->createServerModel(); + + // Set the API $user as a subuser of server 2, but with no permissions + // to do anything with the allocations for that server. + Subuser::factory()->create(['server_id' => $server2->id, 'user_id' => $user->id]); + + $allocation1 = Allocation::factory()->create(['server_id' => $server1->id, 'node_id' => $server1->node_id]); + $allocation2 = Allocation::factory()->create(['server_id' => $server2->id, 'node_id' => $server2->node_id]); + $allocation3 = Allocation::factory()->create(['server_id' => $server3->id, 'node_id' => $server3->node_id]); + + // 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)); + $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(); + + // 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(); + } + + /** + * @return \string[][] + */ + public function methodDataProvider(): array + { + return [ + ['POST', ''], + ['DELETE', ''], + ['POST', '/primary'], + ]; + } +} diff --git a/tests/Integration/Api/Client/Server/Allocation/CreateNewAllocationTest.php b/tests/Integration/Api/Client/Server/Allocation/CreateNewAllocationTest.php index ab33ba81b..6b8da4048 100644 --- a/tests/Integration/Api/Client/Server/Allocation/CreateNewAllocationTest.php +++ b/tests/Integration/Api/Client/Server/Allocation/CreateNewAllocationTest.php @@ -3,8 +3,8 @@ namespace Pterodactyl\Tests\Integration\Api\Client\Server\Allocation; use Illuminate\Http\Response; -use Pterodactyl\Models\Permission; use Pterodactyl\Models\Allocation; +use Pterodactyl\Models\Permission; use Pterodactyl\Tests\Integration\Api\Client\ClientApiIntegrationTestCase; class CreateNewAllocationTest extends ClientApiIntegrationTestCase @@ -24,7 +24,6 @@ class CreateNewAllocationTest extends ClientApiIntegrationTestCase /** * Tests that a new allocation can be properly assigned to a server. * - * @param array $permission * @dataProvider permissionDataProvider */ public function testNewAllocationCanBeAssignedToServer(array $permission) @@ -33,7 +32,7 @@ class CreateNewAllocationTest extends ClientApiIntegrationTestCase [$user, $server] = $this->generateTestAccount($permission); $server->update(['allocation_limit' => 2]); - $response = $this->actingAs($user)->postJson($this->link($server, "/network/allocations")); + $response = $this->actingAs($user)->postJson($this->link($server, '/network/allocations')); $response->assertJsonPath('object', Allocation::RESOURCE_NAME); $matched = Allocation::query()->findOrFail($response->json('attributes.id')); @@ -52,7 +51,7 @@ class CreateNewAllocationTest extends ClientApiIntegrationTestCase [$user, $server] = $this->generateTestAccount([Permission::ACTION_ALLOCATION_UPDATE]); $server->update(['allocation_limit' => 2]); - $this->actingAs($user)->postJson($this->link($server, "/network/allocations"))->assertForbidden(); + $this->actingAs($user)->postJson($this->link($server, '/network/allocations'))->assertForbidden(); } /** @@ -66,7 +65,7 @@ class CreateNewAllocationTest extends ClientApiIntegrationTestCase [$user, $server] = $this->generateTestAccount(); $server->update(['allocation_limit' => 2]); - $this->actingAs($user)->postJson($this->link($server, "/network/allocations")) + $this->actingAs($user)->postJson($this->link($server, '/network/allocations')) ->assertStatus(Response::HTTP_BAD_REQUEST) ->assertJsonPath('errors.0.code', 'AutoAllocationNotEnabledException') ->assertJsonPath('errors.0.detail', 'Server auto-allocation is not enabled for this instance.'); @@ -81,7 +80,7 @@ class CreateNewAllocationTest extends ClientApiIntegrationTestCase [$user, $server] = $this->generateTestAccount(); $server->update(['allocation_limit' => 1]); - $this->actingAs($user)->postJson($this->link($server, "/network/allocations")) + $this->actingAs($user)->postJson($this->link($server, '/network/allocations')) ->assertStatus(Response::HTTP_BAD_REQUEST) ->assertJsonPath('errors.0.code', 'DisplayException') ->assertJsonPath('errors.0.detail', 'Cannot assign additional allocations to this server: limit has been reached.'); diff --git a/tests/Integration/Api/Client/Server/Allocation/DeleteAllocationTest.php b/tests/Integration/Api/Client/Server/Allocation/DeleteAllocationTest.php index 5b14c1a7e..c986de784 100644 --- a/tests/Integration/Api/Client/Server/Allocation/DeleteAllocationTest.php +++ b/tests/Integration/Api/Client/Server/Allocation/DeleteAllocationTest.php @@ -3,8 +3,8 @@ namespace Pterodactyl\Tests\Integration\Api\Client\Server\Allocation; use Illuminate\Http\Response; -use Pterodactyl\Models\Permission; use Pterodactyl\Models\Allocation; +use Pterodactyl\Models\Permission; use Pterodactyl\Tests\Integration\Api\Client\ClientApiIntegrationTestCase; class DeleteAllocationTest extends ClientApiIntegrationTestCase @@ -13,7 +13,6 @@ class DeleteAllocationTest extends ClientApiIntegrationTestCase * Test that an allocation is deleted from the server and the notes are properly reset * to an empty value on assignment. * - * @param array $permission * @dataProvider permissionDataProvider */ public function testAllocationCanBeDeletedFromServer(array $permission) @@ -22,7 +21,7 @@ class DeleteAllocationTest extends ClientApiIntegrationTestCase [$user, $server] = $this->generateTestAccount($permission); /** @var \Pterodactyl\Models\Allocation $allocation */ - $allocation = factory(Allocation::class)->create([ + $allocation = Allocation::factory()->create([ 'server_id' => $server->id, 'node_id' => $server->node_id, 'notes' => 'hodor', @@ -42,7 +41,7 @@ class DeleteAllocationTest extends ClientApiIntegrationTestCase [$user, $server] = $this->generateTestAccount([Permission::ACTION_ALLOCATION_CREATE]); /** @var \Pterodactyl\Models\Allocation $allocation */ - $allocation = factory(Allocation::class)->create([ + $allocation = Allocation::factory()->create([ 'server_id' => $server->id, 'node_id' => $server->node_id, 'notes' => 'hodor', diff --git a/tests/Integration/Api/Client/Server/Backup/BackupAuthorizationTest.php b/tests/Integration/Api/Client/Server/Backup/BackupAuthorizationTest.php new file mode 100644 index 000000000..aaaf38a6f --- /dev/null +++ b/tests/Integration/Api/Client/Server/Backup/BackupAuthorizationTest.php @@ -0,0 +1,69 @@ +generateTestAccount(); + // Will be a subuser of $server2. + $server2 = $this->createServerModel(); + // And as no access to $server3. + $server3 = $this->createServerModel(); + + // Set the API $user as a subuser of server 2, but with no permissions + // to do anything with the backups for that server. + Subuser::factory()->create(['server_id' => $server2->id, 'user_id' => $user->id]); + + $backup1 = Backup::factory()->create(['server_id' => $server1->id, 'completed_at' => CarbonImmutable::now()]); + $backup2 = Backup::factory()->create(['server_id' => $server2->id, 'completed_at' => CarbonImmutable::now()]); + $backup3 = Backup::factory()->create(['server_id' => $server3->id, 'completed_at' => CarbonImmutable::now()]); + + $this->instance(DeleteBackupService::class, $mock = Mockery::mock(DeleteBackupService::class)); + + if ($method === 'DELETE') { + $mock->expects('handle')->andReturnUndefined(); + } + + // 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)) + ->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(); + + // 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(); + } + + /** + * @return \string[][] + */ + public function methodDataProvider(): array + { + return [ + ['GET', ''], + ['GET', '/download'], + ['DELETE', ''], + ]; + } +} diff --git a/tests/Integration/Api/Client/Server/CommandControllerTest.php b/tests/Integration/Api/Client/Server/CommandControllerTest.php index f3e9df7b2..d6010b675 100644 --- a/tests/Integration/Api/Client/Server/CommandControllerTest.php +++ b/tests/Integration/Api/Client/Server/CommandControllerTest.php @@ -69,7 +69,7 @@ class CommandControllerTest extends ClientApiIntegrationTestCase $this->repository->expects('setServer')->with(Mockery::on(function ($value) use ($server) { return $value->uuid === $server->uuid; }))->andReturnSelf(); - $this->repository->expects('send')->with('say Test')->andReturn(new GuzzleResponse); + $this->repository->expects('send')->with('say Test')->andReturn(new GuzzleResponse()); $response = $this->actingAs($user)->postJson("/api/client/servers/{$server->uuid}/command", [ 'command' => 'say Test', diff --git a/tests/Integration/Api/Client/Server/Database/DatabaseAuthorizationTest.php b/tests/Integration/Api/Client/Server/Database/DatabaseAuthorizationTest.php new file mode 100644 index 000000000..d7063ea33 --- /dev/null +++ b/tests/Integration/Api/Client/Server/Database/DatabaseAuthorizationTest.php @@ -0,0 +1,76 @@ +generateTestAccount(); + // Will be a subuser of $server2. + $server2 = $this->createServerModel(); + // And as no access to $server3. + $server3 = $this->createServerModel(); + + $host = DatabaseHost::factory()->create([]); + + // Set the API $user as a subuser of server 2, but with no permissions + // to do anything with the databases for that server. + Subuser::factory()->create(['server_id' => $server2->id, 'user_id' => $user->id]); + + $database1 = Database::factory()->create(['server_id' => $server1->id, 'database_host_id' => $host->id]); + $database2 = Database::factory()->create(['server_id' => $server2->id, 'database_host_id' => $host->id]); + $database3 = Database::factory()->create(['server_id' => $server3->id, 'database_host_id' => $host->id]); + + $this->instance(DatabasePasswordService::class, $mock = Mockery::mock(DatabasePasswordService::class)); + $this->instance(DatabaseManagementService::class, $mock2 = Mockery::mock(DatabaseManagementService::class)); + + if ($method === 'POST') { + $mock->expects('handle')->andReturnUndefined(); + } else { + $mock2->expects('delete')->andReturnUndefined(); + } + + $hashids = $this->app->make(HashidsInterface::class); + // 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/' . $hashids->encode($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/' . $hashids->encode($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/' . $hashids->encode($database2->id) . $endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server1, '/databases/' . $hashids->encode($database3->id) . $endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server2, '/databases/' . $hashids->encode($database3->id) . $endpoint))->assertNotFound(); + $this->actingAs($user)->json($method, $this->link($server3, '/databases/' . $hashids->encode($database3->id) . $endpoint))->assertNotFound(); + } + + /** + * @return \string[][] + */ + public function methodDataProvider(): array + { + return [ + ['POST', '/rotate-password'], + ['DELETE', ''], + ]; + } +} diff --git a/tests/Integration/Api/Client/Server/NetworkAllocationControllerTest.php b/tests/Integration/Api/Client/Server/NetworkAllocationControllerTest.php index 185375e86..9741af974 100644 --- a/tests/Integration/Api/Client/Server/NetworkAllocationControllerTest.php +++ b/tests/Integration/Api/Client/Server/NetworkAllocationControllerTest.php @@ -32,7 +32,7 @@ class NetworkAllocationControllerTest extends ClientApiIntegrationTestCase public function testServerAllocationsAreNotReturnedWithoutPermission() { [$user, $server] = $this->generateTestAccount(); - $user2 = factory(User::class)->create(); + $user2 = User::factory()->create(); $server->owner_id = $user2->id; $server->save(); @@ -49,7 +49,6 @@ class NetworkAllocationControllerTest extends ClientApiIntegrationTestCase /** * Tests that notes on an allocation can be set correctly. * - * @param array $permissions * @dataProvider updatePermissionsDataProvider */ public function testAllocationNotesCanBeUpdated(array $permissions) @@ -85,7 +84,7 @@ class NetworkAllocationControllerTest extends ClientApiIntegrationTestCase public function testAllocationNotesCannotBeUpdatedByInvalidUsers() { [$user, $server] = $this->generateTestAccount(); - $user2 = factory(User::class)->create(); + $user2 = User::factory()->create(); $server->owner_id = $user2->id; $server->save(); @@ -98,14 +97,13 @@ class NetworkAllocationControllerTest extends ClientApiIntegrationTestCase } /** - * @param array $permissions * @dataProvider updatePermissionsDataProvider */ public function testPrimaryAllocationCanBeModified(array $permissions) { [$user, $server] = $this->generateTestAccount($permissions); $allocation = $server->allocation; - $allocation2 = factory(Allocation::class)->create(['node_id' => $server->node_id, 'server_id' => $server->id]); + $allocation2 = Allocation::factory()->create(['node_id' => $server->node_id, 'server_id' => $server->id]); $server->allocation_id = $allocation->id; $server->save(); @@ -121,7 +119,7 @@ class NetworkAllocationControllerTest extends ClientApiIntegrationTestCase public function testPrimaryAllocationCannotBeModifiedByInvalidUser() { [$user, $server] = $this->generateTestAccount(); - $user2 = factory(User::class)->create(); + $user2 = User::factory()->create(); $server->owner_id = $user2->id; $server->save(); diff --git a/tests/Integration/Api/Client/Server/PowerControllerTest.php b/tests/Integration/Api/Client/Server/PowerControllerTest.php index 96911cf37..6aed481a8 100644 --- a/tests/Integration/Api/Client/Server/PowerControllerTest.php +++ b/tests/Integration/Api/Client/Server/PowerControllerTest.php @@ -15,7 +15,6 @@ class PowerControllerTest extends ClientApiIntegrationTestCase * an error in response. This checks against the specific permission needed to send * the command to the server. * - * @param string $action * @param string[] $permissions * @dataProvider invalidPermissionDataProvider */ @@ -47,8 +46,6 @@ class PowerControllerTest extends ClientApiIntegrationTestCase /** * Test that sending a valid power actions works. * - * @param string $action - * @param string $permission * @dataProvider validPowerActionDataProvider */ public function testActionCanBeSentToServer(string $action, string $permission) @@ -74,8 +71,6 @@ class PowerControllerTest extends ClientApiIntegrationTestCase /** * Returns invalid permission combinations for a given power action. - * - * @return array */ public function invalidPermissionDataProvider(): array { @@ -88,9 +83,6 @@ class PowerControllerTest extends ClientApiIntegrationTestCase ]; } - /** - * @return array - */ public function validPowerActionDataProvider(): array { return [ diff --git a/tests/Integration/Api/Client/Server/Schedule/CreateServerScheduleTest.php b/tests/Integration/Api/Client/Server/Schedule/CreateServerScheduleTest.php index 51345fa79..cde99b090 100644 --- a/tests/Integration/Api/Client/Server/Schedule/CreateServerScheduleTest.php +++ b/tests/Integration/Api/Client/Server/Schedule/CreateServerScheduleTest.php @@ -25,6 +25,7 @@ class CreateServerScheduleTest extends ClientApiIntegrationTestCase 'minute' => '0', 'hour' => '*/2', 'day_of_week' => '2', + 'month' => '1', 'day_of_month' => '*', ]); @@ -39,6 +40,7 @@ class CreateServerScheduleTest extends ClientApiIntegrationTestCase $this->assertSame('0', $schedule->cron_minute); $this->assertSame('*/2', $schedule->cron_hour); $this->assertSame('2', $schedule->cron_day_of_week); + $this->assertSame('1', $schedule->cron_month); $this->assertSame('*', $schedule->cron_day_of_month); $this->assertSame('Test Schedule', $schedule->name); @@ -69,6 +71,7 @@ class CreateServerScheduleTest extends ClientApiIntegrationTestCase 'minute' => '*', 'hour' => '*', 'day_of_month' => '*', + 'month' => '*', 'day_of_week' => '*', ]) ->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY) @@ -87,9 +90,6 @@ class CreateServerScheduleTest extends ClientApiIntegrationTestCase ->assertForbidden(); } - /** - * @return array - */ public function permissionsDataProvider(): array { return [[[]], [[Permission::ACTION_SCHEDULE_CREATE]]]; diff --git a/tests/Integration/Api/Client/Server/Schedule/DeleteServerScheduleTest.php b/tests/Integration/Api/Client/Server/Schedule/DeleteServerScheduleTest.php index cff7591ba..25f274115 100644 --- a/tests/Integration/Api/Client/Server/Schedule/DeleteServerScheduleTest.php +++ b/tests/Integration/Api/Client/Server/Schedule/DeleteServerScheduleTest.php @@ -20,8 +20,8 @@ class DeleteServerScheduleTest extends ClientApiIntegrationTestCase { [$user, $server] = $this->generateTestAccount($permissions); - $schedule = factory(Schedule::class)->create(['server_id' => $server->id]); - $task = factory(Task::class)->create(['schedule_id' => $schedule->id]); + $schedule = Schedule::factory()->create(['server_id' => $server->id]); + $task = Task::factory()->create(['schedule_id' => $schedule->id]); $this->actingAs($user) ->deleteJson("/api/client/servers/{$server->uuid}/schedules/{$schedule->id}") @@ -52,7 +52,7 @@ class DeleteServerScheduleTest extends ClientApiIntegrationTestCase [$user, $server] = $this->generateTestAccount(); [, $server2] = $this->generateTestAccount(['user_id' => $user->id]); - $schedule = factory(Schedule::class)->create(['server_id' => $server2->id]); + $schedule = Schedule::factory()->create(['server_id' => $server2->id]); $this->actingAs($user) ->deleteJson("/api/client/servers/{$server->uuid}/schedules/{$schedule->id}") @@ -69,7 +69,7 @@ class DeleteServerScheduleTest extends ClientApiIntegrationTestCase { [$user, $server] = $this->generateTestAccount([Permission::ACTION_SCHEDULE_UPDATE]); - $schedule = factory(Schedule::class)->create(['server_id' => $server->id]); + $schedule = Schedule::factory()->create(['server_id' => $server->id]); $this->actingAs($user) ->deleteJson("/api/client/servers/{$server->uuid}/schedules/{$schedule->id}") @@ -78,9 +78,6 @@ class DeleteServerScheduleTest extends ClientApiIntegrationTestCase $this->assertDatabaseHas('schedules', ['id' => $schedule->id]); } - /** - * @return array - */ public function permissionsDataProvider(): array { return [[[]], [[Permission::ACTION_SCHEDULE_DELETE]]]; diff --git a/tests/Integration/Api/Client/Server/Schedule/ExecuteScheduleTest.php b/tests/Integration/Api/Client/Server/Schedule/ExecuteScheduleTest.php index d83faae3c..7c9d34d18 100644 --- a/tests/Integration/Api/Client/Server/Schedule/ExecuteScheduleTest.php +++ b/tests/Integration/Api/Client/Server/Schedule/ExecuteScheduleTest.php @@ -15,7 +15,6 @@ class ExecuteScheduleTest extends ClientApiIntegrationTestCase /** * Test that a schedule can be executed and is updated in the database correctly. * - * @param array $permissions * @dataProvider permissionsDataProvider */ public function testScheduleIsExecutedRightAway(array $permissions) @@ -25,7 +24,7 @@ class ExecuteScheduleTest extends ClientApiIntegrationTestCase Bus::fake(); /** @var \Pterodactyl\Models\Schedule $schedule */ - $schedule = factory(Schedule::class)->create([ + $schedule = Schedule::factory()->create([ 'server_id' => $server->id, ]); @@ -35,7 +34,7 @@ class ExecuteScheduleTest extends ClientApiIntegrationTestCase $response->assertJsonPath('errors.0.detail', 'Cannot process schedule for task execution: no tasks are registered.'); /** @var \Pterodactyl\Models\Task $task */ - $task = factory(Task::class)->create([ + $task = Task::factory()->create([ 'schedule_id' => $schedule->id, 'sequence_id' => 1, 'time_offset' => 2, @@ -60,12 +59,12 @@ class ExecuteScheduleTest extends ClientApiIntegrationTestCase [$user, $server] = $this->generateTestAccount(); /** @var \Pterodactyl\Models\Schedule $schedule */ - $schedule = factory(Schedule::class)->create([ + $schedule = Schedule::factory()->create([ 'server_id' => $server->id, 'is_active' => false, ]); - $response = $this->actingAs($user)->postJson($this->link($schedule, "/execute")); + $response = $this->actingAs($user)->postJson($this->link($schedule, '/execute')); $response->assertStatus(Response::HTTP_BAD_REQUEST); $response->assertJsonPath('errors.0.code', 'BadRequestHttpException'); @@ -80,14 +79,11 @@ class ExecuteScheduleTest extends ClientApiIntegrationTestCase [$user, $server] = $this->generateTestAccount([Permission::ACTION_SCHEDULE_CREATE]); /** @var \Pterodactyl\Models\Schedule $schedule */ - $schedule = factory(Schedule::class)->create(['server_id' => $server->id]); + $schedule = Schedule::factory()->create(['server_id' => $server->id]); $this->actingAs($user)->postJson($this->link($schedule, '/execute'))->assertForbidden(); } - /** - * @return array - */ public function permissionsDataProvider(): array { return [[[]], [[Permission::ACTION_SCHEDULE_UPDATE]]]; diff --git a/tests/Integration/Api/Client/Server/Schedule/GetServerSchedulesTest.php b/tests/Integration/Api/Client/Server/Schedule/GetServerSchedulesTest.php index 67be3fd84..45ae92680 100644 --- a/tests/Integration/Api/Client/Server/Schedule/GetServerSchedulesTest.php +++ b/tests/Integration/Api/Client/Server/Schedule/GetServerSchedulesTest.php @@ -24,7 +24,7 @@ class GetServerSchedulesTest extends ClientApiIntegrationTestCase * Test that schedules for a server are returned. * * @param array $permissions - * @param bool $individual + * @param bool $individual * @dataProvider permissionsDataProvider */ public function testServerSchedulesAreReturned($permissions, $individual) @@ -32,9 +32,9 @@ class GetServerSchedulesTest extends ClientApiIntegrationTestCase [$user, $server] = $this->generateTestAccount($permissions); /** @var \Pterodactyl\Models\Schedule $schedule */ - $schedule = factory(Schedule::class)->create(['server_id' => $server->id]); + $schedule = Schedule::factory()->create(['server_id' => $server->id]); /** @var \Pterodactyl\Models\Task $task */ - $task = factory(Task::class)->create(['schedule_id' => $schedule->id, 'sequence_id' => 1, 'time_offset' => 0]); + $task = Task::factory()->create(['schedule_id' => $schedule->id, 'sequence_id' => 1, 'time_offset' => 0]); $response = $this->actingAs($user) ->getJson( @@ -45,7 +45,7 @@ class GetServerSchedulesTest extends ClientApiIntegrationTestCase ->assertOk(); $prefix = $individual ? '' : 'data.0.'; - if (! $individual) { + if (!$individual) { $response->assertJsonCount(1, 'data'); } @@ -66,7 +66,7 @@ class GetServerSchedulesTest extends ClientApiIntegrationTestCase [$user, $server] = $this->generateTestAccount(); [, $server2] = $this->generateTestAccount(['user_id' => $user->id]); - $schedule = factory(Schedule::class)->create(['server_id' => $server2->id]); + $schedule = Schedule::factory()->create(['server_id' => $server2->id]); $this->actingAs($user) ->getJson("/api/client/servers/{$server->uuid}/schedules/{$schedule->id}") @@ -84,16 +84,13 @@ class GetServerSchedulesTest extends ClientApiIntegrationTestCase ->getJson("/api/client/servers/{$server->uuid}/schedules") ->assertForbidden(); - $schedule = factory(Schedule::class)->create(['server_id' => $server->id]); + $schedule = Schedule::factory()->create(['server_id' => $server->id]); $this->actingAs($user) ->getJson("/api/client/servers/{$server->uuid}/schedules/{$schedule->id}") ->assertForbidden(); } - /** - * @return array - */ public function permissionsDataProvider(): array { return [ diff --git a/tests/Integration/Api/Client/Server/Schedule/ScheduleAuthorizationTest.php b/tests/Integration/Api/Client/Server/Schedule/ScheduleAuthorizationTest.php new file mode 100644 index 000000000..223e9a673 --- /dev/null +++ b/tests/Integration/Api/Client/Server/Schedule/ScheduleAuthorizationTest.php @@ -0,0 +1,70 @@ +generateTestAccount(); + // Will be a subuser of $server2. + $server2 = $this->createServerModel(); + // And as no access to $server3. + $server3 = $this->createServerModel(); + + // Set the API $user as a subuser of server 2, but with no permissions + // to do anything with the schedules for that server. + Subuser::factory()->create(['server_id' => $server2->id, 'user_id' => $user->id]); + + $schedule1 = Schedule::factory()->create(['server_id' => $server1->id]); + $schedule2 = Schedule::factory()->create(['server_id' => $server2->id]); + $schedule3 = Schedule::factory()->create(['server_id' => $server3->id]); + + // 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)); + $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(); + + // 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(); + } + + /** + * @return \string[][] + */ + public function methodDataProvider(): array + { + return [ + ['GET', ''], + ['POST', ''], + ['DELETE', ''], + ['POST', '/execute'], + ['POST', '/tasks'], + ]; + } +} diff --git a/tests/Integration/Api/Client/Server/Schedule/UpdateServerScheduleTest.php b/tests/Integration/Api/Client/Server/Schedule/UpdateServerScheduleTest.php index ec60a4137..e99486d4e 100644 --- a/tests/Integration/Api/Client/Server/Schedule/UpdateServerScheduleTest.php +++ b/tests/Integration/Api/Client/Server/Schedule/UpdateServerScheduleTest.php @@ -19,6 +19,7 @@ class UpdateServerScheduleTest extends ClientApiIntegrationTestCase 'minute' => '5', 'hour' => '*', 'day_of_week' => '*', + 'month' => '*', 'day_of_month' => '*', 'is_active' => false, ]; @@ -34,8 +35,8 @@ class UpdateServerScheduleTest extends ClientApiIntegrationTestCase [$user, $server] = $this->generateTestAccount($permissions); /** @var \Pterodactyl\Models\Schedule $schedule */ - $schedule = factory(Schedule::class)->create(['server_id' => $server->id]); - $expected = Utilities::getScheduleNextRunDate('5', '*', '*', '*'); + $schedule = Schedule::factory()->create(['server_id' => $server->id]); + $expected = Utilities::getScheduleNextRunDate('5', '*', '*', '*', '*'); $response = $this->actingAs($user) ->postJson("/api/client/servers/{$server->uuid}/schedules/{$schedule->id}", $this->updateData); @@ -59,7 +60,7 @@ class UpdateServerScheduleTest extends ClientApiIntegrationTestCase [$user, $server] = $this->generateTestAccount(); [, $server2] = $this->generateTestAccount(['user_id' => $user->id]); - $schedule = factory(Schedule::class)->create(['server_id' => $server2->id]); + $schedule = Schedule::factory()->create(['server_id' => $server2->id]); $this->actingAs($user) ->postJson("/api/client/servers/{$server->uuid}/schedules/{$schedule->id}") @@ -74,7 +75,7 @@ class UpdateServerScheduleTest extends ClientApiIntegrationTestCase { [$user, $server] = $this->generateTestAccount([Permission::ACTION_SCHEDULE_CREATE]); - $schedule = factory(Schedule::class)->create(['server_id' => $server->id]); + $schedule = Schedule::factory()->create(['server_id' => $server->id]); $this->actingAs($user) ->postJson("/api/client/servers/{$server->uuid}/schedules/{$schedule->id}") @@ -92,7 +93,7 @@ class UpdateServerScheduleTest extends ClientApiIntegrationTestCase [$user, $server] = $this->generateTestAccount(); /** @var \Pterodactyl\Models\Schedule $schedule */ - $schedule = factory(Schedule::class)->create([ + $schedule = Schedule::factory()->create([ 'server_id' => $server->id, 'is_active' => true, 'is_processing' => true, @@ -111,9 +112,6 @@ class UpdateServerScheduleTest extends ClientApiIntegrationTestCase $this->assertFalse($schedule->is_processing); } - /** - * @return array - */ public function permissionsDataProvider(): array { return [[[]], [[Permission::ACTION_SCHEDULE_UPDATE]]]; diff --git a/tests/Integration/Api/Client/Server/ScheduleTask/CreateServerScheduleTaskTest.php b/tests/Integration/Api/Client/Server/ScheduleTask/CreateServerScheduleTaskTest.php index 9f263acd7..6add744cd 100644 --- a/tests/Integration/Api/Client/Server/ScheduleTask/CreateServerScheduleTaskTest.php +++ b/tests/Integration/Api/Client/Server/ScheduleTask/CreateServerScheduleTaskTest.php @@ -21,7 +21,7 @@ class CreateServerScheduleTaskTest extends ClientApiIntegrationTestCase [$user, $server] = $this->generateTestAccount($permissions); /** @var \Pterodactyl\Models\Schedule $schedule */ - $schedule = factory(Schedule::class)->create(['server_id' => $server->id]); + $schedule = Schedule::factory()->create(['server_id' => $server->id]); $this->assertEmpty($schedule->tasks); $response = $this->actingAs($user)->postJson($this->link($schedule, '/tasks'), [ @@ -51,7 +51,7 @@ class CreateServerScheduleTaskTest extends ClientApiIntegrationTestCase [$user, $server] = $this->generateTestAccount(); /** @var \Pterodactyl\Models\Schedule $schedule */ - $schedule = factory(Schedule::class)->create(['server_id' => $server->id]); + $schedule = Schedule::factory()->create(['server_id' => $server->id]); $response = $this->actingAs($user)->postJson($this->link($schedule, '/tasks'))->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY); @@ -96,7 +96,7 @@ class CreateServerScheduleTaskTest extends ClientApiIntegrationTestCase [$user, $server] = $this->generateTestAccount(); /** @var \Pterodactyl\Models\Schedule $schedule */ - $schedule = factory(Schedule::class)->create(['server_id' => $server->id]); + $schedule = Schedule::factory()->create(['server_id' => $server->id]); $this->actingAs($user)->postJson($this->link($schedule, '/tasks'), [ 'action' => 'backup', @@ -121,8 +121,8 @@ class CreateServerScheduleTaskTest extends ClientApiIntegrationTestCase [$user, $server] = $this->generateTestAccount(); /** @var \Pterodactyl\Models\Schedule $schedule */ - $schedule = factory(Schedule::class)->create(['server_id' => $server->id]); - factory(Task::class)->times(2)->create(['schedule_id' => $schedule->id]); + $schedule = Schedule::factory()->create(['server_id' => $server->id]); + Task::factory()->times(2)->create(['schedule_id' => $schedule->id]); $this->actingAs($user)->postJson($this->link($schedule, '/tasks'), [ 'action' => 'command', @@ -144,7 +144,7 @@ class CreateServerScheduleTaskTest extends ClientApiIntegrationTestCase [, $server2] = $this->generateTestAccount(['user_id' => $user->id]); /** @var \Pterodactyl\Models\Schedule $schedule */ - $schedule = factory(Schedule::class)->create(['server_id' => $server2->id]); + $schedule = Schedule::factory()->create(['server_id' => $server2->id]); $this->actingAs($user) ->postJson("/api/client/servers/{$server->uuid}/schedules/{$schedule->id}/tasks") @@ -160,16 +160,13 @@ class CreateServerScheduleTaskTest extends ClientApiIntegrationTestCase [$user, $server] = $this->generateTestAccount([Permission::ACTION_SCHEDULE_CREATE]); /** @var \Pterodactyl\Models\Schedule $schedule */ - $schedule = factory(Schedule::class)->create(['server_id' => $server->id]); + $schedule = Schedule::factory()->create(['server_id' => $server->id]); $this->actingAs($user) ->postJson($this->link($schedule, '/tasks')) ->assertForbidden(); } - /** - * @return array - */ public function permissionsDataProvider(): array { return [[[]], [[Permission::ACTION_SCHEDULE_UPDATE]]]; diff --git a/tests/Integration/Api/Client/Server/ScheduleTask/DeleteScheduleTaskTest.php b/tests/Integration/Api/Client/Server/ScheduleTask/DeleteScheduleTaskTest.php index ef3e1dee4..dc9b3fd42 100644 --- a/tests/Integration/Api/Client/Server/ScheduleTask/DeleteScheduleTaskTest.php +++ b/tests/Integration/Api/Client/Server/ScheduleTask/DeleteScheduleTaskTest.php @@ -19,8 +19,8 @@ class DeleteScheduleTaskTest extends ClientApiIntegrationTestCase $server2 = $this->createServerModel(); [$user] = $this->generateTestAccount(); - $schedule = factory(Schedule::class)->create(['server_id' => $server2->id]); - $task = factory(Task::class)->create(['schedule_id' => $schedule->id]); + $schedule = Schedule::factory()->create(['server_id' => $server2->id]); + $task = Task::factory()->create(['schedule_id' => $schedule->id]); $this->actingAs($user)->deleteJson($this->link($task))->assertNotFound(); } @@ -33,9 +33,9 @@ class DeleteScheduleTaskTest extends ClientApiIntegrationTestCase { [$user, $server] = $this->generateTestAccount(); - $schedule = factory(Schedule::class)->create(['server_id' => $server->id]); - $schedule2 = factory(Schedule::class)->create(['server_id' => $server->id]); - $task = factory(Task::class)->create(['schedule_id' => $schedule->id]); + $schedule = Schedule::factory()->create(['server_id' => $server->id]); + $schedule2 = Schedule::factory()->create(['server_id' => $server->id]); + $task = Task::factory()->create(['schedule_id' => $schedule->id]); $this->actingAs($user)->deleteJson("/api/client/servers/{$server->uuid}/schedules/{$schedule2->id}/tasks/{$task->id}")->assertNotFound(); } @@ -47,12 +47,12 @@ class DeleteScheduleTaskTest extends ClientApiIntegrationTestCase { [$user, $server] = $this->generateTestAccount([Permission::ACTION_SCHEDULE_CREATE]); - $schedule = factory(Schedule::class)->create(['server_id' => $server->id]); - $task = factory(Task::class)->create(['schedule_id' => $schedule->id]); + $schedule = Schedule::factory()->create(['server_id' => $server->id]); + $task = Task::factory()->create(['schedule_id' => $schedule->id]); $this->actingAs($user)->deleteJson($this->link($task))->assertForbidden(); - $user2 = factory(User::class)->create(); + $user2 = User::factory()->create(); $this->actingAs($user2)->deleteJson($this->link($task))->assertNotFound(); } @@ -65,12 +65,12 @@ class DeleteScheduleTaskTest extends ClientApiIntegrationTestCase { [$user, $server] = $this->generateTestAccount(); - $schedule = factory(Schedule::class)->create(['server_id' => $server->id]); + $schedule = Schedule::factory()->create(['server_id' => $server->id]); $tasks = [ - factory(Task::class)->create(['schedule_id' => $schedule->id, 'sequence_id' => 1]), - factory(Task::class)->create(['schedule_id' => $schedule->id, 'sequence_id' => 2]), - factory(Task::class)->create(['schedule_id' => $schedule->id, 'sequence_id' => 3]), - factory(Task::class)->create(['schedule_id' => $schedule->id, 'sequence_id' => 4]), + Task::factory()->create(['schedule_id' => $schedule->id, 'sequence_id' => 1]), + Task::factory()->create(['schedule_id' => $schedule->id, 'sequence_id' => 2]), + Task::factory()->create(['schedule_id' => $schedule->id, 'sequence_id' => 3]), + Task::factory()->create(['schedule_id' => $schedule->id, 'sequence_id' => 4]), ]; $response = $this->actingAs($user)->deleteJson($this->link($tasks[1])); diff --git a/tests/Integration/Api/Client/Server/SettingsControllerTest.php b/tests/Integration/Api/Client/Server/SettingsControllerTest.php index 44a850a7c..87ae1eb46 100644 --- a/tests/Integration/Api/Client/Server/SettingsControllerTest.php +++ b/tests/Integration/Api/Client/Server/SettingsControllerTest.php @@ -110,17 +110,11 @@ class SettingsControllerTest extends ClientApiIntegrationTestCase $this->assertSame(Server::STATUS_INSTALLED, $server->installed); } - /** - * @return array - */ public function renamePermissionsDataProvider(): array { return [[[]], [[Permission::ACTION_SETTINGS_RENAME]]]; } - /** - * @return array - */ public function reinstallPermissionsDataProvider(): array { return [[[]], [[Permission::ACTION_SETTINGS_REINSTALL]]]; diff --git a/tests/Integration/Api/Client/Server/Startup/GetStartupAndVariablesTest.php b/tests/Integration/Api/Client/Server/Startup/GetStartupAndVariablesTest.php index 6daa05958..09a6abd02 100644 --- a/tests/Integration/Api/Client/Server/Startup/GetStartupAndVariablesTest.php +++ b/tests/Integration/Api/Client/Server/Startup/GetStartupAndVariablesTest.php @@ -34,7 +34,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]'); @@ -53,10 +53,10 @@ class GetStartupAndVariablesTest extends ClientApiIntegrationTestCase public function testStartupDataIsNotReturnedWithoutPermission() { [$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 = factory(User::class)->create(); - $this->actingAs($user2)->getJson($this->link($server) . "/startup")->assertNotFound(); + $user2 = User::factory()->create(); + $this->actingAs($user2)->getJson($this->link($server) . '/startup')->assertNotFound(); } /** diff --git a/tests/Integration/Api/Client/Server/Startup/UpdateStartupVariableTest.php b/tests/Integration/Api/Client/Server/Startup/UpdateStartupVariableTest.php index 3ed1a89cc..0e5e421c1 100644 --- a/tests/Integration/Api/Client/Server/Startup/UpdateStartupVariableTest.php +++ b/tests/Integration/Api/Client/Server/Startup/UpdateStartupVariableTest.php @@ -49,7 +49,6 @@ class UpdateStartupVariableTest extends ClientApiIntegrationTestCase * Test that variables that are either not user_viewable, or not user_editable, cannot be * updated via this endpoint. * - * @param array $permissions * @dataProvider permissionsDataProvider */ public function testStartupVariableCannotBeUpdatedIfNotUserViewableOrEditable(array $permissions) @@ -145,10 +144,10 @@ class UpdateStartupVariableTest extends ClientApiIntegrationTestCase public function testStartupVariableCannotBeUpdatedIfNotUserViewable() { [$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 = factory(User::class)->create(); - $this->actingAs($user2)->putJson($this->link($server) . "/startup/variable")->assertNotFound(); + $user2 = User::factory()->create(); + $this->actingAs($user2)->putJson($this->link($server) . '/startup/variable')->assertNotFound(); } /** diff --git a/tests/Integration/Api/Client/Server/Subuser/CreateServerSubuserTest.php b/tests/Integration/Api/Client/Server/Subuser/CreateServerSubuserTest.php index 3a1f8bc6b..94c9b17ef 100644 --- a/tests/Integration/Api/Client/Server/Subuser/CreateServerSubuserTest.php +++ b/tests/Integration/Api/Client/Server/Subuser/CreateServerSubuserTest.php @@ -24,7 +24,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, @@ -61,7 +61,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' => $email = $this->faker->email, 'permissions' => [ Permission::ACTION_USER_CREATE, @@ -83,7 +83,7 @@ class CreateServerSubuserTest extends ClientApiIntegrationTestCase $email = str_repeat(Str::random(20), 9) . '1@gmail.com'; // 191 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, @@ -92,7 +92,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 . '.au', 'permissions' => [ Permission::ACTION_USER_CREATE, @@ -113,9 +113,9 @@ class CreateServerSubuserTest extends ClientApiIntegrationTestCase [$user, $server] = $this->generateTestAccount(); /** @var \Pterodactyl\Models\User $existing */ - $existing = factory(User::class)->create(['email' => $this->faker->email]); + $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, @@ -135,7 +135,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, @@ -144,7 +144,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, @@ -156,9 +156,6 @@ class CreateServerSubuserTest extends ClientApiIntegrationTestCase $response->assertJsonPath('errors.0.detail', 'A user with that email address is already assigned as a subuser for this server.'); } - /** - * @return array - */ public function permissionsDataProvider(): array { return [[[]], [[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 5810c73b4..eeb248510 100644 --- a/tests/Integration/Api/Client/Server/Subuser/DeleteSubuserTest.php +++ b/tests/Integration/Api/Client/Server/Subuser/DeleteSubuserTest.php @@ -30,13 +30,13 @@ class DeleteSubuserTest extends ClientApiIntegrationTestCase [$user, $server] = $this->generateTestAccount(); /** @var \Pterodactyl\Models\User $differentUser */ - $differentUser = factory(User::class)->create(); + $differentUser = User::factory()->create(); // Generate a UUID that lines up with a user in the database if it were to be cast to an int. - $uuid = $differentUser->id . str_repeat('a', strlen((string)$differentUser->id)) . substr(Uuid::uuid4()->toString(), 8); + $uuid = $differentUser->id . str_repeat('a', strlen((string) $differentUser->id)) . substr(Uuid::uuid4()->toString(), 8); /** @var \Pterodactyl\Models\User $subuser */ - $subuser = factory(User::class)->create(['uuid' => $uuid]); + $subuser = User::factory()->create(['uuid' => $uuid]); Subuser::query()->forceCreate([ 'user_id' => $subuser->id, @@ -52,7 +52,7 @@ class DeleteSubuserTest extends ClientApiIntegrationTestCase // anything in the database. $uuid = '18180000' . substr(Uuid::uuid4()->toString(), 8); /** @var \Pterodactyl\Models\User $subuser */ - $subuser = factory(User::class)->create(['uuid' => $uuid]); + $subuser = User::factory()->create(['uuid' => $uuid]); Subuser::query()->forceCreate([ 'user_id' => $subuser->id, diff --git a/tests/Integration/Api/Client/Server/Subuser/SubuserAuthorizationTest.php b/tests/Integration/Api/Client/Server/Subuser/SubuserAuthorizationTest.php new file mode 100644 index 000000000..f95e06f72 --- /dev/null +++ b/tests/Integration/Api/Client/Server/Subuser/SubuserAuthorizationTest.php @@ -0,0 +1,60 @@ +create(); + + // The API $user is the owner of $server1. + [$user, $server1] = $this->generateTestAccount(); + // Will be a subuser of $server2. + $server2 = $this->createServerModel(); + // And as no access to $server3. + $server3 = $this->createServerModel(); + + // Set the API $user as a subuser of server 2, but with no permissions + // to do anything with the subusers for that server. + Subuser::factory()->create(['server_id' => $server2->id, 'user_id' => $user->id]); + + Subuser::factory()->create(['server_id' => $server1->id, 'user_id' => $internal->id]); + Subuser::factory()->create(['server_id' => $server2->id, 'user_id' => $internal->id]); + Subuser::factory()->create(['server_id' => $server3->id, 'user_id' => $internal->id]); + + $this->instance(DaemonServerRepository::class, $mock = Mockery::mock(DaemonServerRepository::class)); + if ($method === 'DELETE') { + $mock->expects('setServer->revokeUserJTI')->with($internal->id)->andReturnUndefined(); + } + + // 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 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(); + } + + /** + * @return \string[][] + */ + public function methodDataProvider(): array + { + return [['GET'], ['POST'], ['DELETE']]; + } +} diff --git a/tests/Integration/Api/Client/Server/WebsocketControllerTest.php b/tests/Integration/Api/Client/Server/WebsocketControllerTest.php index e39f3ba00..d6c2119b6 100644 --- a/tests/Integration/Api/Client/Server/WebsocketControllerTest.php +++ b/tests/Integration/Api/Client/Server/WebsocketControllerTest.php @@ -2,12 +2,13 @@ namespace Pterodactyl\Tests\Integration\Api\Client\Server; -use Carbon\Carbon; -use Lcobucci\JWT\Parser; use Carbon\CarbonImmutable; use Illuminate\Http\Response; +use Lcobucci\JWT\Configuration; use Pterodactyl\Models\Permission; use Lcobucci\JWT\Signer\Hmac\Sha256; +use Lcobucci\JWT\Signer\Key\InMemory; +use Lcobucci\JWT\Validation\Constraint\SignedWith; use Pterodactyl\Tests\Integration\Api\Client\ClientApiIntegrationTestCase; class WebsocketControllerTest extends ClientApiIntegrationTestCase @@ -32,8 +33,6 @@ class WebsocketControllerTest extends ClientApiIntegrationTestCase */ public function testJwtAndWebsocketUrlAreReturnedForServerOwner() { - CarbonImmutable::setTestNow(Carbon::now()); - /** @var \Pterodactyl\Models\User $user */ /** @var \Pterodactyl\Models\Server $server */ [$user, $server] = $this->generateTestAccount(); @@ -51,22 +50,33 @@ class WebsocketControllerTest extends ClientApiIntegrationTestCase $this->assertStringStartsWith('wss://', $connection, 'Failed asserting that websocket connection address has expected "wss://" prefix.'); $this->assertStringEndsWith("/api/servers/{$server->uuid}/ws", $connection, 'Failed asserting that websocket connection address uses expected Wings endpoint.'); - $token = (new Parser)->parse($response->json('data.token')); + $config = Configuration::forSymmetricSigner(new Sha256(), $key = InMemory::plainText($server->node->getDecryptedKey())); + $config->setValidationConstraints(new SignedWith(new Sha256(), $key)); + /** @var \Lcobucci\JWT\Token\Plain $token */ + $token = $config->parser()->parse($response->json('data.token')); $this->assertTrue( - $token->verify(new Sha256, $server->node->getDecryptedKey()), + $config->validator()->validate($token, ...$config->validationConstraints()), 'Failed to validate that the JWT data returned was signed using the Node\'s secret key.' ); + // The way we generate times for the JWT will truncate the microseconds from the + // time, but CarbonImmutable::now() will include them, thus causing test failures. + // + // This little chunk of logic just strips those out by generating a new CarbonImmutable + // instance from the current timestamp, which is how the JWT works. We also need to + // switch to UTC here for consistency. + $expect = CarbonImmutable::createFromTimestamp(CarbonImmutable::now()->getTimestamp())->timezone('UTC'); + // Check that the claims are generated correctly. - $this->assertSame(config('app.url'), $token->getClaim('iss')); - $this->assertSame($server->node->getConnectionAddress(), $token->getClaim('aud')); - $this->assertSame(CarbonImmutable::now()->getTimestamp(), $token->getClaim('iat')); - $this->assertSame(CarbonImmutable::now()->subMinutes(5)->getTimestamp(), $token->getClaim('nbf')); - $this->assertSame(CarbonImmutable::now()->addMinutes(10)->getTimestamp(), $token->getClaim('exp')); - $this->assertSame($user->id, $token->getClaim('user_id')); - $this->assertSame($server->uuid, $token->getClaim('server_uuid')); - $this->assertSame(['*'], $token->getClaim('permissions')); + $this->assertTrue($token->hasBeenIssuedBy(config('app.url'))); + $this->assertTrue($token->isPermittedFor($server->node->getConnectionAddress())); + $this->assertEquals($expect, $token->claims()->get('iat')); + $this->assertEquals($expect->subMinutes(5), $token->claims()->get('nbf')); + $this->assertEquals($expect->addMinutes(10), $token->claims()->get('exp')); + $this->assertSame($user->id, $token->claims()->get('user_id')); + $this->assertSame($server->uuid, $token->claims()->get('server_uuid')); + $this->assertSame(['*'], $token->claims()->get('permissions')); } /** @@ -85,14 +95,17 @@ class WebsocketControllerTest extends ClientApiIntegrationTestCase $response->assertOk(); $response->assertJsonStructure(['data' => ['token', 'socket']]); - $token = (new Parser)->parse($response->json('data.token')); + $config = Configuration::forSymmetricSigner(new Sha256(), $key = InMemory::plainText($server->node->getDecryptedKey())); + $config->setValidationConstraints(new SignedWith(new Sha256(), $key)); + /** @var \Lcobucci\JWT\Token\Plain $token */ + $token = $config->parser()->parse($response->json('data.token')); $this->assertTrue( - $token->verify(new Sha256, $server->node->getDecryptedKey()), + $config->validator()->validate($token, ...$config->validationConstraints()), 'Failed to validate that the JWT data returned was signed using the Node\'s secret key.' ); // Check that the claims are generated correctly. - $this->assertSame($permissions, $token->getClaim('permissions')); + $this->assertSame($permissions, $token->claims()->get('permissions')); } } diff --git a/tests/Integration/Api/Client/TwoFactorControllerTest.php b/tests/Integration/Api/Client/TwoFactorControllerTest.php index 1c9b467f6..8af7e31a8 100644 --- a/tests/Integration/Api/Client/TwoFactorControllerTest.php +++ b/tests/Integration/Api/Client/TwoFactorControllerTest.php @@ -18,7 +18,7 @@ class TwoFactorControllerTest extends ClientApiIntegrationTestCase public function testTwoFactorImageDataIsReturned() { /** @var \Pterodactyl\Models\User $user */ - $user = factory(User::class)->create(['use_totp' => false]); + $user = User::factory()->create(['use_totp' => false]); $this->assertFalse($user->use_totp); $this->assertEmpty($user->totp_secret); @@ -42,7 +42,7 @@ class TwoFactorControllerTest extends ClientApiIntegrationTestCase public function testErrorIsReturnedWhenTwoFactorIsAlreadyEnabled() { /** @var \Pterodactyl\Models\User $user */ - $user = factory(User::class)->create(['use_totp' => true]); + $user = User::factory()->create(['use_totp' => true]); $response = $this->actingAs($user)->getJson('/api/client/account/two-factor'); @@ -57,7 +57,7 @@ class TwoFactorControllerTest extends ClientApiIntegrationTestCase public function testValidationErrorIsReturnedIfInvalidDataIsPassedToEnabled2FA() { /** @var \Pterodactyl\Models\User $user */ - $user = factory(User::class)->create(['use_totp' => false]); + $user = User::factory()->create(['use_totp' => false]); $response = $this->actingAs($user)->postJson('/api/client/account/two-factor', [ 'code' => '', @@ -74,7 +74,7 @@ class TwoFactorControllerTest extends ClientApiIntegrationTestCase public function testTwoFactorCanBeEnabledOnAccount() { /** @var \Pterodactyl\Models\User $user */ - $user = factory(User::class)->create(['use_totp' => false]); + $user = User::factory()->create(['use_totp' => false]); // Make the initial call to get the account setup for 2FA. $this->actingAs($user)->getJson('/api/client/account/two-factor')->assertOk(); @@ -111,9 +111,7 @@ class TwoFactorControllerTest extends ClientApiIntegrationTestCase } } - throw new ExpectationFailedException( - sprintf('Failed asserting that token [%s] exists as a hashed value in recovery_tokens table.', $raw) - ); + throw new ExpectationFailedException(sprintf('Failed asserting that token [%s] exists as a hashed value in recovery_tokens table.', $raw)); } } @@ -126,7 +124,7 @@ class TwoFactorControllerTest extends ClientApiIntegrationTestCase Carbon::setTestNow(Carbon::now()); /** @var \Pterodactyl\Models\User $user */ - $user = factory(User::class)->create(['use_totp' => true]); + $user = User::factory()->create(['use_totp' => true]); $response = $this->actingAs($user)->deleteJson('/api/client/account/two-factor', [ 'password' => 'invalid', @@ -157,7 +155,7 @@ class TwoFactorControllerTest extends ClientApiIntegrationTestCase Carbon::setTestNow(Carbon::now()); /** @var \Pterodactyl\Models\User $user */ - $user = factory(User::class)->create(['use_totp' => false]); + $user = User::factory()->create(['use_totp' => false]); $response = $this->actingAs($user)->deleteJson('/api/client/account/two-factor', [ 'password' => 'password', diff --git a/tests/Integration/IntegrationTestCase.php b/tests/Integration/IntegrationTestCase.php index ee7229660..f12eaaef1 100644 --- a/tests/Integration/IntegrationTestCase.php +++ b/tests/Integration/IntegrationTestCase.php @@ -2,10 +2,10 @@ namespace Pterodactyl\Tests\Integration; -use Tests\TestCase; -use Cake\Chronos\Chronos; +use Carbon\CarbonImmutable; +use Pterodactyl\Tests\TestCase; use Illuminate\Database\Eloquent\Model; -use Tests\Traits\Integration\CreatesTestModels; +use Pterodactyl\Tests\Traits\Integration\CreatesTestModels; use Pterodactyl\Transformers\Api\Application\BaseTransformer; abstract class IntegrationTestCase extends TestCase @@ -36,13 +36,10 @@ abstract class IntegrationTestCase extends TestCase /** * Return an ISO-8601 formatted timestamp to use in the API response. - * - * @param string $timestamp - * @return string */ protected function formatTimestamp(string $timestamp): string { - return Chronos::createFromFormat(Chronos::DEFAULT_TO_STRING_FORMAT, $timestamp) + return CarbonImmutable::createFromFormat(CarbonImmutable::DEFAULT_TO_STRING_FORMAT, $timestamp) ->setTimezone(BaseTransformer::RESPONSE_TIMEZONE) ->toIso8601String(); } diff --git a/tests/Integration/Services/Allocations/FindAssignableAllocationServiceTest.php b/tests/Integration/Services/Allocations/FindAssignableAllocationServiceTest.php index ce49a1873..c3b88e2cf 100644 --- a/tests/Integration/Services/Allocations/FindAssignableAllocationServiceTest.php +++ b/tests/Integration/Services/Allocations/FindAssignableAllocationServiceTest.php @@ -32,7 +32,7 @@ class FindAssignableAllocationServiceTest extends IntegrationTestCase { $server = $this->createServerModel(); - $created = factory(Allocation::class)->create([ + $created = Allocation::factory()->create([ 'node_id' => $server->node_id, 'ip' => $server->allocation->ip, ]); @@ -74,7 +74,7 @@ class FindAssignableAllocationServiceTest extends IntegrationTestCase config()->set('pterodactyl.client_features.allocations.range_start', 5000); config()->set('pterodactyl.client_features.allocations.range_end', 5001); - factory(Allocation::class)->create([ + Allocation::factory()->create([ 'server_id' => $server2->id, 'node_id' => $server->node_id, 'ip' => $server->allocation->ip, @@ -92,8 +92,8 @@ class FindAssignableAllocationServiceTest extends IntegrationTestCase config()->set('pterodactyl.client_features.allocations.range_start', 5000); config()->set('pterodactyl.client_features.allocations.range_end', 5005); - for ($i = 5000; $i <= 5005; $i++) { - factory(Allocation::class)->create([ + for ($i = 5000; $i <= 5005; ++$i) { + Allocation::factory()->create([ 'ip' => $server->allocation->ip, 'port' => $i, 'node_id' => $server->node_id, @@ -115,7 +115,7 @@ class FindAssignableAllocationServiceTest extends IntegrationTestCase { $server = $this->createServerModel(); - factory(Allocation::class)->times(5)->create(['node_id' => $server->node_id]); + Allocation::factory()->times(5)->create(['node_id' => $server->node_id]); $this->expectException(NoAutoAllocationSpaceAvailableException::class); $this->expectExceptionMessage('Cannot assign additional allocation: no more space available on node.'); diff --git a/tests/Integration/Services/Databases/DatabaseManagementServiceTest.php b/tests/Integration/Services/Databases/DatabaseManagementServiceTest.php index b5e1565a2..e354e0299 100644 --- a/tests/Integration/Services/Databases/DatabaseManagementServiceTest.php +++ b/tests/Integration/Services/Databases/DatabaseManagementServiceTest.php @@ -3,7 +3,6 @@ namespace Pterodactyl\Tests\Integration\Services\Databases; use Mockery; -use Exception; use BadMethodCallException; use InvalidArgumentException; use Pterodactyl\Models\Database; @@ -63,9 +62,9 @@ class DatabaseManagementServiceTest extends IntegrationTestCase public function testDatabaseCannotBeCreatedIfServerHasReachedLimit() { $server = $this->createServerModel(['database_limit' => 2]); - $host = factory(DatabaseHost::class)->create(['node_id' => $server->node_id]); + $host = DatabaseHost::factory()->create(['node_id' => $server->node_id]); - factory(Database::class)->times(2)->create(['server_id' => $server->id, 'database_host_id' => $host->id]); + Database::factory()->times(2)->create(['server_id' => $server->id, 'database_host_id' => $host->id]); $this->expectException(TooManyDatabasesException::class); @@ -96,9 +95,9 @@ class DatabaseManagementServiceTest extends IntegrationTestCase $server = $this->createServerModel(); $name = DatabaseManagementService::generateUniqueDatabaseName('soemthing', $server->id); - $host = factory(DatabaseHost::class)->create(['node_id' => $server->node_id]); - $host2 = factory(DatabaseHost::class)->create(['node_id' => $server->node_id]); - factory(Database::class)->create([ + $host = DatabaseHost::factory()->create(['node_id' => $server->node_id]); + $host2 = DatabaseHost::factory()->create(['node_id' => $server->node_id]); + Database::factory()->create([ 'database' => $name, 'database_host_id' => $host->id, 'server_id' => $server->id, @@ -125,7 +124,7 @@ class DatabaseManagementServiceTest extends IntegrationTestCase $server = $this->createServerModel(); $name = DatabaseManagementService::generateUniqueDatabaseName('soemthing', $server->id); - $host = factory(DatabaseHost::class)->create(['node_id' => $server->node_id]); + $host = DatabaseHost::factory()->create(['node_id' => $server->node_id]); $this->repository->expects('createDatabase')->with($name); @@ -167,7 +166,7 @@ class DatabaseManagementServiceTest extends IntegrationTestCase $this->assertInstanceOf(Database::class, $response); $this->assertSame($response->server_id, $server->id); - $this->assertRegExp('/^(u[\d]+_)(\w){10}$/', $username); + $this->assertMatchesRegularExpression('/^(u[\d]+_)(\w){10}$/', $username); $this->assertSame($username, $secondUsername); $this->assertSame(24, strlen($password)); @@ -183,11 +182,11 @@ class DatabaseManagementServiceTest extends IntegrationTestCase $server = $this->createServerModel(); $name = DatabaseManagementService::generateUniqueDatabaseName('soemthing', $server->id); - $host = factory(DatabaseHost::class)->create(['node_id' => $server->node_id]); + $host = DatabaseHost::factory()->create(['node_id' => $server->node_id]); - $this->repository->expects('createDatabase')->with($name)->andThrows(new BadMethodCallException); + $this->repository->expects('createDatabase')->with($name)->andThrows(new BadMethodCallException()); $this->repository->expects('dropDatabase')->with($name); - $this->repository->expects('dropUser')->withAnyArgs()->andThrows(new InvalidArgumentException); + $this->repository->expects('dropUser')->withAnyArgs()->andThrows(new InvalidArgumentException()); $this->expectException(BadMethodCallException::class); @@ -200,9 +199,6 @@ class DatabaseManagementServiceTest extends IntegrationTestCase $this->assertDatabaseMissing('databases', ['server_id' => $server->id]); } - /** - * @return array - */ public function invalidDataDataProvider(): array { return [ diff --git a/tests/Integration/Services/Databases/DeployServerDatabaseServiceTest.php b/tests/Integration/Services/Databases/DeployServerDatabaseServiceTest.php index cc66ffe8e..2d4719571 100644 --- a/tests/Integration/Services/Databases/DeployServerDatabaseServiceTest.php +++ b/tests/Integration/Services/Databases/DeployServerDatabaseServiceTest.php @@ -7,7 +7,6 @@ use Pterodactyl\Models\Node; use InvalidArgumentException; use Pterodactyl\Models\Database; use Pterodactyl\Models\DatabaseHost; -use Symfony\Component\VarDumper\Cloner\Data; use Pterodactyl\Tests\Integration\IntegrationTestCase; use Pterodactyl\Services\Databases\DatabaseManagementService; use Pterodactyl\Services\Databases\DeployServerDatabaseService; @@ -53,7 +52,7 @@ class DeployServerDatabaseServiceTest extends IntegrationTestCase $server = $this->createServerModel(); $this->expectException(InvalidArgumentException::class); - $this->expectExceptionMessageMatches('/^Expected a non-empty value\. Got: /',); + $this->expectExceptionMessageMatches('/^Expected a non-empty value\. Got: /', ); $this->getService()->handle($server, $data); } @@ -65,8 +64,8 @@ class DeployServerDatabaseServiceTest extends IntegrationTestCase { $server = $this->createServerModel(); - $node = factory(Node::class)->create(['location_id' => $server->location->id]); - factory(DatabaseHost::class)->create(['node_id' => $node->id]); + $node = Node::factory()->create(['location_id' => $server->location->id]); + DatabaseHost::factory()->create(['node_id' => $node->id]); config()->set('pterodactyl.client_features.databases.allow_random', false); @@ -100,15 +99,15 @@ class DeployServerDatabaseServiceTest extends IntegrationTestCase { $server = $this->createServerModel(); - $node = factory(Node::class)->create(['location_id' => $server->location->id]); - factory(DatabaseHost::class)->create(['node_id' => $node->id]); - $host = factory(DatabaseHost::class)->create(['node_id' => $server->node_id]); + $node = Node::factory()->create(['location_id' => $server->location->id]); + DatabaseHost::factory()->create(['node_id' => $node->id]); + $host = DatabaseHost::factory()->create(['node_id' => $server->node_id]); $this->managementService->expects('create')->with($server, [ 'database_host_id' => $host->id, 'database' => "s{$server->id}_something", 'remote' => '%', - ])->andReturns(new Database); + ])->andReturns(new Database()); $response = $this->getService()->handle($server, [ 'database' => 'something', @@ -127,14 +126,14 @@ class DeployServerDatabaseServiceTest extends IntegrationTestCase { $server = $this->createServerModel(); - $node = factory(Node::class)->create(['location_id' => $server->location->id]); - $host = factory(DatabaseHost::class)->create(['node_id' => $node->id]); + $node = Node::factory()->create(['location_id' => $server->location->id]); + $host = DatabaseHost::factory()->create(['node_id' => $node->id]); $this->managementService->expects('create')->with($server, [ 'database_host_id' => $host->id, 'database' => "s{$server->id}_something", 'remote' => '%', - ])->andReturns(new Database); + ])->andReturns(new Database()); $response = $this->getService()->handle($server, [ 'database' => 'something', @@ -144,9 +143,6 @@ class DeployServerDatabaseServiceTest extends IntegrationTestCase $this->assertInstanceOf(Database::class, $response); } - /** - * @return array - */ public function invalidDataProvider(): array { return [ diff --git a/tests/Integration/Services/Deployment/FindViableNodesServiceTest.php b/tests/Integration/Services/Deployment/FindViableNodesServiceTest.php index abc0bd9a7..f32810cc8 100644 --- a/tests/Integration/Services/Deployment/FindViableNodesServiceTest.php +++ b/tests/Integration/Services/Deployment/FindViableNodesServiceTest.php @@ -6,8 +6,8 @@ use Exception; use Pterodactyl\Models\Node; use InvalidArgumentException; use Pterodactyl\Models\Server; -use Pterodactyl\Models\Location; use Pterodactyl\Models\Database; +use Pterodactyl\Models\Location; use Illuminate\Support\Collection; use Pterodactyl\Tests\Integration\IntegrationTestCase; use Pterodactyl\Services\Deployment\FindViableNodesService; @@ -71,24 +71,24 @@ class FindViableNodesServiceTest extends IntegrationTestCase public function testExpectedNodeIsReturnedForLocation() { /** @var \Pterodactyl\Models\Location[] $locations */ - $locations = factory(Location::class)->times(2)->create(); + $locations = Location::factory()->times(2)->create(); /** @var \Pterodactyl\Models\Node[] $nodes */ $nodes = [ // This node should never be returned once we've completed the initial test which // runs without a location filter. - factory(Node::class)->create([ + Node::factory()->create([ 'location_id' => $locations[0]->id, 'memory' => 2048, 'disk' => 1024 * 100, ]), - factory(Node::class)->create([ + Node::factory()->create([ 'location_id' => $locations[1]->id, 'memory' => 1024, 'disk' => 10240, 'disk_overallocate' => 10, ]), - factory(Node::class)->create([ + Node::factory()->create([ 'location_id' => $locations[1]->id, 'memory' => 1024 * 4, 'memory_overallocate' => 50, @@ -112,7 +112,7 @@ class FindViableNodesServiceTest extends IntegrationTestCase // Helper, I am lazy. $base = function () use ($locations) { - return $this->getService()->setLocations([ $locations[1]->id ])->setDisk(512); + return $this->getService()->setLocations([$locations[1]->id])->setDisk(512); }; // Expect that we can create this server on either node since the disk and memory diff --git a/tests/Integration/Services/Schedules/ProcessScheduleServiceTest.php b/tests/Integration/Services/Schedules/ProcessScheduleServiceTest.php index 93c793d6c..e5dd9e234 100644 --- a/tests/Integration/Services/Schedules/ProcessScheduleServiceTest.php +++ b/tests/Integration/Services/Schedules/ProcessScheduleServiceTest.php @@ -23,7 +23,7 @@ class ProcessScheduleServiceTest extends IntegrationTestCase public function testScheduleWithNoTasksReturnsException() { $server = $this->createServerModel(); - $schedule = factory(Schedule::class)->create(['server_id' => $server->id]); + $schedule = Schedule::factory()->create(['server_id' => $server->id]); $this->expectException(DisplayException::class); $this->expectExceptionMessage('Cannot process schedule for task execution: no tasks are registered.'); @@ -39,13 +39,13 @@ class ProcessScheduleServiceTest extends IntegrationTestCase $server = $this->createServerModel(); /** @var \Pterodactyl\Models\Schedule $schedule */ - $schedule = factory(Schedule::class)->create([ + $schedule = Schedule::factory()->create([ 'server_id' => $server->id, 'cron_minute' => 'hodor', // this will break the getNextRunDate() function. ]); /** @var \Pterodactyl\Models\Task $task */ - $task = factory(Task::class)->create(['schedule_id' => $schedule->id, 'sequence_id' => 1]); + $task = Task::factory()->create(['schedule_id' => $schedule->id, 'sequence_id' => 1]); $this->expectException(InvalidArgumentException::class); @@ -68,10 +68,10 @@ class ProcessScheduleServiceTest extends IntegrationTestCase $server = $this->createServerModel(); /** @var \Pterodactyl\Models\Schedule $schedule */ - $schedule = factory(Schedule::class)->create(['server_id' => $server->id]); + $schedule = Schedule::factory()->create(['server_id' => $server->id]); /** @var \Pterodactyl\Models\Task $task */ - $task = factory(Task::class)->create(['schedule_id' => $schedule->id, 'time_offset' => 10, 'sequence_id' => 1]); + $task = Task::factory()->create(['schedule_id' => $schedule->id, 'time_offset' => 10, 'sequence_id' => 1]); $this->getService()->handle($schedule, $now); @@ -100,16 +100,16 @@ class ProcessScheduleServiceTest extends IntegrationTestCase $server = $this->createServerModel(); /** @var \Pterodactyl\Models\Schedule $schedule */ - $schedule = factory(Schedule::class)->create(['server_id' => $server->id]); + $schedule = Schedule::factory()->create(['server_id' => $server->id]); /** @var \Pterodactyl\Models\Task $task */ - $task2 = factory(Task::class)->create(['schedule_id' => $schedule->id, 'sequence_id' => 4]); - $task = factory(Task::class)->create(['schedule_id' => $schedule->id, 'sequence_id' => 2]); - $task3 = factory(Task::class)->create(['schedule_id' => $schedule->id, 'sequence_id' => 3]); + $task2 = Task::factory()->create(['schedule_id' => $schedule->id, 'sequence_id' => 4]); + $task = Task::factory()->create(['schedule_id' => $schedule->id, 'sequence_id' => 2]); + $task3 = Task::factory()->create(['schedule_id' => $schedule->id, 'sequence_id' => 3]); $this->getService()->handle($schedule); - Bus::assertDispatched(RunTaskJob::class, function (RunTaskJob $job) use ($task) { + Bus::assertDispatched(RunTaskJob::class, function (RunTaskJob $job) use ($task) { return $task->id === $job->task->id; }); @@ -131,9 +131,9 @@ class ProcessScheduleServiceTest extends IntegrationTestCase $server = $this->createServerModel(); /** @var \Pterodactyl\Models\Schedule $schedule */ - $schedule = factory(Schedule::class)->create(['server_id' => $server->id, 'last_run_at' => null]); + $schedule = Schedule::factory()->create(['server_id' => $server->id, 'last_run_at' => null]); /** @var \Pterodactyl\Models\Task $task */ - $task = factory(Task::class)->create(['schedule_id' => $schedule->id, 'sequence_id' => 1]); + $task = Task::factory()->create(['schedule_id' => $schedule->id, 'sequence_id' => 1]); $dispatcher->expects('dispatchNow')->andThrows(new Exception('Test thrown exception')); @@ -151,9 +151,6 @@ class ProcessScheduleServiceTest extends IntegrationTestCase $this->assertDatabaseHas('tasks', ['id' => $task->id, 'is_queued' => false]); } - /** - * @return array - */ public function dispatchNowDataProvider(): array { return [[true], [false]]; diff --git a/tests/Integration/Services/Servers/BuildModificationServiceTest.php b/tests/Integration/Services/Servers/BuildModificationServiceTest.php index 4444cc857..359dff67e 100644 --- a/tests/Integration/Services/Servers/BuildModificationServiceTest.php +++ b/tests/Integration/Services/Servers/BuildModificationServiceTest.php @@ -36,7 +36,7 @@ class BuildModificationServiceTest extends IntegrationTestCase $server2 = $this->createServerModel(); /** @var \Pterodactyl\Models\Allocation[] $allocations */ - $allocations = factory(Allocation::class)->times(4)->create(['node_id' => $server->node_id, 'notes' => 'Random notes']); + $allocations = Allocation::factory()->times(4)->create(['node_id' => $server->node_id, 'notes' => 'Random notes']); $initialAllocationId = $server->allocation_id; $allocations[0]->update(['server_id' => $server->id, 'notes' => 'Test notes']); @@ -83,7 +83,7 @@ class BuildModificationServiceTest extends IntegrationTestCase { $server = $this->createServerModel(); /** @var \Pterodactyl\Models\Allocation[] $allocations */ - $allocations = factory(Allocation::class)->times(4)->create(['node_id' => $server->node_id]); + $allocations = Allocation::factory()->times(4)->create(['node_id' => $server->node_id]); $allocations[0]->update(['server_id' => $server->id]); @@ -155,8 +155,8 @@ class BuildModificationServiceTest extends IntegrationTestCase public function testNoExceptionIsThrownIfOnlyRemovingAllocation() { $server = $this->createServerModel(); - /** @var \Pterodactyl\Models\Allocation[] $allocations */ - $allocation = factory(Allocation::class)->create(['node_id' => $server->node_id, 'server_id' => $server->id]); + /** @var \Pterodactyl\Models\Allocation $allocation */ + $allocation = Allocation::factory()->create(['node_id' => $server->node_id, 'server_id' => $server->id]); $this->daemonServerRepository->expects('setServer->update')->andReturnUndefined(); @@ -178,8 +178,8 @@ class BuildModificationServiceTest extends IntegrationTestCase public function testAllocationInBothAddAndRemoveIsAdded() { $server = $this->createServerModel(); - /** @var \Pterodactyl\Models\Allocation[] $allocations */ - $allocation = factory(Allocation::class)->create(['node_id' => $server->node_id]); + /** @var \Pterodactyl\Models\Allocation $allocation */ + $allocation = Allocation::factory()->create(['node_id' => $server->node_id]); $this->daemonServerRepository->expects('setServer->update')->andReturnUndefined(); @@ -197,9 +197,10 @@ class BuildModificationServiceTest extends IntegrationTestCase public function testUsingSameAllocationIdMultipleTimesDoesNotError() { $server = $this->createServerModel(); - /** @var \Pterodactyl\Models\Allocation[] $allocations */ - $allocation = factory(Allocation::class)->create(['node_id' => $server->node_id, 'server_id' => $server->id]); - $allocation2 = factory(Allocation::class)->create(['node_id' => $server->node_id]); + /** @var \Pterodactyl\Models\Allocation $allocation */ + $allocation = Allocation::factory()->create(['node_id' => $server->node_id, 'server_id' => $server->id]); + /** @var \Pterodactyl\Models\Allocation $allocation2 */ + $allocation2 = Allocation::factory()->create(['node_id' => $server->node_id]); $this->daemonServerRepository->expects('setServer->update')->andReturnUndefined(); @@ -219,8 +220,8 @@ class BuildModificationServiceTest extends IntegrationTestCase public function testThatUpdatesAreRolledBackIfExceptionIsEncountered() { $server = $this->createServerModel(); - /** @var \Pterodactyl\Models\Allocation[] $allocations */ - $allocation = factory(Allocation::class)->create(['node_id' => $server->node_id]); + /** @var \Pterodactyl\Models\Allocation $allocation */ + $allocation = Allocation::factory()->create(['node_id' => $server->node_id]); $this->daemonServerRepository->expects('setServer->update')->andThrows(new DisplayException('Test')); diff --git a/tests/Integration/Services/Servers/ServerCreationServiceTest.php b/tests/Integration/Services/Servers/ServerCreationServiceTest.php index daf198f22..c33844c29 100644 --- a/tests/Integration/Services/Servers/ServerCreationServiceTest.php +++ b/tests/Integration/Services/Servers/ServerCreationServiceTest.php @@ -4,16 +4,16 @@ namespace Pterodactyl\Tests\Integration\Services\Servers; use Mockery; use Pterodactyl\Models\Egg; +use GuzzleHttp\Psr7\Request; use Pterodactyl\Models\Node; use Pterodactyl\Models\User; -use GuzzleHttp\Psr7\Request; use GuzzleHttp\Psr7\Response; use Pterodactyl\Models\Server; use Pterodactyl\Models\Location; use Pterodactyl\Models\Allocation; use Illuminate\Foundation\Testing\WithFaker; -use Illuminate\Validation\ValidationException; use GuzzleHttp\Exception\BadResponseException; +use Illuminate\Validation\ValidationException; use Pterodactyl\Models\Objects\DeploymentObject; use Pterodactyl\Tests\Integration\IntegrationTestCase; use Pterodactyl\Services\Servers\ServerCreationService; @@ -48,15 +48,18 @@ class ServerCreationServiceTest extends IntegrationTestCase public function testServerIsCreatedWithDeploymentObject() { /** @var \Pterodactyl\Models\User $user */ - $user = factory(User::class)->create(); + $user = User::factory()->create(); + + /** @var \Pterodactyl\Models\Location $location */ + $location = Location::factory()->create(); /** @var \Pterodactyl\Models\Node $node */ - $node = factory(Node::class)->create([ - 'location_id' => factory(Location::class)->create()->id, + $node = Node::factory()->create([ + 'location_id' => $location->id, ]); /** @var \Pterodactyl\Models\Allocation[]|\Illuminate\Database\Eloquent\Collection $allocations */ - $allocations = factory(Allocation::class)->times(5)->create([ + $allocations = Allocation::factory()->times(5)->create([ 'node_id' => $node->id, ]); @@ -156,15 +159,18 @@ class ServerCreationServiceTest extends IntegrationTestCase public function testErrorEncounteredByWingsCausesServerToBeDeleted() { /** @var \Pterodactyl\Models\User $user */ - $user = factory(User::class)->create(); + $user = User::factory()->create(); + + /** @var \Pterodactyl\Models\Location $location */ + $location = Location::factory()->create(); /** @var \Pterodactyl\Models\Node $node */ - $node = factory(Node::class)->create([ - 'location_id' => factory(Location::class)->create()->id, + $node = Node::factory()->create([ + 'location_id' => $location->id, ]); /** @var \Pterodactyl\Models\Allocation $allocation */ - $allocation = factory(Allocation::class)->create([ + $allocation = Allocation::factory()->create([ 'node_id' => $node->id, ]); diff --git a/tests/Integration/Services/Servers/ServerDeletionServiceTest.php b/tests/Integration/Services/Servers/ServerDeletionServiceTest.php index bcc4cce25..197e6b38f 100644 --- a/tests/Integration/Services/Servers/ServerDeletionServiceTest.php +++ b/tests/Integration/Services/Servers/ServerDeletionServiceTest.php @@ -6,6 +6,7 @@ use Mockery; use Exception; use GuzzleHttp\Psr7\Request; use GuzzleHttp\Psr7\Response; +use Pterodactyl\Models\Server; use Pterodactyl\Models\Database; use Pterodactyl\Models\DatabaseHost; use GuzzleHttp\Exception\BadResponseException; @@ -65,7 +66,7 @@ class ServerDeletionServiceTest extends IntegrationTestCase $this->expectException(DaemonConnectionException::class); $this->daemonServerRepository->expects('setServer->delete')->withNoArgs()->andThrows( - new DaemonConnectionException(new BadResponseException('Bad request', new Request('GET', '/test'))) + new DaemonConnectionException(new BadResponseException('Bad request', new Request('GET', '/test'), new Response())) ); $this->getService()->handle($server); @@ -113,17 +114,17 @@ class ServerDeletionServiceTest extends IntegrationTestCase public function testExceptionWhileDeletingStopsProcess() { $server = $this->createServerModel(); - $host = factory(DatabaseHost::class)->create(); + $host = DatabaseHost::factory()->create(); /** @var \Pterodactyl\Models\Database $db */ - $db = factory(Database::class)->create(['database_host_id' => $host->id, 'server_id' => $server->id]); + $db = Database::factory()->create(['database_host_id' => $host->id, 'server_id' => $server->id]); $server->refresh(); $this->daemonServerRepository->expects('setServer->delete')->withNoArgs()->andReturnUndefined(); $this->databaseManagementService->expects('delete')->with(Mockery::on(function ($value) use ($db) { return $value instanceof Database && $value->id === $db->id; - }))->andThrows(new Exception); + }))->andThrows(new Exception()); $this->expectException(Exception::class); $this->getService()->handle($server); @@ -138,17 +139,17 @@ class ServerDeletionServiceTest extends IntegrationTestCase public function testExceptionWhileDeletingDatabasesDoesNotAbortIfForceDeleted() { $server = $this->createServerModel(); - $host = factory(DatabaseHost::class)->create(); + $host = DatabaseHost::factory()->create(); /** @var \Pterodactyl\Models\Database $db */ - $db = factory(Database::class)->create(['database_host_id' => $host->id, 'server_id' => $server->id]); + $db = Database::factory()->create(['database_host_id' => $host->id, 'server_id' => $server->id]); $server->refresh(); $this->daemonServerRepository->expects('setServer->delete')->withNoArgs()->andReturnUndefined(); $this->databaseManagementService->expects('delete')->with(Mockery::on(function ($value) use ($db) { return $value instanceof Database && $value->id === $db->id; - }))->andThrows(new Exception); + }))->andThrows(new Exception()); $this->getService()->withForce(true)->handle($server); diff --git a/tests/Integration/Services/Servers/StartupModificationServiceTest.php b/tests/Integration/Services/Servers/StartupModificationServiceTest.php index 84fee3be8..36a0348f4 100644 --- a/tests/Integration/Services/Servers/StartupModificationServiceTest.php +++ b/tests/Integration/Services/Servers/StartupModificationServiceTest.php @@ -3,10 +3,9 @@ namespace Pterodactyl\Tests\Integration\Services\Servers; use Exception; -use Ramsey\Uuid\Uuid; use Pterodactyl\Models\Egg; -use Pterodactyl\Models\User; use Pterodactyl\Models\Nest; +use Pterodactyl\Models\User; use Pterodactyl\Models\Server; use Pterodactyl\Models\ServerVariable; use Illuminate\Validation\ValidationException; diff --git a/tests/Integration/Services/Servers/VariableValidatorServiceTest.php b/tests/Integration/Services/Servers/VariableValidatorServiceTest.php index 79a97ff73..01f6f7f02 100644 --- a/tests/Integration/Services/Servers/VariableValidatorServiceTest.php +++ b/tests/Integration/Services/Servers/VariableValidatorServiceTest.php @@ -92,7 +92,6 @@ class VariableValidatorServiceTest extends IntegrationTestCase $this->assertArrayHasKey('environment.BUNGEE_VERSION', $exception->errors()); } - $response = $this->getService()->setUserLevel(User::USER_LEVEL_ADMIN)->handle($egg->id, [ 'BUNGEE_VERSION' => '123', 'SERVER_JARFILE' => 'server.jar', diff --git a/tests/Integration/TestResponse.php b/tests/Integration/TestResponse.php new file mode 100644 index 000000000..2185598c9 --- /dev/null +++ b/tests/Integration/TestResponse.php @@ -0,0 +1,38 @@ +getStatusCode(); + + // Dump the response to the screen before making the assertion which is going + // to fail so that debugging isn't such a nightmare. + if ($actual !== $status && $status !== 500) { + $this->dump(); + if (!is_null($this->exception) && !$this->exception instanceof DisplayException && !$this->exception instanceof ValidationException) { + dump($this->exception); + } + } + + PHPUnit::assertSame($actual, $status, "Expected status code {$status} but received {$actual}."); + + return $this; + } +} diff --git a/tests/TestCase.php b/tests/TestCase.php index 1908ac15e..5e131fa8b 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -1,8 +1,9 @@ make($args); + $user = User::factory()->make($args); $this->setRequestUserModel($user); return $user; @@ -59,8 +52,7 @@ trait RequestMockHelpers /** * Set a request attribute on the mock object. * - * @param string $attribute - * @param mixed $value + * @param mixed $value */ public function setRequestAttribute(string $attribute, $value) { @@ -69,8 +61,6 @@ trait RequestMockHelpers /** * Set the request route name. - * - * @param string $name */ public function setRequestRouteName(string $name) { @@ -83,7 +73,7 @@ trait RequestMockHelpers protected function buildRequestMock() { $this->request = m::mock($this->requestMockClass); - if (! $this->request instanceof Request) { + if (!$this->request instanceof Request) { throw new InvalidArgumentException('Request mock class must be an instance of ' . Request::class . ' when mocked.'); } @@ -94,13 +84,11 @@ trait RequestMockHelpers * Sets the mocked request user. If a user model is not provided, a factory model * will be created and returned. * - * @param \Pterodactyl\Models\User|null $user - * @return \Pterodactyl\Models\User * @deprecated */ protected function setRequestUser(User $user = null): User { - $user = $user instanceof User ? $user : factory(User::class)->make(); + $user = $user instanceof User ? $user : User::factory()->make(); $this->request->shouldReceive('user')->withNoArgs()->andReturn($user); return $user; diff --git a/tests/Traits/Integration/CreatesTestModels.php b/tests/Traits/Integration/CreatesTestModels.php index 59d2e9ed5..bafa9baa8 100644 --- a/tests/Traits/Integration/CreatesTestModels.php +++ b/tests/Traits/Integration/CreatesTestModels.php @@ -1,6 +1,6 @@ app->make(EloquentFactory::class); - if (isset($attributes['user_id'])) { $attributes['owner_id'] = $attributes['user_id']; } - if (! isset($attributes['owner_id'])) { - $user = $factory->of(User::class)->create(); + if (!isset($attributes['owner_id'])) { + /** @var \Pterodactyl\Models\User $user */ + $user = User::factory()->create(); $attributes['owner_id'] = $user->id; } - if (! isset($attributes['node_id'])) { - if (! isset($attributes['location_id'])) { - $location = $factory->of(Location::class)->create(); + if (!isset($attributes['node_id'])) { + if (!isset($attributes['location_id'])) { + /** @var \Pterodactyl\Models\Location $location */ + $location = Location::factory()->create(); $attributes['location_id'] = $location->id; } - $node = $factory->of(Node::class)->create(['location_id' => $attributes['location_id']]); + /** @var \Pterodactyl\Models\Node $node */ + $node = Node::factory()->create(['location_id' => $attributes['location_id']]); $attributes['node_id'] = $node->id; } - if (! isset($attributes['allocation_id'])) { - $allocation = $factory->of(Allocation::class)->create(['node_id' => $attributes['node_id']]); + if (!isset($attributes['allocation_id'])) { + /** @var \Pterodactyl\Models\Allocation $allocation */ + $allocation = Allocation::factory()->create(['node_id' => $attributes['node_id']]); $attributes['allocation_id'] = $allocation->id; } - if (! isset($attributes['nest_id'])) { + if (!isset($attributes['nest_id'])) { + /** @var \Pterodactyl\Models\Nest $nest */ $nest = Nest::with('eggs')->first(); $attributes['nest_id'] = $nest->id; - if (! isset($attributes['egg_id'])) { + if (!isset($attributes['egg_id'])) { $attributes['egg_id'] = $nest->getRelation('eggs')->first()->id; } } - if (! isset($attributes['egg_id'])) { + if (!isset($attributes['egg_id'])) { + /** @var \Pterodactyl\Models\Egg $egg */ $egg = Egg::where('nest_id', $attributes['nest_id'])->first(); $attributes['egg_id'] = $egg->id; } @@ -71,21 +71,18 @@ trait CreatesTestModels unset($attributes['user_id'], $attributes['location_id']); /** @var \Pterodactyl\Models\Server $server */ - $server = $factory->of(Server::class)->create($attributes); + $server = Server::factory()->create($attributes); Allocation::query()->where('id', $server->allocation_id)->update(['server_id' => $server->id]); - return Server::with([ + return $server->fresh([ 'location', 'user', 'node', 'allocation', 'nest', 'egg', - ])->findOrFail($server->id); + ]); } /** * Clones a given egg allowing us to make modifications that don't affect other * tests that rely on the egg existing in the correct state. - * - * @param \Pterodactyl\Models\Egg $egg - * @return \Pterodactyl\Models\Egg */ protected function cloneEggAndVariables(Egg $egg): Egg { diff --git a/tests/Traits/MocksPdoConnection.php b/tests/Traits/MocksPdoConnection.php index 01c26d12b..c7fe8cdd0 100644 --- a/tests/Traits/MocksPdoConnection.php +++ b/tests/Traits/MocksPdoConnection.php @@ -1,6 +1,6 @@ . - * - * This software is licensed under the terms of the MIT license. - * https://opensource.org/licenses/MIT - */ -namespace Tests\Unit\Helpers; +namespace Pterodactyl\Tests\Unit\Helpers; -use Tests\TestCase; +use Pterodactyl\Tests\TestCase; class IsDigitTest extends TestCase { diff --git a/tests/Unit/Http/Middleware/AdminAuthenticateTest.php b/tests/Unit/Http/Middleware/AdminAuthenticateTest.php index efe6e8212..75fb2280e 100644 --- a/tests/Unit/Http/Middleware/AdminAuthenticateTest.php +++ b/tests/Unit/Http/Middleware/AdminAuthenticateTest.php @@ -1,6 +1,6 @@ make(['root_admin' => 1]); + $user = User::factory()->make(['root_admin' => 1]); $this->request->shouldReceive('user')->withNoArgs()->twice()->andReturn($user); @@ -39,7 +39,7 @@ class AdminAuthenticateTest extends MiddlewareTestCase { $this->expectException(AccessDeniedHttpException::class); - $user = factory(User::class)->make(['root_admin' => 0]); + $user = User::factory()->make(['root_admin' => 0]); $this->request->shouldReceive('user')->withNoArgs()->twice()->andReturn($user); @@ -48,8 +48,6 @@ class AdminAuthenticateTest extends MiddlewareTestCase /** * Return an instance of the middleware using mocked dependencies. - * - * @return \Pterodactyl\Http\Middleware\AdminAuthenticate */ private function getMiddleware(): AdminAuthenticate { diff --git a/tests/Unit/Http/Middleware/Api/Application/AuthenticateUserTest.php b/tests/Unit/Http/Middleware/Api/Application/AuthenticateUserTest.php index 3cbd7debf..8ba4c75fc 100644 --- a/tests/Unit/Http/Middleware/Api/Application/AuthenticateUserTest.php +++ b/tests/Unit/Http/Middleware/Api/Application/AuthenticateUserTest.php @@ -1,8 +1,8 @@ make(['allowed_ips' => []]); + $model = ApiKey::factory()->make(['allowed_ips' => []]); $this->setRequestAttribute('api_key', $model); $this->getMiddleware()->handle($this->request, $this->getClosureAssertions()); @@ -26,7 +26,7 @@ class AuthenticateIPAccessTest extends MiddlewareTestCase */ public function testWithValidIP() { - $model = factory(ApiKey::class)->make(['allowed_ips' => ['127.0.0.1']]); + $model = ApiKey::factory()->make(['allowed_ips' => ['127.0.0.1']]); $this->setRequestAttribute('api_key', $model); $this->request->shouldReceive('ip')->withNoArgs()->once()->andReturn('127.0.0.1'); @@ -39,7 +39,7 @@ class AuthenticateIPAccessTest extends MiddlewareTestCase */ public function testValidIPAgainstCIDRRange() { - $model = factory(ApiKey::class)->make(['allowed_ips' => ['192.168.1.1/28']]); + $model = ApiKey::factory()->make(['allowed_ips' => ['192.168.1.1/28']]); $this->setRequestAttribute('api_key', $model); $this->request->shouldReceive('ip')->withNoArgs()->once()->andReturn('192.168.1.15'); @@ -55,7 +55,7 @@ class AuthenticateIPAccessTest extends MiddlewareTestCase { $this->expectException(AccessDeniedHttpException::class); - $model = factory(ApiKey::class)->make(['allowed_ips' => ['127.0.0.1']]); + $model = ApiKey::factory()->make(['allowed_ips' => ['127.0.0.1']]); $this->setRequestAttribute('api_key', $model); $this->request->shouldReceive('ip')->withNoArgs()->twice()->andReturn('127.0.0.2'); @@ -65,8 +65,6 @@ class AuthenticateIPAccessTest extends MiddlewareTestCase /** * Return an instance of the middleware to be used when testing. - * - * @return \Pterodactyl\Http\Middleware\Api\AuthenticateIPAccess */ private function getMiddleware(): AuthenticateIPAccess { diff --git a/tests/Unit/Http/Middleware/Api/AuthenticateKeyTest.php b/tests/Unit/Http/Middleware/Api/AuthenticateKeyTest.php index 79715e4c8..211e810df 100644 --- a/tests/Unit/Http/Middleware/Api/AuthenticateKeyTest.php +++ b/tests/Unit/Http/Middleware/Api/AuthenticateKeyTest.php @@ -1,17 +1,17 @@ auth = m::mock(AuthManager::class); $this->encrypter = m::mock(Encrypter::class); @@ -69,7 +68,7 @@ class AuthenticateKeyTest extends MiddlewareTestCase $this->expectException(AccessDeniedHttpException::class); $this->request->shouldReceive('bearerToken')->withNoArgs()->twice()->andReturn('abcd1234'); - $this->repository->shouldReceive('findFirstWhere')->andThrow(new RecordNotFoundException); + $this->repository->shouldReceive('findFirstWhere')->andThrow(new RecordNotFoundException()); $this->getMiddleware()->handle($this->request, $this->getClosureAssertions(), ApiKey::TYPE_APPLICATION); } @@ -79,7 +78,7 @@ class AuthenticateKeyTest extends MiddlewareTestCase */ public function testValidToken() { - $model = factory(ApiKey::class)->make(); + $model = ApiKey::factory()->make(); $this->request->shouldReceive('bearerToken')->withNoArgs()->twice()->andReturn($model->identifier . 'decrypted'); $this->repository->shouldReceive('findFirstWhere')->with([ @@ -90,7 +89,7 @@ class AuthenticateKeyTest extends MiddlewareTestCase $this->auth->shouldReceive('guard->loginUsingId')->with($model->user_id)->once()->andReturnNull(); $this->repository->shouldReceive('withoutFreshModel->update')->with($model->id, [ - 'last_used_at' => Chronos::now(), + 'last_used_at' => CarbonImmutable::now(), ])->once()->andReturnNull(); $this->getMiddleware()->handle($this->request, $this->getClosureAssertions(), ApiKey::TYPE_APPLICATION); @@ -102,7 +101,7 @@ class AuthenticateKeyTest extends MiddlewareTestCase */ public function testValidTokenWithUserKey() { - $model = factory(ApiKey::class)->make(); + $model = ApiKey::factory()->make(); $this->request->shouldReceive('bearerToken')->withNoArgs()->twice()->andReturn($model->identifier . 'decrypted'); $this->repository->shouldReceive('findFirstWhere')->with([ @@ -113,7 +112,7 @@ class AuthenticateKeyTest extends MiddlewareTestCase $this->auth->shouldReceive('guard->loginUsingId')->with($model->user_id)->once()->andReturnNull(); $this->repository->shouldReceive('withoutFreshModel->update')->with($model->id, [ - 'last_used_at' => Chronos::now(), + 'last_used_at' => CarbonImmutable::now(), ])->once()->andReturnNull(); $this->getMiddleware()->handle($this->request, $this->getClosureAssertions(), ApiKey::TYPE_ACCOUNT); @@ -126,7 +125,7 @@ class AuthenticateKeyTest extends MiddlewareTestCase */ public function testAccessWithoutToken() { - $user = factory(User::class)->make(['id' => 123]); + $user = User::factory()->make(['id' => 123]); $this->request->shouldReceive('user')->andReturn($user); $this->request->shouldReceive('bearerToken')->withNoArgs()->twice()->andReturnNull(); @@ -147,7 +146,7 @@ class AuthenticateKeyTest extends MiddlewareTestCase { $this->expectException(AccessDeniedHttpException::class); - $model = factory(ApiKey::class)->make(); + $model = ApiKey::factory()->make(); $this->request->shouldReceive('bearerToken')->withNoArgs()->twice()->andReturn($model->identifier . 'asdf'); $this->repository->shouldReceive('findFirstWhere')->with([ @@ -161,8 +160,6 @@ class AuthenticateKeyTest extends MiddlewareTestCase /** * Return an instance of the middleware with mocked dependencies for testing. - * - * @return \Pterodactyl\Http\Middleware\Api\AuthenticateKey */ private function getMiddleware(): AuthenticateKey { diff --git a/tests/Unit/Http/Middleware/Api/Daemon/DaemonAuthenticateTest.php b/tests/Unit/Http/Middleware/Api/Daemon/DaemonAuthenticateTest.php index 35699eb65..945e08701 100644 --- a/tests/Unit/Http/Middleware/Api/Daemon/DaemonAuthenticateTest.php +++ b/tests/Unit/Http/Middleware/Api/Daemon/DaemonAuthenticateTest.php @@ -1,15 +1,15 @@ expectException(AccessDeniedHttpException::class); /** @var \Pterodactyl\Models\Node $model */ - $model = factory(Node::class)->make(); + $model = Node::factory()->make(); $this->request->expects('route->getName')->withNoArgs()->andReturn('random.route'); $this->request->expects('bearerToken')->withNoArgs()->andReturn($model->daemon_token_id . '.random_string_123'); @@ -125,7 +124,7 @@ class DaemonAuthenticateTest extends MiddlewareTestCase public function testSuccessfulMiddlewareProcess() { /** @var \Pterodactyl\Models\Node $model */ - $model = factory(Node::class)->make(); + $model = Node::factory()->make(); $this->request->expects('route->getName')->withNoArgs()->andReturn('random.route'); $this->request->expects('bearerToken')->withNoArgs()->andReturn($model->daemon_token_id . '.' . decrypt($model->daemon_token)); @@ -159,8 +158,6 @@ class DaemonAuthenticateTest extends MiddlewareTestCase /** * Return an instance of the middleware using mocked dependencies. - * - * @return \Pterodactyl\Http\Middleware\Api\Daemon\DaemonAuthenticate */ private function getMiddleware(): DaemonAuthenticate { diff --git a/tests/Unit/Http/Middleware/Api/SetSessionDriverTest.php b/tests/Unit/Http/Middleware/Api/SetSessionDriverTest.php index c41d742ef..83fc2b7bc 100644 --- a/tests/Unit/Http/Middleware/Api/SetSessionDriverTest.php +++ b/tests/Unit/Http/Middleware/Api/SetSessionDriverTest.php @@ -1,11 +1,11 @@ make(['language' => 'de']); + $user = User::factory()->make(['language' => 'de']); $this->request->shouldReceive('user')->withNoArgs()->andReturn($user); $this->appMock->shouldReceive('setLocale')->with('de')->once()->andReturnNull(); @@ -50,8 +50,6 @@ class LanguageMiddlewareTest extends MiddlewareTestCase /** * Return an instance of the middleware using mocked dependencies. - * - * @return \Pterodactyl\Http\Middleware\LanguageMiddleware */ private function getMiddleware(): LanguageMiddleware { diff --git a/tests/Unit/Http/Middleware/MaintenanceMiddlewareTest.php b/tests/Unit/Http/Middleware/MaintenanceMiddlewareTest.php index 68b971e65..a007dd34a 100644 --- a/tests/Unit/Http/Middleware/MaintenanceMiddlewareTest.php +++ b/tests/Unit/Http/Middleware/MaintenanceMiddlewareTest.php @@ -1,6 +1,6 @@ make(); - $node = factory(Node::class)->make(['maintenance' => 0]); + $server = Server::factory()->make(); + $node = Node::factory()->make(['maintenance' => 0]); $server->setRelation('node', $node); $this->setRequestAttribute('server', $server); @@ -45,8 +45,8 @@ class MaintenanceMiddlewareTest extends MiddlewareTestCase */ public function testHandleInMaintenanceMode() { - $server = factory(Server::class)->make(); - $node = factory(Node::class)->make(['maintenance_mode' => 1]); + $server = Server::factory()->make(); + $node = Node::factory()->make(['maintenance_mode' => 1]); $server->setRelation('node', $node); $this->setRequestAttribute('server', $server); @@ -54,15 +54,12 @@ class MaintenanceMiddlewareTest extends MiddlewareTestCase $this->response->shouldReceive('view') ->once() ->with('errors.maintenance') - ->andReturn(new Response); + ->andReturn(new Response()); $response = $this->getMiddleware()->handle($this->request, $this->getClosureAssertions()); $this->assertInstanceOf(Response::class, $response); } - /** - * @return \Pterodactyl\Http\Middleware\MaintenanceMiddleware - */ private function getMiddleware(): MaintenanceMiddleware { return new MaintenanceMiddleware($this->response); diff --git a/tests/Unit/Http/Middleware/MiddlewareTestCase.php b/tests/Unit/Http/Middleware/MiddlewareTestCase.php index ac7fd5098..b716681d8 100644 --- a/tests/Unit/Http/Middleware/MiddlewareTestCase.php +++ b/tests/Unit/Http/Middleware/MiddlewareTestCase.php @@ -1,15 +1,17 @@ expectException(AccessDeniedHttpException::class); $this->expectExceptionMessage('Server is suspended and cannot be accessed.'); - $model = factory(Server::class)->make(['suspended' => 1]); + $model = Server::factory()->make(['suspended' => 1]); $this->request->shouldReceive('route->parameter')->with('server')->once()->andReturn('123456'); $this->request->shouldReceive('expectsJson')->withNoArgs()->once()->andReturn(true); @@ -67,7 +67,7 @@ class AccessingValidServerTest extends MiddlewareTestCase $this->expectException(ConflictHttpException::class); $this->expectExceptionMessage('Server is still completing the installation process.'); - $model = factory(Server::class)->make(['installed' => 0]); + $model = Server::factory()->make(['installed' => 0]); $this->request->shouldReceive('route->parameter')->with('server')->once()->andReturn('123456'); $this->request->shouldReceive('expectsJson')->withNoArgs()->once()->andReturn(true); @@ -101,7 +101,7 @@ class AccessingValidServerTest extends MiddlewareTestCase */ public function testValidServerProcess() { - $model = factory(Server::class)->make(); + $model = Server::factory()->make(); $this->request->shouldReceive('route->parameter')->with('server')->once()->andReturn('123456'); $this->request->shouldReceive('expectsJson')->withNoArgs()->once()->andReturn(false); @@ -117,8 +117,6 @@ class AccessingValidServerTest extends MiddlewareTestCase /** * Provide test data that checks that the correct view is returned for each model type. - * - * @return array */ public function viewDataProvider(): array { @@ -126,16 +124,14 @@ class AccessingValidServerTest extends MiddlewareTestCase $this->refreshApplication(); return [ - [factory(Server::class)->make(['suspended' => 1]), 'errors.suspended', 403], - [factory(Server::class)->make(['installed' => 0]), 'errors.installing', 409], - [factory(Server::class)->make(['installed' => 2]), 'errors.installing', 409], + [Server::factory()->make(['suspended' => 1]), 'errors.suspended', 403], + [Server::factory()->make(['installed' => 0]), 'errors.installing', 409], + [Server::factory()->make(['installed' => 2]), 'errors.installing', 409], ]; } /** * Return an instance of the middleware using mocked dependencies. - * - * @return \Pterodactyl\Http\Middleware\Server\AccessingValidServer */ private function getMiddleware(): AccessingValidServer { diff --git a/tests/Unit/Rules/UsernameTest.php b/tests/Unit/Rules/UsernameTest.php index 7f7bdbb73..829cab2c3 100644 --- a/tests/Unit/Rules/UsernameTest.php +++ b/tests/Unit/Rules/UsernameTest.php @@ -1,9 +1,9 @@ assertSame('p_username', (string) new Username); + $this->assertSame('p_username', (string) new Username()); } /** @@ -22,7 +22,7 @@ class UsernameTest extends TestCase */ public function testValidUsernames(string $username) { - $this->assertTrue((new Username)->passes('test', $username), 'Assert username is valid.'); + $this->assertTrue((new Username())->passes('test', $username), 'Assert username is valid.'); } /** @@ -32,12 +32,11 @@ class UsernameTest extends TestCase */ public function testInvalidUsernames(string $username) { - $this->assertFalse((new Username)->passes('test', $username), 'Assert username is not valid.'); + $this->assertFalse((new Username())->passes('test', $username), 'Assert username is not valid.'); } /** * Provide valid usernames. - * @return array */ public function validUsernameDataProvider(): array { @@ -54,8 +53,6 @@ class UsernameTest extends TestCase /** * Provide invalid usernames. - * - * @return array */ public function invalidUsernameDataProvider(): array { diff --git a/tests/Unit/Services/Acl/Api/AdminAclTest.php b/tests/Unit/Services/Acl/Api/AdminAclTest.php index 325af82c7..daaea838f 100644 --- a/tests/Unit/Services/Acl/Api/AdminAclTest.php +++ b/tests/Unit/Services/Acl/Api/AdminAclTest.php @@ -1,9 +1,9 @@ make(['r_servers' => AdminAcl::READ | AdminAcl::WRITE]); + $model = ApiKey::factory()->make(['r_servers' => AdminAcl::READ | AdminAcl::WRITE]); $this->assertTrue(AdminAcl::check($model, AdminAcl::RESOURCE_SERVERS, AdminAcl::WRITE)); } /** * Provide valid and invalid permissions combos for testing. - * - * @return array */ public function permissionsDataProvider(): array { diff --git a/tests/Unit/Services/Api/KeyCreationServiceTest.php b/tests/Unit/Services/Api/KeyCreationServiceTest.php index 3f04f24e3..5c847f144 100644 --- a/tests/Unit/Services/Api/KeyCreationServiceTest.php +++ b/tests/Unit/Services/Api/KeyCreationServiceTest.php @@ -1,11 +1,11 @@ make(); + $model = ApiKey::factory()->make(); $this->getFunctionMock('\\Pterodactyl\\Services\\Api', 'str_random') ->expects($this->exactly(2))->willReturnCallback(function ($length) { @@ -68,7 +68,7 @@ class KeyCreationServiceTest extends TestCase */ public function testIdentifierAndTokenAreOnlySetByFunction() { - $model = factory(ApiKey::class)->make(); + $model = ApiKey::factory()->make(); $this->getFunctionMock('\\Pterodactyl\\Services\\Api', 'str_random') ->expects($this->exactly(2))->willReturnCallback(function ($length) { @@ -95,7 +95,7 @@ class KeyCreationServiceTest extends TestCase */ public function testPermissionsAreRetrievedForApplicationKeys() { - $model = factory(ApiKey::class)->make(); + $model = ApiKey::factory()->make(); $this->getFunctionMock('\\Pterodactyl\\Services\\Api', 'str_random') ->expects($this->exactly(2))->willReturnCallback(function ($length) { @@ -125,7 +125,7 @@ class KeyCreationServiceTest extends TestCase */ public function testPermissionsAreNotRetrievedForNonApplicationKeys($keyType) { - $model = factory(ApiKey::class)->make(); + $model = ApiKey::factory()->make(); $this->getFunctionMock('\\Pterodactyl\\Services\\Api', 'str_random') ->expects($this->exactly(2))->willReturnCallback(function ($length) { @@ -149,8 +149,6 @@ class KeyCreationServiceTest extends TestCase /** * Provide key types that are not an application specific key. - * - * @return array */ public function keyTypeDataProvider(): array { @@ -161,8 +159,6 @@ class KeyCreationServiceTest extends TestCase /** * Return an instance of the service with mocked dependencies for testing. - * - * @return \Pterodactyl\Services\Api\KeyCreationService */ private function getService(): KeyCreationService {