From dd9ac31e7d6c80ddd5544f2448340ce6c3d68b3a Mon Sep 17 00:00:00 2001 From: Jeremy Mikola Date: Wed, 9 Oct 2024 10:06:37 -0400 Subject: [PATCH] PHPLIB-1545: Deprecate CreateCollection flags option and related constants (#1477) --- src/Operation/CreateCollection.php | 7 +++++++ tests/Operation/CreateCollectionTest.php | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/src/Operation/CreateCollection.php b/src/Operation/CreateCollection.php index a633dd682..e0f267af3 100644 --- a/src/Operation/CreateCollection.php +++ b/src/Operation/CreateCollection.php @@ -45,7 +45,10 @@ */ class CreateCollection implements Executable { + /** @deprecated 1.21 */ public const USE_POWER_OF_2_SIZES = 1; + + /** @deprecated 1.21 */ public const NO_PADDING = 2; /** @@ -233,6 +236,10 @@ public function __construct(private string $databaseName, private string $collec trigger_error('The "autoIndexId" option is deprecated and will be removed in version 2.0', E_USER_DEPRECATED); } + if (isset($this->options['flags'])) { + trigger_error('The "flags" option is deprecated and will be removed in version 2.0', E_USER_DEPRECATED); + } + if (isset($this->options['pipeline']) && ! is_pipeline($this->options['pipeline'], true /* allowEmpty */)) { throw new InvalidArgumentException('"pipeline" option is not a valid aggregation pipeline'); } diff --git a/tests/Operation/CreateCollectionTest.php b/tests/Operation/CreateCollectionTest.php index 21a280032..4012a7ed5 100644 --- a/tests/Operation/CreateCollectionTest.php +++ b/tests/Operation/CreateCollectionTest.php @@ -60,4 +60,11 @@ public function testAutoIndexIdOptionIsDeprecated(): void new CreateCollection($this->getDatabaseName(), $this->getCollectionName(), ['autoIndexId' => false]); }); } + + public function testFlagsOptionIsDeprecated(): void + { + $this->assertDeprecated(function (): void { + new CreateCollection($this->getDatabaseName(), $this->getCollectionName(), ['flags' => CreateCollection::USE_POWER_OF_2_SIZES]); + }); + } }