@@ -70,12 +70,23 @@ class Find implements Executable
7070 * NON_TAILABLE, TAILABLE, or TAILABLE_AWAIT. The default is
7171 * NON_TAILABLE.
7272 *
73+ * * hint (string|document): The index to use. Specify either the index
74+ * name as a string or the index key pattern as a document. If specified,
75+ * then the query system will only consider plans using the hinted index.
76+ *
7377 * * limit (integer): The maximum number of documents to return.
7478 *
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+ *
7584 * * maxTimeMS (integer): The maximum amount of time to allow the query to
7685 * run. If "$maxTimeMS" also exists in the modifiers document, this
7786 * option will take precedence.
7887 *
88+ * * min (document): The inclusive upper bound for a specific index.
89+ *
7990 * * modifiers (document): Meta operators that modify the output or
8091 * behavior of a query. Use of these operators is deprecated in favor of
8192 * named options.
@@ -97,8 +108,18 @@ class Find implements Executable
97108 *
98109 * * readPreference (MongoDB\Driver\ReadPreference): Read preference.
99110 *
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+ *
100118 * * skip (integer): The number of documents to skip before returning.
101119 *
120+ * * snapshot (boolean): Prevents the cursor from returning a document more
121+ * than once because of an intervening write operation.
122+ *
102123 * * sort (document): The order in which to return matching documents. If
103124 * "$orderby" also exists in the modifiers document, this option will
104125 * take precedence.
@@ -146,14 +167,30 @@ public function __construct($databaseName, $collectionName, $filter, array $opti
146167 }
147168 }
148169
170+ if (isset ($ options ['hint ' ]) && ! is_string ($ options ['hint ' ]) && ! is_array ($ options ['hint ' ]) && ! is_object ($ options ['hint ' ])) {
171+ throw InvalidArgumentException::invalidType ('"hint" option ' , $ options ['hint ' ], 'string or array or object ' );
172+ }
173+
149174 if (isset ($ options ['limit ' ]) && ! is_integer ($ options ['limit ' ])) {
150175 throw InvalidArgumentException::invalidType ('"limit" option ' , $ options ['limit ' ], 'integer ' );
151176 }
152177
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+
153186 if (isset ($ options ['maxTimeMS ' ]) && ! is_integer ($ options ['maxTimeMS ' ])) {
154187 throw InvalidArgumentException::invalidType ('"maxTimeMS" option ' , $ options ['maxTimeMS ' ], 'integer ' );
155188 }
156189
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+
157194 if (isset ($ options ['modifiers ' ]) && ! is_array ($ options ['modifiers ' ]) && ! is_object ($ options ['modifiers ' ])) {
158195 throw InvalidArgumentException::invalidType ('"modifiers" option ' , $ options ['modifiers ' ], 'array or object ' );
159196 }
@@ -178,10 +215,22 @@ public function __construct($databaseName, $collectionName, $filter, array $opti
178215 throw InvalidArgumentException::invalidType ('"readPreference" option ' , $ options ['readPreference ' ], 'MongoDB\Driver\ReadPreference ' );
179216 }
180217
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+
181226 if (isset ($ options ['skip ' ]) && ! is_integer ($ options ['skip ' ])) {
182227 throw InvalidArgumentException::invalidType ('"skip" option ' , $ options ['skip ' ], 'integer ' );
183228 }
184229
230+ if (isset ($ options ['snapshot ' ]) && ! is_bool ($ options ['snapshot ' ])) {
231+ throw InvalidArgumentException::invalidType ('"snapshot" option ' , $ options ['snapshot ' ], 'boolean ' );
232+ }
233+
185234 if (isset ($ options ['sort ' ]) && ! is_array ($ options ['sort ' ]) && ! is_object ($ options ['sort ' ])) {
186235 throw InvalidArgumentException::invalidType ('"sort" option ' , $ options ['sort ' ], 'array or object ' );
187236 }
@@ -249,14 +298,16 @@ private function createQuery()
249298 }
250299 }
251300
252- foreach (['allowPartialResults ' , 'batchSize ' , 'comment ' , '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 ) {
253302 if (isset ($ this ->options [$ option ])) {
254303 $ options [$ option ] = $ this ->options [$ option ];
255304 }
256305 }
257306
258- if (isset ($ this ->options ['collation ' ])) {
259- $ 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+ }
260311 }
261312
262313 $ modifiers = empty ($ this ->options ['modifiers ' ]) ? [] : (array ) $ this ->options ['modifiers ' ];
0 commit comments