34
34
use function is_integer ;
35
35
use function is_object ;
36
36
use function is_string ;
37
- use function MongoDB \document_to_array ;
38
37
use function MongoDB \is_document ;
39
38
40
39
/**
@@ -88,28 +87,15 @@ final class Find implements Executable, Explainable
88
87
* * maxAwaitTimeMS (integer): The maxium amount of time for the server to wait
89
88
* on new documents to satisfy a query, if cursorType is TAILABLE_AWAIT.
90
89
*
91
- * * maxScan (integer): Maximum number of documents or index keys to scan
92
- * when executing the query.
93
- *
94
- * This option has been deprecated since version 1.4.
95
- *
96
90
* * maxTimeMS (integer): The maximum amount of time to allow the query to
97
- * run. If "$maxTimeMS" also exists in the modifiers document, this
98
- * option will take precedence.
91
+ * run.
99
92
*
100
93
* * min (document): The inclusive upper bound for a specific index.
101
94
*
102
- * * modifiers (document): Meta operators that modify the output or
103
- * behavior of a query. Use of these operators is deprecated in favor of
104
- * named options.
105
- *
106
95
* * noCursorTimeout (boolean): The server normally times out idle cursors
107
96
* after an inactivity period (10 minutes) to prevent excess memory use.
108
97
* Set this option to prevent that.
109
98
*
110
- * * oplogReplay (boolean): Internal replication use only. The driver
111
- * should not set this. This option is deprecated as of MongoDB 4.4.
112
- *
113
99
* * projection (document): Limits the fields to return for the matching
114
100
* document.
115
101
*
@@ -128,14 +114,7 @@ final class Find implements Executable, Explainable
128
114
*
129
115
* * skip (integer): The number of documents to skip before returning.
130
116
*
131
- * * snapshot (boolean): Prevents the cursor from returning a document more
132
- * than once because of an intervening write operation.
133
- *
134
- * This options has been deprecated since version 1.4.
135
- *
136
- * * sort (document): The order in which to return matching documents. If
137
- * "$orderby" also exists in the modifiers document, this option will
138
- * take precedence.
117
+ * * sort (document): The order in which to return matching documents.
139
118
*
140
119
* * let (document): Map of parameter names and values. Values must be
141
120
* constant or closed expressions that do not reference document fields.
@@ -207,10 +186,6 @@ public function __construct(private string $databaseName, private string $collec
207
186
throw InvalidArgumentException::invalidType ('"maxAwaitTimeMS" option ' , $ this ->options ['maxAwaitTimeMS ' ], 'integer ' );
208
187
}
209
188
210
- if (isset ($ this ->options ['maxScan ' ]) && ! is_integer ($ this ->options ['maxScan ' ])) {
211
- throw InvalidArgumentException::invalidType ('"maxScan" option ' , $ this ->options ['maxScan ' ], 'integer ' );
212
- }
213
-
214
189
if (isset ($ this ->options ['maxTimeMS ' ]) && ! is_integer ($ this ->options ['maxTimeMS ' ])) {
215
190
throw InvalidArgumentException::invalidType ('"maxTimeMS" option ' , $ this ->options ['maxTimeMS ' ], 'integer ' );
216
191
}
@@ -219,18 +194,10 @@ public function __construct(private string $databaseName, private string $collec
219
194
throw InvalidArgumentException::expectedDocumentType ('"min" option ' , $ this ->options ['min ' ]);
220
195
}
221
196
222
- if (isset ($ this ->options ['modifiers ' ]) && ! is_document ($ this ->options ['modifiers ' ])) {
223
- throw InvalidArgumentException::expectedDocumentType ('"modifiers" option ' , $ this ->options ['modifiers ' ]);
224
- }
225
-
226
197
if (isset ($ this ->options ['noCursorTimeout ' ]) && ! is_bool ($ this ->options ['noCursorTimeout ' ])) {
227
198
throw InvalidArgumentException::invalidType ('"noCursorTimeout" option ' , $ this ->options ['noCursorTimeout ' ], 'boolean ' );
228
199
}
229
200
230
- if (isset ($ this ->options ['oplogReplay ' ]) && ! is_bool ($ this ->options ['oplogReplay ' ])) {
231
- throw InvalidArgumentException::invalidType ('"oplogReplay" option ' , $ this ->options ['oplogReplay ' ], 'boolean ' );
232
- }
233
-
234
201
if (isset ($ this ->options ['projection ' ]) && ! is_document ($ this ->options ['projection ' ])) {
235
202
throw InvalidArgumentException::expectedDocumentType ('"projection" option ' , $ this ->options ['projection ' ]);
236
203
}
@@ -259,10 +226,6 @@ public function __construct(private string $databaseName, private string $collec
259
226
throw InvalidArgumentException::invalidType ('"skip" option ' , $ this ->options ['skip ' ], 'integer ' );
260
227
}
261
228
262
- if (isset ($ this ->options ['snapshot ' ]) && ! is_bool ($ this ->options ['snapshot ' ])) {
263
- throw InvalidArgumentException::invalidType ('"snapshot" option ' , $ this ->options ['snapshot ' ], 'boolean ' );
264
- }
265
-
266
229
if (isset ($ this ->options ['sort ' ]) && ! is_document ($ this ->options ['sort ' ])) {
267
230
throw InvalidArgumentException::expectedDocumentType ('"sort" option ' , $ this ->options ['sort ' ]);
268
231
}
@@ -329,28 +292,6 @@ public function getCommandDocument(): array
329
292
// maxAwaitTimeMS is a Query level option so should not be considered here
330
293
unset($ options ['maxAwaitTimeMS ' ]);
331
294
332
- $ modifierFallback = [
333
- ['allowPartialResults ' , 'partial ' ],
334
- ['comment ' , '$comment ' ],
335
- ['hint ' , '$hint ' ],
336
- ['maxScan ' , '$maxScan ' ],
337
- ['max ' , '$max ' ],
338
- ['maxTimeMS ' , '$maxTimeMS ' ],
339
- ['min ' , '$min ' ],
340
- ['returnKey ' , '$returnKey ' ],
341
- ['showRecordId ' , '$showDiskLoc ' ],
342
- ['sort ' , '$orderby ' ],
343
- ['snapshot ' , '$snapshot ' ],
344
- ];
345
-
346
- foreach ($ modifierFallback as $ modifier ) {
347
- if (! isset ($ options [$ modifier [0 ]]) && isset ($ options ['modifiers ' ][$ modifier [1 ]])) {
348
- $ options [$ modifier [0 ]] = $ options ['modifiers ' ][$ modifier [1 ]];
349
- }
350
- }
351
-
352
- unset($ options ['modifiers ' ]);
353
-
354
295
return $ cmd + $ options ;
355
296
}
356
297
@@ -395,7 +336,7 @@ private function createQueryOptions(): array
395
336
}
396
337
}
397
338
398
- foreach (['allowDiskUse ' , 'allowPartialResults ' , 'batchSize ' , 'comment ' , 'hint ' , 'limit ' , 'maxAwaitTimeMS ' , 'maxScan ' , ' maxTimeMS ' , 'noCursorTimeout ' , 'oplogReplay ' , ' projection ' , 'readConcern ' , 'returnKey ' , 'showRecordId ' , 'skip ' , ' snapshot ' , 'sort ' ] as $ option ) {
339
+ foreach (['allowDiskUse ' , 'allowPartialResults ' , 'batchSize ' , 'comment ' , 'hint ' , 'limit ' , 'maxAwaitTimeMS ' , 'maxTimeMS ' , 'noCursorTimeout ' , 'projection ' , 'readConcern ' , 'returnKey ' , 'showRecordId ' , 'skip ' , 'sort ' ] as $ option ) {
399
340
if (isset ($ this ->options [$ option ])) {
400
341
$ options [$ option ] = $ this ->options [$ option ];
401
342
}
@@ -407,12 +348,6 @@ private function createQueryOptions(): array
407
348
}
408
349
}
409
350
410
- if (! empty ($ this ->options ['modifiers ' ])) {
411
- /** @psalm-var array|object */
412
- $ modifiers = $ this ->options ['modifiers ' ];
413
- $ options ['modifiers ' ] = is_object ($ modifiers ) ? document_to_array ($ modifiers ) : $ modifiers ;
414
- }
415
-
416
351
return $ options ;
417
352
}
418
353
}
0 commit comments