1 | <?php |
||
32 | class Finder implements FinderInterface |
||
33 | { |
||
34 | |||
35 | /** |
||
36 | * Model |
||
37 | * @var AnnotatedInterface |
||
38 | */ |
||
39 | public $model = null; |
||
40 | |||
41 | /** |
||
42 | * Mangan instance |
||
43 | * @var Mangan |
||
44 | */ |
||
45 | private $mn = null; |
||
46 | |||
47 | /** |
||
48 | * Entity manager instance |
||
49 | * @var EntityManagerInterface |
||
50 | */ |
||
51 | private $em = null; |
||
52 | |||
53 | /** |
||
54 | * Scope manager instance |
||
55 | * @var ScopeManager |
||
56 | */ |
||
57 | private $sm = null; |
||
58 | |||
59 | /** |
||
60 | * Finder criteria |
||
61 | * @var Criteria |
||
62 | */ |
||
63 | private $_criteria = null; |
||
64 | |||
65 | /** |
||
66 | * Whenever to use corsors |
||
67 | * @var bool |
||
68 | */ |
||
69 | private $_useCursor = false; |
||
70 | |||
71 | /** |
||
72 | * Constructor |
||
73 | * |
||
74 | * @param object $model Model instance |
||
75 | * @param EntityManagerInterface $em |
||
76 | * @param Mangan $mangan |
||
77 | */ |
||
78 | public function __construct($model, $em = null, $mangan = null) |
||
90 | |||
91 | /** |
||
92 | * Create model related finder. |
||
93 | * This will create customized finder if defined in model with Finder annotation. |
||
94 | * If no custom finder is defined this will return default Finder. |
||
95 | * |
||
96 | * @param AnnotatedInterface $model |
||
97 | * @param EntityManagerInterface $em |
||
98 | * @param Mangan $mangan |
||
99 | * @return FinderInterface |
||
100 | */ |
||
101 | public static function create(AnnotatedInterface $model, $em = null, Mangan $mangan = null) |
||
106 | |||
107 | /** |
||
108 | * Finds a single Document with the specified condition. |
||
109 | * |
||
110 | * @param array|CriteriaInterface $criteria query criteria. |
||
111 | * @return AnnotatedInterface |
||
112 | * @Ignored |
||
113 | */ |
||
114 | public function find($criteria = null) |
||
125 | |||
126 | /** |
||
127 | * Finds document with the specified primary key. Primary key by default |
||
128 | * is defined by `_id` field. But could be any other. For simple (one column) |
||
129 | * keys use it's value. |
||
130 | * |
||
131 | * For composite use key-value with column names as keys |
||
132 | * and values for values. |
||
133 | * |
||
134 | * Example for simple pk: |
||
135 | * ```php |
||
136 | * $pk = '51b616fcc0986e30026d0748' |
||
137 | * ``` |
||
138 | * |
||
139 | * Composite pk: |
||
140 | * ```php |
||
141 | * $pk = [ |
||
142 | * 'mainPk' => 1, |
||
143 | * 'secondaryPk' => 2 |
||
144 | * ]; |
||
145 | * ``` |
||
146 | * |
||
147 | * @param mixed $pkValue primary key value. Use array for composite key. |
||
148 | * @param array|CriteriaInterface $criteria |
||
149 | * @return AnnotatedInterface|null |
||
150 | * @Ignored |
||
151 | */ |
||
152 | public function findByPk($pkValue, $criteria = null) |
||
160 | |||
161 | /** |
||
162 | * Finds document with the specified attributes. |
||
163 | * Attributes should be specified as key-value pairs. |
||
164 | * This allows easier syntax for simple queries. |
||
165 | * |
||
166 | * Example: |
||
167 | * ```php |
||
168 | * $attributes = [ |
||
169 | * 'name' => 'John', |
||
170 | * 'title' => 'dr' |
||
171 | * ]; |
||
172 | * ``` |
||
173 | * |
||
174 | * @param mixed[] Array of stributes and values in form of ['attributeName' => 'value'] |
||
175 | * @return AnnotatedInterface|null |
||
176 | */ |
||
177 | public function findByAttributes(array $attributes) |
||
187 | |||
188 | /** |
||
189 | * Finds all documents satisfying the specified condition. |
||
190 | * See {@link find()} for detailed explanation about $condition and $params. |
||
191 | * |
||
192 | * @param array|CriteriaInterface $criteria query criteria. |
||
193 | * @return AnnotatedInterface[]|Cursor |
||
194 | */ |
||
195 | public function findAll($criteria = null) |
||
231 | |||
232 | /** |
||
233 | * Finds all documents with the specified attributes. |
||
234 | * |
||
235 | * @param mixed[] Array of stributes and values in form of ['attributeName' => 'value'] |
||
236 | * @return AnnotatedInterface[]|Cursor - Array or cursor of Documents |
||
237 | * @since v1.0 |
||
238 | */ |
||
239 | public function findAllByAttributes(array $attributes) |
||
250 | |||
251 | /** |
||
252 | * Finds all documents with the specified primary keys. |
||
253 | * In MongoDB world every document has '_id' unique field, so with this method that |
||
254 | * field is in use as PK by default. |
||
255 | * See {@link find()} for detailed explanation about $condition. |
||
256 | * |
||
257 | * @param mixed $pkValues primary key value(s). Use array for multiple primary keys. For composite key, each key value must be an array (column name=>column value). |
||
258 | * @param array|CriteriaInterface $criteria query criteria. |
||
259 | * @return AnnotatedInterface[]|Cursor - Array or cursor of Documents |
||
260 | * @since v1.0 |
||
261 | */ |
||
262 | public function findAllByPk($pkValues, $criteria = null) |
||
270 | |||
271 | /** |
||
272 | * Counts all documents satisfying the specified condition. |
||
273 | * See {@link find()} for detailed explanation about $condition and $params. |
||
274 | * @param array|CriteriaInterface $criteria query criteria. |
||
275 | * @return integer Count of all documents satisfying the specified condition. |
||
276 | * @since v1.0 |
||
277 | */ |
||
278 | public function count($criteria = null) |
||
284 | |||
285 | /** |
||
286 | * Counts all documents found by attribute values. |
||
287 | * |
||
288 | * Example: |
||
289 | * ```php |
||
290 | * $attributes = [ |
||
291 | * 'name' => 'John', |
||
292 | * 'title' => 'dr' |
||
293 | * ]; |
||
294 | * ``` |
||
295 | * |
||
296 | * @param mixed[] Array of attributes and values in form of ['attributeName' => 'value'] |
||
297 | * @return int |
||
298 | * @since v1.2.2 |
||
299 | * @Ignored |
||
300 | */ |
||
301 | public function countByAttributes(array $attributes) |
||
314 | |||
315 | /** |
||
316 | * Checks whether there is document satisfying the specified condition. |
||
317 | * |
||
318 | * @param CriteriaInterface $criteria |
||
319 | * @return bool |
||
320 | */ |
||
321 | public function exists(CriteriaInterface $criteria = null) |
||
336 | |||
337 | /** |
||
338 | * Whenever to use cursor |
||
339 | * @param bool $useCursor |
||
340 | * @return FinderInterface |
||
341 | */ |
||
342 | public function withCursor($useCursor = true) |
||
347 | |||
348 | /** |
||
349 | * Resets all scopes and criteria applied including default scope. |
||
350 | * |
||
351 | * @return Finder |
||
352 | * @since v1.0 |
||
353 | */ |
||
354 | public function resetScope() |
||
360 | |||
361 | /** |
||
362 | * Creates an model with the given attributes. |
||
363 | * This method is internally used by the find methods. |
||
364 | * @param mixed[] $data attribute values (column name=>column value) |
||
365 | * @return AnnotatedInterface|null the newly created document. The class of the object is the same as the model class. |
||
366 | * Null is returned if the input data is false. |
||
367 | * @since v1.0 |
||
368 | */ |
||
369 | protected function populateRecord($data) |
||
383 | |||
384 | /** |
||
385 | * Creates a list of documents based on the input data. |
||
386 | * This method is internally used by the find methods. |
||
387 | * @param MongoCursor $cursor Results found to populate active records. |
||
388 | * @return AnnotatedInterface[] array list of active records. |
||
389 | * @since v1.0 |
||
390 | */ |
||
391 | protected function populateRecords(MongoCursor $cursor) |
||
400 | |||
401 | /** |
||
402 | * Trigger before find event |
||
403 | * @return boolean |
||
404 | */ |
||
405 | private function _beforeFind() |
||
413 | |||
414 | } |
||
415 |
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: