Skip to content

Commit

Permalink
[Pagerfanta] Fixed incorrect return types of SearchHitAdapterFactory …
Browse files Browse the repository at this point in the history
…methods
  • Loading branch information
alongosz committed Dec 11, 2024
1 parent 604e48a commit 58d0f4b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use Ibexa\Core\Pagination\Pagerfanta\ContentSearchHitAdapter;
use Ibexa\Core\Pagination\Pagerfanta\FixedSearchResultHitAdapter;
use Ibexa\Core\Pagination\Pagerfanta\LocationSearchHitAdapter;
use Pagerfanta\Adapter\AdapterInterface;
use Ibexa\Core\Pagination\Pagerfanta\SearchResultAdapter;

/**
* @internal
Expand All @@ -24,19 +24,14 @@
final class SearchHitAdapterFactory implements SearchHitAdapterFactoryInterface
{
/** @var \Ibexa\Contracts\Core\Repository\SearchService */
private $searchService;
private SearchService $searchService;

public function __construct(SearchService $searchService)
{
$this->searchService = $searchService;
}

/**
* @phpstan-param TSearchLanguageFilter $languageFilter
*
* @phpstan-return \Pagerfanta\Adapter\AdapterInterface<\Ibexa\Contracts\Core\Repository\Values\ValueObject>
*/
public function createAdapter(Query $query, array $languageFilter = []): AdapterInterface
public function createAdapter(Query $query, array $languageFilter = []): SearchResultAdapter
{
if ($query instanceof LocationQuery) {
return new LocationSearchHitAdapter($query, $this->searchService, $languageFilter);
Expand All @@ -45,14 +40,7 @@ public function createAdapter(Query $query, array $languageFilter = []): Adapter
return new ContentSearchHitAdapter($query, $this->searchService, $languageFilter);
}

/**
* @phpstan-return \Pagerfanta\Adapter\AdapterInterface<\Ibexa\Contracts\Core\Repository\Values\ValueObject>
*
* @phpstan-param TSearchLanguageFilter $languageFilter
*
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException
*/
public function createFixedAdapter(Query $query, array $languageFilter = []): AdapterInterface
public function createFixedAdapter(Query $query, array $languageFilter = []): SearchResultAdapter
{
if ($query instanceof LocationQuery) {
$searchResults = $this->searchService->findLocations($query, $languageFilter);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,28 @@
namespace Ibexa\Core\Pagination\Pagerfanta\AdapterFactory;

use Ibexa\Contracts\Core\Repository\Values\Content\Query;
use Pagerfanta\Adapter\AdapterInterface;
use Ibexa\Core\Pagination\Pagerfanta\SearchResultAdapter;

/**
* @internal
*
* @phpstan-import-type TSearchLanguageFilter from \Ibexa\Contracts\Core\Repository\SearchService
*/
interface SearchHitAdapterFactoryInterface
{
public function createAdapter(Query $query, array $languageFilter = []): AdapterInterface;
/**
* @phpstan-param TSearchLanguageFilter $languageFilter
*
* @phpstan-return \Ibexa\Core\Pagination\Pagerfanta\SearchResultAdapter<\Ibexa\Contracts\Core\Repository\Values\ValueObject>
*/
public function createAdapter(Query $query, array $languageFilter = []): SearchResultAdapter;

public function createFixedAdapter(Query $query, array $languageFilter = []): AdapterInterface;
/**
* @phpstan-return \Ibexa\Core\Pagination\Pagerfanta\SearchResultAdapter<\Ibexa\Contracts\Core\Repository\Values\ValueObject>
*
* @phpstan-param TSearchLanguageFilter $languageFilter
*
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException
*/
public function createFixedAdapter(Query $query, array $languageFilter = []): SearchResultAdapter;
}

0 comments on commit 58d0f4b

Please sign in to comment.