From e5a14557a27440de724b46bd4c333dba7232a51b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Sun, 11 Jun 2023 19:05:27 +0200 Subject: [PATCH] Fixed strict typing errors --- .../Constraints/AbstractConstraint.php | 6 +++-- .../Filters/Constraints/BooleanConstraint.php | 8 ++++-- .../Filters/Constraints/ChoiceConstraint.php | 4 +-- .../Filters/Constraints/EntityConstraint.php | 7 ++++- .../Constraints/InstanceOfConstraint.php | 4 +-- .../Filters/Constraints/NumberConstraint.php | 26 +++++++++---------- 6 files changed, 32 insertions(+), 23 deletions(-) diff --git a/src/DataTables/Filters/Constraints/AbstractConstraint.php b/src/DataTables/Filters/Constraints/AbstractConstraint.php index 4dc79a41..cbb62352 100644 --- a/src/DataTables/Filters/Constraints/AbstractConstraint.php +++ b/src/DataTables/Filters/Constraints/AbstractConstraint.php @@ -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); } diff --git a/src/DataTables/Filters/Constraints/BooleanConstraint.php b/src/DataTables/Filters/Constraints/BooleanConstraint.php index 1f971b0a..b3f1dc47 100644 --- a/src/DataTables/Filters/Constraints/BooleanConstraint.php +++ b/src/DataTables/Filters/Constraints/BooleanConstraint.php @@ -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); } diff --git a/src/DataTables/Filters/Constraints/ChoiceConstraint.php b/src/DataTables/Filters/Constraints/ChoiceConstraint.php index aea35571..621edfe9 100644 --- a/src/DataTables/Filters/Constraints/ChoiceConstraint.php +++ b/src/DataTables/Filters/Constraints/ChoiceConstraint.php @@ -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[] diff --git a/src/DataTables/Filters/Constraints/EntityConstraint.php b/src/DataTables/Filters/Constraints/EntityConstraint.php index df8a670c..b0eed001 100644 --- a/src/DataTables/Filters/Constraints/EntityConstraint.php +++ b/src/DataTables/Filters/Constraints/EntityConstraint.php @@ -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'); diff --git a/src/DataTables/Filters/Constraints/InstanceOfConstraint.php b/src/DataTables/Filters/Constraints/InstanceOfConstraint.php index 582a1b90..227bdaba 100644 --- a/src/DataTables/Filters/Constraints/InstanceOfConstraint.php +++ b/src/DataTables/Filters/Constraints/InstanceOfConstraint.php @@ -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[] diff --git a/src/DataTables/Filters/Constraints/NumberConstraint.php b/src/DataTables/Filters/Constraints/NumberConstraint.php index e1c741ea..cad1c6a8 100644 --- a/src/DataTables/Filters/Constraints/NumberConstraint.php +++ b/src/DataTables/Filters/Constraints/NumberConstraint.php @@ -63,20 +63,18 @@ class NumberConstraint extends AbstractConstraint } - /** - * @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, /** - * The second value used when operator is RANGE; this is the upper bound of the range - */ - protected float|int|\DateTimeInterface|null $value2 = null) + 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, + 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) { parent::__construct($property, $identifier); }