diff --git a/src/contracts/Repository/Values/Content/Query/Criterion.php b/src/contracts/Repository/Values/Content/Query/Criterion.php index 94899bdd5b..7e80664698 100644 --- a/src/contracts/Repository/Values/Content/Query/Criterion.php +++ b/src/contracts/Repository/Values/Content/Query/Criterion.php @@ -25,7 +25,7 @@ abstract class Criterion implements CriterionInterface /** * The value(s) matched by the criteria. * - * @var string[]|int[]|int|string|bool + * @var scalar[]|scalar */ public $value; @@ -50,7 +50,7 @@ abstract class Criterion implements CriterionInterface * @param string|null $operator * The operator the Criterion uses. If null is given, will default to Operator::IN if $value is an array, * Operator::EQ if it is not. - * @param string[]|int[]|int|string|bool $value + * @param scalar[]|scalar $value * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Value|null $valueData * * @todo Add a dedicated exception diff --git a/src/contracts/Repository/Values/Content/Query/Criterion/Image/AbstractImageCompositeCriterion.php b/src/contracts/Repository/Values/Content/Query/Criterion/Image/AbstractImageCompositeCriterion.php index f3b43d1e99..4baf235d00 100644 --- a/src/contracts/Repository/Values/Content/Query/Criterion/Image/AbstractImageCompositeCriterion.php +++ b/src/contracts/Repository/Values/Content/Query/Criterion/Image/AbstractImageCompositeCriterion.php @@ -16,8 +16,8 @@ * @template TImageCriteria of array * * @phpstan-type Range array{ - * min?: int|null, - * max?: int|null, + * min?: numeric|null, + * max?: numeric|null, * } */ abstract class AbstractImageCompositeCriterion extends CompositeCriterion @@ -91,17 +91,21 @@ protected function validate( } /** - * @param array{min?: int|null} $data + * @param array{min?: numeric|null} $data + * + * @return numeric */ - protected function getMinValue(array $data): int + protected function getMinValue(array $data) { return $data['min'] ?? 0; } /** - * @param array{max?: int|null} $data + * @param array{max?: numeric|null} $data + * + * @return numeric|null */ - protected function getMaxValue(array $data): ?int + protected function getMaxValue(array $data) { return $data['max'] ?? null; } diff --git a/src/contracts/Repository/Values/Content/Query/Criterion/Image/AbstractImageRangeCriterion.php b/src/contracts/Repository/Values/Content/Query/Criterion/Image/AbstractImageRangeCriterion.php index 31bc7c6c3d..b72c6f6dd6 100644 --- a/src/contracts/Repository/Values/Content/Query/Criterion/Image/AbstractImageRangeCriterion.php +++ b/src/contracts/Repository/Values/Content/Query/Criterion/Image/AbstractImageRangeCriterion.php @@ -16,19 +16,22 @@ abstract class AbstractImageRangeCriterion extends Criterion { /** + * @param numeric $minValue + * @param numeric|null $maxValue + * * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException */ public function __construct( string $fieldDefIdentifier, - int $minValue = 0, - ?int $maxValue = null + $minValue = 0, + $maxValue = null ) { $this->validate($minValue, $maxValue); $value[] = $minValue; $operator = Operator::GTE; - if ($maxValue >= 1) { + if ($maxValue > 0) { $operator = Operator::BETWEEN; $value[] = $maxValue; } @@ -57,12 +60,13 @@ public function getSpecifications(): array } /** + * @param numeric $minValue + * @param numeric|null $maxValue + * * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException */ - protected function validate( - int $minValue, - ?int $maxValue - ): void { + protected function validate($minValue, $maxValue): void + { if ($minValue < 0) { throw new InvalidArgumentException( '$minValue', @@ -72,11 +76,11 @@ protected function validate( if ( null !== $maxValue - && $maxValue < 1 + && $maxValue <= 0 ) { throw new InvalidArgumentException( '$maxValue', - 'Value should be grater or equal 1' + 'Value should be grater than 0' ); } diff --git a/src/contracts/Repository/Values/Content/Query/Criterion/Image/FileSize.php b/src/contracts/Repository/Values/Content/Query/Criterion/Image/FileSize.php index 63fc9f64d9..f3f7f2db41 100644 --- a/src/contracts/Repository/Values/Content/Query/Criterion/Image/FileSize.php +++ b/src/contracts/Repository/Values/Content/Query/Criterion/Image/FileSize.php @@ -11,12 +11,15 @@ final class FileSize extends AbstractImageRangeCriterion { /** + * @param numeric $minFileSize + * @param numeric|null $maxFileSize + * * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException */ public function __construct( string $fieldDefIdentifier, - int $minFileSize = 0, - ?int $maxFileSize = null + $minFileSize = 0, + $maxFileSize = null ) { if ($minFileSize > 0) { $minFileSize *= 1024 * 1024;