Skip to content

Commit 4c5f1fc

Browse files
authored
Merge pull request #355 from norkunas/typehint
Fix phpdoc typehint
2 parents a6ee705 + e98e4c8 commit 4c5f1fc

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

src/Engine.php

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,20 @@ public function __construct(Client $client)
2121
* This method allows you to create records on your index by sending one or more objects.
2222
* Each object contains a set of attributes and values, which represents a full record on an index.
2323
*
24-
* @param array|SearchableEntity $searchableEntities
24+
* @param array<SearchableEntity>|SearchableEntity $searchableEntities
2525
*
2626
* @throws ApiException
2727
*/
2828
public function index($searchableEntities): array
2929
{
3030
if ($searchableEntities instanceof SearchableEntity) {
31-
/** @var SearchableEntity[] $searchableEntities */
3231
$searchableEntities = [$searchableEntities];
3332
}
3433

3534
$data = [];
3635
foreach ($searchableEntities as $entity) {
3736
$searchableArray = $entity->getSearchableArray();
38-
if (null === $searchableArray || 0 === \count($searchableArray)) {
37+
if ([] === $searchableArray) {
3938
continue;
4039
}
4140

@@ -62,18 +61,16 @@ public function index($searchableEntities): array
6261
* Remove objects from an index using their object UIDs.
6362
* This method enables you to remove one or more objects from an index.
6463
*
65-
* @param array|SearchableEntity $searchableEntities
64+
* @param array<SearchableEntity>|SearchableEntity $searchableEntities
6665
*/
6766
public function remove($searchableEntities): array
6867
{
6968
if ($searchableEntities instanceof SearchableEntity) {
70-
/** @var SearchableEntity[] $searchableEntities */
7169
$searchableEntities = [$searchableEntities];
7270
}
7371

7472
$data = [];
7573

76-
/** @var SearchableEntity $entity */
7774
foreach ($searchableEntities as $entity) {
7875
$searchableArray = $entity->getSearchableArray();
7976
if (0 === \count($searchableArray)) {
@@ -111,9 +108,8 @@ public function remove($searchableEntities): array
111108
public function clear(string $indexUid): array
112109
{
113110
$index = $this->client->index($indexUid);
114-
$task = $index->deleteAllDocuments();
115111

116-
return $task;
112+
return $index->deleteAllDocuments();
117113
}
118114

119115
/**
@@ -129,11 +125,7 @@ public function delete(string $indexUid): ?array
129125
*/
130126
public function search(string $query, string $indexUid, array $searchParams): array
131127
{
132-
if ('' === $query) {
133-
$query = null;
134-
}
135-
136-
return $this->client->index($indexUid)->rawSearch($query, $searchParams);
128+
return $this->client->index($indexUid)->rawSearch('' !== $query ? $query : null, $searchParams);
137129
}
138130

139131
/**

0 commit comments

Comments
 (0)