From e98e4c82f16472092c2ddde0b5b25793c89d70fb Mon Sep 17 00:00:00 2001 From: Tomas Date: Fri, 4 Oct 2024 22:36:21 +0300 Subject: [PATCH] Fix phpdoc typehint --- src/Engine.php | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/src/Engine.php b/src/Engine.php index 662f21a..82353ca 100644 --- a/src/Engine.php +++ b/src/Engine.php @@ -21,21 +21,20 @@ public function __construct(Client $client) * This method allows you to create records on your index by sending one or more objects. * Each object contains a set of attributes and values, which represents a full record on an index. * - * @param array|SearchableEntity $searchableEntities + * @param array|SearchableEntity $searchableEntities * * @throws ApiException */ public function index($searchableEntities): array { if ($searchableEntities instanceof SearchableEntity) { - /** @var SearchableEntity[] $searchableEntities */ $searchableEntities = [$searchableEntities]; } $data = []; foreach ($searchableEntities as $entity) { $searchableArray = $entity->getSearchableArray(); - if (null === $searchableArray || 0 === \count($searchableArray)) { + if ([] === $searchableArray) { continue; } @@ -62,18 +61,16 @@ public function index($searchableEntities): array * Remove objects from an index using their object UIDs. * This method enables you to remove one or more objects from an index. * - * @param array|SearchableEntity $searchableEntities + * @param array|SearchableEntity $searchableEntities */ public function remove($searchableEntities): array { if ($searchableEntities instanceof SearchableEntity) { - /** @var SearchableEntity[] $searchableEntities */ $searchableEntities = [$searchableEntities]; } $data = []; - /** @var SearchableEntity $entity */ foreach ($searchableEntities as $entity) { $searchableArray = $entity->getSearchableArray(); if (0 === \count($searchableArray)) { @@ -111,9 +108,8 @@ public function remove($searchableEntities): array public function clear(string $indexUid): array { $index = $this->client->index($indexUid); - $task = $index->deleteAllDocuments(); - return $task; + return $index->deleteAllDocuments(); } /** @@ -129,11 +125,7 @@ public function delete(string $indexUid): ?array */ public function search(string $query, string $indexUid, array $searchParams): array { - if ('' === $query) { - $query = null; - } - - return $this->client->index($indexUid)->rawSearch($query, $searchParams); + return $this->client->index($indexUid)->rawSearch('' !== $query ? $query : null, $searchParams); } /**