Skip to content

Commit aa06a3d

Browse files
authored
Merge branch 'main' into meili-bot/bump-version
2 parents 3d128eb + 20f68c7 commit aa06a3d

File tree

4 files changed

+36
-19
lines changed

4 files changed

+36
-19
lines changed

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@
4444
"php-cs-fixer/shim": "^3.59.3",
4545
"guzzlehttp/guzzle": "^7.8.1",
4646
"http-interop/http-factory-guzzle": "^1.2.0",
47-
"phpstan/phpstan": "^1.11.5",
47+
"phpstan/phpstan": "^2.0",
4848
"phpstan/extension-installer": "^1.4.1",
49-
"phpstan/phpstan-strict-rules": "^1.6.0",
50-
"phpstan/phpstan-phpunit": "^1.4.0",
51-
"phpstan/phpstan-deprecation-rules": "^1.2.0"
49+
"phpstan/phpstan-strict-rules": "^2.0",
50+
"phpstan/phpstan-phpunit": "^2.0",
51+
"phpstan/phpstan-deprecation-rules": "^2.0"
5252
},
5353
"scripts": {
5454
"lint": [

src/Http/Client.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ public function __construct(
4747
$this->http = $httpClient ?? Psr18ClientDiscovery::find();
4848
$this->requestFactory = $reqFactory ?? Psr17FactoryDiscovery::findRequestFactory();
4949
$this->streamFactory = $streamFactory ?? Psr17FactoryDiscovery::findStreamFactory();
50-
$this->headers = array_filter([
50+
$this->headers = [
5151
'User-Agent' => implode(';', array_merge($clientAgents, [Meilisearch::qualifiedVersion()])),
52-
]);
52+
];
5353
if (null !== $apiKey && '' !== $apiKey) {
5454
$this->headers['Authorization'] = \sprintf('Bearer %s', $apiKey);
5555
}

src/Search/SearchResult.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,16 @@ class SearchResult implements \Countable, \IteratorAggregate
1919
* and its value will not be modified by the methods in this class.
2020
* Please, use `hitsCount` if you want to know the real size of the `hits` array at any time.
2121
*/
22-
private ?int $estimatedTotalHits;
23-
private ?int $hitsCount;
24-
private ?int $offset;
25-
private ?int $limit;
26-
private ?int $semanticHitCount;
22+
private ?int $estimatedTotalHits = null;
23+
private int $hitsCount;
24+
private ?int $offset = null;
25+
private ?int $limit = null;
26+
private int $semanticHitCount;
2727

28-
private ?int $hitsPerPage;
29-
private ?int $page;
30-
private ?int $totalPages;
31-
private ?int $totalHits;
28+
private ?int $hitsPerPage = null;
29+
private ?int $page = null;
30+
private ?int $totalPages = null;
31+
private ?int $totalHits = null;
3232

3333
private int $processingTimeMs;
3434
private bool $numberedPagination;
@@ -126,12 +126,12 @@ public function getHits(): array
126126
return $this->hits;
127127
}
128128

129-
public function getOffset(): int
129+
public function getOffset(): ?int
130130
{
131131
return $this->offset;
132132
}
133133

134-
public function getLimit(): int
134+
public function getLimit(): ?int
135135
{
136136
return $this->limit;
137137
}
@@ -154,7 +154,7 @@ public function count(): int
154154
return $this->hitsCount;
155155
}
156156

157-
public function getEstimatedTotalHits(): int
157+
public function getEstimatedTotalHits(): ?int
158158
{
159159
return $this->estimatedTotalHits;
160160
}

tests/Endpoints/SearchTest.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,17 @@ public function testBasicSearch(): void
2626
$response = $this->index->search('prince');
2727

2828
$this->assertEstimatedPagination($response->toArray());
29-
self::assertSame(2, $response->getEstimatedTotalHits());
3029
self::assertCount(2, $response->getHits());
3130

31+
self::assertSame(2, $response->getEstimatedTotalHits());
32+
self::assertSame(0, $response->getOffset());
33+
self::assertSame(20, $response->getLimit());
34+
35+
self::assertNull($response->getHitsPerPage());
36+
self::assertNull($response->getPage());
37+
self::assertNull($response->getTotalPages());
38+
self::assertNull($response->getTotalHits());
39+
3240
$response = $this->index->search('prince', [], [
3341
'raw' => true,
3442
]);
@@ -44,6 +52,15 @@ public function testBasicSearchWithFinitePagination(): void
4452
$this->assertFinitePagination($response->toArray());
4553
self::assertCount(2, $response->getHits());
4654

55+
self::assertSame(2, $response->getHitsPerPage());
56+
self::assertSame(1, $response->getPage());
57+
self::assertSame(1, $response->getTotalPages());
58+
self::assertSame(2, $response->getTotalHits());
59+
60+
self::assertNull($response->getEstimatedTotalHits());
61+
self::assertNull($response->getOffset());
62+
self::assertNull($response->getLimit());
63+
4764
$response = $this->index->search('prince', ['hitsPerPage' => 2], [
4865
'raw' => true,
4966
]);

0 commit comments

Comments
 (0)