3030use function is_string ;
3131use function MongoDB \is_document ;
3232use function MongoDB \is_pipeline ;
33- use function trigger_error ;
34-
35- use const E_USER_DEPRECATED ;
3633
3734/**
3835 * Operation for the create command.
4239 */
4340final class CreateCollection
4441{
45- public const USE_POWER_OF_2_SIZES = 1 ;
46- public const NO_PADDING = 2 ;
47-
4842 /**
4943 * Constructs a create command.
5044 *
5145 * Supported options:
5246 *
53- * * autoIndexId (boolean): Specify false to disable the automatic creation
54- * of an index on the _id field. For replica sets, this option cannot be
55- * false. The default is true.
56- *
57- * This option has been deprecated since MongoDB 3.2. As of MongoDB 4.0,
58- * this option cannot be false when creating a replicated collection
59- * (i.e. a collection outside of the local database in any mongod mode).
60- *
6147 * * capped (boolean): Specify true to create a capped collection. If set,
6248 * the size option must also be specified. The default is false.
6349 *
@@ -83,11 +69,6 @@ final class CreateCollection
8369 *
8470 * This is not supported for servers versions < 5.0.
8571 *
86- * * flags (integer): Options for the MMAPv1 storage engine only. Must be a
87- * bitwise combination CreateCollection::USE_POWER_OF_2_SIZES and
88- * CreateCollection::NO_PADDING. The default is
89- * CreateCollection::USE_POWER_OF_2_SIZES.
90- *
9172 * * indexOptionDefaults (document): Default configuration for indexes when
9273 * creating the collection.
9374 *
@@ -131,10 +112,6 @@ final class CreateCollection
131112 */
132113 public function __construct (private string $ databaseName , private string $ collectionName , private array $ options = [])
133114 {
134- if (isset ($ this ->options ['autoIndexId ' ]) && ! is_bool ($ this ->options ['autoIndexId ' ])) {
135- throw InvalidArgumentException::invalidType ('"autoIndexId" option ' , $ this ->options ['autoIndexId ' ], 'boolean ' );
136- }
137-
138115 if (isset ($ this ->options ['capped ' ]) && ! is_bool ($ this ->options ['capped ' ])) {
139116 throw InvalidArgumentException::invalidType ('"capped" option ' , $ this ->options ['capped ' ], 'boolean ' );
140117 }
@@ -159,10 +136,6 @@ public function __construct(private string $databaseName, private string $collec
159136 throw InvalidArgumentException::invalidType ('"expireAfterSeconds" option ' , $ this ->options ['expireAfterSeconds ' ], 'integer ' );
160137 }
161138
162- if (isset ($ this ->options ['flags ' ]) && ! is_integer ($ this ->options ['flags ' ])) {
163- throw InvalidArgumentException::invalidType ('"flags" option ' , $ this ->options ['flags ' ], 'integer ' );
164- }
165-
166139 if (isset ($ this ->options ['indexOptionDefaults ' ]) && ! is_document ($ this ->options ['indexOptionDefaults ' ])) {
167140 throw InvalidArgumentException::expectedDocumentType ('"indexOptionDefaults" option ' , $ this ->options ['indexOptionDefaults ' ]);
168141 }
@@ -219,10 +192,6 @@ public function __construct(private string $databaseName, private string $collec
219192 unset($ this ->options ['writeConcern ' ]);
220193 }
221194
222- if (isset ($ this ->options ['autoIndexId ' ])) {
223- trigger_error ('The "autoIndexId" option is deprecated and will be removed in version 2.0 ' , E_USER_DEPRECATED );
224- }
225-
226195 if (isset ($ this ->options ['pipeline ' ]) && ! is_pipeline ($ this ->options ['pipeline ' ], true /* allowEmpty */ )) {
227196 throw new InvalidArgumentException ('"pipeline" option is not a valid aggregation pipeline ' );
228197 }
@@ -245,7 +214,7 @@ private function createCommand(): Command
245214 {
246215 $ cmd = ['create ' => $ this ->collectionName ];
247216
248- foreach (['autoIndexId ' , ' capped ' , 'comment ' , 'expireAfterSeconds ' , ' flags ' , 'max ' , 'maxTimeMS ' , 'pipeline ' , 'size ' , 'validationAction ' , 'validationLevel ' , 'viewOn ' ] as $ option ) {
217+ foreach (['capped ' , 'comment ' , 'expireAfterSeconds ' , 'max ' , 'maxTimeMS ' , 'pipeline ' , 'size ' , 'validationAction ' , 'validationLevel ' , 'viewOn ' ] as $ option ) {
249218 if (isset ($ this ->options [$ option ])) {
250219 $ cmd [$ option ] = $ this ->options [$ option ];
251220 }
0 commit comments