Skip to content

Commit

Permalink
fix: property should be a string or null
Browse files Browse the repository at this point in the history
  • Loading branch information
jrean committed Dec 23, 2023
1 parent 5c865d0 commit a1370d3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
15 changes: 9 additions & 6 deletions src/Doctrine/Rest/Action/CollectionAction.php
Expand Up @@ -22,7 +22,7 @@ class CollectionAction extends RestAction
/**
* Field that can be filtered if filter is string.
*
* @var string
* @var string|null
*/
protected $filterProperty;

Expand All @@ -41,11 +41,11 @@ class CollectionAction extends RestAction
protected $filterable = [];

/**
* @param string $property
* @param string|null $property
*
* @return $this
*/
public function setFilterProperty($property)
public function setFilterProperty(?string $property): self
{
$this->filterProperty = $property;
return $this;
Expand All @@ -56,7 +56,7 @@ public function setFilterProperty($property)
*
* @return $this
*/
public function setFilterable(array $filterable)
public function setFilterable(array $filterable): self
{
$this->filterable = $filterable;
return $this;
Expand All @@ -82,6 +82,9 @@ public function setFilterPropertyStrict(bool $filterPropertyStrict): self
return $this;
}

/**
* @return bool
*/
public function getFilterPropertyStrict()
{
return $this->filterPropertyStrict;
Expand Down Expand Up @@ -150,7 +153,7 @@ function(int $page) use ($request) {
* @throws \Doctrine\ORM\Query\QueryException
* @return $this
*/
protected function applyPagination(RestRequestContract $request, QueryBuilder $qb)
protected function applyPagination(RestRequestContract $request, QueryBuilder $qb): self
{
$qb->addCriteria(
new Criteria(null,
Expand All @@ -170,7 +173,7 @@ protected function applyPagination(RestRequestContract $request, QueryBuilder $q
* @throws \Doctrine\ORM\Query\QueryException
* @return $this
*/
protected function applyFilter(RestRequestContract $request, QueryBuilder $qb)
protected function applyFilter(RestRequestContract $request, QueryBuilder $qb): self
{
$qb->addCriteria(
CriteriaChain::create($this->filterParsers($request))->process()
Expand Down
4 changes: 2 additions & 2 deletions src/Doctrine/Rest/Action/Related/RelatedCollectionAction.php
Expand Up @@ -60,7 +60,7 @@ public function base()
* @return $this
* @throws \Pz\Doctrine\Rest\Exceptions\RestException
*/
protected function applyFilter(RestRequestContract $request, QueryBuilder $qb)
protected function applyFilter(RestRequestContract $request, QueryBuilder $qb): self
{
$entity = $this->base()->findById($request->getId());

Expand All @@ -70,6 +70,6 @@ protected function applyFilter(RestRequestContract $request, QueryBuilder $qb)
$qb->innerJoin($qb->getRootAliases()[0].'.'.$this->mappedBy(), $this->mappedBy());
$qb->addCriteria($relateCriteria);

parent::applyFilter($request, $qb);
return parent::applyFilter($request, $qb);
}
}
4 changes: 2 additions & 2 deletions src/Doctrine/Rest/QueryParser/SearchFilterParser.php
Expand Up @@ -28,13 +28,13 @@ class SearchFilterParser extends FilterParserAbstract
* StringParser constructor.
*
* @param RestRequestContract $request
* @param string $property Property name that will be filtered by query.
* @param string|null $property Property name to be filtered by.
* @param string $searchKey
* @param bool $strict
*/
public function __construct(
RestRequestContract $request,
string $property,
?string $property,
string $searchKey = self::SEARCH_KEY,
bool $strict = false
) {
Expand Down

0 comments on commit a1370d3

Please sign in to comment.