Skip to content

Commit dd9ac31

Browse files
authored
PHPLIB-1545: Deprecate CreateCollection flags option and related constants (#1477)
1 parent a8db4b6 commit dd9ac31

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/Operation/CreateCollection.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@
4545
*/
4646
class CreateCollection implements Executable
4747
{
48+
/** @deprecated 1.21 */
4849
public const USE_POWER_OF_2_SIZES = 1;
50+
51+
/** @deprecated 1.21 */
4952
public const NO_PADDING = 2;
5053

5154
/**
@@ -233,6 +236,10 @@ public function __construct(private string $databaseName, private string $collec
233236
trigger_error('The "autoIndexId" option is deprecated and will be removed in version 2.0', E_USER_DEPRECATED);
234237
}
235238

239+
if (isset($this->options['flags'])) {
240+
trigger_error('The "flags" option is deprecated and will be removed in version 2.0', E_USER_DEPRECATED);
241+
}
242+
236243
if (isset($this->options['pipeline']) && ! is_pipeline($this->options['pipeline'], true /* allowEmpty */)) {
237244
throw new InvalidArgumentException('"pipeline" option is not a valid aggregation pipeline');
238245
}

tests/Operation/CreateCollectionTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,11 @@ public function testAutoIndexIdOptionIsDeprecated(): void
6060
new CreateCollection($this->getDatabaseName(), $this->getCollectionName(), ['autoIndexId' => false]);
6161
});
6262
}
63+
64+
public function testFlagsOptionIsDeprecated(): void
65+
{
66+
$this->assertDeprecated(function (): void {
67+
new CreateCollection($this->getDatabaseName(), $this->getCollectionName(), ['flags' => CreateCollection::USE_POWER_OF_2_SIZES]);
68+
});
69+
}
6370
}

0 commit comments

Comments
 (0)