1 | <?php |
||
19 | class Search |
||
20 | { |
||
21 | protected $index; |
||
22 | protected $query; |
||
23 | private $path; |
||
24 | private $limit = 25; |
||
25 | |||
26 | /** |
||
27 | * Search constructor. |
||
28 | * |
||
29 | * @param Index $index |
||
30 | * @param Query $query |
||
31 | */ |
||
32 | 11 | public function __construct(Index $index, Query $query) |
|
37 | |||
38 | /** |
||
39 | * @param $name |
||
40 | * @param $arguments |
||
41 | * @return $this |
||
42 | * @throws \BadMethodCallException |
||
43 | */ |
||
44 | 2 | public function __call($name, $arguments) |
|
53 | |||
54 | /** |
||
55 | * @param $limit |
||
56 | * @return $this |
||
57 | */ |
||
58 | 1 | public function limit($limit) |
|
63 | |||
64 | /** |
||
65 | * @param bool $path |
||
66 | * @return $this |
||
67 | */ |
||
68 | 1 | public function path($path = false) |
|
73 | |||
74 | /** |
||
75 | * @param $string |
||
76 | * @return $this |
||
77 | */ |
||
78 | 1 | public function raw($string) |
|
83 | |||
84 | /** |
||
85 | * @param $string |
||
86 | * @param bool $field |
||
87 | * @param null $offsets |
||
88 | * @return $this |
||
89 | * @return $this |
||
90 | */ |
||
91 | 1 | public function phrase($string, $field = false, $offsets = null) |
|
97 | |||
98 | /** |
||
99 | * @param $string |
||
100 | * @param bool $field |
||
101 | * @return $this |
||
102 | */ |
||
103 | 1 | public function fuzzy($string, $field = false) |
|
108 | |||
109 | /** |
||
110 | * @param $string |
||
111 | * @param bool $field |
||
112 | * @return Term |
||
113 | */ |
||
114 | 2 | protected function term($string, $field = false) |
|
118 | |||
119 | /** |
||
120 | * @param $string |
||
121 | * @param bool $field |
||
122 | * @param array $options |
||
123 | */ |
||
124 | 1 | public function wildcard($string, $field = false, $options = [ ]) |
|
129 | |||
130 | /** |
||
131 | * @param $string |
||
132 | * @param bool|string $field |
||
133 | * @return $this|bool |
||
134 | * @todo Work out why the search only works if the string is uppercase... |
||
135 | */ |
||
136 | 1 | public function where($string, $field = false) |
|
144 | |||
145 | /** |
||
146 | * @param array $terms |
||
147 | * @return $this |
||
148 | */ |
||
149 | 1 | public function multiTerm(array $terms) |
|
150 | { |
||
151 | 1 | $multiTerm = new MultiTerm; |
|
152 | 1 | foreach ($terms as $field => $value) { |
|
153 | 1 | $multiTerm->addTerm($this->term($value, $field), $this->query->getSign()); |
|
154 | 1 | } |
|
155 | |||
156 | 1 | $this->query->add($multiTerm); |
|
157 | |||
158 | 1 | return $this; |
|
159 | } |
||
160 | |||
161 | /** |
||
162 | * @param $string |
||
163 | * @param array $array |
||
164 | * @return mixed |
||
165 | * @todo abstract this out |
||
166 | */ |
||
167 | 1 | private function mapWhereArray($string, array $array) |
|
168 | { |
||
169 | 1 | return array_map( |
|
170 | function() use ($string) { |
||
171 | 1 | return $string; |
|
172 | 1 | }, array_flip($array) |
|
173 | 1 | ); |
|
174 | } |
||
175 | |||
176 | /** |
||
177 | * @param $string |
||
178 | * @param $field |
||
179 | * @return QueryTerm |
||
180 | */ |
||
181 | 2 | public function singleTerm($string, $field = false) |
|
185 | |||
186 | /** |
||
187 | * @return mixed |
||
188 | */ |
||
189 | public function hits() |
||
195 | |||
196 | /** |
||
197 | * @param array $array |
||
198 | * @return mixed |
||
199 | * @todo abstract this out |
||
200 | */ |
||
201 | 1 | private function mapIds(array $array) |
|
209 | } |
||
210 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: