@@ -76,10 +76,17 @@ class Find implements Executable
7676 *
7777 * * limit (integer): The maximum number of documents to return.
7878 *
79+ * * max (document): The exclusive upper bound for a specific index.
80+ *
81+ * * maxScan (integer): Maximum number of documents or index keys to scan
82+ * when executing the query.
83+ *
7984 * * maxTimeMS (integer): The maximum amount of time to allow the query to
8085 * run. If "$maxTimeMS" also exists in the modifiers document, this
8186 * option will take precedence.
8287 *
88+ * * min (document): The inclusive upper bound for a specific index.
89+ *
8390 * * modifiers (document): Meta operators that modify the output or
8491 * behavior of a query. Use of these operators is deprecated in favor of
8592 * named options.
@@ -101,8 +108,18 @@ class Find implements Executable
101108 *
102109 * * readPreference (MongoDB\Driver\ReadPreference): Read preference.
103110 *
111+ * * returnKey (boolean): If true, returns only the index keys in the
112+ * resulting documents.
113+ *
114+ * * showRecordId (boolean): Determines whether to return the record
115+ * identifier for each document. If true, adds a field $recordId to the
116+ * returned documents.
117+ *
104118 * * skip (integer): The number of documents to skip before returning.
105119 *
120+ * * snapshot (boolean): Prevents the cursor from returning a document more
121+ * than once because of an intervening write operation.
122+ *
106123 * * sort (document): The order in which to return matching documents. If
107124 * "$orderby" also exists in the modifiers document, this option will
108125 * take precedence.
@@ -158,10 +175,22 @@ public function __construct($databaseName, $collectionName, $filter, array $opti
158175 throw InvalidArgumentException::invalidType ('"limit" option ' , $ options ['limit ' ], 'integer ' );
159176 }
160177
178+ if (isset ($ options ['max ' ]) && ! is_array ($ options ['max ' ]) && ! is_object ($ options ['max ' ])) {
179+ throw InvalidArgumentException::invalidType ('"max" option ' , $ options ['max ' ], 'array or object ' );
180+ }
181+
182+ if (isset ($ options ['maxScan ' ]) && ! is_integer ($ options ['maxScan ' ])) {
183+ throw InvalidArgumentException::invalidType ('"maxScan" option ' , $ options ['maxScan ' ], 'integer ' );
184+ }
185+
161186 if (isset ($ options ['maxTimeMS ' ]) && ! is_integer ($ options ['maxTimeMS ' ])) {
162187 throw InvalidArgumentException::invalidType ('"maxTimeMS" option ' , $ options ['maxTimeMS ' ], 'integer ' );
163188 }
164189
190+ if (isset ($ options ['min ' ]) && ! is_array ($ options ['min ' ]) && ! is_object ($ options ['min ' ])) {
191+ throw InvalidArgumentException::invalidType ('"min" option ' , $ options ['min ' ], 'array or object ' );
192+ }
193+
165194 if (isset ($ options ['modifiers ' ]) && ! is_array ($ options ['modifiers ' ]) && ! is_object ($ options ['modifiers ' ])) {
166195 throw InvalidArgumentException::invalidType ('"modifiers" option ' , $ options ['modifiers ' ], 'array or object ' );
167196 }
@@ -186,10 +215,22 @@ public function __construct($databaseName, $collectionName, $filter, array $opti
186215 throw InvalidArgumentException::invalidType ('"readPreference" option ' , $ options ['readPreference ' ], 'MongoDB\Driver\ReadPreference ' );
187216 }
188217
218+ if (isset ($ options ['returnKey ' ]) && ! is_bool ($ options ['returnKey ' ])) {
219+ throw InvalidArgumentException::invalidType ('"returnKey" option ' , $ options ['returnKey ' ], 'boolean ' );
220+ }
221+
222+ if (isset ($ options ['showRecordId ' ]) && ! is_bool ($ options ['showRecordId ' ])) {
223+ throw InvalidArgumentException::invalidType ('"showRecordId" option ' , $ options ['showRecordId ' ], 'boolean ' );
224+ }
225+
189226 if (isset ($ options ['skip ' ]) && ! is_integer ($ options ['skip ' ])) {
190227 throw InvalidArgumentException::invalidType ('"skip" option ' , $ options ['skip ' ], 'integer ' );
191228 }
192229
230+ if (isset ($ options ['snapshot ' ]) && ! is_bool ($ options ['snapshot ' ])) {
231+ throw InvalidArgumentException::invalidType ('"snapshot" option ' , $ options ['snapshot ' ], 'boolean ' );
232+ }
233+
193234 if (isset ($ options ['sort ' ]) && ! is_array ($ options ['sort ' ]) && ! is_object ($ options ['sort ' ])) {
194235 throw InvalidArgumentException::invalidType ('"sort" option ' , $ options ['sort ' ], 'array or object ' );
195236 }
@@ -257,14 +298,16 @@ private function createQuery()
257298 }
258299 }
259300
260- foreach (['allowPartialResults ' , 'batchSize ' , 'comment ' , 'hint ' , 'limit ' , 'maxTimeMS ' , 'noCursorTimeout ' , 'oplogReplay ' , 'projection ' , 'readConcern ' , 'skip ' , 'sort ' ] as $ option ) {
301+ foreach (['allowPartialResults ' , 'batchSize ' , 'comment ' , 'hint ' , 'limit ' , 'maxScan ' , ' maxTimeMS ' , 'noCursorTimeout ' , 'oplogReplay ' , 'projection ' , 'readConcern ' , 'returnKey ' , ' showRecordId ' , ' skip ' , ' snapshot ' , 'sort ' ] as $ option ) {
261302 if (isset ($ this ->options [$ option ])) {
262303 $ options [$ option ] = $ this ->options [$ option ];
263304 }
264305 }
265306
266- if (isset ($ this ->options ['collation ' ])) {
267- $ options ['collation ' ] = (object ) $ this ->options ['collation ' ];
307+ foreach (['collation ' , 'max ' , 'min ' ] as $ option ) {
308+ if (isset ($ this ->options [$ option ])) {
309+ $ options [$ option ] = (object ) $ this ->options [$ option ];
310+ }
268311 }
269312
270313 $ modifiers = empty ($ this ->options ['modifiers ' ]) ? [] : (array ) $ this ->options ['modifiers ' ];
0 commit comments