Skip to content

Commit

Permalink
php-cs-fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewpi committed Feb 23, 2023
1 parent e040f11 commit 2618d74
Show file tree
Hide file tree
Showing 86 changed files with 148 additions and 251 deletions.
3 changes: 1 addition & 2 deletions app/Console/Commands/Environment/AppSettingsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Pterodactyl\Console\Commands\Environment;

use DateTimeZone;
use Illuminate\Console\Command;
use Illuminate\Contracts\Console\Kernel;
use Pterodactyl\Traits\Commands\EnvironmentWriterTrait;
Expand Down Expand Up @@ -89,7 +88,7 @@ public function handle(): int
$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.');
$this->variables['APP_TIMEZONE'] = $this->option('timezone') ?? $this->anticipate(
'Application Timezone',
DateTimeZone::listIdentifiers(),
\DateTimeZone::listIdentifiers(),
config('app.timezone')
);

Expand Down
3 changes: 1 addition & 2 deletions app/Console/Commands/Environment/DatabaseSettingsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Pterodactyl\Console\Commands\Environment;

use PDOException;
use Illuminate\Console\Command;
use Illuminate\Contracts\Console\Kernel;
use Illuminate\Database\DatabaseManager;
Expand Down Expand Up @@ -72,7 +71,7 @@ public function handle(): int

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Pterodactyl\Console\Commands\Maintenance;

use SplFileInfo;
use Carbon\Carbon;
use Illuminate\Console\Command;
use Illuminate\Contracts\Filesystem\Filesystem;
Expand Down Expand Up @@ -35,7 +34,7 @@ public function handle()
{
$files = $this->disk->files('services/.bak');

collect($files)->each(function (SplFileInfo $file) {
collect($files)->each(function (\SplFileInfo $file) {
$lastModified = Carbon::createFromTimestamp($this->disk->lastModified($file->getPath()));
if ($lastModified->diffInMinutes(Carbon::now()) > self::BACKUP_THRESHOLD_MINUTES) {
$this->disk->delete($file->getPath());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Pterodactyl\Console\Commands\Maintenance;

use Carbon\CarbonImmutable;
use InvalidArgumentException;
use Illuminate\Console\Command;
use Pterodactyl\Repositories\Eloquent\BackupRepository;

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

$query = $this->backupRepository->getBuilder()
Expand Down
3 changes: 1 addition & 2 deletions app/Console/Commands/Schedule/ProcessRunnableCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Pterodactyl\Console\Commands\Schedule;

use Exception;
use Throwable;
use Illuminate\Console\Command;
use Pterodactyl\Models\Schedule;
use Illuminate\Support\Facades\Log;
Expand Down Expand Up @@ -68,7 +67,7 @@ protected function processSchedule(Schedule $schedule)
'schedule' => $schedule->name,
'hash' => $schedule->hashid,
]));
} catch (Throwable|Exception $exception) {
} catch (\Throwable|\Exception $exception) {
Log::error($exception, ['schedule_id' => $schedule->id]);

$this->error("An error was encountered while processing Schedule #$schedule->id: " . $exception->getMessage());
Expand Down
3 changes: 1 addition & 2 deletions app/Console/Commands/UpgradeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Pterodactyl\Console\Commands;

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

protected function withProgress(ProgressBar $bar, Closure $callback)
protected function withProgress(ProgressBar $bar, \Closure $callback)
{
$bar->clear();
$callback();
Expand Down
4 changes: 1 addition & 3 deletions app/Exceptions/AccountNotFoundException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace Pterodactyl\Exceptions;

use Exception;

class AccountNotFoundException extends Exception
class AccountNotFoundException extends \Exception
{
}
4 changes: 1 addition & 3 deletions app/Exceptions/AutoDeploymentException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace Pterodactyl\Exceptions;

use Exception;

class AutoDeploymentException extends Exception
class AutoDeploymentException extends \Exception
{
}
5 changes: 2 additions & 3 deletions app/Exceptions/DisplayException.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Pterodactyl\Exceptions;

use Exception;
use Throwable;
use Illuminate\Http\Request;
use Psr\Log\LoggerInterface;
use Illuminate\Http\Response;
Expand All @@ -23,7 +22,7 @@ class DisplayException extends PterodactylException implements HttpExceptionInte
/**
* DisplayException constructor.
*/
public function __construct(string $message, ?Throwable $previous = null, protected string $level = self::LEVEL_ERROR, int $code = 0)
public function __construct(string $message, ?\Throwable $previous = null, protected string $level = self::LEVEL_ERROR, int $code = 0)
{
parent::__construct($message, $code, $previous);
}
Expand Down Expand Up @@ -67,7 +66,7 @@ public function render(Request $request): JsonResponse|RedirectResponse
*/
public function report()
{
if (!$this->getPrevious() instanceof Exception || !Handler::isReportable($this->getPrevious())) {
if (!$this->getPrevious() instanceof \Exception || !Handler::isReportable($this->getPrevious())) {
return null;
}

Expand Down
18 changes: 8 additions & 10 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
namespace Pterodactyl\Exceptions;

use Exception;
use Throwable;
use PDOException;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use Illuminate\Http\JsonResponse;
Expand Down Expand Up @@ -81,7 +79,7 @@ public function register(): void
$this->dontReport = [];
}

$this->reportable(function (PDOException $ex) {
$this->reportable(function (\PDOException $ex) {
$ex = $this->generateCleanedExceptionStack($ex);
});

Expand All @@ -90,7 +88,7 @@ public function register(): void
});
}

private function generateCleanedExceptionStack(Throwable $exception): string
private function generateCleanedExceptionStack(\Throwable $exception): string
{
$cleanedStack = '';
foreach ($exception->getTrace() as $index => $item) {
Expand Down Expand Up @@ -123,7 +121,7 @@ class_basename($exception),
*
* @throws \Throwable
*/
public function render($request, Throwable $e): Response
public function render($request, \Throwable $e): Response
{
$connections = $this->container->make(Connection::class);

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

Expand Down Expand Up @@ -235,7 +233,7 @@ protected function convertExceptionToArray(Throwable $e, array $override = []):
/**
* Return an array of exceptions that should not be reported.
*/
public static function isReportable(Exception $exception): bool
public static function isReportable(\Exception $exception): bool
{
return (new static(Container::getInstance()))->shouldReport($exception);
}
Expand All @@ -260,11 +258,11 @@ protected function unauthenticated($request, AuthenticationException $exception)
*
* @return \Throwable[]
*/
protected function extractPrevious(Throwable $e): array
protected function extractPrevious(\Throwable $e): array
{
$previous = [];
while ($value = $e->getPrevious()) {
if (!$value instanceof Throwable) {
if (!$value instanceof \Throwable) {
break;
}
$previous[] = $value;
Expand All @@ -278,7 +276,7 @@ protected function extractPrevious(Throwable $e): array
* Helper method to allow reaching into the handler to convert an exception
* into the expected array response type.
*/
public static function toArray(Throwable $e): array
public static function toArray(\Throwable $e): array
{
return (new self(app()))->convertExceptionToArray($e);
}
Expand Down
3 changes: 1 addition & 2 deletions app/Exceptions/Http/Server/ServerStateConflictException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Pterodactyl\Exceptions\Http\Server;

use Throwable;
use Pterodactyl\Models\Server;
use Symfony\Component\HttpKernel\Exception\ConflictHttpException;

Expand All @@ -12,7 +11,7 @@ class ServerStateConflictException extends ConflictHttpException
* Exception thrown when the server is in an unsupported state for API access or
* certain operations within the codebase.
*/
public function __construct(Server $server, Throwable $previous = null)
public function __construct(Server $server, \Throwable $previous = null)
{
$message = 'This server is currently in an unsupported state, please try again later.';
if ($server->isSuspended()) {
Expand Down
3 changes: 1 addition & 2 deletions app/Exceptions/Http/TwoFactorAuthRequiredException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Pterodactyl\Exceptions\Http;

use Throwable;
use Illuminate\Http\Response;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
Expand All @@ -12,7 +11,7 @@ class TwoFactorAuthRequiredException extends HttpException implements HttpExcept
/**
* TwoFactorAuthRequiredException constructor.
*/
public function __construct(Throwable $previous = null)
public function __construct(\Throwable $previous = null)
{
parent::__construct(Response::HTTP_BAD_REQUEST, 'Two-factor authentication is required on this account in order to access this endpoint.', $previous);
}
Expand Down
3 changes: 1 addition & 2 deletions app/Exceptions/ManifestDoesNotExistException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

namespace Pterodactyl\Exceptions;

use Exception;
use Spatie\Ignition\Contracts\Solution;
use Spatie\Ignition\Contracts\ProvidesSolution;

class ManifestDoesNotExistException extends Exception implements ProvidesSolution
class ManifestDoesNotExistException extends \Exception implements ProvidesSolution
{
public function getSolution(): Solution
{
Expand Down
4 changes: 1 addition & 3 deletions app/Exceptions/PterodactylException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace Pterodactyl\Exceptions;

use Exception;

class PterodactylException extends Exception
class PterodactylException extends \Exception
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace Pterodactyl\Exceptions\Service\Helper;

use Exception;

class CdnVersionFetchingException extends Exception
class CdnVersionFetchingException extends \Exception
{
}
3 changes: 1 addition & 2 deletions app/Exceptions/Service/ServiceLimitExceededException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Pterodactyl\Exceptions\Service;

use Throwable;
use Pterodactyl\Exceptions\DisplayException;

class ServiceLimitExceededException extends DisplayException
Expand All @@ -11,7 +10,7 @@ class ServiceLimitExceededException extends DisplayException
* Exception thrown when something goes over a defined limit, such as allocated
* ports, tasks, databases, etc.
*/
public function __construct(string $message, Throwable $previous = null)
public function __construct(string $message, \Throwable $previous = null)
{
parent::__construct($message, $previous, self::LEVEL_WARNING);
}
Expand Down
7 changes: 3 additions & 4 deletions app/Extensions/Backups/BackupManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use Webmozart\Assert\Assert;
use InvalidArgumentException;
use Illuminate\Foundation\Application;
use League\Flysystem\FilesystemAdapter;
use Pterodactyl\Extensions\Filesystem\S3Filesystem;
Expand Down Expand Up @@ -70,7 +69,7 @@ protected function resolve(string $name): FilesystemAdapter
$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'];
Expand All @@ -88,7 +87,7 @@ protected function resolve(string $name): FilesystemAdapter
return $instance;
}

throw new InvalidArgumentException("Adapter [$adapter] is not supported.");
throw new \InvalidArgumentException("Adapter [$adapter] is not supported.");
}

/**
Expand Down Expand Up @@ -164,7 +163,7 @@ public function forget(array|string $adapter): self
/**
* Register a custom adapter creator closure.
*/
public function extend(string $adapter, Closure $callback): self
public function extend(string $adapter, \Closure $callback): self
{
$this->customCreators[$adapter] = $callback;

Expand Down
3 changes: 1 addition & 2 deletions app/Extensions/Lcobucci/JWT/Encoding/TimestampDates.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Pterodactyl\Extensions\Lcobucci\JWT\Encoding;

use DateTimeImmutable;
use Lcobucci\JWT\ClaimsFormatter;
use Lcobucci\JWT\Token\RegisteredClaims;

Expand All @@ -21,7 +20,7 @@ public function formatClaims(array $claims): array
continue;
}

assert($claims[$claim] instanceof DateTimeImmutable);
assert($claims[$claim] instanceof \DateTimeImmutable);
$claims[$claim] = $claims[$claim]->getTimestamp();
}

Expand Down
3 changes: 1 addition & 2 deletions app/Helpers/Utilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Pterodactyl\Helpers;

use Exception;
use Carbon\Carbon;
use Cron\CronExpression;
use Illuminate\Support\Facades\Log;
Expand All @@ -25,7 +24,7 @@ public static function randomStringWithSpecialCharacters(int $length = 16): stri

$string = substr_replace($string, $character, random_int(0, $length - 1), 1);
}
} catch (Exception $exception) {
} catch (\Exception $exception) {
// Just log the error and hope for the best at this point.
Log::error($exception);
}
Expand Down
Loading

0 comments on commit 2618d74

Please sign in to comment.