Skip to content

Commit 92b0698

Browse files
committed
Add return type-hint to result classes
1 parent 25f6a68 commit 92b0698

File tree

4 files changed

+11
-28
lines changed

4 files changed

+11
-28
lines changed

src/Paginator/HybridPartialResults.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function __construct(ResultSet $resultSet, ElasticaToModelTransformerInte
3434
/**
3535
* {@inheritdoc}
3636
*/
37-
public function toArray()
37+
public function toArray(): array
3838
{
3939
return $this->transformer->hybridTransform($this->resultSet->getResults());
4040
}

src/Paginator/PartialResultsInterface.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,16 @@ interface PartialResultsInterface
1515
{
1616
/**
1717
* Returns the paginated results.
18-
*
19-
* @return array
2018
*/
21-
public function toArray();
19+
public function toArray(): array;
2220

2321
/**
2422
* Returns the number of results.
25-
*
26-
* @return int The number of results
2723
*/
28-
public function getTotalHits();
24+
public function getTotalHits(): int;
2925

3026
/**
3127
* Returns the aggregations.
32-
*
33-
* @return array
3428
*/
35-
public function getAggregations();
29+
public function getAggregations(): array;
3630
}

src/Paginator/RawPartialResults.php

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function __construct(ResultSet $resultSet)
2929
/**
3030
* {@inheritdoc}
3131
*/
32-
public function toArray()
32+
public function toArray(): array
3333
{
3434
return \array_map(function (Result $result) {
3535
return $result->getSource();
@@ -39,32 +39,21 @@ public function toArray()
3939
/**
4040
* {@inheritdoc}
4141
*/
42-
public function getTotalHits()
42+
public function getTotalHits(): int
4343
{
4444
return $this->resultSet->getTotalHits();
4545
}
4646

4747
/**
4848
* {@inheritdoc}
4949
*/
50-
public function getAggregations()
50+
public function getAggregations(): array
5151
{
52-
if ($this->resultSet->hasAggregations()) {
53-
return $this->resultSet->getAggregations();
54-
}
55-
56-
return;
52+
return $this->resultSet->getAggregations();
5753
}
5854

59-
/**
60-
* {@inheritdoc}
61-
*/
62-
public function getSuggests()
55+
public function getSuggests(): array
6356
{
64-
if ($this->resultSet->hasSuggests()) {
65-
return $this->resultSet->getSuggests();
66-
}
67-
68-
return;
57+
return $this->resultSet->getSuggests();
6958
}
7059
}

src/Paginator/TransformedPartialResults.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function __construct(ResultSet $resultSet, ElasticaToModelTransformerInte
3131
/**
3232
* {@inheritdoc}
3333
*/
34-
public function toArray()
34+
public function toArray(): array
3535
{
3636
return $this->transformer->transform($this->resultSet->getResults());
3737
}

0 commit comments

Comments
 (0)