mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-24 10:49:00 +02:00
Fixed some inspection issues.
This commit is contained in:
parent
eef26f7ae6
commit
639829f5c5
97 changed files with 305 additions and 185 deletions
|
@ -21,7 +21,6 @@
|
|||
namespace App\Validator\Constraints\BigDecimal;
|
||||
|
||||
use Symfony\Component\Validator\Constraints\GreaterThan;
|
||||
use Symfony\Component\Validator\Constraints\NumberConstraintTrait;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
namespace App\Validator\Constraints\BigDecimal;
|
||||
|
||||
use Symfony\Component\Validator\Constraints\GreaterThanOrEqual;
|
||||
use Symfony\Component\Validator\Constraints\NumberConstraintTrait;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
|
|
|
@ -4,13 +4,15 @@ namespace App\Validator\Constraints\BigDecimal;
|
|||
|
||||
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
|
||||
|
||||
use function is_array;
|
||||
|
||||
trait BigNumberConstraintTrait
|
||||
{
|
||||
private function configureNumberConstraintOptions($options): array
|
||||
{
|
||||
if (null === $options) {
|
||||
$options = [];
|
||||
} elseif (!\is_array($options)) {
|
||||
} elseif (!is_array($options)) {
|
||||
$options = [$this->getDefaultOption() => $options];
|
||||
}
|
||||
|
||||
|
|
|
@ -96,8 +96,6 @@ class NoneOfItsChildrenValidator extends ConstraintValidator
|
|||
//Set the entity to a valid state
|
||||
$entity->setParent(null);
|
||||
$this->context->buildViolation($constraint->children_message)->addViolation();
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,6 +47,9 @@ use Symfony\Component\Validator\Constraints\UrlValidator;
|
|||
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
|
||||
use Symfony\Component\Validator\Exception\UnexpectedValueException;
|
||||
|
||||
use function in_array;
|
||||
use function is_object;
|
||||
|
||||
/**
|
||||
* The validator for UrlOrBuiltin.
|
||||
* It checks if the value is either a builtin ressource or a valid url.
|
||||
|
@ -63,7 +66,7 @@ class UrlOrBuiltinValidator extends UrlValidator
|
|||
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 +77,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 (\in_array($tmp[0], $constraint->allowed_placeholders, false)) {
|
||||
if (in_array($tmp[0], $constraint->allowed_placeholders, false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -48,6 +48,8 @@ use Symfony\Component\Validator\ConstraintValidator;
|
|||
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
|
||||
use Symfony\Component\Validator\Exception\UnexpectedValueException;
|
||||
|
||||
use function is_string;
|
||||
|
||||
class ValidFileFilterValidator extends ConstraintValidator
|
||||
{
|
||||
protected $filterTools;
|
||||
|
@ -73,7 +75,7 @@ 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');
|
||||
}
|
||||
|
|
|
@ -51,6 +51,9 @@ use Symfony\Component\Validator\ConstraintValidator;
|
|||
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
|
||||
use Symfony\Component\Validator\Exception\UnexpectedValueException;
|
||||
|
||||
use function is_string;
|
||||
use function strlen;
|
||||
|
||||
class ValidGoogleAuthCodeValidator extends ConstraintValidator
|
||||
{
|
||||
protected $googleAuthenticator;
|
||||
|
@ -70,7 +73,7 @@ class ValidGoogleAuthCodeValidator extends ConstraintValidator
|
|||
return;
|
||||
}
|
||||
|
||||
if (!\is_string($value)) {
|
||||
if (!is_string($value)) {
|
||||
throw new UnexpectedValueException($value, 'string');
|
||||
}
|
||||
|
||||
|
@ -79,7 +82,7 @@ class ValidGoogleAuthCodeValidator extends ConstraintValidator
|
|||
}
|
||||
|
||||
//Number must have 6 digits
|
||||
if (6 !== \strlen($value)) {
|
||||
if (6 !== strlen($value)) {
|
||||
$this->context->addViolation('validator.google_code.wrong_digit_count');
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue