Skip to content

Commit 1d38b4f

Browse files
authored
Laravel 10 (pterodactyl#4706)
1 parent ad4ddc6 commit 1d38b4f

File tree

136 files changed

+1790
-2063
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

136 files changed

+1790
-2063
lines changed

.github/workflows/ci.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
strategy:
1818
fail-fast: false
1919
matrix:
20-
php: [8.0, 8.1]
20+
php: [8.1, 8.2]
2121
database: ["mariadb:10.2", "mysql:8"]
2222
services:
2323
database:

app/Console/Commands/Environment/AppSettingsCommand.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace Pterodactyl\Console\Commands\Environment;
44

5-
use DateTimeZone;
65
use Illuminate\Console\Command;
76
use Illuminate\Contracts\Console\Kernel;
87
use Pterodactyl\Traits\Commands\EnvironmentWriterTrait;
@@ -89,7 +88,7 @@ public function handle(): int
8988
$this->output->comment('The timezone should match one of PHP\'s supported timezones. If you are unsure, please reference https://php.net/manual/en/timezones.php.');
9089
$this->variables['APP_TIMEZONE'] = $this->option('timezone') ?? $this->anticipate(
9190
'Application Timezone',
92-
DateTimeZone::listIdentifiers(),
91+
\DateTimeZone::listIdentifiers(),
9392
config('app.timezone')
9493
);
9594

app/Console/Commands/Environment/DatabaseSettingsCommand.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace Pterodactyl\Console\Commands\Environment;
44

5-
use PDOException;
65
use Illuminate\Console\Command;
76
use Illuminate\Contracts\Console\Kernel;
87
use Illuminate\Database\DatabaseManager;
@@ -72,7 +71,7 @@ public function handle(): int
7271

7372
try {
7473
$this->testMySQLConnection();
75-
} catch (PDOException $exception) {
74+
} catch (\PDOException $exception) {
7675
$this->output->error(sprintf('Unable to connect to the MySQL server using the provided credentials. The error returned was "%s".', $exception->getMessage()));
7776
$this->output->error('Your connection credentials have NOT been saved. You will need to provide valid connection information before proceeding.');
7877

app/Console/Commands/Maintenance/CleanServiceBackupFilesCommand.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace Pterodactyl\Console\Commands\Maintenance;
44

5-
use SplFileInfo;
65
use Carbon\Carbon;
76
use Illuminate\Console\Command;
87
use Illuminate\Contracts\Filesystem\Filesystem;
@@ -35,7 +34,7 @@ public function handle()
3534
{
3635
$files = $this->disk->files('services/.bak');
3736

38-
collect($files)->each(function (SplFileInfo $file) {
37+
collect($files)->each(function (\SplFileInfo $file) {
3938
$lastModified = Carbon::createFromTimestamp($this->disk->lastModified($file->getPath()));
4039
if ($lastModified->diffInMinutes(Carbon::now()) > self::BACKUP_THRESHOLD_MINUTES) {
4140
$this->disk->delete($file->getPath());

app/Console/Commands/Maintenance/PruneOrphanedBackupsCommand.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace Pterodactyl\Console\Commands\Maintenance;
44

55
use Carbon\CarbonImmutable;
6-
use InvalidArgumentException;
76
use Illuminate\Console\Command;
87
use Pterodactyl\Repositories\Eloquent\BackupRepository;
98

@@ -25,7 +24,7 @@ public function handle()
2524
{
2625
$since = $this->option('prune-age') ?? config('backups.prune_age', 360);
2726
if (!$since || !is_digit($since)) {
28-
throw new InvalidArgumentException('The "--prune-age" argument must be a value greater than 0.');
27+
throw new \InvalidArgumentException('The "--prune-age" argument must be a value greater than 0.');
2928
}
3029

3130
$query = $this->backupRepository->getBuilder()

app/Console/Commands/Schedule/ProcessRunnableCommand.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace Pterodactyl\Console\Commands\Schedule;
44

55
use Exception;
6-
use Throwable;
76
use Illuminate\Console\Command;
87
use Pterodactyl\Models\Schedule;
98
use Illuminate\Support\Facades\Log;
@@ -68,7 +67,7 @@ protected function processSchedule(Schedule $schedule)
6867
'schedule' => $schedule->name,
6968
'hash' => $schedule->hashid,
7069
]));
71-
} catch (Throwable|Exception $exception) {
70+
} catch (\Throwable|\Exception $exception) {
7271
Log::error($exception, ['schedule_id' => $schedule->id]);
7372

7473
$this->error("An error was encountered while processing Schedule #$schedule->id: " . $exception->getMessage());

app/Console/Commands/UpgradeCommand.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace Pterodactyl\Console\Commands;
44

5-
use Closure;
65
use Illuminate\Console\Command;
76
use Pterodactyl\Console\Kernel;
87
use Symfony\Component\Process\Process;
@@ -177,7 +176,7 @@ public function handle()
177176
$this->info('Panel has been successfully upgraded. Please ensure you also update any Wings instances: https://pterodactyl.io/wings/1.0/upgrading.html');
178177
}
179178

180-
protected function withProgress(ProgressBar $bar, Closure $callback)
179+
protected function withProgress(ProgressBar $bar, \Closure $callback)
181180
{
182181
$bar->clear();
183182
$callback();

app/Console/Kernel.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,19 @@ class Kernel extends ConsoleKernel
1818
/**
1919
* Register the commands for the application.
2020
*/
21-
protected function commands()
21+
protected function commands(): void
2222
{
2323
$this->load(__DIR__ . '/Commands');
2424
}
2525

2626
/**
2727
* Define the application's command schedule.
2828
*/
29-
protected function schedule(Schedule $schedule)
29+
protected function schedule(Schedule $schedule): void
3030
{
31+
// https://laravel.com/docs/10.x/upgrade#redis-cache-tags
32+
$schedule->command('cache:prune-stale-tags')->hourly();
33+
3134
// Execute scheduled commands for servers every minute, as if there was a normal cron running.
3235
$schedule->command(ProcessRunnableCommand::class)->everyMinute()->withoutOverlapping();
3336
$schedule->command(CleanServiceBackupFilesCommand::class)->daily();

app/Exceptions/AccountNotFoundException.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
namespace Pterodactyl\Exceptions;
44

5-
use Exception;
6-
7-
class AccountNotFoundException extends Exception
5+
class AccountNotFoundException extends \Exception
86
{
97
}

app/Exceptions/AutoDeploymentException.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
namespace Pterodactyl\Exceptions;
44

5-
use Exception;
6-
7-
class AutoDeploymentException extends Exception
5+
class AutoDeploymentException extends \Exception
86
{
97
}

app/Exceptions/DisplayException.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace Pterodactyl\Exceptions;
44

55
use Exception;
6-
use Throwable;
76
use Illuminate\Http\Request;
87
use Psr\Log\LoggerInterface;
98
use Illuminate\Http\Response;
@@ -23,7 +22,7 @@ class DisplayException extends PterodactylException implements HttpExceptionInte
2322
/**
2423
* DisplayException constructor.
2524
*/
26-
public function __construct(string $message, ?Throwable $previous = null, protected string $level = self::LEVEL_ERROR, int $code = 0)
25+
public function __construct(string $message, ?\Throwable $previous = null, protected string $level = self::LEVEL_ERROR, int $code = 0)
2726
{
2827
parent::__construct($message, $code, $previous);
2928
}
@@ -67,7 +66,7 @@ public function render(Request $request): JsonResponse|RedirectResponse
6766
*/
6867
public function report()
6968
{
70-
if (!$this->getPrevious() instanceof Exception || !Handler::isReportable($this->getPrevious())) {
69+
if (!$this->getPrevious() instanceof \Exception || !Handler::isReportable($this->getPrevious())) {
7170
return null;
7271
}
7372

app/Exceptions/Handler.php

+9-11
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
namespace Pterodactyl\Exceptions;
44

55
use Exception;
6-
use Throwable;
7-
use PDOException;
86
use Illuminate\Support\Arr;
97
use Illuminate\Support\Str;
108
use Illuminate\Http\JsonResponse;
@@ -75,13 +73,13 @@ class Handler extends ExceptionHandler
7573
*
7674
* @noinspection PhpUnusedLocalVariableInspection
7775
*/
78-
public function register()
76+
public function register(): void
7977
{
8078
if (config('app.exceptions.report_all', false)) {
8179
$this->dontReport = [];
8280
}
8381

84-
$this->reportable(function (PDOException $ex) {
82+
$this->reportable(function (\PDOException $ex) {
8583
$ex = $this->generateCleanedExceptionStack($ex);
8684
});
8785

@@ -90,7 +88,7 @@ public function register()
9088
});
9189
}
9290

93-
private function generateCleanedExceptionStack(Throwable $exception): string
91+
private function generateCleanedExceptionStack(\Throwable $exception): string
9492
{
9593
$cleanedStack = '';
9694
foreach ($exception->getTrace() as $index => $item) {
@@ -123,7 +121,7 @@ class_basename($exception),
123121
*
124122
* @throws \Throwable
125123
*/
126-
public function render($request, Throwable $e): Response
124+
public function render($request, \Throwable $e): Response
127125
{
128126
$connections = $this->container->make(Connection::class);
129127

@@ -189,7 +187,7 @@ public function invalidJson($request, ValidationException $exception): JsonRespo
189187
/**
190188
* Return the exception as a JSONAPI representation for use on API requests.
191189
*/
192-
protected function convertExceptionToArray(Throwable $e, array $override = []): array
190+
protected function convertExceptionToArray(\Throwable $e, array $override = []): array
193191
{
194192
$match = self::$exceptionResponseCodes[get_class($e)] ?? null;
195193

@@ -235,7 +233,7 @@ protected function convertExceptionToArray(Throwable $e, array $override = []):
235233
/**
236234
* Return an array of exceptions that should not be reported.
237235
*/
238-
public static function isReportable(Exception $exception): bool
236+
public static function isReportable(\Exception $exception): bool
239237
{
240238
return (new static(Container::getInstance()))->shouldReport($exception);
241239
}
@@ -260,11 +258,11 @@ protected function unauthenticated($request, AuthenticationException $exception)
260258
*
261259
* @return \Throwable[]
262260
*/
263-
protected function extractPrevious(Throwable $e): array
261+
protected function extractPrevious(\Throwable $e): array
264262
{
265263
$previous = [];
266264
while ($value = $e->getPrevious()) {
267-
if (!$value instanceof Throwable) {
265+
if (!$value instanceof \Throwable) {
268266
break;
269267
}
270268
$previous[] = $value;
@@ -278,7 +276,7 @@ protected function extractPrevious(Throwable $e): array
278276
* Helper method to allow reaching into the handler to convert an exception
279277
* into the expected array response type.
280278
*/
281-
public static function toArray(Throwable $e): array
279+
public static function toArray(\Throwable $e): array
282280
{
283281
return (new self(app()))->convertExceptionToArray($e);
284282
}

app/Exceptions/Http/Server/ServerStateConflictException.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace Pterodactyl\Exceptions\Http\Server;
44

5-
use Throwable;
65
use Pterodactyl\Models\Server;
76
use Symfony\Component\HttpKernel\Exception\ConflictHttpException;
87

@@ -12,7 +11,7 @@ class ServerStateConflictException extends ConflictHttpException
1211
* Exception thrown when the server is in an unsupported state for API access or
1312
* certain operations within the codebase.
1413
*/
15-
public function __construct(Server $server, Throwable $previous = null)
14+
public function __construct(Server $server, \Throwable $previous = null)
1615
{
1716
$message = 'This server is currently in an unsupported state, please try again later.';
1817
if ($server->isSuspended()) {

app/Exceptions/Http/TwoFactorAuthRequiredException.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace Pterodactyl\Exceptions\Http;
44

5-
use Throwable;
65
use Illuminate\Http\Response;
76
use Symfony\Component\HttpKernel\Exception\HttpException;
87
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
@@ -12,7 +11,7 @@ class TwoFactorAuthRequiredException extends HttpException implements HttpExcept
1211
/**
1312
* TwoFactorAuthRequiredException constructor.
1413
*/
15-
public function __construct(Throwable $previous = null)
14+
public function __construct(\Throwable $previous = null)
1615
{
1716
parent::__construct(Response::HTTP_BAD_REQUEST, 'Two-factor authentication is required on this account in order to access this endpoint.', $previous);
1817
}

app/Exceptions/ManifestDoesNotExistException.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22

33
namespace Pterodactyl\Exceptions;
44

5-
use Exception;
65
use Spatie\Ignition\Contracts\Solution;
76
use Spatie\Ignition\Contracts\ProvidesSolution;
87

9-
class ManifestDoesNotExistException extends Exception implements ProvidesSolution
8+
class ManifestDoesNotExistException extends \Exception implements ProvidesSolution
109
{
1110
public function getSolution(): Solution
1211
{

app/Exceptions/PterodactylException.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
namespace Pterodactyl\Exceptions;
44

5-
use Exception;
6-
7-
class PterodactylException extends Exception
5+
class PterodactylException extends \Exception
86
{
97
}

app/Exceptions/Service/Helper/CdnVersionFetchingException.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
namespace Pterodactyl\Exceptions\Service\Helper;
44

5-
use Exception;
6-
7-
class CdnVersionFetchingException extends Exception
5+
class CdnVersionFetchingException extends \Exception
86
{
97
}

app/Exceptions/Service/ServiceLimitExceededException.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace Pterodactyl\Exceptions\Service;
44

5-
use Throwable;
65
use Pterodactyl\Exceptions\DisplayException;
76

87
class ServiceLimitExceededException extends DisplayException
@@ -11,7 +10,7 @@ class ServiceLimitExceededException extends DisplayException
1110
* Exception thrown when something goes over a defined limit, such as allocated
1211
* ports, tasks, databases, etc.
1312
*/
14-
public function __construct(string $message, Throwable $previous = null)
13+
public function __construct(string $message, \Throwable $previous = null)
1514
{
1615
parent::__construct($message, $previous, self::LEVEL_WARNING);
1716
}

app/Extensions/Backups/BackupManager.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use Illuminate\Support\Arr;
88
use Illuminate\Support\Str;
99
use Webmozart\Assert\Assert;
10-
use InvalidArgumentException;
1110
use Illuminate\Foundation\Application;
1211
use League\Flysystem\FilesystemAdapter;
1312
use Pterodactyl\Extensions\Filesystem\S3Filesystem;
@@ -70,7 +69,7 @@ protected function resolve(string $name): FilesystemAdapter
7069
$config = $this->getConfig($name);
7170

7271
if (empty($config['adapter'])) {
73-
throw new InvalidArgumentException("Backup disk [$name] does not have a configured adapter.");
72+
throw new \InvalidArgumentException("Backup disk [$name] does not have a configured adapter.");
7473
}
7574

7675
$adapter = $config['adapter'];
@@ -88,7 +87,7 @@ protected function resolve(string $name): FilesystemAdapter
8887
return $instance;
8988
}
9089

91-
throw new InvalidArgumentException("Adapter [$adapter] is not supported.");
90+
throw new \InvalidArgumentException("Adapter [$adapter] is not supported.");
9291
}
9392

9493
/**
@@ -164,7 +163,7 @@ public function forget(array|string $adapter): self
164163
/**
165164
* Register a custom adapter creator closure.
166165
*/
167-
public function extend(string $adapter, Closure $callback): self
166+
public function extend(string $adapter, \Closure $callback): self
168167
{
169168
$this->customCreators[$adapter] = $callback;
170169

app/Extensions/Lcobucci/JWT/Encoding/TimestampDates.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace Pterodactyl\Extensions\Lcobucci\JWT\Encoding;
44

5-
use DateTimeImmutable;
65
use Lcobucci\JWT\ClaimsFormatter;
76
use Lcobucci\JWT\Token\RegisteredClaims;
87

@@ -21,7 +20,7 @@ public function formatClaims(array $claims): array
2120
continue;
2221
}
2322

24-
assert($claims[$claim] instanceof DateTimeImmutable);
23+
assert($claims[$claim] instanceof \DateTimeImmutable);
2524
$claims[$claim] = $claims[$claim]->getTimestamp();
2625
}
2726

0 commit comments

Comments
 (0)