php-cs-fixer

This commit is contained in:
Matthew Penner 2022-11-29 10:53:59 -07:00
parent 16e34af773
commit 3ea6d45cda
No known key found for this signature in database
87 changed files with 151 additions and 256 deletions

View file

@ -62,7 +62,7 @@ jobs:
run: vendor/bin/php-cs-fixer fix --dry-run --diff run: vendor/bin/php-cs-fixer fix --dry-run --diff
mysql: mysql:
name: Tests (MySQL) name: Tests
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
strategy: strategy:
fail-fast: false fail-fast: false
@ -134,7 +134,7 @@ jobs:
DB_PORT: ${{ job.services.database.ports[3306] }} DB_PORT: ${{ job.services.database.ports[3306] }}
postgres: postgres:
name: Tests (PostgreSQL) name: Tests
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
if: "!contains(github.event.head_commit.message, 'skip ci') && !contains(github.event.head_commit.message, 'ci skip')" if: "!contains(github.event.head_commit.message, 'skip ci') && !contains(github.event.head_commit.message, 'ci skip')"
strategy: strategy:

View file

@ -2,7 +2,6 @@
namespace Pterodactyl\Console\Commands\Environment; namespace Pterodactyl\Console\Commands\Environment;
use DateTimeZone;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Contracts\Console\Kernel; use Illuminate\Contracts\Console\Kernel;
use Pterodactyl\Traits\Commands\EnvironmentWriterTrait; use Pterodactyl\Traits\Commands\EnvironmentWriterTrait;
@ -88,7 +87,7 @@ class AppSettingsCommand extends Command
$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->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( $this->variables['APP_TIMEZONE'] = $this->option('timezone') ?? $this->anticipate(
'Application Timezone', 'Application Timezone',
DateTimeZone::listIdentifiers(), \DateTimeZone::listIdentifiers(),
config('app.timezone') config('app.timezone')
); );

View file

@ -2,7 +2,6 @@
namespace Pterodactyl\Console\Commands\Environment; namespace Pterodactyl\Console\Commands\Environment;
use PDOException;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Contracts\Console\Kernel; use Illuminate\Contracts\Console\Kernel;
use Illuminate\Database\DatabaseManager; use Illuminate\Database\DatabaseManager;
@ -72,7 +71,7 @@ class DatabaseSettingsCommand extends Command
try { try {
$this->testMySQLConnection(); $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(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.'); $this->output->error('Your connection credentials have NOT been saved. You will need to provide valid connection information before proceeding.');

View file

@ -2,7 +2,6 @@
namespace Pterodactyl\Console\Commands\Maintenance; namespace Pterodactyl\Console\Commands\Maintenance;
use SplFileInfo;
use Carbon\Carbon; use Carbon\Carbon;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Contracts\Filesystem\Filesystem; use Illuminate\Contracts\Filesystem\Filesystem;
@ -35,7 +34,7 @@ class CleanServiceBackupFilesCommand extends Command
{ {
$files = $this->disk->files('services/.bak'); $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())); $lastModified = Carbon::createFromTimestamp($this->disk->lastModified($file->getPath()));
if ($lastModified->diffInMinutes(Carbon::now()) > self::BACKUP_THRESHOLD_MINUTES) { if ($lastModified->diffInMinutes(Carbon::now()) > self::BACKUP_THRESHOLD_MINUTES) {
$this->disk->delete($file->getPath()); $this->disk->delete($file->getPath());

View file

@ -3,7 +3,6 @@
namespace Pterodactyl\Console\Commands\Maintenance; namespace Pterodactyl\Console\Commands\Maintenance;
use Carbon\CarbonImmutable; use Carbon\CarbonImmutable;
use InvalidArgumentException;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Pterodactyl\Repositories\Eloquent\BackupRepository; use Pterodactyl\Repositories\Eloquent\BackupRepository;
@ -25,7 +24,7 @@ class PruneOrphanedBackupsCommand extends Command
{ {
$since = $this->option('prune-age') ?? config('backups.prune_age', 360); $since = $this->option('prune-age') ?? config('backups.prune_age', 360);
if (!$since || !is_digit($since)) { 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() $query = $this->backupRepository->getBuilder()

View file

@ -3,7 +3,6 @@
namespace Pterodactyl\Console\Commands\Schedule; namespace Pterodactyl\Console\Commands\Schedule;
use Exception; use Exception;
use Throwable;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Pterodactyl\Models\Schedule; use Pterodactyl\Models\Schedule;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
@ -68,7 +67,7 @@ class ProcessRunnableCommand extends Command
'schedule' => $schedule->name, 'schedule' => $schedule->name,
'hash' => $schedule->hashid, 'hash' => $schedule->hashid,
])); ]));
} catch (Throwable|Exception $exception) { } catch (\Throwable|\Exception $exception) {
Log::error($exception, ['schedule_id' => $schedule->id]); Log::error($exception, ['schedule_id' => $schedule->id]);
$this->error("An error was encountered while processing Schedule #$schedule->id: " . $exception->getMessage()); $this->error("An error was encountered while processing Schedule #$schedule->id: " . $exception->getMessage());

View file

@ -2,7 +2,6 @@
namespace Pterodactyl\Console\Commands; namespace Pterodactyl\Console\Commands;
use Closure;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Pterodactyl\Console\Kernel; use Pterodactyl\Console\Kernel;
use Symfony\Component\Process\Process; use Symfony\Component\Process\Process;
@ -177,7 +176,7 @@ class UpgradeCommand extends Command
$this->info('Panel has been successfully upgraded. Please ensure you also update any Wings instances: https://pterodactyl.io/wings/1.0/upgrading.html'); $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(); $bar->clear();
$callback(); $callback();

View file

@ -2,8 +2,6 @@
namespace Pterodactyl\Exceptions; namespace Pterodactyl\Exceptions;
use Exception; class AccountNotFoundException extends \Exception
class AccountNotFoundException extends Exception
{ {
} }

View file

@ -2,8 +2,6 @@
namespace Pterodactyl\Exceptions; namespace Pterodactyl\Exceptions;
use Exception; class AutoDeploymentException extends \Exception
class AutoDeploymentException extends Exception
{ {
} }

View file

@ -3,7 +3,6 @@
namespace Pterodactyl\Exceptions; namespace Pterodactyl\Exceptions;
use Exception; use Exception;
use Throwable;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
use Illuminate\Http\Response; use Illuminate\Http\Response;
@ -23,7 +22,7 @@ class DisplayException extends PterodactylException implements HttpExceptionInte
/** /**
* DisplayException constructor. * 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); parent::__construct($message, $code, $previous);
} }
@ -67,7 +66,7 @@ class DisplayException extends PterodactylException implements HttpExceptionInte
*/ */
public function report() public function report()
{ {
if (!$this->getPrevious() instanceof Exception || !Handler::isReportable($this->getPrevious())) { if (!$this->getPrevious() instanceof \Exception || !Handler::isReportable($this->getPrevious())) {
return null; return null;
} }

View file

@ -3,8 +3,6 @@
namespace Pterodactyl\Exceptions; namespace Pterodactyl\Exceptions;
use Exception; use Exception;
use Throwable;
use PDOException;
use Illuminate\Support\Arr; use Illuminate\Support\Arr;
use Illuminate\Support\Str; use Illuminate\Support\Str;
use Illuminate\Http\JsonResponse; use Illuminate\Http\JsonResponse;
@ -81,7 +79,7 @@ final class Handler extends ExceptionHandler
$this->dontReport = []; $this->dontReport = [];
} }
$this->reportable(function (PDOException $ex) { $this->reportable(function (\PDOException $ex) {
$ex = $this->generateCleanedExceptionStack($ex); $ex = $this->generateCleanedExceptionStack($ex);
}); });
@ -90,7 +88,7 @@ final class Handler extends ExceptionHandler
}); });
} }
private function generateCleanedExceptionStack(Throwable $exception): string private function generateCleanedExceptionStack(\Throwable $exception): string
{ {
$cleanedStack = ''; $cleanedStack = '';
foreach ($exception->getTrace() as $index => $item) { foreach ($exception->getTrace() as $index => $item) {
@ -123,7 +121,7 @@ final class Handler extends ExceptionHandler
* *
* @throws \Throwable * @throws \Throwable
*/ */
public function render($request, Throwable $e): Response public function render($request, \Throwable $e): Response
{ {
$connections = $this->container->make(Connection::class); $connections = $this->container->make(Connection::class);
@ -189,7 +187,7 @@ final class Handler extends ExceptionHandler
/** /**
* Return the exception as a JSONAPI representation for use on API requests. * 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; $match = self::$exceptionResponseCodes[get_class($e)] ?? null;
@ -235,7 +233,7 @@ final class Handler extends ExceptionHandler
/** /**
* Return an array of exceptions that should not be reported. * 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); return (new static(Container::getInstance()))->shouldReport($exception);
} }
@ -260,11 +258,11 @@ final class Handler extends ExceptionHandler
* *
* @return \Throwable[] * @return \Throwable[]
*/ */
protected function extractPrevious(Throwable $e): array protected function extractPrevious(\Throwable $e): array
{ {
$previous = []; $previous = [];
while ($value = $e->getPrevious()) { while ($value = $e->getPrevious()) {
if (!$value instanceof Throwable) { if (!$value instanceof \Throwable) {
break; break;
} }
$previous[] = $value; $previous[] = $value;
@ -278,7 +276,7 @@ final class Handler extends ExceptionHandler
* Helper method to allow reaching into the handler to convert an exception * Helper method to allow reaching into the handler to convert an exception
* into the expected array response type. * 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); return (new self(app()))->convertExceptionToArray($e);
} }

View file

@ -2,7 +2,6 @@
namespace Pterodactyl\Exceptions\Http\Server; namespace Pterodactyl\Exceptions\Http\Server;
use Throwable;
use Pterodactyl\Models\Server; use Pterodactyl\Models\Server;
use Symfony\Component\HttpKernel\Exception\ConflictHttpException; use Symfony\Component\HttpKernel\Exception\ConflictHttpException;
@ -12,7 +11,7 @@ class ServerStateConflictException extends ConflictHttpException
* Exception thrown when the server is in an unsupported state for API access or * Exception thrown when the server is in an unsupported state for API access or
* certain operations within the codebase. * 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.'; $message = 'This server is currently in an unsupported state, please try again later.';
if ($server->isSuspended()) { if ($server->isSuspended()) {

View file

@ -2,7 +2,6 @@
namespace Pterodactyl\Exceptions\Http; namespace Pterodactyl\Exceptions\Http;
use Throwable;
use Illuminate\Http\Response; use Illuminate\Http\Response;
use Symfony\Component\HttpKernel\Exception\HttpException; use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface; use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
@ -12,7 +11,7 @@ class TwoFactorAuthRequiredException extends HttpException implements HttpExcept
/** /**
* TwoFactorAuthRequiredException constructor. * 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); parent::__construct(Response::HTTP_BAD_REQUEST, 'Two-factor authentication is required on this account in order to access this endpoint.', $previous);
} }

View file

@ -2,11 +2,10 @@
namespace Pterodactyl\Exceptions; namespace Pterodactyl\Exceptions;
use Exception;
use Spatie\Ignition\Contracts\Solution; use Spatie\Ignition\Contracts\Solution;
use Spatie\Ignition\Contracts\ProvidesSolution; use Spatie\Ignition\Contracts\ProvidesSolution;
class ManifestDoesNotExistException extends Exception implements ProvidesSolution class ManifestDoesNotExistException extends \Exception implements ProvidesSolution
{ {
public function getSolution(): Solution public function getSolution(): Solution
{ {

View file

@ -2,8 +2,6 @@
namespace Pterodactyl\Exceptions; namespace Pterodactyl\Exceptions;
use Exception; class PterodactylException extends \Exception
class PterodactylException extends Exception
{ {
} }

View file

@ -2,8 +2,6 @@
namespace Pterodactyl\Exceptions\Service\Helper; namespace Pterodactyl\Exceptions\Service\Helper;
use Exception; class CdnVersionFetchingException extends \Exception
class CdnVersionFetchingException extends Exception
{ {
} }

View file

@ -2,7 +2,6 @@
namespace Pterodactyl\Exceptions\Service; namespace Pterodactyl\Exceptions\Service;
use Throwable;
use Pterodactyl\Exceptions\DisplayException; use Pterodactyl\Exceptions\DisplayException;
class ServiceLimitExceededException extends DisplayException class ServiceLimitExceededException extends DisplayException
@ -11,7 +10,7 @@ class ServiceLimitExceededException extends DisplayException
* Exception thrown when something goes over a defined limit, such as allocated * Exception thrown when something goes over a defined limit, such as allocated
* ports, tasks, databases, etc. * 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); parent::__construct($message, $previous, self::LEVEL_WARNING);
} }

View file

@ -7,7 +7,6 @@ use Aws\S3\S3Client;
use Illuminate\Support\Arr; use Illuminate\Support\Arr;
use Illuminate\Support\Str; use Illuminate\Support\Str;
use Webmozart\Assert\Assert; use Webmozart\Assert\Assert;
use InvalidArgumentException;
use Illuminate\Foundation\Application; use Illuminate\Foundation\Application;
use League\Flysystem\FilesystemAdapter; use League\Flysystem\FilesystemAdapter;
use Pterodactyl\Extensions\Filesystem\S3Filesystem; use Pterodactyl\Extensions\Filesystem\S3Filesystem;
@ -70,7 +69,7 @@ class BackupManager
$config = $this->getConfig($name); $config = $this->getConfig($name);
if (empty($config['adapter'])) { 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']; $adapter = $config['adapter'];
@ -88,7 +87,7 @@ class BackupManager
return $instance; return $instance;
} }
throw new InvalidArgumentException("Adapter [$adapter] is not supported."); throw new \InvalidArgumentException("Adapter [$adapter] is not supported.");
} }
/** /**
@ -164,7 +163,7 @@ class BackupManager
/** /**
* Register a custom adapter creator closure. * 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; $this->customCreators[$adapter] = $callback;

View file

@ -2,7 +2,6 @@
namespace Pterodactyl\Extensions\Lcobucci\JWT\Encoding; namespace Pterodactyl\Extensions\Lcobucci\JWT\Encoding;
use DateTimeImmutable;
use Lcobucci\JWT\ClaimsFormatter; use Lcobucci\JWT\ClaimsFormatter;
use Lcobucci\JWT\Token\RegisteredClaims; use Lcobucci\JWT\Token\RegisteredClaims;
@ -21,7 +20,7 @@ final class TimestampDates implements ClaimsFormatter
continue; continue;
} }
assert($claims[$claim] instanceof DateTimeImmutable); assert($claims[$claim] instanceof \DateTimeImmutable);
$claims[$claim] = $claims[$claim]->getTimestamp(); $claims[$claim] = $claims[$claim]->getTimestamp();
} }

View file

@ -2,7 +2,6 @@
namespace Pterodactyl\Helpers; namespace Pterodactyl\Helpers;
use Exception;
use Carbon\Carbon; use Carbon\Carbon;
use Cron\CronExpression; use Cron\CronExpression;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
@ -25,7 +24,7 @@ class Utilities
$string = substr_replace($string, $character, random_int(0, $length - 1), 1); $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. // Just log the error and hope for the best at this point.
Log::error($exception); Log::error($exception);
} }

View file

@ -3,7 +3,6 @@
namespace Pterodactyl\Http\Controllers\Admin; namespace Pterodactyl\Http\Controllers\Admin;
use Exception; use Exception;
use PDOException;
use Illuminate\View\View; use Illuminate\View\View;
use Pterodactyl\Models\DatabaseHost; use Pterodactyl\Models\DatabaseHost;
use Illuminate\Http\RedirectResponse; use Illuminate\Http\RedirectResponse;
@ -67,8 +66,8 @@ class DatabaseController extends Controller
{ {
try { try {
$host = $this->creationService->handle($request->normalize()); $host = $this->creationService->handle($request->normalize());
} catch (Exception $exception) { } catch (\Exception $exception) {
if ($exception instanceof PDOException || $exception->getPrevious() instanceof PDOException) { if ($exception instanceof \PDOException || $exception->getPrevious() instanceof \PDOException) {
$this->alert->danger( $this->alert->danger(
sprintf('There was an error while trying to connect to the host or while executing a query: "%s"', $exception->getMessage()) sprintf('There was an error while trying to connect to the host or while executing a query: "%s"', $exception->getMessage())
)->flash(); )->flash();
@ -96,10 +95,10 @@ class DatabaseController extends Controller
try { try {
$this->updateService->handle($host->id, $request->normalize()); $this->updateService->handle($host->id, $request->normalize());
$this->alert->success('Database host was updated successfully.')->flash(); $this->alert->success('Database host was updated successfully.')->flash();
} catch (Exception $exception) { } catch (\Exception $exception) {
// Catch any SQL related exceptions and display them back to the user, otherwise just // Catch any SQL related exceptions and display them back to the user, otherwise just
// throw the exception like normal and move on with it. // throw the exception like normal and move on with it.
if ($exception instanceof PDOException || $exception->getPrevious() instanceof PDOException) { if ($exception instanceof \PDOException || $exception->getPrevious() instanceof \PDOException) {
$this->alert->danger( $this->alert->danger(
sprintf('There was an error while trying to connect to the host or while executing a query: "%s"', $exception->getMessage()) sprintf('There was an error while trying to connect to the host or while executing a query: "%s"', $exception->getMessage())
)->flash(); )->flash();

View file

@ -2,7 +2,6 @@
namespace Pterodactyl\Http\Controllers\Admin\Nests; namespace Pterodactyl\Http\Controllers\Admin\Nests;
use JavaScript;
use Illuminate\View\View; use Illuminate\View\View;
use Pterodactyl\Models\Egg; use Pterodactyl\Models\Egg;
use Illuminate\Http\RedirectResponse; use Illuminate\Http\RedirectResponse;
@ -40,7 +39,7 @@ class EggController extends Controller
public function create(): View public function create(): View
{ {
$nests = $this->nestRepository->getWithEggs(); $nests = $this->nestRepository->getWithEggs();
JavaScript::put(['nests' => $nests->keyBy('id')]); \JavaScript::put(['nests' => $nests->keyBy('id')]);
return view('admin.eggs.new', ['nests' => $nests]); return view('admin.eggs.new', ['nests' => $nests]);
} }

View file

@ -2,7 +2,6 @@
namespace Pterodactyl\Http\Controllers\Admin\Servers; namespace Pterodactyl\Http\Controllers\Admin\Servers;
use JavaScript;
use Illuminate\View\View; use Illuminate\View\View;
use Pterodactyl\Models\Nest; use Pterodactyl\Models\Nest;
use Pterodactyl\Models\Node; use Pterodactyl\Models\Node;
@ -44,7 +43,7 @@ class CreateServerController extends Controller
$nests = $this->nestRepository->getWithEggs(); $nests = $this->nestRepository->getWithEggs();
JavaScript::put([ \JavaScript::put([
'nodeData' => $this->nodeRepository->getNodesForServerCreation(), 'nodeData' => $this->nodeRepository->getNodesForServerCreation(),
'nests' => $nests->map(function (Nest $item) { 'nests' => $nests->map(function (Nest $item) {
return array_merge($item->toArray(), [ return array_merge($item->toArray(), [

View file

@ -2,7 +2,6 @@
namespace Pterodactyl\Http\Controllers\Admin\Servers; namespace Pterodactyl\Http\Controllers\Admin\Servers;
use JavaScript;
use Illuminate\View\View; use Illuminate\View\View;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Pterodactyl\Models\Nest; use Pterodactyl\Models\Nest;
@ -130,7 +129,7 @@ class ServerViewController extends Controller
$canTransfer = true; $canTransfer = true;
} }
JavaScript::put([ \JavaScript::put([
'nodeData' => $this->nodeRepository->getNodesForServerCreation(), 'nodeData' => $this->nodeRepository->getNodesForServerCreation(),
]); ]);

View file

@ -2,7 +2,6 @@
namespace Pterodactyl\Http\Controllers\Admin\Settings; namespace Pterodactyl\Http\Controllers\Admin\Settings;
use Exception;
use Illuminate\View\View; use Illuminate\View\View;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Http\Response; use Illuminate\Http\Response;
@ -80,7 +79,7 @@ class MailController extends Controller
try { try {
Notification::route('mail', $request->user()->email) Notification::route('mail', $request->user()->email)
->notify(new MailTested($request->user())); ->notify(new MailTested($request->user()));
} catch (Exception $exception) { } catch (\Exception $exception) {
return response($exception->getMessage(), 500); return response($exception->getMessage(), 500);
} }

View file

@ -2,7 +2,6 @@
namespace Pterodactyl\Http\Controllers\Api\Client\Servers; namespace Pterodactyl\Http\Controllers\Api\Client\Servers;
use Exception;
use Carbon\Carbon; use Carbon\Carbon;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Http\Response; use Illuminate\Http\Response;
@ -178,7 +177,7 @@ class ScheduleController extends ClientApiController
$request->input('month'), $request->input('month'),
$request->input('day_of_week') $request->input('day_of_week')
); );
} catch (Exception $exception) { } 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.');
} }
} }

View file

@ -2,9 +2,7 @@
namespace Pterodactyl\Http\Controllers\Api\Remote; namespace Pterodactyl\Http\Controllers\Api\Remote;
use Exception;
use Carbon\Carbon; use Carbon\Carbon;
use DateTimeInterface;
use Illuminate\Support\Str; use Illuminate\Support\Str;
use Pterodactyl\Models\User; use Pterodactyl\Models\User;
use Webmozart\Assert\Assert; use Webmozart\Assert\Assert;
@ -37,11 +35,11 @@ class ActivityProcessingController extends Controller
try { try {
$when = Carbon::createFromFormat( $when = Carbon::createFromFormat(
DateTimeInterface::RFC3339, \DateTimeInterface::RFC3339,
preg_replace('/(\.\d+)Z$/', 'Z', $datum['timestamp']), preg_replace('/(\.\d+)Z$/', 'Z', $datum['timestamp']),
'UTC' 'UTC'
); );
} catch (Exception $exception) { } catch (\Exception $exception) {
Log::warning($exception, ['timestamp' => $datum['timestamp']]); Log::warning($exception, ['timestamp' => $datum['timestamp']]);
// If we cannot parse the value for some reason don't blow up this request, just go ahead // If we cannot parse the value for some reason don't blow up this request, just go ahead

View file

@ -2,7 +2,6 @@
namespace Pterodactyl\Http\Middleware\Activity; namespace Pterodactyl\Http\Middleware\Activity;
use Closure;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Pterodactyl\Facades\LogTarget; use Pterodactyl\Facades\LogTarget;
@ -12,7 +11,7 @@ class AccountSubject
* Sets the actor and default subject for all requests passing through this * Sets the actor and default subject for all requests passing through this
* middleware to be the currently logged in user. * middleware to be the currently logged in user.
*/ */
public function handle(Request $request, Closure $next) public function handle(Request $request, \Closure $next)
{ {
LogTarget::setActor($request->user()); LogTarget::setActor($request->user());
LogTarget::setSubject($request->user()); LogTarget::setSubject($request->user());

View file

@ -2,7 +2,6 @@
namespace Pterodactyl\Http\Middleware\Activity; namespace Pterodactyl\Http\Middleware\Activity;
use Closure;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Pterodactyl\Models\Server; use Pterodactyl\Models\Server;
use Pterodactyl\Facades\LogTarget; use Pterodactyl\Facades\LogTarget;
@ -17,7 +16,7 @@ class ServerSubject
* If no server is found this is a no-op as the activity log service can always * If no server is found this is a no-op as the activity log service can always
* set the user based on the authmanager response. * set the user based on the authmanager response.
*/ */
public function handle(Request $request, Closure $next) public function handle(Request $request, \Closure $next)
{ {
$server = $request->route()->parameter('server'); $server = $request->route()->parameter('server');
if ($server instanceof Server) { if ($server instanceof Server) {

View file

@ -2,7 +2,6 @@
namespace Pterodactyl\Http\Middleware\Activity; namespace Pterodactyl\Http\Middleware\Activity;
use Closure;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Pterodactyl\Models\ApiKey; use Pterodactyl\Models\ApiKey;
use Pterodactyl\Facades\LogTarget; use Pterodactyl\Facades\LogTarget;
@ -15,7 +14,7 @@ class TrackAPIKey
* request singleton so that all tracked activity log events are properly associated * request singleton so that all tracked activity log events are properly associated
* with the given API key. * with the given API key.
*/ */
public function handle(Request $request, Closure $next): mixed public function handle(Request $request, \Closure $next): mixed
{ {
if ($request->user()) { if ($request->user()) {
$token = $request->user()->currentAccessToken(); $token = $request->user()->currentAccessToken();

View file

@ -2,7 +2,6 @@
namespace Pterodactyl\Http\Middleware\Admin\Servers; namespace Pterodactyl\Http\Middleware\Admin\Servers;
use Closure;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Http\Response; use Illuminate\Http\Response;
use Pterodactyl\Models\Server; use Pterodactyl\Models\Server;
@ -14,7 +13,7 @@ class ServerInstalled
/** /**
* Checks that the server is installed before allowing access through the route. * Checks that the server is installed before allowing access through the route.
*/ */
public function handle(Request $request, Closure $next): mixed public function handle(Request $request, \Closure $next): mixed
{ {
/** @var \Pterodactyl\Models\Server|null $server */ /** @var \Pterodactyl\Models\Server|null $server */
$server = $request->route()->parameter('server'); $server = $request->route()->parameter('server');

View file

@ -2,7 +2,6 @@
namespace Pterodactyl\Http\Middleware; namespace Pterodactyl\Http\Middleware;
use Closure;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
@ -13,7 +12,7 @@ class AdminAuthenticate
* *
* @throws \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException * @throws \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException
*/ */
public function handle(Request $request, Closure $next): mixed public function handle(Request $request, \Closure $next): mixed
{ {
if (!$request->user() || !$request->user()->root_admin) { if (!$request->user() || !$request->user()->root_admin) {
throw new AccessDeniedHttpException(); throw new AccessDeniedHttpException();

View file

@ -2,7 +2,6 @@
namespace Pterodactyl\Http\Middleware\Api\Application; namespace Pterodactyl\Http\Middleware\Api\Application;
use Closure;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
@ -12,7 +11,7 @@ class AuthenticateApplicationUser
* Authenticate that the currently authenticated user is an administrator * Authenticate that the currently authenticated user is an administrator
* and should be allowed to proceed through the application API. * and should be allowed to proceed through the application API.
*/ */
public function handle(Request $request, Closure $next): mixed public function handle(Request $request, \Closure $next): mixed
{ {
/** @var \Pterodactyl\Models\User|null $user */ /** @var \Pterodactyl\Models\User|null $user */
$user = $request->user(); $user = $request->user();

View file

@ -2,7 +2,6 @@
namespace Pterodactyl\Http\Middleware\Api; namespace Pterodactyl\Http\Middleware\Api;
use Closure;
use IPTools\IP; use IPTools\IP;
use IPTools\Range; use IPTools\Range;
use Illuminate\Http\Request; use Illuminate\Http\Request;
@ -18,7 +17,7 @@ class AuthenticateIPAccess
* @throws \Exception * @throws \Exception
* @throws \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException * @throws \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException
*/ */
public function handle(Request $request, Closure $next): mixed public function handle(Request $request, \Closure $next): mixed
{ {
/** @var \Laravel\Sanctum\TransientToken|\Pterodactyl\Models\ApiKey $token */ /** @var \Laravel\Sanctum\TransientToken|\Pterodactyl\Models\ApiKey $token */
$token = $request->user()->currentAccessToken(); $token = $request->user()->currentAccessToken();

View file

@ -2,7 +2,6 @@
namespace Pterodactyl\Http\Middleware\Api\Client\Server; namespace Pterodactyl\Http\Middleware\Api\Client\Server;
use Closure;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Pterodactyl\Models\Server; use Pterodactyl\Models\Server;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@ -27,7 +26,7 @@ class AuthenticateServerAccess
/** /**
* Authenticate that this server exists and is not suspended or marked as installing. * Authenticate that this server exists and is not suspended or marked as installing.
*/ */
public function handle(Request $request, Closure $next): mixed public function handle(Request $request, \Closure $next): mixed
{ {
/** @var \Pterodactyl\Models\User $user */ /** @var \Pterodactyl\Models\User $user */
$user = $request->user(); $user = $request->user();

View file

@ -2,11 +2,9 @@
namespace Pterodactyl\Http\Middleware\Api\Client\Server; namespace Pterodactyl\Http\Middleware\Api\Client\Server;
use Closure;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Pterodactyl\Models\Task; use Pterodactyl\Models\Task;
use Pterodactyl\Models\User; use Pterodactyl\Models\User;
use InvalidArgumentException;
use Pterodactyl\Models\Backup; use Pterodactyl\Models\Backup;
use Pterodactyl\Models\Server; use Pterodactyl\Models\Server;
use Pterodactyl\Models\Subuser; use Pterodactyl\Models\Subuser;
@ -26,11 +24,11 @@ class ResourceBelongsToServer
* server that is expected, and that we're not accessing a resource completely * server that is expected, and that we're not accessing a resource completely
* unrelated to the server provided in the request. * unrelated to the server provided in the request.
*/ */
public function handle(Request $request, Closure $next): mixed public function handle(Request $request, \Closure $next): mixed
{ {
$params = $request->route()->parameters(); $params = $request->route()->parameters();
if (!$params['server'] instanceof Server) { if (!$params['server'] instanceof Server) {
throw new InvalidArgumentException('This middleware cannot be used in a context that is missing a server in the parameters.'); throw new \InvalidArgumentException('This middleware cannot be used in a context that is missing a server in the parameters.');
} }
/** @var Server $server */ /** @var Server $server */
@ -81,7 +79,7 @@ class ResourceBelongsToServer
default: default:
// Don't return a 404 here since we want to make sure no one relies // 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. // on this middleware in a context in which it will not work. Fail safe.
throw new InvalidArgumentException('There is no handler configured for a resource of this type: ' . get_class($model)); throw new \InvalidArgumentException('There is no handler configured for a resource of this type: ' . get_class($model));
} }
} }

View file

@ -2,7 +2,6 @@
namespace Pterodactyl\Http\Middleware\Api\Client; namespace Pterodactyl\Http\Middleware\Api\Client;
use Closure;
use Pterodactyl\Models\Server; use Pterodactyl\Models\Server;
use Illuminate\Routing\Middleware\SubstituteBindings; use Illuminate\Routing\Middleware\SubstituteBindings;
@ -11,7 +10,7 @@ class SubstituteClientBindings extends SubstituteBindings
/** /**
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
*/ */
public function handle($request, Closure $next): mixed public function handle($request, \Closure $next): mixed
{ {
// Override default behavior of the model binding to use a specific table // Override default behavior of the model binding to use a specific table
// column rather than the default 'id'. // column rather than the default 'id'.

View file

@ -2,7 +2,6 @@
namespace Pterodactyl\Http\Middleware\Api\Daemon; namespace Pterodactyl\Http\Middleware\Api\Daemon;
use Closure;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Contracts\Encryption\Encrypter; use Illuminate\Contracts\Encryption\Encrypter;
use Pterodactyl\Repositories\Eloquent\NodeRepository; use Pterodactyl\Repositories\Eloquent\NodeRepository;
@ -32,7 +31,7 @@ class DaemonAuthenticate
* *
* @throws \Symfony\Component\HttpKernel\Exception\HttpException * @throws \Symfony\Component\HttpKernel\Exception\HttpException
*/ */
public function handle(Request $request, Closure $next): mixed public function handle(Request $request, \Closure $next): mixed
{ {
if (in_array($request->route()->getName(), $this->except)) { if (in_array($request->route()->getName(), $this->except)) {
return $next($request); return $next($request);

View file

@ -2,8 +2,6 @@
namespace Pterodactyl\Http\Middleware\Api; namespace Pterodactyl\Http\Middleware\Api;
use Closure;
use JsonException;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
@ -14,12 +12,12 @@ class IsValidJson
* parsing the data. This avoids confusing validation errors where every field is flagged and * 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. * it is not immediately clear that there is an issue with the JSON being passed.
*/ */
public function handle(Request $request, Closure $next): mixed public function handle(Request $request, \Closure $next): mixed
{ {
if ($request->isJson() && !empty($request->getContent())) { if ($request->isJson() && !empty($request->getContent())) {
try { try {
json_decode($request->getContent(), true, 512, JSON_THROW_ON_ERROR); json_decode($request->getContent(), true, 512, JSON_THROW_ON_ERROR);
} catch (JsonException $exception) { } catch (\JsonException $exception) {
throw new BadRequestHttpException('The JSON data passed in the request appears to be malformed: ' . $exception->getMessage()); throw new BadRequestHttpException('The JSON data passed in the request appears to be malformed: ' . $exception->getMessage());
} }
} }

View file

@ -2,7 +2,6 @@
namespace Pterodactyl\Http\Middleware; namespace Pterodactyl\Http\Middleware;
use Closure;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Foundation\Application; use Illuminate\Foundation\Application;
@ -18,7 +17,7 @@ class LanguageMiddleware
/** /**
* Handle an incoming request and set the user's preferred language. * Handle an incoming request and set the user's preferred language.
*/ */
public function handle(Request $request, Closure $next): mixed public function handle(Request $request, \Closure $next): mixed
{ {
$this->app->setLocale($request->user()->language ?? config('app.locale', 'en')); $this->app->setLocale($request->user()->language ?? config('app.locale', 'en'));

View file

@ -2,7 +2,6 @@
namespace Pterodactyl\Http\Middleware; namespace Pterodactyl\Http\Middleware;
use Closure;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Contracts\Routing\ResponseFactory; use Illuminate\Contracts\Routing\ResponseFactory;
@ -18,7 +17,7 @@ class MaintenanceMiddleware
/** /**
* Handle an incoming request. * Handle an incoming request.
*/ */
public function handle(Request $request, Closure $next): mixed public function handle(Request $request, \Closure $next): mixed
{ {
/** @var \Pterodactyl\Models\Server $server */ /** @var \Pterodactyl\Models\Server $server */
$server = $request->attributes->get('server'); $server = $request->attributes->get('server');

View file

@ -2,7 +2,6 @@
namespace Pterodactyl\Http\Middleware; namespace Pterodactyl\Http\Middleware;
use Closure;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Auth\AuthManager; use Illuminate\Auth\AuthManager;
@ -18,7 +17,7 @@ class RedirectIfAuthenticated
/** /**
* Handle an incoming request. * Handle an incoming request.
*/ */
public function handle(Request $request, Closure $next, string $guard = null): mixed public function handle(Request $request, \Closure $next, string $guard = null): mixed
{ {
if ($this->authManager->guard($guard)->check()) { if ($this->authManager->guard($guard)->check()) {
return redirect()->route('index'); return redirect()->route('index');

View file

@ -2,7 +2,6 @@
namespace Pterodactyl\Http\Middleware; namespace Pterodactyl\Http\Middleware;
use Closure;
use Illuminate\Support\Str; use Illuminate\Support\Str;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Pterodactyl\Models\User; use Pterodactyl\Models\User;
@ -35,7 +34,7 @@ class RequireTwoFactorAuthentication
* *
* @throws \Pterodactyl\Exceptions\Http\TwoFactorAuthRequiredException * @throws \Pterodactyl\Exceptions\Http\TwoFactorAuthRequiredException
*/ */
public function handle(Request $request, Closure $next): mixed public function handle(Request $request, \Closure $next): mixed
{ {
/** @var User $user */ /** @var User $user */
$user = $request->user(); $user = $request->user();

View file

@ -2,8 +2,6 @@
namespace Pterodactyl\Http\Middleware; namespace Pterodactyl\Http\Middleware;
use Closure;
use stdClass;
use GuzzleHttp\Client; use GuzzleHttp\Client;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Http\Response; use Illuminate\Http\Response;
@ -24,7 +22,7 @@ class VerifyReCaptcha
/** /**
* Handle an incoming request. * Handle an incoming request.
*/ */
public function handle(Request $request, Closure $next): mixed public function handle(Request $request, \Closure $next): mixed
{ {
if (!$this->config->get('recaptcha.enabled')) { if (!$this->config->get('recaptcha.enabled')) {
return $next($request); return $next($request);
@ -61,7 +59,7 @@ class VerifyReCaptcha
/** /**
* Determine if the response from the recaptcha servers was valid. * Determine if the response from the recaptcha servers was valid.
*/ */
private function isResponseVerified(stdClass $result, Request $request): 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; return false;

View file

@ -2,7 +2,6 @@
namespace Pterodactyl\Http\Requests\Api\Client\Account; namespace Pterodactyl\Http\Requests\Api\Client\Account;
use Exception;
use phpseclib3\Crypt\DSA; use phpseclib3\Crypt\DSA;
use phpseclib3\Crypt\RSA; use phpseclib3\Crypt\RSA;
use Pterodactyl\Models\UserSSHKey; use Pterodactyl\Models\UserSSHKey;
@ -71,7 +70,7 @@ class StoreSSHKeyRequest extends ClientApiRequest
public function getKeyFingerprint(): string public function getKeyFingerprint(): string
{ {
if (!$this->key) { if (!$this->key) {
throw new Exception('The public key was not properly loaded for this request.'); throw new \Exception('The public key was not properly loaded for this request.');
} }
return $this->key->getFingerprint('sha256'); return $this->key->getFingerprint('sha256');

View file

@ -6,7 +6,6 @@ use Exception;
use Pterodactyl\Jobs\Job; use Pterodactyl\Jobs\Job;
use Carbon\CarbonImmutable; use Carbon\CarbonImmutable;
use Pterodactyl\Models\Task; use Pterodactyl\Models\Task;
use InvalidArgumentException;
use Illuminate\Queue\SerializesModels; use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Contracts\Queue\ShouldQueue;
@ -72,9 +71,9 @@ class RunTaskJob extends Job implements ShouldQueue
$backupService->setIgnoredFiles(explode(PHP_EOL, $this->task->payload))->handle($server, null, true); $backupService->setIgnoredFiles(explode(PHP_EOL, $this->task->payload))->handle($server, null, true);
break; break;
default: default:
throw new InvalidArgumentException('Invalid task action provided: ' . $this->task->action); throw new \InvalidArgumentException('Invalid task action provided: ' . $this->task->action);
} }
} catch (Exception $exception) { } catch (\Exception $exception) {
// If this isn't a DaemonConnectionException on a task that allows for failures // If this isn't a DaemonConnectionException on a task that allows for failures
// throw the exception back up the chain so that the task is stopped. // throw the exception back up the chain so that the task is stopped.
if (!($this->task->continue_on_failure && $exception instanceof DaemonConnectionException)) { if (!($this->task->continue_on_failure && $exception instanceof DaemonConnectionException)) {
@ -89,7 +88,7 @@ class RunTaskJob extends Job implements ShouldQueue
/** /**
* Handle a failure while sending the action to the daemon or otherwise processing the job. * Handle a failure while sending the action to the daemon or otherwise processing the job.
*/ */
public function failed(Exception $exception = null) public function failed(\Exception $exception = null)
{ {
$this->markTaskNotQueued(); $this->markTaskNotQueued();
$this->markScheduleComplete(); $this->markScheduleComplete();

View file

@ -3,7 +3,6 @@
namespace Pterodactyl\Models; namespace Pterodactyl\Models;
use Carbon\Carbon; use Carbon\Carbon;
use LogicException;
use Illuminate\Support\Facades\Event; use Illuminate\Support\Facades\Event;
use Pterodactyl\Events\ActivityLogged; use Pterodactyl\Events\ActivityLogged;
use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Builder;
@ -124,7 +123,7 @@ class ActivityLog extends Model
public function prunable() public function prunable()
{ {
if (is_null(config('activity.prune_days'))) { if (is_null(config('activity.prune_days'))) {
throw new LogicException('Cannot prune activity logs: no "prune_days" configuration value is set.'); throw new \LogicException('Cannot prune activity logs: no "prune_days" configuration value is set.');
} }
return static::where('timestamp', '<=', Carbon::now()->subDays(config('activity.prune_days'))); return static::where('timestamp', '<=', Carbon::now()->subDays(config('activity.prune_days')));

View file

@ -2,7 +2,6 @@
namespace Pterodactyl\Models\Filters; namespace Pterodactyl\Models\Filters;
use BadMethodCallException;
use Spatie\QueryBuilder\Filters\Filter; use Spatie\QueryBuilder\Filters\Filter;
use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Builder;
@ -17,7 +16,7 @@ class AdminServerFilter implements Filter
public function __invoke(Builder $query, $value, string $property) public function __invoke(Builder $query, $value, string $property)
{ {
if ($query->getQuery()->from !== 'servers') { 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 $query
->select('servers.*') ->select('servers.*')

View file

@ -2,7 +2,6 @@
namespace Pterodactyl\Models\Filters; namespace Pterodactyl\Models\Filters;
use BadMethodCallException;
use Illuminate\Support\Str; use Illuminate\Support\Str;
use Spatie\QueryBuilder\Filters\Filter; use Spatie\QueryBuilder\Filters\Filter;
use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Builder;
@ -25,7 +24,7 @@ class MultiFieldServerFilter implements Filter
public function __invoke(Builder $query, $value, string $property) public function __invoke(Builder $query, $value, string $property)
{ {
if ($query->getQuery()->from !== 'servers') { 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)) { if (preg_match(self::IPV4_REGEX, $value) || preg_match('/^:\d{1,5}$/', $value)) {

View file

@ -2,8 +2,6 @@
namespace Pterodactyl\Repositories\Eloquent; namespace Pterodactyl\Repositories\Eloquent;
use PDO;
use RuntimeException;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Webmozart\Assert\Assert; use Webmozart\Assert\Assert;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
@ -276,7 +274,7 @@ abstract class EloquentRepository extends Repository implements RepositoryInterf
return sprintf('(%s)', $grammar->parameterize($record)); return sprintf('(%s)', $grammar->parameterize($record));
})->implode(', '); })->implode(', ');
$driver = DB::getPdo()->getAttribute(PDO::ATTR_DRIVER_NAME); $driver = DB::getPdo()->getAttribute(\PDO::ATTR_DRIVER_NAME);
switch ($driver) { switch ($driver) {
case 'mysql': case 'mysql':
$statement = "insert ignore into $table ($columns) values $parameters"; $statement = "insert ignore into $table ($columns) values $parameters";
@ -285,7 +283,7 @@ abstract class EloquentRepository extends Repository implements RepositoryInterf
$statement = "insert into $table ($columns) values $parameters on conflict do nothing"; $statement = "insert into $table ($columns) values $parameters on conflict do nothing";
break; break;
default: default:
throw new RuntimeException("Unsupported database driver \"$driver\" for insert ignore."); throw new \RuntimeException("Unsupported database driver \"$driver\" for insert ignore.");
} }
return $this->getBuilder()->getConnection()->statement($statement, $bindings); return $this->getBuilder()->getConnection()->statement($statement, $bindings);

View file

@ -2,7 +2,6 @@
namespace Pterodactyl\Repositories\Eloquent; namespace Pterodactyl\Repositories\Eloquent;
use Exception;
use Pterodactyl\Contracts\Repository\PermissionRepositoryInterface; use Pterodactyl\Contracts\Repository\PermissionRepositoryInterface;
class PermissionRepository extends EloquentRepository implements PermissionRepositoryInterface class PermissionRepository extends EloquentRepository implements PermissionRepositoryInterface
@ -14,6 +13,6 @@ class PermissionRepository extends EloquentRepository implements PermissionRepos
*/ */
public function model(): string public function model(): string
{ {
throw new Exception('This functionality is not implemented.'); throw new \Exception('This functionality is not implemented.');
} }
} }

View file

@ -2,7 +2,6 @@
namespace Pterodactyl\Repositories; namespace Pterodactyl\Repositories;
use InvalidArgumentException;
use Illuminate\Foundation\Application; use Illuminate\Foundation\Application;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Pterodactyl\Contracts\Repository\RepositoryInterface; use Pterodactyl\Contracts\Repository\RepositoryInterface;
@ -97,7 +96,7 @@ abstract class Repository implements RepositoryInterface
case 2: case 2:
return $this->model = call_user_func([$this->app->make($model[0]), $model[1]]); return $this->model = call_user_func([$this->app->make($model[0]), $model[1]]);
default: default:
throw new InvalidArgumentException('Model must be a FQDN or an array with a count of two.'); throw new \InvalidArgumentException('Model must be a FQDN or an array with a count of two.');
} }
} }
} }

View file

@ -2,7 +2,6 @@
namespace Pterodactyl\Services\Acl\Api; namespace Pterodactyl\Services\Acl\Api;
use ReflectionClass;
use Pterodactyl\Models\ApiKey; use Pterodactyl\Models\ApiKey;
class AdminAcl class AdminAcl
@ -63,7 +62,7 @@ class AdminAcl
*/ */
public static function getResourceList(): array public static function getResourceList(): array
{ {
$reflect = new ReflectionClass(__CLASS__); $reflect = new \ReflectionClass(__CLASS__);
return collect($reflect->getConstants())->filter(function ($value, $key) { return collect($reflect->getConstants())->filter(function ($value, $key) {
return substr($key, 0, 9) === 'RESOURCE_'; return substr($key, 0, 9) === 'RESOURCE_';

View file

@ -2,7 +2,6 @@
namespace Pterodactyl\Services\Allocations; namespace Pterodactyl\Services\Allocations;
use Exception;
use IPTools\Network; use IPTools\Network;
use Pterodactyl\Models\Node; use Pterodactyl\Models\Node;
use Illuminate\Database\ConnectionInterface; use Illuminate\Database\ConnectionInterface;
@ -56,7 +55,7 @@ class AssignmentService
// IP to use, not multiple. // IP to use, not multiple.
$underlying = gethostbyname($allocationIp); $underlying = gethostbyname($allocationIp);
$parsed = Network::parse($underlying); $parsed = Network::parse($underlying);
} catch (Exception $exception) { } catch (\Exception $exception) {
throw new DisplayException("Could not parse provided allocation IP address for $allocationIp ($underlying): {$exception->getMessage()}", $exception); throw new DisplayException("Could not parse provided allocation IP address for $allocationIp ($underlying): {$exception->getMessage()}", $exception);
} }

View file

@ -3,7 +3,6 @@
namespace Pterodactyl\Services\Databases; namespace Pterodactyl\Services\Databases;
use Exception; use Exception;
use InvalidArgumentException;
use Pterodactyl\Models\Server; use Pterodactyl\Models\Server;
use Pterodactyl\Models\Database; use Pterodactyl\Models\Database;
use Pterodactyl\Helpers\Utilities; use Pterodactyl\Helpers\Utilities;
@ -86,7 +85,7 @@ class DatabaseManagementService
// Protect against developer mistakes... // Protect against developer mistakes...
if (empty($data['database']) || !preg_match(self::MATCH_NAME_REGEX, $data['database'])) { 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}_".'); throw new \InvalidArgumentException('The database name passed to DatabaseManagementService::handle MUST be prefixed with "s{server_id}_".');
} }
$data = array_merge($data, [ $data = array_merge($data, [
@ -117,7 +116,7 @@ class DatabaseManagementService
return $database; return $database;
}); });
} catch (Exception $exception) { } catch (\Exception $exception) {
try { try {
/** @var ?Database $database */ /** @var ?Database $database */
if ($database instanceof Database) { if ($database instanceof Database) {
@ -125,7 +124,7 @@ class DatabaseManagementService
$this->repository->dropUser($database->username, $database->remote); $this->repository->dropUser($database->username, $database->remote);
$this->repository->flush(); $this->repository->flush();
} }
} catch (Exception $deletionException) { } catch (\Exception $deletionException) {
// Do nothing here. We've already encountered an issue before this point so no // Do nothing here. We've already encountered an issue before this point so no
// reason to prioritize this error over the initial one. // reason to prioritize this error over the initial one.
} }

View file

@ -2,7 +2,6 @@
namespace Pterodactyl\Services\Nodes; namespace Pterodactyl\Services\Nodes;
use DateTimeImmutable;
use Carbon\CarbonImmutable; use Carbon\CarbonImmutable;
use Illuminate\Support\Str; use Illuminate\Support\Str;
use Pterodactyl\Models\Node; use Pterodactyl\Models\Node;
@ -19,7 +18,7 @@ class NodeJWTService
private ?User $user = null; private ?User $user = null;
private ?DateTimeImmutable $expiresAt; private ?\DateTimeImmutable $expiresAt;
private ?string $subject = null; private ?string $subject = null;
@ -44,7 +43,7 @@ class NodeJWTService
return $this; return $this;
} }
public function setExpiresAt(DateTimeImmutable $date): self public function setExpiresAt(\DateTimeImmutable $date): self
{ {
$this->expiresAt = $date; $this->expiresAt = $date;

View file

@ -56,7 +56,7 @@ class ProcessScheduleService
return; return;
} }
} catch (Exception $exception) { } catch (\Exception $exception) {
if (!$exception instanceof DaemonConnectionException) { if (!$exception instanceof DaemonConnectionException) {
// If we encountered some exception during this process that wasn't just an // If we encountered some exception during this process that wasn't just an
// issue connecting to Wings run the failed sequence for a job. Otherwise we // issue connecting to Wings run the failed sequence for a job. Otherwise we
@ -78,7 +78,7 @@ class ProcessScheduleService
// @see https://github.com/pterodactyl/panel/issues/2550 // @see https://github.com/pterodactyl/panel/issues/2550
try { try {
$this->dispatcher->dispatchNow($job); $this->dispatcher->dispatchNow($job);
} catch (Exception $exception) { } catch (\Exception $exception) {
$job->failed($exception); $job->failed($exception);
throw $exception; throw $exception;

View file

@ -2,7 +2,6 @@
namespace Pterodactyl\Services\Servers; namespace Pterodactyl\Services\Servers;
use Exception;
use Illuminate\Http\Response; use Illuminate\Http\Response;
use Pterodactyl\Models\Server; use Pterodactyl\Models\Server;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
@ -61,7 +60,7 @@ class ServerDeletionService
foreach ($server->databases as $database) { foreach ($server->databases as $database) {
try { try {
$this->databaseManagementService->delete($database); $this->databaseManagementService->delete($database);
} catch (Exception $exception) { } catch (\Exception $exception) {
if (!$this->force) { if (!$this->force) {
throw $exception; throw $exception;
} }

View file

@ -2,7 +2,6 @@
namespace Pterodactyl\Services\Telemetry; namespace Pterodactyl\Services\Telemetry;
use PDO;
use Exception; use Exception;
use Ramsey\Uuid\Uuid; use Ramsey\Uuid\Uuid;
use Illuminate\Support\Arr; use Illuminate\Support\Arr;
@ -121,7 +120,7 @@ class TelemetryCollectionService
], ],
'database' => [ 'database' => [
'type' => config('database.default'), 'type' => config('database.default'),
'version' => DB::getPdo()->getAttribute(PDO::ATTR_SERVER_VERSION), 'version' => DB::getPdo()->getAttribute(\PDO::ATTR_SERVER_VERSION),
], ],
], ],
], ],

View file

@ -2,8 +2,6 @@
namespace Pterodactyl\Services\Users; namespace Pterodactyl\Services\Users;
use Exception;
use RuntimeException;
use Pterodactyl\Models\User; use Pterodactyl\Models\User;
use Illuminate\Contracts\Encryption\Encrypter; use Illuminate\Contracts\Encryption\Encrypter;
use Pterodactyl\Contracts\Repository\UserRepositoryInterface; use Pterodactyl\Contracts\Repository\UserRepositoryInterface;
@ -38,8 +36,8 @@ class TwoFactorSetupService
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); $secret .= substr(self::VALID_BASE32_CHARACTERS, random_int(0, 31), 1);
} }
} catch (Exception $exception) { } catch (\Exception $exception) {
throw new RuntimeException($exception->getMessage(), 0, $exception); throw new \RuntimeException($exception->getMessage(), 0, $exception);
} }
$this->repository->withoutFreshModel()->update($user->id, [ $this->repository->withoutFreshModel()->update($user->id, [

View file

@ -2,7 +2,6 @@
namespace Pterodactyl\Traits\Controllers; namespace Pterodactyl\Traits\Controllers;
use JavaScript;
use Illuminate\Http\Request; use Illuminate\Http\Request;
trait JavascriptInjection trait JavascriptInjection
@ -24,6 +23,6 @@ trait JavascriptInjection
*/ */
public function plainInject(array $args = []): string public function plainInject(array $args = []): string
{ {
return JavaScript::put($args); return \JavaScript::put($args);
} }
} }

View file

@ -11,6 +11,6 @@ trait PlainJavascriptInjection
*/ */
public function injectJavascript($data) public function injectJavascript($data)
{ {
JavaScript::put($data); \JavaScript::put($data);
} }
} }

View file

@ -2,7 +2,6 @@
namespace Pterodactyl\Traits\Services; namespace Pterodactyl\Traits\Services;
use BadMethodCallException;
use Illuminate\Support\Str; use Illuminate\Support\Str;
use Illuminate\Contracts\Validation\Factory as ValidationFactory; use Illuminate\Contracts\Validation\Factory as ValidationFactory;
use Pterodactyl\Exceptions\Service\Egg\Variable\BadValidationRuleException; use Pterodactyl\Exceptions\Service\Egg\Variable\BadValidationRuleException;
@ -21,7 +20,7 @@ trait ValidatesValidationRules
{ {
try { try {
$this->getValidator()->make(['__TEST' => 'test'], ['__TEST' => $rules])->fails(); $this->getValidator()->make(['__TEST' => 'test'], ['__TEST' => $rules])->fails();
} catch (BadMethodCallException $exception) { } catch (\BadMethodCallException $exception) {
$matches = []; $matches = [];
if (preg_match('/Method \[(.+)\] does not exist\./', $exception->getMessage(), $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);

View file

@ -2,7 +2,6 @@
namespace Pterodactyl\Transformers\Api\Client; namespace Pterodactyl\Transformers\Api\Client;
use BadMethodCallException;
use Pterodactyl\Models\EggVariable; use Pterodactyl\Models\EggVariable;
class EggVariableTransformer extends BaseClientTransformer class EggVariableTransformer extends BaseClientTransformer
@ -18,7 +17,7 @@ class EggVariableTransformer extends BaseClientTransformer
// them into the transformer and along to the user. Just throw an exception and break the entire // 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. // pathway since you should never be exposing these types of variables to a client.
if (!$variable->user_viewable) { 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 [ return [

View file

@ -2,11 +2,9 @@
namespace Pterodactyl\Tests\Integration\Api\Client; namespace Pterodactyl\Tests\Integration\Api\Client;
use ReflectionClass;
use Pterodactyl\Models\Node; use Pterodactyl\Models\Node;
use Pterodactyl\Models\Task; use Pterodactyl\Models\Task;
use Pterodactyl\Models\User; use Pterodactyl\Models\User;
use InvalidArgumentException;
use Pterodactyl\Models\Model; use Pterodactyl\Models\Model;
use Pterodactyl\Models\Backup; use Pterodactyl\Models\Backup;
use Pterodactyl\Models\Server; use Pterodactyl\Models\Server;
@ -75,7 +73,7 @@ abstract class ClientApiIntegrationTestCase extends IntegrationTestCase
$link = "/api/client/servers/{$model->server->uuid}/backups/$model->uuid"; $link = "/api/client/servers/{$model->server->uuid}/backups/$model->uuid";
break; break;
default: default:
throw new InvalidArgumentException(sprintf('Cannot create link for Model of type %s', class_basename($model))); throw new \InvalidArgumentException(sprintf('Cannot create link for Model of type %s', class_basename($model)));
} }
return $link . ($append ? '/' . ltrim($append, '/') : ''); return $link . ($append ? '/' . ltrim($append, '/') : '');
@ -87,7 +85,7 @@ abstract class ClientApiIntegrationTestCase extends IntegrationTestCase
*/ */
protected function assertJsonTransformedWith(array $data, Model|EloquentModel $model) protected function assertJsonTransformedWith(array $data, Model|EloquentModel $model)
{ {
$reflect = new ReflectionClass($model); $reflect = new \ReflectionClass($model);
$transformer = sprintf('\\Pterodactyl\\Transformers\\Api\\Client\\%sTransformer', $reflect->getShortName()); $transformer = sprintf('\\Pterodactyl\\Transformers\\Api\\Client\\%sTransformer', $reflect->getShortName());
$transformer = new $transformer(); $transformer = new $transformer();

View file

@ -2,7 +2,6 @@
namespace Pterodactyl\Tests\Integration\Api\Client\Server\Backup; namespace Pterodactyl\Tests\Integration\Api\Client\Server\Backup;
use Mockery;
use Carbon\CarbonImmutable; use Carbon\CarbonImmutable;
use Pterodactyl\Models\Backup; use Pterodactyl\Models\Backup;
use Pterodactyl\Models\Subuser; use Pterodactyl\Models\Subuser;
@ -31,7 +30,7 @@ class BackupAuthorizationTest extends ClientApiIntegrationTestCase
$backup2 = Backup::factory()->create(['server_id' => $server2->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()]); $backup3 = Backup::factory()->create(['server_id' => $server3->id, 'completed_at' => CarbonImmutable::now()]);
$this->instance(DeleteBackupService::class, $mock = Mockery::mock(DeleteBackupService::class)); $this->instance(DeleteBackupService::class, $mock = \Mockery::mock(DeleteBackupService::class));
if ($method === 'DELETE') { if ($method === 'DELETE') {
$mock->expects('handle')->andReturnUndefined(); $mock->expects('handle')->andReturnUndefined();

View file

@ -2,7 +2,6 @@
namespace Pterodactyl\Tests\Integration\Api\Client\Server\Backup; namespace Pterodactyl\Tests\Integration\Api\Client\Server\Backup;
use Mockery;
use Mockery\MockInterface; use Mockery\MockInterface;
use Illuminate\Http\Response; use Illuminate\Http\Response;
use Pterodactyl\Models\Backup; use Pterodactyl\Models\Backup;
@ -48,7 +47,7 @@ class DeleteBackupTest extends ClientApiIntegrationTestCase
$backup = Backup::factory()->create(['server_id' => $server->id]); $backup = Backup::factory()->create(['server_id' => $server->id]);
$this->repository->expects('setServer->delete')->with( $this->repository->expects('setServer->delete')->with(
Mockery::on(function ($value) use ($backup) { \Mockery::on(function ($value) use ($backup) {
return $value instanceof Backup && $value->uuid === $backup->uuid; return $value instanceof Backup && $value->uuid === $backup->uuid;
}) })
)->andReturn(new Response()); )->andReturn(new Response());

View file

@ -2,7 +2,6 @@
namespace Pterodactyl\Tests\Integration\Api\Client\Server; namespace Pterodactyl\Tests\Integration\Api\Client\Server;
use Mockery;
use GuzzleHttp\Psr7\Request; use GuzzleHttp\Psr7\Request;
use Illuminate\Http\Response; use Illuminate\Http\Response;
use Pterodactyl\Models\Server; use Pterodactyl\Models\Server;
@ -55,7 +54,7 @@ class CommandControllerTest extends ClientApiIntegrationTestCase
$mock = $this->mock(DaemonCommandRepository::class); $mock = $this->mock(DaemonCommandRepository::class);
$mock->expects('setServer') $mock->expects('setServer')
->with(Mockery::on(fn (Server $value) => $value->is($server))) ->with(\Mockery::on(fn (Server $value) => $value->is($server)))
->andReturnSelf(); ->andReturnSelf();
$mock->expects('send')->with('say Test')->andReturn(new GuzzleResponse()); $mock->expects('send')->with('say Test')->andReturn(new GuzzleResponse());

View file

@ -2,7 +2,6 @@
namespace Pterodactyl\Tests\Integration\Api\Client\Server; namespace Pterodactyl\Tests\Integration\Api\Client\Server;
use Mockery;
use Illuminate\Http\Response; use Illuminate\Http\Response;
use Pterodactyl\Models\Permission; use Pterodactyl\Models\Permission;
use Pterodactyl\Repositories\Wings\DaemonPowerRepository; use Pterodactyl\Repositories\Wings\DaemonPowerRepository;
@ -51,13 +50,13 @@ class PowerControllerTest extends ClientApiIntegrationTestCase
*/ */
public function testActionCanBeSentToServer(string $action, string $permission) public function testActionCanBeSentToServer(string $action, string $permission)
{ {
$service = Mockery::mock(DaemonPowerRepository::class); $service = \Mockery::mock(DaemonPowerRepository::class);
$this->app->instance(DaemonPowerRepository::class, $service); $this->app->instance(DaemonPowerRepository::class, $service);
[$user, $server] = $this->generateTestAccount([$permission]); [$user, $server] = $this->generateTestAccount([$permission]);
$service->expects('setServer') $service->expects('setServer')
->with(Mockery::on(function ($value) use ($server) { ->with(\Mockery::on(function ($value) use ($server) {
return $server->uuid === $value->uuid; return $server->uuid === $value->uuid;
})) }))
->andReturnSelf() ->andReturnSelf()

View file

@ -2,7 +2,6 @@
namespace Pterodactyl\Tests\Integration\Api\Client\Server; namespace Pterodactyl\Tests\Integration\Api\Client\Server;
use Mockery;
use Pterodactyl\Models\Permission; use Pterodactyl\Models\Permission;
use Pterodactyl\Repositories\Wings\DaemonServerRepository; use Pterodactyl\Repositories\Wings\DaemonServerRepository;
use Pterodactyl\Tests\Integration\Api\Client\ClientApiIntegrationTestCase; use Pterodactyl\Tests\Integration\Api\Client\ClientApiIntegrationTestCase;
@ -14,12 +13,12 @@ class ResourceUtilizationControllerTest extends ClientApiIntegrationTestCase
*/ */
public function testServerResourceUtilizationIsReturned() public function testServerResourceUtilizationIsReturned()
{ {
$service = Mockery::mock(DaemonServerRepository::class); $service = \Mockery::mock(DaemonServerRepository::class);
$this->app->instance(DaemonServerRepository::class, $service); $this->app->instance(DaemonServerRepository::class, $service);
[$user, $server] = $this->generateTestAccount([Permission::ACTION_WEBSOCKET_CONNECT]); [$user, $server] = $this->generateTestAccount([Permission::ACTION_WEBSOCKET_CONNECT]);
$service->expects('setServer')->with(Mockery::on(function ($value) use ($server) { $service->expects('setServer')->with(\Mockery::on(function ($value) use ($server) {
return $server->uuid === $value->uuid; return $server->uuid === $value->uuid;
}))->andReturnSelf()->getMock()->expects('getDetails')->andReturns([]); }))->andReturnSelf()->getMock()->expects('getDetails')->andReturns([]);

View file

@ -2,7 +2,6 @@
namespace Pterodactyl\Tests\Integration\Api\Client\Server; namespace Pterodactyl\Tests\Integration\Api\Client\Server;
use Mockery;
use Illuminate\Http\Response; use Illuminate\Http\Response;
use Pterodactyl\Models\Server; use Pterodactyl\Models\Server;
use Pterodactyl\Models\Permission; use Pterodactyl\Models\Permission;
@ -78,11 +77,11 @@ class SettingsControllerTest extends ClientApiIntegrationTestCase
[$user, $server] = $this->generateTestAccount($permissions); [$user, $server] = $this->generateTestAccount($permissions);
$this->assertTrue($server->isInstalled()); $this->assertTrue($server->isInstalled());
$service = Mockery::mock(DaemonServerRepository::class); $service = \Mockery::mock(DaemonServerRepository::class);
$this->app->instance(DaemonServerRepository::class, $service); $this->app->instance(DaemonServerRepository::class, $service);
$service->expects('setServer') $service->expects('setServer')
->with(Mockery::on(function ($value) use ($server) { ->with(\Mockery::on(function ($value) use ($server) {
return $value->uuid === $server->uuid; return $value->uuid === $server->uuid;
})) }))
->andReturnSelf() ->andReturnSelf()

View file

@ -2,7 +2,6 @@
namespace Pterodactyl\Tests\Integration\Api\Client\Server\Subuser; namespace Pterodactyl\Tests\Integration\Api\Client\Server\Subuser;
use Mockery;
use Ramsey\Uuid\Uuid; use Ramsey\Uuid\Uuid;
use Pterodactyl\Models\User; use Pterodactyl\Models\User;
use Pterodactyl\Models\Subuser; use Pterodactyl\Models\Subuser;
@ -25,7 +24,7 @@ class DeleteSubuserTest extends ClientApiIntegrationTestCase
*/ */
public function testCorrectSubuserIsDeletedFromServer() public function testCorrectSubuserIsDeletedFromServer()
{ {
$this->swap(DaemonServerRepository::class, $mock = Mockery::mock(DaemonServerRepository::class)); $this->swap(DaemonServerRepository::class, $mock = \Mockery::mock(DaemonServerRepository::class));
[$user, $server] = $this->generateTestAccount(); [$user, $server] = $this->generateTestAccount();

View file

@ -2,7 +2,6 @@
namespace Pterodactyl\Tests\Integration\Api\Client\Server\Subuser; namespace Pterodactyl\Tests\Integration\Api\Client\Server\Subuser;
use Mockery;
use Pterodactyl\Models\User; use Pterodactyl\Models\User;
use Pterodactyl\Models\Subuser; use Pterodactyl\Models\Subuser;
use Pterodactyl\Repositories\Wings\DaemonServerRepository; use Pterodactyl\Repositories\Wings\DaemonServerRepository;
@ -36,7 +35,7 @@ class SubuserAuthorizationTest extends ClientApiIntegrationTestCase
Subuser::factory()->create(['server_id' => $server2->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]); Subuser::factory()->create(['server_id' => $server3->id, 'user_id' => $internal->id]);
$this->instance(DaemonServerRepository::class, $mock = Mockery::mock(DaemonServerRepository::class)); $this->instance(DaemonServerRepository::class, $mock = \Mockery::mock(DaemonServerRepository::class));
if ($method === 'DELETE') { if ($method === 'DELETE') {
$mock->expects('setServer->revokeUserJTI')->with($internal->id)->andReturnUndefined(); $mock->expects('setServer->revokeUserJTI')->with($internal->id)->andReturnUndefined();
} }

View file

@ -2,14 +2,11 @@
namespace Pterodactyl\Tests\Integration\Jobs\Schedule; namespace Pterodactyl\Tests\Integration\Jobs\Schedule;
use Mockery;
use Carbon\Carbon; use Carbon\Carbon;
use DateTimeInterface;
use Carbon\CarbonImmutable; use Carbon\CarbonImmutable;
use GuzzleHttp\Psr7\Request; use GuzzleHttp\Psr7\Request;
use Pterodactyl\Models\Task; use Pterodactyl\Models\Task;
use GuzzleHttp\Psr7\Response; use GuzzleHttp\Psr7\Response;
use InvalidArgumentException;
use Pterodactyl\Models\Server; use Pterodactyl\Models\Server;
use Pterodactyl\Models\Schedule; use Pterodactyl\Models\Schedule;
use Illuminate\Support\Facades\Bus; use Illuminate\Support\Facades\Bus;
@ -48,7 +45,7 @@ class RunTaskJobTest extends IntegrationTestCase
$this->assertFalse($task->is_queued); $this->assertFalse($task->is_queued);
$this->assertFalse($schedule->is_processing); $this->assertFalse($schedule->is_processing);
$this->assertFalse($schedule->is_active); $this->assertFalse($schedule->is_active);
$this->assertTrue(CarbonImmutable::now()->isSameAs(DateTimeInterface::ATOM, $schedule->last_run_at)); $this->assertTrue(CarbonImmutable::now()->isSameAs(\DateTimeInterface::ATOM, $schedule->last_run_at));
} }
public function testJobWithInvalidActionThrowsException() public function testJobWithInvalidActionThrowsException()
@ -62,7 +59,7 @@ class RunTaskJobTest extends IntegrationTestCase
$job = new RunTaskJob($task); $job = new RunTaskJob($task);
$this->expectException(InvalidArgumentException::class); $this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('Invalid task action provided: foobar'); $this->expectExceptionMessage('Invalid task action provided: foobar');
Bus::dispatchNow($job); Bus::dispatchNow($job);
} }
@ -90,10 +87,10 @@ class RunTaskJobTest extends IntegrationTestCase
'continue_on_failure' => false, 'continue_on_failure' => false,
]); ]);
$mock = Mockery::mock(DaemonPowerRepository::class); $mock = \Mockery::mock(DaemonPowerRepository::class);
$this->instance(DaemonPowerRepository::class, $mock); $this->instance(DaemonPowerRepository::class, $mock);
$mock->expects('setServer')->with(Mockery::on(function ($value) use ($server) { $mock->expects('setServer')->with(\Mockery::on(function ($value) use ($server) {
return $value instanceof Server && $value->id === $server->id; return $value instanceof Server && $value->id === $server->id;
}))->andReturnSelf(); }))->andReturnSelf();
$mock->expects('send')->with('start')->andReturn(new Response()); $mock->expects('send')->with('start')->andReturn(new Response());
@ -105,7 +102,7 @@ class RunTaskJobTest extends IntegrationTestCase
$this->assertFalse($task->is_queued); $this->assertFalse($task->is_queued);
$this->assertFalse($schedule->is_processing); $this->assertFalse($schedule->is_processing);
$this->assertTrue(CarbonImmutable::now()->isSameAs(DateTimeInterface::ATOM, $schedule->last_run_at)); $this->assertTrue(CarbonImmutable::now()->isSameAs(\DateTimeInterface::ATOM, $schedule->last_run_at));
} }
/** /**
@ -125,7 +122,7 @@ class RunTaskJobTest extends IntegrationTestCase
'continue_on_failure' => $continueOnFailure, 'continue_on_failure' => $continueOnFailure,
]); ]);
$mock = Mockery::mock(DaemonPowerRepository::class); $mock = \Mockery::mock(DaemonPowerRepository::class);
$this->instance(DaemonPowerRepository::class, $mock); $this->instance(DaemonPowerRepository::class, $mock);
$mock->expects('setServer->send')->andThrow( $mock->expects('setServer->send')->andThrow(
@ -144,7 +141,7 @@ class RunTaskJobTest extends IntegrationTestCase
$this->assertFalse($task->is_queued); $this->assertFalse($task->is_queued);
$this->assertFalse($schedule->is_processing); $this->assertFalse($schedule->is_processing);
$this->assertTrue(CarbonImmutable::now()->isSameAs(DateTimeInterface::ATOM, $schedule->last_run_at)); $this->assertTrue(CarbonImmutable::now()->isSameAs(\DateTimeInterface::ATOM, $schedule->last_run_at));
} }
} }
@ -175,7 +172,7 @@ class RunTaskJobTest extends IntegrationTestCase
$this->assertFalse($task->is_queued); $this->assertFalse($task->is_queued);
$this->assertFalse($schedule->is_processing); $this->assertFalse($schedule->is_processing);
$this->assertTrue(Carbon::now()->isSameAs(DateTimeInterface::ATOM, $schedule->last_run_at)); $this->assertTrue(Carbon::now()->isSameAs(\DateTimeInterface::ATOM, $schedule->last_run_at));
} }
public function isManualRunDataProvider(): array public function isManualRunDataProvider(): array

View file

@ -2,8 +2,6 @@
namespace Pterodactyl\Tests\Integration\Services\Allocations; namespace Pterodactyl\Tests\Integration\Services\Allocations;
use Exception;
use InvalidArgumentException;
use Pterodactyl\Models\Allocation; use Pterodactyl\Models\Allocation;
use Pterodactyl\Tests\Integration\IntegrationTestCase; use Pterodactyl\Tests\Integration\IntegrationTestCase;
use Pterodactyl\Services\Allocations\FindAssignableAllocationService; use Pterodactyl\Services\Allocations\FindAssignableAllocationService;
@ -142,8 +140,8 @@ class FindAssignableAllocationServiceTest extends IntegrationTestCase
try { try {
$this->getService()->handle($server); $this->getService()->handle($server);
$this->fail('This assertion should not be reached.'); $this->fail('This assertion should not be reached.');
} catch (Exception $exception) { } catch (\Exception $exception) {
$this->assertInstanceOf(InvalidArgumentException::class, $exception); $this->assertInstanceOf(\InvalidArgumentException::class, $exception);
$this->assertSame('Expected an integerish value. Got: string', $exception->getMessage()); $this->assertSame('Expected an integerish value. Got: string', $exception->getMessage());
} }
@ -153,8 +151,8 @@ class FindAssignableAllocationServiceTest extends IntegrationTestCase
try { try {
$this->getService()->handle($server); $this->getService()->handle($server);
$this->fail('This assertion should not be reached.'); $this->fail('This assertion should not be reached.');
} catch (Exception $exception) { } catch (\Exception $exception) {
$this->assertInstanceOf(InvalidArgumentException::class, $exception); $this->assertInstanceOf(\InvalidArgumentException::class, $exception);
$this->assertSame('Expected an integerish value. Got: string', $exception->getMessage()); $this->assertSame('Expected an integerish value. Got: string', $exception->getMessage());
} }
} }

View file

@ -2,10 +2,7 @@
namespace Pterodactyl\Tests\Integration\Services\Databases; namespace Pterodactyl\Tests\Integration\Services\Databases;
use Mockery;
use Mockery\MockInterface; use Mockery\MockInterface;
use BadMethodCallException;
use InvalidArgumentException;
use Pterodactyl\Models\Database; use Pterodactyl\Models\Database;
use Pterodactyl\Models\DatabaseHost; use Pterodactyl\Models\DatabaseHost;
use Pterodactyl\Tests\Integration\IntegrationTestCase; use Pterodactyl\Tests\Integration\IntegrationTestCase;
@ -79,7 +76,7 @@ class DatabaseManagementServiceTest extends IntegrationTestCase
{ {
$server = $this->createServerModel(); $server = $this->createServerModel();
$this->expectException(InvalidArgumentException::class); $this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('The database name passed to DatabaseManagementService::handle MUST be prefixed with "s{server_id}_".'); $this->expectExceptionMessage('The database name passed to DatabaseManagementService::handle MUST be prefixed with "s{server_id}_".');
$this->getService()->create($server, $data); $this->getService()->create($server, $data);
@ -134,13 +131,13 @@ class DatabaseManagementServiceTest extends IntegrationTestCase
// assertions that would get caught by the functions catcher and thus lead to the exception // assertions that would get caught by the functions catcher and thus lead to the exception
// being swallowed incorrectly. // being swallowed incorrectly.
$this->repository->expects('createUser')->with( $this->repository->expects('createUser')->with(
Mockery::on(function ($value) use (&$username) { \Mockery::on(function ($value) use (&$username) {
$username = $value; $username = $value;
return true; return true;
}), }),
'%', '%',
Mockery::on(function ($value) use (&$password) { \Mockery::on(function ($value) use (&$password) {
$password = $value; $password = $value;
return true; return true;
@ -148,7 +145,7 @@ class DatabaseManagementServiceTest extends IntegrationTestCase
null null
); );
$this->repository->expects('assignUserToDatabase')->with($name, Mockery::on(function ($value) use (&$secondUsername) { $this->repository->expects('assignUserToDatabase')->with($name, \Mockery::on(function ($value) use (&$secondUsername) {
$secondUsername = $value; $secondUsername = $value;
return true; return true;
@ -182,11 +179,11 @@ class DatabaseManagementServiceTest extends IntegrationTestCase
$host = DatabaseHost::factory()->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('dropDatabase')->with($name);
$this->repository->expects('dropUser')->withAnyArgs()->andThrows(new InvalidArgumentException()); $this->repository->expects('dropUser')->withAnyArgs()->andThrows(new \InvalidArgumentException());
$this->expectException(BadMethodCallException::class); $this->expectException(\BadMethodCallException::class);
$this->getService()->create($server, [ $this->getService()->create($server, [
'remote' => '%', 'remote' => '%',

View file

@ -2,10 +2,8 @@
namespace Pterodactyl\Tests\Integration\Services\Databases; namespace Pterodactyl\Tests\Integration\Services\Databases;
use Mockery;
use Mockery\MockInterface; use Mockery\MockInterface;
use Pterodactyl\Models\Node; use Pterodactyl\Models\Node;
use InvalidArgumentException;
use Pterodactyl\Models\Database; use Pterodactyl\Models\Database;
use Pterodactyl\Models\DatabaseHost; use Pterodactyl\Models\DatabaseHost;
use Pterodactyl\Tests\Integration\IntegrationTestCase; use Pterodactyl\Tests\Integration\IntegrationTestCase;
@ -24,7 +22,7 @@ class DeployServerDatabaseServiceTest extends IntegrationTestCase
{ {
parent::setUp(); parent::setUp();
$this->managementService = Mockery::mock(DatabaseManagementService::class); $this->managementService = \Mockery::mock(DatabaseManagementService::class);
$this->swap(DatabaseManagementService::class, $this->managementService); $this->swap(DatabaseManagementService::class, $this->managementService);
} }
@ -50,7 +48,7 @@ class DeployServerDatabaseServiceTest extends IntegrationTestCase
{ {
$server = $this->createServerModel(); $server = $this->createServerModel();
$this->expectException(InvalidArgumentException::class); $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); $this->getService()->handle($server, $data);
} }

View file

@ -2,9 +2,7 @@
namespace Pterodactyl\Tests\Integration\Services\Deployment; namespace Pterodactyl\Tests\Integration\Services\Deployment;
use Exception;
use Pterodactyl\Models\Node; use Pterodactyl\Models\Node;
use InvalidArgumentException;
use Pterodactyl\Models\Server; use Pterodactyl\Models\Server;
use Pterodactyl\Models\Database; use Pterodactyl\Models\Database;
use Pterodactyl\Models\Location; use Pterodactyl\Models\Location;
@ -26,7 +24,7 @@ class FindViableNodesServiceTest extends IntegrationTestCase
public function testExceptionIsThrownIfNoDiskSpaceHasBeenSet() public function testExceptionIsThrownIfNoDiskSpaceHasBeenSet()
{ {
$this->expectException(InvalidArgumentException::class); $this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('Disk space must be an int, got NULL'); $this->expectExceptionMessage('Disk space must be an int, got NULL');
$this->getService()->handle(); $this->getService()->handle();
@ -34,7 +32,7 @@ class FindViableNodesServiceTest extends IntegrationTestCase
public function testExceptionIsThrownIfNoMemoryHasBeenSet() public function testExceptionIsThrownIfNoMemoryHasBeenSet()
{ {
$this->expectException(InvalidArgumentException::class); $this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('Memory usage must be an int, got NULL'); $this->expectExceptionMessage('Memory usage must be an int, got NULL');
$this->getService()->setDisk(10)->handle(); $this->getService()->setDisk(10)->handle();
@ -54,16 +52,16 @@ class FindViableNodesServiceTest extends IntegrationTestCase
try { try {
$this->getService()->setLocations(['a']); $this->getService()->setLocations(['a']);
$this->fail('This expectation should not be called.'); $this->fail('This expectation should not be called.');
} catch (Exception $exception) { } catch (\Exception $exception) {
$this->assertInstanceOf(InvalidArgumentException::class, $exception); $this->assertInstanceOf(\InvalidArgumentException::class, $exception);
$this->assertSame('An array of location IDs should be provided when calling setLocations.', $exception->getMessage()); $this->assertSame('An array of location IDs should be provided when calling setLocations.', $exception->getMessage());
} }
try { try {
$this->getService()->setLocations(['1.2', '1', 2]); $this->getService()->setLocations(['1.2', '1', 2]);
$this->fail('This expectation should not be called.'); $this->fail('This expectation should not be called.');
} catch (Exception $exception) { } catch (\Exception $exception) {
$this->assertInstanceOf(InvalidArgumentException::class, $exception); $this->assertInstanceOf(\InvalidArgumentException::class, $exception);
$this->assertSame('An array of location IDs should be provided when calling setLocations.', $exception->getMessage()); $this->assertSame('An array of location IDs should be provided when calling setLocations.', $exception->getMessage());
} }
} }

View file

@ -2,11 +2,9 @@
namespace Pterodactyl\Tests\Integration\Services\Schedules; namespace Pterodactyl\Tests\Integration\Services\Schedules;
use Mockery;
use Exception; use Exception;
use Carbon\CarbonImmutable; use Carbon\CarbonImmutable;
use Pterodactyl\Models\Task; use Pterodactyl\Models\Task;
use InvalidArgumentException;
use Pterodactyl\Models\Schedule; use Pterodactyl\Models\Schedule;
use Illuminate\Support\Facades\Bus; use Illuminate\Support\Facades\Bus;
use Illuminate\Contracts\Bus\Dispatcher; use Illuminate\Contracts\Bus\Dispatcher;
@ -47,7 +45,7 @@ class ProcessScheduleServiceTest extends IntegrationTestCase
/** @var \Pterodactyl\Models\Task $task */ /** @var \Pterodactyl\Models\Task $task */
$task = Task::factory()->create(['schedule_id' => $schedule->id, 'sequence_id' => 1]); $task = Task::factory()->create(['schedule_id' => $schedule->id, 'sequence_id' => 1]);
$this->expectException(InvalidArgumentException::class); $this->expectException(\InvalidArgumentException::class);
$this->getService()->handle($schedule); $this->getService()->handle($schedule);
@ -126,7 +124,7 @@ class ProcessScheduleServiceTest extends IntegrationTestCase
*/ */
public function testTaskDispatchedNowIsResetProperlyIfErrorIsEncountered() public function testTaskDispatchedNowIsResetProperlyIfErrorIsEncountered()
{ {
$this->swap(Dispatcher::class, $dispatcher = Mockery::mock(Dispatcher::class)); $this->swap(Dispatcher::class, $dispatcher = \Mockery::mock(Dispatcher::class));
$server = $this->createServerModel(); $server = $this->createServerModel();
/** @var \Pterodactyl\Models\Schedule $schedule */ /** @var \Pterodactyl\Models\Schedule $schedule */
@ -134,9 +132,9 @@ class ProcessScheduleServiceTest extends IntegrationTestCase
/** @var \Pterodactyl\Models\Task $task */ /** @var \Pterodactyl\Models\Task $task */
$task = Task::factory()->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')); $dispatcher->expects('dispatchNow')->andThrows(new \Exception('Test thrown exception'));
$this->expectException(Exception::class); $this->expectException(\Exception::class);
$this->expectExceptionMessage('Test thrown exception'); $this->expectExceptionMessage('Test thrown exception');
$this->getService()->handle($schedule, true); $this->getService()->handle($schedule, true);

View file

@ -2,7 +2,6 @@
namespace Pterodactyl\Tests\Integration\Services\Servers; namespace Pterodactyl\Tests\Integration\Services\Servers;
use Mockery;
use Mockery\MockInterface; use Mockery\MockInterface;
use GuzzleHttp\Psr7\Request; use GuzzleHttp\Psr7\Request;
use GuzzleHttp\Psr7\Response; use GuzzleHttp\Psr7\Response;
@ -108,7 +107,7 @@ class BuildModificationServiceTest extends IntegrationTestCase
{ {
$server = $this->createServerModel(); $server = $this->createServerModel();
$this->daemonServerRepository->expects('setServer')->with(Mockery::on(function (Server $s) use ($server) { $this->daemonServerRepository->expects('setServer')->with(\Mockery::on(function (Server $s) use ($server) {
return $s->id === $server->id; return $s->id === $server->id;
}))->andReturnSelf(); }))->andReturnSelf();

View file

@ -2,7 +2,6 @@
namespace Pterodactyl\Tests\Integration\Services\Servers; namespace Pterodactyl\Tests\Integration\Services\Servers;
use Mockery;
use Mockery\MockInterface; use Mockery\MockInterface;
use Pterodactyl\Models\Egg; use Pterodactyl\Models\Egg;
use GuzzleHttp\Psr7\Request; use GuzzleHttp\Psr7\Request;
@ -42,7 +41,7 @@ class ServerCreationServiceTest extends IntegrationTestCase
->where('name', 'Bungeecord') ->where('name', 'Bungeecord')
->firstOrFail(); ->firstOrFail();
$this->daemonServerRepository = Mockery::mock(DaemonServerRepository::class); $this->daemonServerRepository = \Mockery::mock(DaemonServerRepository::class);
$this->swap(DaemonServerRepository::class, $this->daemonServerRepository); $this->swap(DaemonServerRepository::class, $this->daemonServerRepository);
} }

View file

@ -2,8 +2,6 @@
namespace Pterodactyl\Tests\Integration\Services\Servers; namespace Pterodactyl\Tests\Integration\Services\Servers;
use Mockery;
use Exception;
use Mockery\MockInterface; use Mockery\MockInterface;
use GuzzleHttp\Psr7\Request; use GuzzleHttp\Psr7\Request;
use GuzzleHttp\Psr7\Response; use GuzzleHttp\Psr7\Response;
@ -35,8 +33,8 @@ class ServerDeletionServiceTest extends IntegrationTestCase
// There will be some log calls during this test, don't actually write to the disk. // There will be some log calls during this test, don't actually write to the disk.
config()->set('logging.default', 'null'); config()->set('logging.default', 'null');
$this->daemonServerRepository = Mockery::mock(DaemonServerRepository::class); $this->daemonServerRepository = \Mockery::mock(DaemonServerRepository::class);
$this->databaseManagementService = Mockery::mock(DatabaseManagementService::class); $this->databaseManagementService = \Mockery::mock(DatabaseManagementService::class);
$this->app->instance(DaemonServerRepository::class, $this->daemonServerRepository); $this->app->instance(DaemonServerRepository::class, $this->daemonServerRepository);
$this->app->instance(DatabaseManagementService::class, $this->databaseManagementService); $this->app->instance(DatabaseManagementService::class, $this->databaseManagementService);
@ -120,11 +118,11 @@ class ServerDeletionServiceTest extends IntegrationTestCase
$server->refresh(); $server->refresh();
$this->daemonServerRepository->expects('setServer->delete')->withNoArgs()->andReturnUndefined(); $this->daemonServerRepository->expects('setServer->delete')->withNoArgs()->andReturnUndefined();
$this->databaseManagementService->expects('delete')->with(Mockery::on(function ($value) use ($db) { $this->databaseManagementService->expects('delete')->with(\Mockery::on(function ($value) use ($db) {
return $value instanceof Database && $value->id === $db->id; return $value instanceof Database && $value->id === $db->id;
}))->andThrows(new Exception()); }))->andThrows(new \Exception());
$this->expectException(Exception::class); $this->expectException(\Exception::class);
$this->getService()->handle($server); $this->getService()->handle($server);
$this->assertDatabaseHas('servers', ['id' => $server->id]); $this->assertDatabaseHas('servers', ['id' => $server->id]);
@ -145,9 +143,9 @@ class ServerDeletionServiceTest extends IntegrationTestCase
$server->refresh(); $server->refresh();
$this->daemonServerRepository->expects('setServer->delete')->withNoArgs()->andReturnUndefined(); $this->daemonServerRepository->expects('setServer->delete')->withNoArgs()->andReturnUndefined();
$this->databaseManagementService->expects('delete')->with(Mockery::on(function ($value) use ($db) { $this->databaseManagementService->expects('delete')->with(\Mockery::on(function ($value) use ($db) {
return $value instanceof Database && $value->id === $db->id; return $value instanceof Database && $value->id === $db->id;
}))->andThrows(new Exception()); }))->andThrows(new \Exception());
$this->getService()->withForce(true)->handle($server); $this->getService()->withForce(true)->handle($server);

View file

@ -34,7 +34,7 @@ class StartupModificationServiceTest extends IntegrationTestCase
]); ]);
$this->fail('This assertion should not be called.'); $this->fail('This assertion should not be called.');
} catch (Exception $exception) { } catch (\Exception $exception) {
$this->assertInstanceOf(ValidationException::class, $exception); $this->assertInstanceOf(ValidationException::class, $exception);
/** @var \Illuminate\Validation\ValidationException $exception */ /** @var \Illuminate\Validation\ValidationException $exception */

View file

@ -2,9 +2,7 @@
namespace Pterodactyl\Tests\Integration\Services\Servers; namespace Pterodactyl\Tests\Integration\Services\Servers;
use Mockery;
use Mockery\MockInterface; use Mockery\MockInterface;
use InvalidArgumentException;
use Pterodactyl\Models\Server; use Pterodactyl\Models\Server;
use Pterodactyl\Services\Servers\SuspensionService; use Pterodactyl\Services\Servers\SuspensionService;
use Pterodactyl\Tests\Integration\IntegrationTestCase; use Pterodactyl\Tests\Integration\IntegrationTestCase;
@ -21,7 +19,7 @@ class SuspensionServiceTest extends IntegrationTestCase
{ {
parent::setUp(); parent::setUp();
$this->repository = Mockery::mock(DaemonServerRepository::class); $this->repository = \Mockery::mock(DaemonServerRepository::class);
$this->app->instance(DaemonServerRepository::class, $this->repository); $this->app->instance(DaemonServerRepository::class, $this->repository);
} }
@ -60,7 +58,7 @@ class SuspensionServiceTest extends IntegrationTestCase
{ {
$server = $this->createServerModel(); $server = $this->createServerModel();
$this->expectException(InvalidArgumentException::class); $this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('Expected one of: "suspend", "unsuspend". Got: "foo"'); $this->expectExceptionMessage('Expected one of: "suspend", "unsuspend". Got: "foo"');
$this->getService()->toggle($server, 'foo'); $this->getService()->toggle($server, 'foo');

View file

@ -4,7 +4,6 @@ namespace Pterodactyl\Tests\Traits\Http;
use Closure; use Closure;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use BadFunctionCallException;
trait MocksMiddlewareClosure trait MocksMiddlewareClosure
{ {
@ -12,10 +11,10 @@ trait MocksMiddlewareClosure
* Provide a closure to be used when validating that the response from the middleware * Provide a closure to be used when validating that the response from the middleware
* is the same request object we passed into it. * is the same request object we passed into it.
*/ */
protected function getClosureAssertions(): Closure protected function getClosureAssertions(): \Closure
{ {
if (is_null($this->request)) { if (is_null($this->request)) {
throw new BadFunctionCallException('Calling getClosureAssertions without defining a request object is not supported.'); throw new \BadFunctionCallException('Calling getClosureAssertions without defining a request object is not supported.');
} }
return function ($response) { return function ($response) {

View file

@ -6,7 +6,6 @@ use Mockery as m;
use Mockery\Mock; use Mockery\Mock;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Pterodactyl\Models\User; use Pterodactyl\Models\User;
use InvalidArgumentException;
use Symfony\Component\HttpFoundation\ParameterBag; use Symfony\Component\HttpFoundation\ParameterBag;
trait RequestMockHelpers trait RequestMockHelpers
@ -68,7 +67,7 @@ trait RequestMockHelpers
{ {
$this->request = m::mock($this->requestMockClass); $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.'); throw new \InvalidArgumentException('Request mock class must be an instance of ' . Request::class . ' when mocked.');
} }
$this->request->attributes = new ParameterBag(); $this->request->attributes = new ParameterBag();

View file

@ -2,7 +2,6 @@
namespace Pterodactyl\Tests\Traits; namespace Pterodactyl\Tests\Traits;
use Mockery;
use Mockery\Mock; use Mockery\Mock;
use Mockery\MockInterface; use Mockery\MockInterface;
use GuzzleHttp\Exception\RequestException; use GuzzleHttp\Exception\RequestException;
@ -27,6 +26,6 @@ trait MocksRequestException
*/ */
protected function getExceptionMock(string $abstract = RequestException::class): MockInterface protected function getExceptionMock(string $abstract = RequestException::class): MockInterface
{ {
return $this->exception ?? $this->exception = Mockery::mock($abstract); return $this->exception ?? $this->exception = \Mockery::mock($abstract);
} }
} }