Upgrade to Laravel 9 (#4413)

Co-authored-by: DaneEveritt <dane@daneeveritt.com>
This commit is contained in:
Matthew Penner 2022-10-14 10:59:20 -06:00 committed by GitHub
parent 95e15d2c8a
commit cbcf62086f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
573 changed files with 4387 additions and 9411 deletions

View file

@ -10,42 +10,25 @@ use Pterodactyl\Exceptions\Service\Deployment\NoViableAllocationException;
class AllocationSelectionService
{
/**
* @var \Pterodactyl\Contracts\Repository\AllocationRepositoryInterface
*/
private $repository;
protected bool $dedicated = false;
/**
* @var bool
*/
protected $dedicated = false;
protected array $nodes = [];
/**
* @var array
*/
protected $nodes = [];
/**
* @var array
*/
protected $ports = [];
protected array $ports = [];
/**
* AllocationSelectionService constructor.
*/
public function __construct(AllocationRepositoryInterface $repository)
public function __construct(private AllocationRepositoryInterface $repository)
{
$this->repository = $repository;
}
/**
* Toggle if the selected allocation should be the only allocation belonging
* to the given IP address. If true an allocation will not be selected if an IP
* already has another server set to use on if its allocations.
*
* @return $this
*/
public function setDedicated(bool $dedicated)
public function setDedicated(bool $dedicated): self
{
$this->dedicated = $dedicated;
@ -55,10 +38,8 @@ class AllocationSelectionService
/**
* A list of node IDs that should be used when selecting an allocation. If empty, all
* nodes will be used to filter with.
*
* @return $this
*/
public function setNodes(array $nodes)
public function setNodes(array $nodes): self
{
$this->nodes = $nodes;
@ -70,11 +51,9 @@ class AllocationSelectionService
* empty, all ports will be considered when finding an allocation. If set, only ports appearing
* in the array or range will be used.
*
* @return $this
*
* @throws \Pterodactyl\Exceptions\DisplayException
*/
public function setPorts(array $ports)
public function setPorts(array $ports): self
{
$stored = [];
foreach ($ports as $port) {

View file

@ -4,29 +4,18 @@ namespace Pterodactyl\Services\Deployment;
use Pterodactyl\Models\Node;
use Webmozart\Assert\Assert;
use Illuminate\Support\Collection;
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
use Pterodactyl\Exceptions\Service\Deployment\NoViableNodeException;
class FindViableNodesService
{
/**
* @var array
*/
protected $locations = [];
/**
* @var int
*/
protected $disk;
/**
* @var int
*/
protected $memory;
protected array $locations = [];
protected ?int $disk = null;
protected ?int $memory = null;
/**
* Set the locations that should be searched through to locate available nodes.
*
* @return $this
*/
public function setLocations(array $locations): self
{
@ -41,8 +30,6 @@ class FindViableNodesService
* Set the amount of disk that will be used by the server being created. Nodes will be
* filtered out if they do not have enough available free disk space for this server
* to be placed on.
*
* @return $this
*/
public function setDisk(int $disk): self
{
@ -54,8 +41,6 @@ class FindViableNodesService
/**
* Set the amount of memory that this server will be using. As with disk space, nodes that
* do not have enough free memory will be filtered out.
*
* @return $this
*/
public function setMemory(int $memory): self
{
@ -79,11 +64,9 @@ class FindViableNodesService
* If "null" is provided as the value no pagination will
* be used.
*
* @return \Illuminate\Support\Collection|\Illuminate\Contracts\Pagination\LengthAwarePaginator
*
* @throws \Pterodactyl\Exceptions\Service\Deployment\NoViableNodeException
*/
public function handle(int $perPage = null, int $page = null)
public function handle(int $perPage = null, int $page = null): LengthAwarePaginator|Collection
{
Assert::integer($this->disk, 'Disk space must be an int, got %s');
Assert::integer($this->memory, 'Memory usage must be an int, got %s');