1 | <?php |
||
11 | abstract class BaseQuery |
||
12 | { |
||
13 | /** |
||
14 | * Bitrix object to be queried. |
||
15 | * |
||
16 | * @var object |
||
17 | */ |
||
18 | protected $bxObject; |
||
19 | |||
20 | /** |
||
21 | * Name of the model that calls the query. |
||
22 | * |
||
23 | * @var string |
||
24 | */ |
||
25 | protected $modelName; |
||
26 | |||
27 | /** |
||
28 | * Model that calls the query. |
||
29 | * |
||
30 | * @var object |
||
31 | */ |
||
32 | protected $model; |
||
33 | |||
34 | /** |
||
35 | * Query sort. |
||
36 | * |
||
37 | * @var array |
||
38 | */ |
||
39 | public $sort = []; |
||
40 | |||
41 | /** |
||
42 | * Query filter. |
||
43 | * |
||
44 | * @var array |
||
45 | */ |
||
46 | public $filter = []; |
||
47 | |||
48 | /** |
||
49 | * Query navigation. |
||
50 | * |
||
51 | * @var array|bool |
||
52 | */ |
||
53 | public $navigation = false; |
||
54 | |||
55 | /** |
||
56 | * Query select. |
||
57 | * |
||
58 | * @var array |
||
59 | */ |
||
60 | public $select = ['FIELDS', 'PROPS']; |
||
61 | |||
62 | /** |
||
63 | * The key to list items in array of results. |
||
64 | * Set to false to have auto incrementing integer. |
||
65 | * |
||
66 | * @var string|bool |
||
67 | */ |
||
68 | public $keyBy = false; |
||
69 | |||
70 | /** |
||
71 | * Indicates that the query should be stopped instead of touching the DB. |
||
72 | * Can be set in query scopes or manually. |
||
73 | * |
||
74 | * @var bool |
||
75 | */ |
||
76 | protected $queryShouldBeStopped = false; |
||
77 | |||
78 | /** |
||
79 | * Get count of users that match $filter. |
||
80 | * |
||
81 | * @return int |
||
82 | */ |
||
83 | abstract public function count(); |
||
84 | |||
85 | /** |
||
86 | * Get list of items. |
||
87 | * |
||
88 | * @return Collection |
||
89 | */ |
||
90 | abstract public function getList(); |
||
91 | |||
92 | /** |
||
93 | * Constructor. |
||
94 | * |
||
95 | * @param object $bxObject |
||
96 | * @param string $modelName |
||
97 | */ |
||
98 | public function __construct($bxObject, $modelName) |
||
104 | |||
105 | /** |
||
106 | * Paginate the given query into a paginator. |
||
107 | * |
||
108 | * @param int $perPage |
||
109 | * @param array $columns |
||
|
|||
110 | * @param string $pageName |
||
111 | * @param int|null $page |
||
112 | * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator |
||
113 | */ |
||
114 | public function paginate($perPage = 15, $pageName = 'page', $page = null) |
||
124 | |||
125 | /** |
||
126 | * Get the first item that matches query params. |
||
127 | * |
||
128 | * @return mixed |
||
129 | */ |
||
130 | public function first() |
||
134 | |||
135 | /** |
||
136 | * Get item by its id. |
||
137 | * |
||
138 | * @param int $id |
||
139 | * |
||
140 | * @return mixed |
||
141 | */ |
||
142 | public function getById($id) |
||
156 | |||
157 | /** |
||
158 | * Setter for sort. |
||
159 | * |
||
160 | * @param mixed $by |
||
161 | * @param string $order |
||
162 | * |
||
163 | * @return $this |
||
164 | */ |
||
165 | public function sort($by, $order = 'ASC') |
||
171 | |||
172 | /** |
||
173 | * Setter for filter. |
||
174 | * |
||
175 | * @param array $filter |
||
176 | * |
||
177 | * @return $this |
||
178 | */ |
||
179 | public function filter($filter) |
||
185 | |||
186 | /** |
||
187 | * Reset filter. |
||
188 | * |
||
189 | * @return $this |
||
190 | */ |
||
191 | public function resetFilter() |
||
197 | |||
198 | /** |
||
199 | * Add another filter to filters array. |
||
200 | * |
||
201 | * @param $filters |
||
202 | * |
||
203 | * @return $this |
||
204 | */ |
||
205 | public function addFilter($filters) |
||
213 | |||
214 | /** |
||
215 | * Setter for navigation. |
||
216 | * |
||
217 | * @param $value |
||
218 | * |
||
219 | * @return $this |
||
220 | */ |
||
221 | public function navigation($value) |
||
227 | |||
228 | /** |
||
229 | * Setter for select. |
||
230 | * |
||
231 | * @param $value |
||
232 | * |
||
233 | * @return $this |
||
234 | */ |
||
235 | public function select($value) |
||
241 | |||
242 | /** |
||
243 | * Setter for keyBy. |
||
244 | * |
||
245 | * @param $value |
||
246 | * |
||
247 | * @return $this |
||
248 | */ |
||
249 | public function keyBy($value) |
||
255 | |||
256 | /** |
||
257 | * Set the "limit" value of the query. |
||
258 | * |
||
259 | * @param int $value |
||
260 | * |
||
261 | * @return $this |
||
262 | */ |
||
263 | public function limit($value) |
||
269 | |||
270 | /** |
||
271 | * Set the "page number" value of the query. |
||
272 | * |
||
273 | * @param int $num |
||
274 | * |
||
275 | * @return $this |
||
276 | */ |
||
277 | public function page($num) |
||
283 | |||
284 | /** |
||
285 | * Alias for "limit". |
||
286 | * |
||
287 | * @param int $value |
||
288 | * |
||
289 | * @return $this |
||
290 | */ |
||
291 | public function take($value) |
||
295 | |||
296 | /** |
||
297 | * Stop the query from touching DB. |
||
298 | * |
||
299 | * @return $this |
||
300 | */ |
||
301 | public function stopQuery() |
||
307 | |||
308 | /** |
||
309 | * Adds $item to $results using keyBy value. |
||
310 | * |
||
311 | * @param $results |
||
312 | * @param $item |
||
313 | * |
||
314 | * @return array |
||
315 | */ |
||
316 | protected function addItemToResultsUsingKeyBy(&$results, $item) |
||
326 | |||
327 | /** |
||
328 | * Determine if all fields must be selected. |
||
329 | * |
||
330 | * @return bool |
||
331 | */ |
||
332 | protected function fieldsMustBeSelected() |
||
336 | |||
337 | /** |
||
338 | * Determine if all fields must be selected. |
||
339 | * |
||
340 | * @return bool |
||
341 | */ |
||
342 | protected function propsMustBeSelected() |
||
348 | |||
349 | /** |
||
350 | * Set $array[$new] as $array[$old] and delete $array[$old]. |
||
351 | * |
||
352 | * @param array $array |
||
353 | * @param $old |
||
354 | * @param $new |
||
355 | * |
||
356 | * return null |
||
357 | */ |
||
358 | protected function substituteField(&$array, $old, $new) |
||
366 | |||
367 | /** |
||
368 | * Clear select array from duplication and additional fields. |
||
369 | * |
||
370 | * @return array |
||
371 | */ |
||
372 | protected function clearSelectArray() |
||
378 | |||
379 | /** |
||
380 | * Handle dynamic method calls into the method. |
||
381 | * |
||
382 | * @param string $method |
||
383 | * @param array $parameters |
||
384 | * |
||
385 | * @throws BadMethodCallException |
||
386 | * |
||
387 | * @return $this |
||
388 | */ |
||
389 | public function __call($method, $parameters) |
||
407 | } |
||
408 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.