Use more standardized phpcs
This commit is contained in:
parent
a043071e3c
commit
c449ca5155
493 changed files with 1116 additions and 3903 deletions
|
@ -22,8 +22,6 @@ class DeleteAllocationRequest extends ApplicationApiRequest
|
|||
/**
|
||||
* Determine if the requested allocation exists and belongs to the node that
|
||||
* is being passed in the URL.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function resourceExists(): bool
|
||||
{
|
||||
|
|
|
@ -21,8 +21,6 @@ class GetAllocationsRequest extends ApplicationApiRequest
|
|||
/**
|
||||
* Determine if the node that we are requesting the allocations
|
||||
* for exists on the Panel.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function resourceExists(): bool
|
||||
{
|
||||
|
|
|
@ -17,9 +17,6 @@ class StoreAllocationRequest extends ApplicationApiRequest
|
|||
*/
|
||||
protected $permission = AdminAcl::WRITE;
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
|
|
|
@ -40,8 +40,6 @@ abstract class ApplicationApiRequest extends FormRequest
|
|||
* Determine if the current user is authorized to perform
|
||||
* the requested action against the API.
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\PterodactylException
|
||||
*/
|
||||
public function authorize(): bool
|
||||
|
@ -55,8 +53,6 @@ abstract class ApplicationApiRequest extends FormRequest
|
|||
|
||||
/**
|
||||
* Determine if the requested resource exists on the server.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function resourceExists(): bool
|
||||
{
|
||||
|
@ -65,8 +61,6 @@ abstract class ApplicationApiRequest extends FormRequest
|
|||
|
||||
/**
|
||||
* Default set of rules to apply to API requests.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
|
@ -75,8 +69,6 @@ abstract class ApplicationApiRequest extends FormRequest
|
|||
|
||||
/**
|
||||
* Return the API key being used for the request.
|
||||
*
|
||||
* @return \Pterodactyl\Models\ApiKey
|
||||
*/
|
||||
public function key(): ApiKey
|
||||
{
|
||||
|
@ -87,8 +79,8 @@ abstract class ApplicationApiRequest extends FormRequest
|
|||
* Grab a model from the route parameters. If no model is found in the
|
||||
* binding mappings an exception will be thrown.
|
||||
*
|
||||
* @param string $model
|
||||
* @return mixed
|
||||
*
|
||||
* @deprecated
|
||||
*
|
||||
* @throws \Symfony\Component\Routing\Exception\InvalidParameterException
|
||||
|
@ -98,7 +90,7 @@ abstract class ApplicationApiRequest extends FormRequest
|
|||
$parameterKey = array_get(array_flip(ApiSubstituteBindings::getMappings()), $model);
|
||||
|
||||
if (is_null($parameterKey)) {
|
||||
throw new InvalidParameterException;
|
||||
throw new InvalidParameterException();
|
||||
}
|
||||
|
||||
return $this->route()->parameter($parameterKey);
|
||||
|
@ -112,7 +104,7 @@ abstract class ApplicationApiRequest extends FormRequest
|
|||
*/
|
||||
protected function prepareForValidation()
|
||||
{
|
||||
if (! $this->passesAuthorization()) {
|
||||
if (!$this->passesAuthorization()) {
|
||||
$this->failedAuthorization();
|
||||
}
|
||||
|
||||
|
@ -137,7 +129,7 @@ abstract class ApplicationApiRequest extends FormRequest
|
|||
return true;
|
||||
}
|
||||
|
||||
if (! parent::passesAuthorization()) {
|
||||
if (!parent::passesAuthorization()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -145,7 +137,7 @@ abstract class ApplicationApiRequest extends FormRequest
|
|||
// authenticated to access the endpoint. This avoids exposing that
|
||||
// an item exists (or does not exist) to the user until they can prove
|
||||
// that they have permission to know about it.
|
||||
if ($this->attributes->get('is_missing_model', false) || ! $this->resourceExists()) {
|
||||
if ($this->attributes->get('is_missing_model', false) || !$this->resourceExists()) {
|
||||
throw new NotFoundHttpException(trans('exceptions.api.resource_not_found'));
|
||||
}
|
||||
|
||||
|
|
|
@ -20,8 +20,6 @@ class DeleteLocationRequest extends ApplicationApiRequest
|
|||
|
||||
/**
|
||||
* Determine if the requested location exists on the Panel.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function resourceExists(): bool
|
||||
{
|
||||
|
|
|
@ -8,8 +8,6 @@ class GetLocationRequest extends GetLocationsRequest
|
|||
{
|
||||
/**
|
||||
* Determine if the requested location exists on the Panel.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function resourceExists(): bool
|
||||
{
|
||||
|
|
|
@ -20,8 +20,6 @@ class StoreLocationRequest extends ApplicationApiRequest
|
|||
|
||||
/**
|
||||
* Rules to validate the request against.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
|
|
|
@ -8,8 +8,6 @@ class UpdateLocationRequest extends StoreLocationRequest
|
|||
{
|
||||
/**
|
||||
* Determine if the requested location exists on the Panel.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function resourceExists(): bool
|
||||
{
|
||||
|
@ -20,8 +18,6 @@ class UpdateLocationRequest extends StoreLocationRequest
|
|||
|
||||
/**
|
||||
* Rules to validate this request against.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
|
|
|
@ -21,8 +21,6 @@ class GetEggRequest extends ApplicationApiRequest
|
|||
|
||||
/**
|
||||
* Determine if the requested egg exists for the selected nest.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function resourceExists(): bool
|
||||
{
|
||||
|
|
|
@ -21,8 +21,6 @@ class DeleteNodeRequest extends ApplicationApiRequest
|
|||
/**
|
||||
* Determine if the node being requested for editing exists
|
||||
* on the Panel before validating the data.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function resourceExists(): bool
|
||||
{
|
||||
|
|
|
@ -8,8 +8,6 @@ class GetNodeRequest extends GetNodesRequest
|
|||
{
|
||||
/**
|
||||
* Determine if the requested node exists on the Panel.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function resourceExists(): bool
|
||||
{
|
||||
|
|
|
@ -20,9 +20,6 @@ class StoreNodeRequest extends ApplicationApiRequest
|
|||
|
||||
/**
|
||||
* Validation rules to apply to this request.
|
||||
*
|
||||
* @param array|null $rules
|
||||
* @return array
|
||||
*/
|
||||
public function rules(array $rules = null): array
|
||||
{
|
||||
|
@ -74,7 +71,7 @@ class StoreNodeRequest extends ApplicationApiRequest
|
|||
$response = parent::validated();
|
||||
$response['daemonListen'] = $response['daemon_listen'];
|
||||
$response['daemonSFTP'] = $response['daemon_sftp'];
|
||||
$response['daemonBase'] = $response['daemon_base'] ?? (new Node)->getAttribute('daemonBase');
|
||||
$response['daemonBase'] = $response['daemon_base'] ?? (new Node())->getAttribute('daemonBase');
|
||||
|
||||
unset($response['daemon_base'], $response['daemon_listen'], $response['daemon_sftp']);
|
||||
|
||||
|
|
|
@ -9,9 +9,6 @@ class UpdateNodeRequest extends StoreNodeRequest
|
|||
/**
|
||||
* Apply validation rules to this request. Uses the parent class rules()
|
||||
* function but passes in the rules for updating rather than creating.
|
||||
*
|
||||
* @param array|null $rules
|
||||
* @return array
|
||||
*/
|
||||
public function rules(array $rules = null): array
|
||||
{
|
||||
|
|
|
@ -19,8 +19,6 @@ class GetServerDatabaseRequest extends ApplicationApiRequest
|
|||
|
||||
/**
|
||||
* Determine if the requested server database exists.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function resourceExists(): bool
|
||||
{
|
||||
|
|
|
@ -24,8 +24,6 @@ class StoreServerDatabaseRequest extends ApplicationApiRequest
|
|||
|
||||
/**
|
||||
* Validation rules for database creation.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
|
@ -76,8 +74,6 @@ class StoreServerDatabaseRequest extends ApplicationApiRequest
|
|||
|
||||
/**
|
||||
* Returns the database name in the expected format.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function databaseName(): string
|
||||
{
|
||||
|
|
|
@ -27,8 +27,6 @@ class GetExternalServerRequest extends ApplicationApiRequest
|
|||
|
||||
/**
|
||||
* Determine if the requested external user exists.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function resourceExists(): bool
|
||||
{
|
||||
|
@ -47,8 +45,6 @@ class GetExternalServerRequest extends ApplicationApiRequest
|
|||
|
||||
/**
|
||||
* Return the server model for the requested external server.
|
||||
*
|
||||
* @return \Pterodactyl\Models\Server
|
||||
*/
|
||||
public function getServerModel(): Server
|
||||
{
|
||||
|
|
|
@ -4,9 +4,6 @@ namespace Pterodactyl\Http\Requests\Api\Application\Servers;
|
|||
|
||||
class GetServersRequest extends GetServerRequest
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
|
|
|
@ -23,8 +23,6 @@ class StoreServerRequest extends ApplicationApiRequest
|
|||
|
||||
/**
|
||||
* Rules to be applied to this request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
|
@ -120,7 +118,7 @@ class StoreServerRequest extends ApplicationApiRequest
|
|||
$query->whereNull('server_id');
|
||||
}),
|
||||
], function ($input) {
|
||||
return ! ($input->deploy);
|
||||
return !($input->deploy);
|
||||
});
|
||||
|
||||
$validator->sometimes('allocation.additional.*', [
|
||||
|
@ -129,7 +127,7 @@ class StoreServerRequest extends ApplicationApiRequest
|
|||
$query->whereNull('server_id');
|
||||
}),
|
||||
], function ($input) {
|
||||
return ! ($input->deploy);
|
||||
return !($input->deploy);
|
||||
});
|
||||
|
||||
$validator->sometimes('deploy.locations', 'present', function ($input) {
|
||||
|
@ -152,7 +150,7 @@ class StoreServerRequest extends ApplicationApiRequest
|
|||
return null;
|
||||
}
|
||||
|
||||
$object = new DeploymentObject;
|
||||
$object = new DeploymentObject();
|
||||
$object->setDedicated($this->input('deploy.dedicated_ip', false));
|
||||
$object->setLocations($this->input('deploy.locations', []));
|
||||
$object->setPorts($this->input('deploy.port_range', []));
|
||||
|
|
|
@ -9,8 +9,6 @@ class UpdateServerBuildConfigurationRequest extends ServerWriteRequest
|
|||
{
|
||||
/**
|
||||
* Return the rules to validate this request against.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
|
@ -67,7 +65,7 @@ class UpdateServerBuildConfigurationRequest extends ServerWriteRequest
|
|||
unset($data['allocation'], $data['feature_limits']);
|
||||
|
||||
// Adjust the limits field to match what is expected by the model.
|
||||
if (! empty($data['limits'])) {
|
||||
if (!empty($data['limits'])) {
|
||||
foreach ($data['limits'] as $key => $value) {
|
||||
$data[$key] = $value;
|
||||
}
|
||||
|
@ -101,16 +99,13 @@ class UpdateServerBuildConfigurationRequest extends ServerWriteRequest
|
|||
* compatability with the old API endpoint while also supporting a more correct API
|
||||
* call.
|
||||
*
|
||||
* @param string $field
|
||||
* @param array $rules
|
||||
* @param bool $limits
|
||||
* @return array
|
||||
*
|
||||
* @see https://github.com/pterodactyl/panel/issues/1500
|
||||
*/
|
||||
protected function requiredToOptional(string $field, array $rules, bool $limits = false)
|
||||
{
|
||||
if (! in_array('required', $rules)) {
|
||||
if (!in_array('required', $rules)) {
|
||||
return $rules;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,8 +8,6 @@ class UpdateServerDetailsRequest extends ServerWriteRequest
|
|||
{
|
||||
/**
|
||||
* Rules to apply to a server details update request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
|
@ -26,8 +24,6 @@ class UpdateServerDetailsRequest extends ServerWriteRequest
|
|||
/**
|
||||
* Convert the posted data into the correct format that is expected
|
||||
* by the application.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function validated(): array
|
||||
{
|
||||
|
@ -42,8 +38,6 @@ class UpdateServerDetailsRequest extends ServerWriteRequest
|
|||
/**
|
||||
* Rename some of the attributes in error messages to clarify the field
|
||||
* being discussed.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function attributes(): array
|
||||
{
|
||||
|
|
|
@ -20,8 +20,6 @@ class UpdateServerStartupRequest extends ApplicationApiRequest
|
|||
|
||||
/**
|
||||
* Validation rules to run the input against.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
|
|
|
@ -20,8 +20,6 @@ class DeleteUserRequest extends ApplicationApiRequest
|
|||
|
||||
/**
|
||||
* Determine if the requested user exists on the Panel.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function resourceExists(): bool
|
||||
{
|
||||
|
|
|
@ -27,8 +27,6 @@ class GetExternalUserRequest extends ApplicationApiRequest
|
|||
|
||||
/**
|
||||
* Determine if the requested external user exists.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function resourceExists(): bool
|
||||
{
|
||||
|
@ -47,8 +45,6 @@ class GetExternalUserRequest extends ApplicationApiRequest
|
|||
|
||||
/**
|
||||
* Return the user model for the requested external user.
|
||||
*
|
||||
* @return \Pterodactyl\Models\User
|
||||
*/
|
||||
public function getUserModel(): User
|
||||
{
|
||||
|
|
|
@ -20,9 +20,6 @@ class StoreUserRequest extends ApplicationApiRequest
|
|||
|
||||
/**
|
||||
* Return the validation rules for this request.
|
||||
*
|
||||
* @param array|null $rules
|
||||
* @return array
|
||||
*/
|
||||
public function rules(array $rules = null): array
|
||||
{
|
||||
|
|
|
@ -8,9 +8,6 @@ class UpdateUserRequest extends StoreUserRequest
|
|||
{
|
||||
/**
|
||||
* Return the validation rules for this request.
|
||||
*
|
||||
* @param array|null $rules
|
||||
* @return array
|
||||
*/
|
||||
public function rules(array $rules = null): array
|
||||
{
|
||||
|
|
Reference in a new issue