1 | <?php |
||
14 | class Search |
||
15 | { |
||
16 | protected $index; |
||
17 | protected $query; |
||
18 | private $path; |
||
19 | private $limit = 25; |
||
20 | |||
21 | /** |
||
22 | * Search constructor. |
||
23 | * @param Index $index |
||
24 | * @param Query $query |
||
25 | */ |
||
26 | 3 | public function __construct(Index $index, Query $query) |
|
31 | |||
32 | /** |
||
33 | * @param $name |
||
34 | * @param $arguments |
||
35 | * @return $this |
||
36 | * @throws \BadMethodCallException |
||
37 | */ |
||
38 | public function __call($name, $arguments) |
||
51 | |||
52 | /** |
||
53 | * @param $limit |
||
54 | * @return $this |
||
55 | */ |
||
56 | 1 | public function limit($limit) |
|
61 | |||
62 | /** |
||
63 | * @param bool $path |
||
64 | * @return $this |
||
65 | */ |
||
66 | 1 | public function path($path = false) |
|
71 | |||
72 | /** |
||
73 | * @param $string |
||
74 | */ |
||
75 | 1 | public function raw($string) |
|
80 | |||
81 | /** |
||
82 | * @param $string |
||
83 | * @param bool $field |
||
84 | */ |
||
85 | public function phrase($string, $field = false, $offsets = null) |
||
91 | |||
92 | /** |
||
93 | * @param $string |
||
94 | * @param bool $field |
||
95 | */ |
||
96 | public function fuzzy($string, $field = false) |
||
101 | |||
102 | /** |
||
103 | * @param $string |
||
104 | * @param bool $field |
||
105 | * @return Term |
||
106 | */ |
||
107 | protected function term($string, $field = false) |
||
111 | |||
112 | /** |
||
113 | * @param $string |
||
114 | * @param bool $field |
||
115 | * @param array $options |
||
116 | */ |
||
117 | public function wildcard($string, $field = false, $options = [ ]) |
||
121 | |||
122 | /** |
||
123 | * @param $string |
||
124 | * @param string $field |
||
125 | * @todo Work out why the search only works if the string is uppercase... |
||
126 | * @return $this|bool |
||
127 | */ |
||
128 | public function where($string, $field = false) |
||
129 | { |
||
130 | is_array($field) |
||
131 | ? $this->multiTerm($this->mapWhereArray($string, $field)) |
||
132 | : $this->query->add($this->singleTerm($string, $field)); |
||
133 | |||
134 | return $this; |
||
135 | } |
||
136 | |||
137 | /** |
||
138 | * @param array $terms |
||
139 | * @return $this |
||
140 | */ |
||
141 | public function multiTerm(array $terms) |
||
152 | |||
153 | /** |
||
154 | * @param $string |
||
155 | * @param array $array |
||
156 | * @return mixed |
||
157 | * @todo abstract this out |
||
158 | */ |
||
159 | private function mapWhereArray($string, array $array) |
||
165 | |||
166 | /** |
||
167 | * @param $string |
||
168 | * @param $field |
||
169 | * @return QueryTerm |
||
170 | */ |
||
171 | public function singleTerm($string, $field = false) |
||
175 | |||
176 | /** |
||
177 | * @return mixed |
||
178 | */ |
||
179 | public function hits() |
||
183 | |||
184 | /** |
||
185 | * @param array $array |
||
186 | * @return mixed |
||
187 | * @todo abstract this out |
||
188 | */ |
||
189 | private function mapIds(array $array) |
||
195 | } |
||
196 |
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: