Skip to content

Commit

Permalink
Revert "Fix issue with error parsing cuz in non manticore like respon…
Browse files Browse the repository at this point in the history
…ses it may contain array"

This reverts commit 495b9b4.
  • Loading branch information
donhardman committed Dec 12, 2024
1 parent 74c1c78 commit 6c0272b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 10 deletions.
8 changes: 4 additions & 4 deletions src/ManticoreSearch/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ class Response {
protected bool $hasData = false;

/**
* @var string|array<string,string> $error
* @var string $error
*/
protected string|array $error = '';
protected string $error = '';

/**
* @var string $warning
Expand Down Expand Up @@ -69,9 +69,9 @@ private function __construct(
}

/**
* @return null|string|array<string,string>
* @return ?string
*/
public function getError(): null|string|array {
public function getError(): ?string {
return $this->error;
}

Expand Down
5 changes: 1 addition & 4 deletions src/Task/TaskResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,7 @@ public static function fromResponse(Response $response): static {
}

if ($response->hasError()) {
// In this case error only string and may not be array, cuz array is only for raw (non manticore)
/** @var string $error */
$error = $response->getError() ?? '';
return new static(null, $error, $response->getWarning() ?? '');
return new static(null, $response->getError() ?? '', $response->getWarning() ?? '');
}

// No error
Expand Down
1 change: 0 additions & 1 deletion test/BuddyCore/GetManticoreResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ public function testFailResponsesToJSONRequest(): void {
$this->setUpServer(true);
$query = '{"index":"test","id":1,"doc":{"col1" : 1}}';
$mntResp = Response::fromBody(MockManticoreServer::JSON_INSERT_RESPONSE['fail']);

$this->assertEquals(
$mntResp,
$this->httpClient->sendRequest($query, ManticoreEndpoint::Insert->value)
Expand Down
2 changes: 1 addition & 1 deletion test/src/Lib/SocketError.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

final class SocketError extends Exception {

public function __construct(string $message = null, int $code = 0, ?Throwable $previous = null) {
public function __construct(?string $message = null, int $code = 0, ?Throwable $previous = null) {
if (isset($message)) {
$message .= ': ';
}
Expand Down

0 comments on commit 6c0272b

Please sign in to comment.