Skip to content

Commit

Permalink
Added strict types to the contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
alongosz committed Nov 19, 2024
1 parent ab96038 commit 80a3c54
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,7 @@ protected function getComparisonOperator(FieldValueCriterion $criterion): string
));
}

/**
* @return mixed
*/
protected function getComparisonValue(FieldValueCriterion $criterion)
protected function getComparisonValue(FieldValueCriterion $criterion): mixed
{
return $criterion->getValue();
}
Expand Down
2 changes: 1 addition & 1 deletion src/contracts/Values/Query/AbstractCriterionQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
abstract class AbstractCriterionQuery
{
public const DEFAULT_LIMIT = 25;
public const int DEFAULT_LIMIT = 25;

/** @var TCriterion|null */
private ?CriterionInterface $query;
Expand Down
4 changes: 2 additions & 2 deletions src/contracts/Values/Query/AbstractSortClause.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
abstract class AbstractSortClause
{
/** @final */
public const SORT_ASC = SortDirection::ASC;
public const string SORT_ASC = SortDirection::ASC;

/** @final */
public const SORT_DESC = SortDirection::DESC;
public const string SORT_DESC = SortDirection::DESC;

/**
* Sort direction.
Expand Down
37 changes: 15 additions & 22 deletions src/contracts/Values/Query/Criterion/FieldValueCriterion.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,33 @@
class FieldValueCriterion implements CriterionInterface
{
/** @final */
public const COMPARISON_EQ = '=';
public const string COMPARISON_EQ = '=';
/** @final */
public const COMPARISON_NEQ = '<>';
public const string COMPARISON_NEQ = '<>';
/** @final */
public const COMPARISON_LT = '<';
public const string COMPARISON_LT = '<';
/** @final */
public const COMPARISON_LTE = '<=';
public const string COMPARISON_LTE = '<=';
/** @final */
public const COMPARISON_GT = '>';
public const string COMPARISON_GT = '>';
/** @final */
public const COMPARISON_GTE = '>=';
public const string COMPARISON_GTE = '>=';
/** @final */
public const COMPARISON_IN = 'IN';
public const string COMPARISON_IN = 'IN';
/** @final */
public const COMPARISON_NIN = 'NIN';
public const string COMPARISON_NIN = 'NIN';
/** @final */
public const COMPARISON_CONTAINS = 'CONTAINS';
public const string COMPARISON_CONTAINS = 'CONTAINS';
/** @final */
public const COMPARISON_MEMBER_OF = 'MEMBER_OF';
public const string COMPARISON_MEMBER_OF = 'MEMBER_OF';
/** @final */
public const COMPARISON_STARTS_WITH = 'STARTS_WITH';
public const string COMPARISON_STARTS_WITH = 'STARTS_WITH';
/** @final */
public const COMPARISON_ENDS_WITH = 'ENDS_WITH';
public const string COMPARISON_ENDS_WITH = 'ENDS_WITH';

private string $field;

/** @var mixed */
private $value;
private mixed $value;

private string $operator;

Expand All @@ -57,18 +56,12 @@ public function getField(): string
return $this->field;
}

/**
* @param mixed $value
*/
public function setValue($value): void
public function setValue(mixed $value): void
{
$this->value = $value;
}

/**
* @return mixed
*/
public function getValue()
public function getValue(): mixed
{
return $this->value;
}
Expand Down
4 changes: 2 additions & 2 deletions src/contracts/Values/Query/SortDirection.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
*/
class SortDirection
{
public const ASC = 'ascending';
public const DESC = 'descending';
public const string ASC = 'ascending';
public const string DESC = 'descending';

/**
* @phpstan-assert-if-true self::ASC|self::DESC $value
Expand Down

0 comments on commit 80a3c54

Please sign in to comment.