Skip to content

Commit 450a030

Browse files
Merge #257
257: Improve static analysis in SearchService r=brunoocasali a=norkunas # Pull Request ## Related issue Fixes #<issue_number> ## What does this PR do? - Improves static analysis ## PR checklist Please check if your PR fulfills the following requirements: - [ ] Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)? - [x] Have you read the contributing guidelines? - [x] Have you made sure that the title is accurate and descriptive of the changes? Co-authored-by: Tomas <[email protected]>
2 parents 5795e6e + 43b466a commit 450a030

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

src/SearchService.php

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,47 @@ interface SearchService
1515
public const RESULT_KEY_OBJECTID = 'objectID';
1616

1717
/**
18-
* @param string|object $className
18+
* @param class-string|object $className
1919
*/
2020
public function isSearchable($className): bool;
2121

22+
/**
23+
* @return list<class-string>
24+
*/
2225
public function getSearchable(): array;
2326

2427
public function getConfiguration(): Collection;
2528

2629
/**
2730
* Get the index name for the given `$className`.
31+
*
32+
* @param class-string $className
2833
*/
2934
public function searchableAs(string $className): string;
3035

3136
public function index(ObjectManager $objectManager, $searchable): array;
3237

3338
public function remove(ObjectManager $objectManager, $searchable): array;
3439

40+
/**
41+
* @param class-string $className
42+
*/
3543
public function clear(string $className): array;
3644

45+
/**
46+
* @param class-string $className
47+
*/
3748
public function delete(string $className): ?array;
3849

3950
public function deleteByIndexName(string $indexName): ?array;
4051

52+
/**
53+
* @template T of object
54+
*
55+
* @param class-string<T> $className
56+
*
57+
* @return list<T>
58+
*/
4159
public function search(
4260
ObjectManager $objectManager,
4361
string $className,
@@ -49,12 +67,19 @@ public function search(
4967
* Get the raw search result.
5068
*
5169
* @see https://docs.meilisearch.com/reference/api/search.html#response
70+
*
71+
* @param class-string $className
5272
*/
5373
public function rawSearch(
5474
string $className,
5575
string $query = '',
5676
array $searchParams = []
5777
): array;
5878

79+
/**
80+
* @param class-string $className
81+
*
82+
* @return int<0, max>
83+
*/
5984
public function count(string $className, string $query = '', array $searchParams = []): int;
6085
}

src/Services/MeilisearchService.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,21 @@ final class MeilisearchService implements SearchService
2727
private Engine $engine;
2828
private Collection $configuration;
2929
private PropertyAccessor $propertyAccessor;
30+
/**
31+
* @var list<class-string>
32+
*/
3033
private array $searchableEntities;
34+
/**
35+
* @var array<class-string, list<class-string>>
36+
*/
3137
private array $entitiesAggregators;
38+
/**
39+
* @var list<class-string<Aggregator>>
40+
*/
3241
private array $aggregators;
42+
/**
43+
* @var array<class-string, array<string>>
44+
*/
3345
private array $classToSerializerGroup;
3446
private array $indexIfMapping;
3547

0 commit comments

Comments
 (0)