Fixed strict typing errors

This commit is contained in:
Jan Böhmer 2023-06-11 19:05:27 +02:00
parent 6a2ff9d153
commit e5a14557a2
6 changed files with 32 additions and 23 deletions

View file

@ -40,10 +40,12 @@ abstract class AbstractConstraint implements FilterInterface
*/
abstract public function isEnabled(): bool;
public function __construct(/**
public function __construct(
/**
* @var string The property where this BooleanConstraint should apply to
*/
protected string $property, string $identifier = null)
protected string $property,
string $identifier = null)
{
$this->identifier = $identifier ?? $this->generateParameterIdentifier($property);
}

View file

@ -26,8 +26,12 @@ use Doctrine\ORM\QueryBuilder;
class BooleanConstraint extends AbstractConstraint
{
public function __construct(string $property, string $identifier = null, /** @var bool|null The value of our constraint */
protected ?bool $value = null)
public function __construct(
string $property,
string $identifier = null,
/** @var bool|null The value of our constraint */
protected ?bool $value = null
)
{
parent::__construct($property, $identifier);
}

View file

@ -31,12 +31,12 @@ class ChoiceConstraint extends AbstractConstraint
/**
* @var string[]|int[] The values to compare to
*/
protected array $value;
protected array $value = [];
/**
* @var string The operator to use
*/
protected string $operator;
protected string $operator = "";
/**
* @return string[]|int[]

View file

@ -43,7 +43,12 @@ class EntityConstraint extends AbstractConstraint
* @param null $value
* @param string $operator
*/
public function __construct(protected ?NodesListBuilder $nodesListBuilder, protected string $class, string $property, string $identifier = null, protected $value = null, protected ?string $operator = '')
public function __construct(protected ?NodesListBuilder $nodesListBuilder,
protected string $class,
string $property,
string $identifier = null,
protected $value = null,
protected ?string $operator = null)
{
if (!$nodesListBuilder instanceof NodesListBuilder && $this->isStructural()) {
throw new \InvalidArgumentException('NodesListBuilder must be provided for structural entities');

View file

@ -34,12 +34,12 @@ class InstanceOfConstraint extends AbstractConstraint
/**
* @var string[] The values to compare to (fully qualified class names)
*/
protected array $value;
protected array $value = [];
/**
* @var string The operator to use
*/
protected string $operator;
protected string $operator = "";
/**
* @return string[]

View file

@ -63,17 +63,15 @@ class NumberConstraint extends AbstractConstraint
}
public function __construct(
string $property,
string $identifier = null,
/**
* @param float|null|int|\DateTimeInterface $value1
* @param float|null|int|\DateTimeInterface $value2
*/
public function __construct(string $property, string $identifier = null, /**
* The value1 used for comparison (this is the main one used for all mono-value comparisons)
*/
protected float|int|\DateTimeInterface|null $value1 = null, /**
* @var string|null The operator to use
*/
protected ?string $operator = null, /**
protected float|int|\DateTimeInterface|null $value1 = null,
protected ?string $operator = null,
/**
* The second value used when operator is RANGE; this is the upper bound of the range
*/
protected float|int|\DateTimeInterface|null $value2 = null)