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 | * Set from. |
||
70 | * |
||
71 | * @param int $from |
||
72 | */ |
||
73 | public function setFrom($from) |
||
77 | |||
78 | /** |
||
79 | * @return BuilderInterface[] |
||
80 | */ |
||
81 | public function getSorts() |
||
85 | |||
86 | /** |
||
87 | * @param BuilderInterface[] $sorts |
||
88 | */ |
||
89 | public function setSorts(array $sorts) |
||
93 | |||
94 | /** |
||
95 | * Add sort. |
||
96 | * |
||
97 | * @param BuilderInterface $sort |
||
98 | */ |
||
99 | public function addSort($sort) |
||
103 | |||
104 | /** |
||
105 | * Set size. |
||
106 | * |
||
107 | * @param int $size |
||
108 | */ |
||
109 | public function setSize($size) |
||
113 | |||
114 | /** |
||
115 | * Return size. |
||
116 | * |
||
117 | * @return int |
||
118 | */ |
||
119 | public function getSize() |
||
123 | |||
124 | /** |
||
125 | * {@inheritdoc} |
||
126 | */ |
||
127 | public function getType() |
||
131 | |||
132 | /** |
||
133 | * {@inheritdoc} |
||
134 | */ |
||
135 | public function getArray() |
||
160 | |||
161 | /** |
||
162 | * @deprecated sorts now is a container, use `getSorts()`instead. |
||
163 | * Return sort. |
||
164 | * |
||
165 | * @return BuilderInterface |
||
166 | */ |
||
167 | public function getSort() |
||
175 | |||
176 | /** |
||
177 | * @deprecated sorts now is a container, use `addSort()`instead. |
||
178 | * |
||
179 | * Set sort. |
||
180 | * |
||
181 | * @param BuilderInterface $sort |
||
182 | */ |
||
183 | public function setSort(BuilderInterface $sort) |
||
187 | } |
||
188 |
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):