Fixed code style.

This commit is contained in:
Jan Böhmer 2020-08-21 21:36:22 +02:00
parent 2853e471c4
commit d0b1024d80
212 changed files with 495 additions and 1005 deletions

View file

@ -20,7 +20,6 @@
namespace App\Validator\Constraints\BigDecimal;
use Brick\Math\BigDecimal;
use Symfony\Component\Validator\Constraints\AbstractComparisonValidator;
use Symfony\Component\Validator\Constraints\GreaterThan;
@ -56,4 +55,4 @@ class BigDecimalGreaterThanValidator extends AbstractComparisonValidator
{
return GreaterThan::TOO_LOW_ERROR;
}
}
}

View file

@ -20,7 +20,6 @@
namespace App\Validator\Constraints\BigDecimal;
use Brick\Math\BigDecimal;
use Symfony\Component\Validator\Constraints\AbstractComparisonValidator;
use Symfony\Component\Validator\Constraints\GreaterThanOrEqual;

View file

@ -20,9 +20,7 @@
namespace App\Validator\Constraints\BigDecimal;
use Symfony\Component\Validator\Constraints\GreaterThan;
use Symfony\Component\Validator\Constraints\GreaterThanValidator;
use Symfony\Component\Validator\Constraints\NumberConstraintTrait;
/**
@ -46,4 +44,4 @@ class BigDecimalPositive extends GreaterThan
{
return BigDecimalGreaterThanValidator::class;
}
}
}

View file

@ -20,7 +20,6 @@
namespace App\Validator\Constraints\BigDecimal;
use Symfony\Component\Validator\Constraints\GreaterThanOrEqual;
use Symfony\Component\Validator\Constraints\NumberConstraintTrait;
@ -45,4 +44,4 @@ class BigDecimalPositiveOrZero extends GreaterThanOrEqual
{
return BigDecimalGreaterThenOrEqualValidator::class;
}
}
}

View file

@ -40,7 +40,7 @@ class ValidRangeValidator extends ConstraintValidator
public function validate($value, Constraint $constraint): void
{
if (! $constraint instanceof ValidRange) {
if (!$constraint instanceof ValidRange) {
throw new UnexpectedTypeException($constraint, ValidRange::class);
}
@ -50,11 +50,11 @@ class ValidRangeValidator extends ConstraintValidator
return;
}
if (! is_string($value)) {
if (!is_string($value)) {
throw new UnexpectedValueException($value, 'string');
}
if (! $this->rangeParser->isValidRange($value)) {
if (!$this->rangeParser->isValidRange($value)) {
$this->context->buildViolation($constraint->message)
->addViolation();
}

View file

@ -74,7 +74,7 @@ class NoLockoutValidator extends ConstraintValidator
*/
public function validate($value, Constraint $constraint): void
{
if (! $constraint instanceof NoLockout) {
if (!$constraint instanceof NoLockout) {
throw new UnexpectedTypeException($constraint, NoLockout::class);
}

View file

@ -61,7 +61,7 @@ class NoneOfItsChildrenValidator extends ConstraintValidator
*/
public function validate($value, Constraint $constraint): void
{
if (! $constraint instanceof NoneOfItsChildren) {
if (!$constraint instanceof NoneOfItsChildren) {
throw new UnexpectedTypeException($constraint, NoneOfItsChildren::class);
}
@ -72,7 +72,7 @@ class NoneOfItsChildrenValidator extends ConstraintValidator
}
//Check type of value. Validating only works for StructuralDBElements
if (! $value instanceof AbstractStructuralDBElement) {
if (!$value instanceof AbstractStructuralDBElement) {
throw new UnexpectedValueException($value, 'StructuralDBElement');
}

View file

@ -61,7 +61,7 @@ class SelectableValidator extends ConstraintValidator
*/
public function validate($value, Constraint $constraint): void
{
if (! $constraint instanceof Selectable) {
if (!$constraint instanceof Selectable) {
throw new UnexpectedTypeException($constraint, Selectable::class);
}
@ -72,7 +72,7 @@ class SelectableValidator extends ConstraintValidator
}
//Check type of value. Validating only works for StructuralDBElements
if (! $value instanceof AbstractStructuralDBElement) {
if (!$value instanceof AbstractStructuralDBElement) {
throw new UnexpectedValueException($value, 'StructuralDBElement');
}

View file

@ -56,14 +56,14 @@ class UrlOrBuiltinValidator extends UrlValidator
{
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;
@ -74,7 +74,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

@ -65,7 +65,7 @@ class ValidFileFilterValidator extends ConstraintValidator
*/
public function validate($value, Constraint $constraint): void
{
if (! $constraint instanceof ValidFileFilter) {
if (!$constraint instanceof ValidFileFilter) {
throw new UnexpectedTypeException($constraint, ValidFileFilter::class);
}
@ -73,12 +73,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

@ -61,7 +61,7 @@ class ValidGoogleAuthCodeValidator extends ConstraintValidator
public function validate($value, Constraint $constraint): void
{
if (! $constraint instanceof ValidGoogleAuthCode) {
if (!$constraint instanceof ValidGoogleAuthCode) {
throw new UnexpectedTypeException($constraint, ValidGoogleAuthCode::class);
}
@ -69,11 +69,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');
}
@ -89,7 +89,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

@ -67,11 +67,11 @@ class ValidPartLotValidator extends ConstraintValidator
*/
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);
}
@ -79,7 +79,7 @@ class ValidPartLotValidator extends ConstraintValidator
if ($value->getStorageLocation()) {
$repo = $this->em->getRepository(Storelocation::class);
//We can only determine associated parts, if the part have an ID
if ($value->getID() !== null) {
if (null !== $value->getID()) {
$parts = new ArrayCollection($repo->getParts($value->getStorageLocation()));
} else {
$parts = new ArrayCollection([]);
@ -97,7 +97,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();
}
@ -105,7 +105,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();
}
@ -113,7 +113,7 @@ class ValidPartLotValidator extends ConstraintValidator
//Check for only single part
if ($value->getStorageLocation()->isOnlySinglePart()) {
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

@ -67,7 +67,7 @@ class ValidPermissionValidator extends ConstraintValidator
*/
public function validate($value, Constraint $constraint): void
{
if (! $constraint instanceof ValidPermission) {
if (!$constraint instanceof ValidPermission) {
throw new UnexpectedTypeException($constraint, ValidPermission::class);
}
@ -77,7 +77,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) {