30
30
use function is_string ;
31
31
use function MongoDB \is_document ;
32
32
use function MongoDB \is_pipeline ;
33
- use function trigger_error ;
34
-
35
- use const E_USER_DEPRECATED ;
36
33
37
34
/**
38
35
* Operation for the create command.
42
39
*/
43
40
final class CreateCollection
44
41
{
45
- public const USE_POWER_OF_2_SIZES = 1 ;
46
- public const NO_PADDING = 2 ;
47
-
48
42
/**
49
43
* Constructs a create command.
50
44
*
51
45
* Supported options:
52
46
*
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
- *
61
47
* * capped (boolean): Specify true to create a capped collection. If set,
62
48
* the size option must also be specified. The default is false.
63
49
*
@@ -83,11 +69,6 @@ final class CreateCollection
83
69
*
84
70
* This is not supported for servers versions < 5.0.
85
71
*
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
- *
91
72
* * indexOptionDefaults (document): Default configuration for indexes when
92
73
* creating the collection.
93
74
*
@@ -131,10 +112,6 @@ final class CreateCollection
131
112
*/
132
113
public function __construct (private string $ databaseName , private string $ collectionName , private array $ options = [])
133
114
{
134
- if (isset ($ this ->options ['autoIndexId ' ]) && ! is_bool ($ this ->options ['autoIndexId ' ])) {
135
- throw InvalidArgumentException::invalidType ('"autoIndexId" option ' , $ this ->options ['autoIndexId ' ], 'boolean ' );
136
- }
137
-
138
115
if (isset ($ this ->options ['capped ' ]) && ! is_bool ($ this ->options ['capped ' ])) {
139
116
throw InvalidArgumentException::invalidType ('"capped" option ' , $ this ->options ['capped ' ], 'boolean ' );
140
117
}
@@ -159,10 +136,6 @@ public function __construct(private string $databaseName, private string $collec
159
136
throw InvalidArgumentException::invalidType ('"expireAfterSeconds" option ' , $ this ->options ['expireAfterSeconds ' ], 'integer ' );
160
137
}
161
138
162
- if (isset ($ this ->options ['flags ' ]) && ! is_integer ($ this ->options ['flags ' ])) {
163
- throw InvalidArgumentException::invalidType ('"flags" option ' , $ this ->options ['flags ' ], 'integer ' );
164
- }
165
-
166
139
if (isset ($ this ->options ['indexOptionDefaults ' ]) && ! is_document ($ this ->options ['indexOptionDefaults ' ])) {
167
140
throw InvalidArgumentException::expectedDocumentType ('"indexOptionDefaults" option ' , $ this ->options ['indexOptionDefaults ' ]);
168
141
}
@@ -219,10 +192,6 @@ public function __construct(private string $databaseName, private string $collec
219
192
unset($ this ->options ['writeConcern ' ]);
220
193
}
221
194
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
-
226
195
if (isset ($ this ->options ['pipeline ' ]) && ! is_pipeline ($ this ->options ['pipeline ' ], true /* allowEmpty */ )) {
227
196
throw new InvalidArgumentException ('"pipeline" option is not a valid aggregation pipeline ' );
228
197
}
@@ -245,7 +214,7 @@ private function createCommand(): Command
245
214
{
246
215
$ cmd = ['create ' => $ this ->collectionName ];
247
216
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 ) {
249
218
if (isset ($ this ->options [$ option ])) {
250
219
$ cmd [$ option ] = $ this ->options [$ option ];
251
220
}
0 commit comments