1 | <?php |
||
23 | class TopHitsAggregation extends AbstractAggregation |
||
24 | { |
||
25 | use MetricTrait; |
||
26 | |||
27 | /** |
||
28 | * @var int Number of top matching hits to return per bucket. |
||
29 | */ |
||
30 | private $size; |
||
31 | |||
32 | /** |
||
33 | * @var int The offset from the first result you want to fetch. |
||
34 | */ |
||
35 | private $from; |
||
36 | |||
37 | /** |
||
38 | * @var BuilderInterface[] How the top matching hits should be sorted. |
||
39 | */ |
||
40 | private $sorts = []; |
||
41 | |||
42 | /** |
||
43 | * Constructor for top hits. |
||
44 | * |
||
45 | * @param string $name Aggregation name. |
||
46 | * @param null|int $size Number of top matching hits to return per bucket. |
||
47 | * @param null|int $from The offset from the first result you want to fetch. |
||
48 | * @param null|BuilderInterface $sort How the top matching hits should be sorted. |
||
49 | */ |
||
50 | public function __construct($name, $size = null, $from = null, $sort = null) |
||
57 | |||
58 | /** |
||
59 | * Return from. |
||
60 | * |
||
61 | * @return int |
||
62 | */ |
||
63 | public function getFrom() |
||
67 | |||
68 | /** |
||
69 | * @param int $from |
||
70 | * |
||
71 | * @return $this |
||
72 | */ |
||
73 | public function setFrom($from) |
||
79 | |||
80 | /** |
||
81 | * @return BuilderInterface[] |
||
82 | */ |
||
83 | public function getSorts() |
||
87 | |||
88 | /** |
||
89 | * @param BuilderInterface[] $sorts |
||
90 | * |
||
91 | * @return $this |
||
92 | */ |
||
93 | public function setSorts(array $sorts) |
||
99 | |||
100 | /** |
||
101 | * Add sort. |
||
102 | * |
||
103 | * @param BuilderInterface $sort |
||
104 | */ |
||
105 | public function addSort($sort) |
||
109 | |||
110 | /** |
||
111 | * @param int $size |
||
112 | * |
||
113 | * @return $this |
||
114 | */ |
||
115 | public function setSize($size) |
||
121 | |||
122 | /** |
||
123 | * Return size. |
||
124 | * |
||
125 | * @return int |
||
126 | */ |
||
127 | public function getSize() |
||
131 | |||
132 | /** |
||
133 | * {@inheritdoc} |
||
134 | */ |
||
135 | public function getType() |
||
139 | |||
140 | /** |
||
141 | * {@inheritdoc} |
||
142 | */ |
||
143 | public function getArray() |
||
168 | |||
169 | /** |
||
170 | * @deprecated sorts now is a container, use `getSorts()`instead. |
||
171 | * Return sort. |
||
172 | * |
||
173 | * @return BuilderInterface |
||
174 | */ |
||
175 | public function getSort() |
||
183 | |||
184 | /** |
||
185 | * @deprecated sorts now is a container, use `addSort()`instead. |
||
186 | * |
||
187 | * @param BuilderInterface $sort |
||
188 | * |
||
189 | * @return $this |
||
190 | */ |
||
191 | public function setSort(BuilderInterface $sort) |
||
197 | } |
||
198 |
It seems like you allow that null is being passed for a parameter, however the function which is called does not seem to accept null.
We recommend to add an additional type check (or disallow null for the parameter):