Applied code style rules to src/

This commit is contained in:
Jan Böhmer 2020-01-05 15:46:58 +01:00
parent 700c049d26
commit f861de791f
186 changed files with 1462 additions and 1059 deletions

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -44,9 +47,9 @@ class AllowedFileExtensionValidator extends ConstraintValidator
* @param mixed $value The value that should be validated
* @param Constraint $constraint The constraint for the validation
*/
public function validate($value, Constraint $constraint)
public function validate($value, Constraint $constraint): void
{
if (!$constraint instanceof AllowedFileExtension) {
if (! $constraint instanceof AllowedFileExtension) {
throw new UnexpectedTypeException($constraint, AllowedFileExtension::class);
}
@ -67,7 +70,7 @@ class AllowedFileExtensionValidator extends ConstraintValidator
return;
}
if (!$this->filterTools->isExtensionAllowed(
if (! $this->filterTools->isExtensionAllowed(
$attachment_type->getFiletypeFilter(),
$value->getClientOriginalExtension()
)) {

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -51,9 +54,9 @@ class NoLockoutValidator extends ConstraintValidator
* @param mixed $value The value that should be validated
* @param Constraint $constraint The constraint for the validation
*/
public function validate($value, Constraint $constraint)
public function validate($value, Constraint $constraint): void
{
if (!$constraint instanceof NoLockout) {
if (! $constraint instanceof NoLockout) {
throw new UnexpectedTypeException($constraint, NoLockout::class);
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -38,9 +41,9 @@ class NoneOfItsChildrenValidator extends ConstraintValidator
* @param mixed $value The value that should be validated
* @param Constraint $constraint The constraint for the validation
*/
public function validate($value, Constraint $constraint)
public function validate($value, Constraint $constraint): void
{
if (!$constraint instanceof NoneOfItsChildren) {
if (! $constraint instanceof NoneOfItsChildren) {
throw new UnexpectedTypeException($constraint, NoneOfItsChildren::class);
}
@ -51,7 +54,7 @@ class NoneOfItsChildrenValidator extends ConstraintValidator
}
//Check type of value. Validating only works for StructuralDBElements
if (!$value instanceof StructuralDBElement) {
if (! $value instanceof StructuralDBElement) {
throw new UnexpectedValueException($value, 'StructuralDBElement');
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -38,9 +41,9 @@ class SelectableValidator extends ConstraintValidator
* @param mixed $value The value that should be validated
* @param \Symfony\Component\Validator\Constraint $constraint The constraint for the validation
*/
public function validate($value, Constraint $constraint)
public function validate($value, Constraint $constraint): void
{
if (!$constraint instanceof Selectable) {
if (! $constraint instanceof Selectable) {
throw new UnexpectedTypeException($constraint, Selectable::class);
}
@ -51,7 +54,7 @@ class SelectableValidator extends ConstraintValidator
}
//Check type of value. Validating only works for StructuralDBElements
if (!$value instanceof StructuralDBElement) {
if (! $value instanceof StructuralDBElement) {
throw new UnexpectedValueException($value, 'StructuralDBElement');
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -33,16 +36,16 @@ use Symfony\Component\Validator\Exception\UnexpectedValueException;
*/
class UrlOrBuiltinValidator extends UrlValidator
{
public function validate($value, Constraint $constraint)
public function validate($value, Constraint $constraint): void
{
if (!$constraint instanceof UrlOrBuiltin) {
if (! $constraint instanceof UrlOrBuiltin) {
throw new UnexpectedTypeException($constraint, UrlOrBuiltin::class);
}
if (null === $value || '' === $value) {
return;
}
if (!is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) {
if (! is_scalar($value) && ! (\is_object($value) && method_exists($value, '__toString'))) {
throw new UnexpectedValueException($value, 'string');
}
$value = (string) $value;
@ -53,7 +56,7 @@ class UrlOrBuiltinValidator extends UrlValidator
//After the %PLACEHOLDER% comes a slash, so we can check if we have a placholder via explode
$tmp = explode('/', $value);
//Builtins must have a %PLACEHOLDER% construction
if (!empty($tmp) && \in_array($tmp[0], $constraint->allowed_placeholders, false)) {
if (! empty($tmp) && \in_array($tmp[0], $constraint->allowed_placeholders, false)) {
return;
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -42,9 +45,9 @@ class ValidFileFilterValidator extends ConstraintValidator
* @param mixed $value The value that should be validated
* @param Constraint $constraint The constraint for the validation
*/
public function validate($value, Constraint $constraint)
public function validate($value, Constraint $constraint): void
{
if (!$constraint instanceof ValidFileFilter) {
if (! $constraint instanceof ValidFileFilter) {
throw new UnexpectedTypeException($constraint, ValidFileFilter::class);
}
@ -52,12 +55,12 @@ class ValidFileFilterValidator extends ConstraintValidator
return;
}
if (!\is_string($value)) {
if (! \is_string($value)) {
// throw this exception if your validator cannot handle the passed type so that it can be marked as invalid
throw new UnexpectedValueException($value, 'string');
}
if (!$this->filterTools->validateFilterString($value)) {
if (! $this->filterTools->validateFilterString($value)) {
$this->context->buildViolation('validator.file_type_filter.invalid')
->addViolation();
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -38,12 +41,9 @@ class ValidGoogleAuthCodeValidator extends ConstraintValidator
$this->googleAuthenticator = $googleAuthenticator;
}
/**
* {@inheritdoc}
*/
public function validate($value, Constraint $constraint)
public function validate($value, Constraint $constraint): void
{
if (!$constraint instanceof ValidGoogleAuthCode) {
if (! $constraint instanceof ValidGoogleAuthCode) {
throw new UnexpectedTypeException($constraint, ValidGoogleAuthCode::class);
}
@ -51,11 +51,11 @@ class ValidGoogleAuthCodeValidator extends ConstraintValidator
return;
}
if (!\is_string($value)) {
if (! \is_string($value)) {
throw new UnexpectedValueException($value, 'string');
}
if (!ctype_digit($value)) {
if (! ctype_digit($value)) {
$this->context->addViolation('validator.google_code.only_digits_allowed');
}
@ -71,7 +71,7 @@ class ValidGoogleAuthCodeValidator extends ConstraintValidator
$user = $this->context->getObject()->getParent()->getData();
//Check if the given code is valid
if (!$this->googleAuthenticator->checkCode($user, $value)) {
if (! $this->googleAuthenticator->checkCode($user, $value)) {
$this->context->addViolation('validator.google_code.wrong_code');
}
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -42,13 +45,13 @@ class ValidPartLotValidator extends ConstraintValidator
* @param mixed $value The value that should be validated
* @param Constraint $constraint The constraint for the validation
*/
public function validate($value, Constraint $constraint)
public function validate($value, Constraint $constraint): void
{
if (!$constraint instanceof ValidPartLot) {
if (! $constraint instanceof ValidPartLot) {
throw new UnexpectedTypeException($constraint, ValidPartLot::class);
}
if (!$value instanceof PartLot) {
if (! $value instanceof PartLot) {
throw new UnexpectedTypeException($value, PartLot::class);
}
@ -68,7 +71,7 @@ class ValidPartLotValidator extends ConstraintValidator
->atPath('amount')->addViolation();
}
if (!$parts->contains($value->getPart())) {
if (! $parts->contains($value->getPart())) {
$this->context->buildViolation('validator.part_lot.location_full')
->atPath('storage_location')->addViolation();
}
@ -76,7 +79,7 @@ class ValidPartLotValidator extends ConstraintValidator
//Check for onlyExisting
if ($value->getStorageLocation()->isLimitToExistingParts()) {
if (!$parts->contains($value->getPart())) {
if (! $parts->contains($value->getPart())) {
$this->context->buildViolation('validator.part_lot.only_existing')
->atPath('storage_location')->addViolation();
}
@ -84,7 +87,7 @@ class ValidPartLotValidator extends ConstraintValidator
//Check for only single part
if ($value->getStorageLocation()->isLimitToExistingParts()) {
if (($parts->count() > 0) && !$parts->contains($value->getPart())) {
if (($parts->count() > 0) && ! $parts->contains($value->getPart())) {
$this->context->buildViolation('validator.part_lot.single_part')
->atPath('storage_location')->addViolation();
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -44,9 +47,9 @@ class ValidPermissionValidator extends ConstraintValidator
* @param mixed $value The value that should be validated
* @param Constraint $constraint The constraint for the validation
*/
public function validate($value, Constraint $constraint)
public function validate($value, Constraint $constraint): void
{
if (!$constraint instanceof ValidPermission) {
if (! $constraint instanceof ValidPermission) {
throw new UnexpectedTypeException($constraint, ValidPermission::class);
}
@ -56,7 +59,7 @@ class ValidPermissionValidator extends ConstraintValidator
//Check for each permission and operation, for an alsoSet attribute
foreach ($this->perm_structure['perms'] as $perm_key => $permission) {
foreach ($permission['operations'] as $op_key => $op) {
if (!empty($op['alsoSet']) &&
if (! empty($op['alsoSet']) &&
true === $this->resolver->dontInherit($perm_holder, $perm_key, $op_key)) {
//Set every op listed in also Set
foreach ($op['alsoSet'] as $set_also) {