Skip to content

Commit

Permalink
Merge branch 'main' into bump-meilisearch-v1.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
curquiza authored Feb 16, 2024
2 parents 79e18c9 + a0bcb5a commit 8fea95e
Show file tree
Hide file tree
Showing 14 changed files with 41 additions and 41 deletions.
8 changes: 4 additions & 4 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ class Client
*/
public function __construct(
string $url,
string $apiKey = null,
ClientInterface $httpClient = null,
RequestFactoryInterface $requestFactory = null,
?string $apiKey = null,
?ClientInterface $httpClient = null,
?RequestFactoryInterface $requestFactory = null,
array $clientAgents = [],
StreamFactoryInterface $streamFactory = null
?StreamFactoryInterface $streamFactory = null
) {
$this->http = new MeilisearchClientAdapter($url, $apiKey, $httpClient, $requestFactory, $clientAgents, $streamFactory);
$this->index = new Indexes($this->http);
Expand Down
2 changes: 1 addition & 1 deletion src/Contracts/Endpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ abstract class Endpoint
protected Http $http;
protected ?string $apiKey;

public function __construct(Http $http, string $apiKey = null)
public function __construct(Http $http, ?string $apiKey = null)
{
$this->http = $http;
$this->apiKey = $apiKey;
Expand Down
4 changes: 2 additions & 2 deletions src/Contracts/Http.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ interface Http
{
public function get(string $path, array $query = []);

public function post(string $path, $body = null, array $query = [], string $contentType = null);
public function post(string $path, $body = null, array $query = [], ?string $contentType = null);

public function put(string $path, $body = null, array $query = [], string $contentType = null);
public function put(string $path, $body = null, array $query = [], ?string $contentType = null);

public function patch(string $path, $body = null, array $query = []);

Expand Down
32 changes: 16 additions & 16 deletions src/Endpoints/Delegates/HandlesDocuments.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@

trait HandlesDocuments
{
public function getDocument($documentId, array $fields = null)
public function getDocument($documentId, ?array $fields = null)
{
$this->assertValidDocumentId($documentId);
$query = isset($fields) ? ['fields' => implode(',', $fields)] : [];

return $this->http->get(self::PATH.'/'.$this->uid.'/documents/'.$documentId, $query);
}

public function getDocuments(DocumentsQuery $options = null): DocumentsResults
public function getDocuments(?DocumentsQuery $options = null): DocumentsResults
{
try {
$options = $options ?? new DocumentsQuery();
Expand All @@ -38,27 +38,27 @@ public function getDocuments(DocumentsQuery $options = null): DocumentsResults
}
}

public function addDocuments(array $documents, string $primaryKey = null)
public function addDocuments(array $documents, ?string $primaryKey = null)
{
return $this->http->post(self::PATH.'/'.$this->uid.'/documents', $documents, ['primaryKey' => $primaryKey]);
}

public function addDocumentsJson(string $documents, string $primaryKey = null)
public function addDocumentsJson(string $documents, ?string $primaryKey = null)
{
return $this->http->post(self::PATH.'/'.$this->uid.'/documents', $documents, ['primaryKey' => $primaryKey], 'application/json');
}

public function addDocumentsCsv(string $documents, string $primaryKey = null, string $delimiter = null)
public function addDocumentsCsv(string $documents, ?string $primaryKey = null, ?string $delimiter = null)
{
return $this->http->post(self::PATH.'/'.$this->uid.'/documents', $documents, ['primaryKey' => $primaryKey, 'csvDelimiter' => $delimiter], 'text/csv');
}

public function addDocumentsNdjson(string $documents, string $primaryKey = null)
public function addDocumentsNdjson(string $documents, ?string $primaryKey = null)
{
return $this->http->post(self::PATH.'/'.$this->uid.'/documents', $documents, ['primaryKey' => $primaryKey], 'application/x-ndjson');
}

public function addDocumentsInBatches(array $documents, ?int $batchSize = 1000, string $primaryKey = null)
public function addDocumentsInBatches(array $documents, ?int $batchSize = 1000, ?string $primaryKey = null)
{
$promises = [];
foreach (self::batch($documents, $batchSize) as $batch) {
Expand All @@ -68,7 +68,7 @@ public function addDocumentsInBatches(array $documents, ?int $batchSize = 1000,
return $promises;
}

public function addDocumentsCsvInBatches(string $documents, ?int $batchSize = 1000, string $primaryKey = null, string $delimiter = null)
public function addDocumentsCsvInBatches(string $documents, ?int $batchSize = 1000, ?string $primaryKey = null, ?string $delimiter = null)
{
$promises = [];

Expand All @@ -79,7 +79,7 @@ public function addDocumentsCsvInBatches(string $documents, ?int $batchSize = 10
return $promises;
}

public function addDocumentsNdjsonInBatches(string $documents, ?int $batchSize = 1000, string $primaryKey = null)
public function addDocumentsNdjsonInBatches(string $documents, ?int $batchSize = 1000, ?string $primaryKey = null)
{
$promises = [];
foreach (self::batchNdjsonString($documents, $batchSize) as $batch) {
Expand All @@ -89,27 +89,27 @@ public function addDocumentsNdjsonInBatches(string $documents, ?int $batchSize =
return $promises;
}

public function updateDocuments(array $documents, string $primaryKey = null)
public function updateDocuments(array $documents, ?string $primaryKey = null)
{
return $this->http->put(self::PATH.'/'.$this->uid.'/documents', $documents, ['primaryKey' => $primaryKey]);
}

public function updateDocumentsJson(string $documents, string $primaryKey = null)
public function updateDocumentsJson(string $documents, ?string $primaryKey = null)
{
return $this->http->put(self::PATH.'/'.$this->uid.'/documents', $documents, ['primaryKey' => $primaryKey], 'application/json');
}

public function updateDocumentsCsv(string $documents, string $primaryKey = null, string $delimiter = null)
public function updateDocumentsCsv(string $documents, ?string $primaryKey = null, ?string $delimiter = null)
{
return $this->http->put(self::PATH.'/'.$this->uid.'/documents', $documents, ['primaryKey' => $primaryKey, 'csvDelimiter' => $delimiter], 'text/csv');
}

public function updateDocumentsNdjson(string $documents, string $primaryKey = null)
public function updateDocumentsNdjson(string $documents, ?string $primaryKey = null)
{
return $this->http->put(self::PATH.'/'.$this->uid.'/documents', $documents, ['primaryKey' => $primaryKey], 'application/x-ndjson');
}

public function updateDocumentsInBatches(array $documents, ?int $batchSize = 1000, string $primaryKey = null)
public function updateDocumentsInBatches(array $documents, ?int $batchSize = 1000, ?string $primaryKey = null)
{
$promises = [];
foreach (self::batch($documents, $batchSize) as $batch) {
Expand All @@ -119,7 +119,7 @@ public function updateDocumentsInBatches(array $documents, ?int $batchSize = 100
return $promises;
}

public function updateDocumentsCsvInBatches(string $documents, ?int $batchSize = 1000, string $primaryKey = null, string $delimiter = null)
public function updateDocumentsCsvInBatches(string $documents, ?int $batchSize = 1000, ?string $primaryKey = null, ?string $delimiter = null)
{
$promises = [];
foreach (self::batchCsvString($documents, $batchSize) as $batch) {
Expand All @@ -129,7 +129,7 @@ public function updateDocumentsCsvInBatches(string $documents, ?int $batchSize =
return $promises;
}

public function updateDocumentsNdjsonInBatches(string $documents, ?int $batchSize = 1000, string $primaryKey = null)
public function updateDocumentsNdjsonInBatches(string $documents, ?int $batchSize = 1000, ?string $primaryKey = null)
{
$promises = [];
foreach (self::batchNdjsonString($documents, $batchSize) as $batch) {
Expand Down
2 changes: 1 addition & 1 deletion src/Endpoints/Delegates/HandlesIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ trait HandlesIndex
{
protected Indexes $index;

public function getIndexes(IndexesQuery $options = null): IndexesResults
public function getIndexes(?IndexesQuery $options = null): IndexesResults
{
return $this->index->all($options ?? null);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Endpoints/Delegates/HandlesKeys.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ trait HandlesKeys
{
protected Keys $keys;

public function getKeys(KeysQuery $options = null): KeysResults
public function getKeys(?KeysQuery $options = null): KeysResults
{
return $this->keys->all($options);
}
Expand Down
6 changes: 3 additions & 3 deletions src/Endpoints/Delegates/HandlesTasks.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function getTask($uid): array
return $this->tasks->get($uid);
}

public function getTasks(TasksQuery $options = null): TasksResults
public function getTasks(?TasksQuery $options = null): TasksResults
{
$query = isset($options) ? $options->toArray() : [];

Expand All @@ -29,12 +29,12 @@ public function getTasks(TasksQuery $options = null): TasksResults
return new TasksResults($response);
}

public function deleteTasks(DeleteTasksQuery $options = null): array
public function deleteTasks(?DeleteTasksQuery $options = null): array
{
return $this->tasks->deleteTasks($options);
}

public function cancelTasks(CancelTasksQuery $options = null): array
public function cancelTasks(?CancelTasksQuery $options = null): array
{
return $this->tasks->cancelTasks($options);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Endpoints/Indexes.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function create(string $uid, array $options = []): array
return $this->http->post(self::PATH, $options);
}

public function all(IndexesQuery $options = null): IndexesResults
public function all(?IndexesQuery $options = null): IndexesResults
{
$indexes = [];
$query = isset($options) ? $options->toArray() : [];
Expand Down Expand Up @@ -159,7 +159,7 @@ public function getTask($uid): array
return $this->http->get('/tasks/'.$uid);
}

public function getTasks(TasksQuery $options = null): TasksResults
public function getTasks(?TasksQuery $options = null): TasksResults
{
$options = $options ?? new TasksQuery();

Expand Down
2 changes: 1 addition & 1 deletion src/Endpoints/Keys.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public function get($keyOrUid): self
return $this->fill($response);
}

public function all(KeysQuery $options = null): KeysResults
public function all(?KeysQuery $options = null): KeysResults
{
$query = isset($options) ? $options->toArray() : [];

Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/JsonDecodingException.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

final class JsonDecodingException extends \Exception implements ExceptionInterface
{
public function __construct(string $message, int $code = 0, \Throwable $previous = null)
public function __construct(string $message, int $code = 0, ?\Throwable $previous = null)
{
parent::__construct($message, $code, $previous);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/JsonEncodingException.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

final class JsonEncodingException extends \Exception implements ExceptionInterface
{
public function __construct(string $message, int $code = 0, \Throwable $previous = null)
public function __construct(string $message, int $code = 0, ?\Throwable $previous = null)
{
parent::__construct($message, $code, $previous);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/TimeOutException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class TimeOutException extends \Exception implements ExceptionInterface
public $code;
public $message;

public function __construct(string $message = null, int $code = null, \Throwable $previous = null)
public function __construct(?string $message = null, ?int $code = null, ?\Throwable $previous = null)
{
$this->message = $message ?? 'Request timed out';
$this->code = $code ?? 408;
Expand Down
12 changes: 6 additions & 6 deletions src/Http/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ class Client implements Http
*/
public function __construct(
string $url,
string $apiKey = null,
ClientInterface $httpClient = null,
RequestFactoryInterface $reqFactory = null,
?string $apiKey = null,
?ClientInterface $httpClient = null,
?RequestFactoryInterface $reqFactory = null,
array $clientAgents = [],
StreamFactoryInterface $streamFactory = null
?StreamFactoryInterface $streamFactory = null
) {
$this->baseUrl = $url;
$this->http = $httpClient ?? Psr18ClientDiscovery::find();
Expand Down Expand Up @@ -79,7 +79,7 @@ public function get(string $path, array $query = [])
* @throws CommunicationException
* @throws JsonEncodingException
*/
public function post(string $path, $body = null, array $query = [], string $contentType = null)
public function post(string $path, $body = null, array $query = [], ?string $contentType = null)
{
if (!\is_null($contentType)) {
$this->headers['Content-type'] = $contentType;
Expand All @@ -95,7 +95,7 @@ public function post(string $path, $body = null, array $query = [], string $cont
return $this->execute($request);
}

public function put(string $path, $body = null, array $query = [], string $contentType = null)
public function put(string $path, $body = null, array $query = [], ?string $contentType = null)
{
if (!\is_null($contentType)) {
$this->headers['Content-type'] = $contentType;
Expand Down
2 changes: 1 addition & 1 deletion src/Meilisearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class Meilisearch
{
public const VERSION = '1.6.0';
public const VERSION = '1.6.1';

public static function qualifiedVersion()
{
Expand Down

0 comments on commit 8fea95e

Please sign in to comment.