diff --git a/src/Client.php b/src/Client.php index 5ed76a0e0..f21d09d72 100644 --- a/src/Client.php +++ b/src/Client.php @@ -49,6 +49,10 @@ use function array_diff_key; use function is_array; use function is_string; +use function sprintf; +use function trigger_error; + +use const E_USER_DEPRECATED; class Client { @@ -228,6 +232,8 @@ public function dropDatabase(string $databaseName, array $options = []) { if (! isset($options['typeMap'])) { $options['typeMap'] = $this->typeMap; + } else { + @trigger_error(sprintf('The function %s() will return nothing in mongodb/mongodb v2.0, the "typeMap" option is deprecated', __FUNCTION__), E_USER_DEPRECATED); } $server = select_server_for_write($this->manager, $options); diff --git a/src/Collection.php b/src/Collection.php index 937f22f5b..c596d3e96 100644 --- a/src/Collection.php +++ b/src/Collection.php @@ -524,7 +524,7 @@ public function distinct(string $fieldName, array|object $filter = [], array $op public function drop(array $options = []) { $options = $this->inheritWriteOptions($options); - $options = $this->inheritTypeMap($options); + $options = $this->inheritTypeMap($options, __FUNCTION__); $server = select_server_for_write($this->manager, $options); @@ -560,7 +560,7 @@ public function dropIndex(string|IndexInfo $indexName, array $options = []) } $options = $this->inheritWriteOptions($options); - $options = $this->inheritTypeMap($options); + $options = $this->inheritTypeMap($options, __FUNCTION__); $operation = new DropIndexes($this->databaseName, $this->collectionName, $indexName, $options); @@ -580,7 +580,7 @@ public function dropIndex(string|IndexInfo $indexName, array $options = []) public function dropIndexes(array $options = []) { $options = $this->inheritWriteOptions($options); - $options = $this->inheritTypeMap($options); + $options = $this->inheritTypeMap($options, __FUNCTION__); $operation = new DropIndexes($this->databaseName, $this->collectionName, '*', $options); @@ -1212,8 +1212,12 @@ private function inheritReadPreference(array $options): array return $options; } - private function inheritTypeMap(array $options): array + private function inheritTypeMap(array $options, ?string $deprecatedFunction = null): array { + if ($deprecatedFunction !== null && isset($options['typeMap'])) { + @trigger_error(sprintf('The function %s() will return nothing in mongodb/mongodb v2.0, the "typeMap" option is deprecated', $deprecatedFunction), E_USER_DEPRECATED); + } + // Only inherit the type map if no codec is used if (! isset($options['typeMap']) && ! isset($options['codec'])) { $options['typeMap'] = $this->typeMap; diff --git a/src/Database.php b/src/Database.php index 4d15637a4..0561ea943 100644 --- a/src/Database.php +++ b/src/Database.php @@ -55,7 +55,11 @@ use Traversable; use function is_array; +use function sprintf; use function strlen; +use function trigger_error; + +use const E_USER_DEPRECATED; class Database { @@ -286,6 +290,8 @@ public function createCollection(string $collectionName, array $options = []) { if (! isset($options['typeMap'])) { $options['typeMap'] = $this->typeMap; + } else { + @trigger_error(sprintf('The function %s() will return nothing in mongodb/mongodb v2.0, the "typeMap" option is deprecated', __FUNCTION__), E_USER_DEPRECATED); } if (! isset($options['writeConcern']) && ! is_in_transaction($options)) { @@ -329,6 +335,8 @@ public function createEncryptedCollection(string $collectionName, ClientEncrypti { if (! isset($options['typeMap'])) { $options['typeMap'] = $this->typeMap; + } else { + @trigger_error(sprintf('The function %s() will return nothing in mongodb/mongodb v2.0, the "typeMap" option is deprecated', __FUNCTION__), E_USER_DEPRECATED); } if (! isset($options['writeConcern']) && ! is_in_transaction($options)) { @@ -362,6 +370,8 @@ public function drop(array $options = []) { if (! isset($options['typeMap'])) { $options['typeMap'] = $this->typeMap; + } else { + @trigger_error(sprintf('The function %s() will return nothing in mongodb/mongodb v2.0, the "typeMap" option is deprecated', __FUNCTION__), E_USER_DEPRECATED); } $server = select_server_for_write($this->manager, $options); @@ -390,6 +400,8 @@ public function dropCollection(string $collectionName, array $options = []) { if (! isset($options['typeMap'])) { $options['typeMap'] = $this->typeMap; + } else { + @trigger_error(sprintf('The function %s() will return nothing in mongodb/mongodb v2.0, the "typeMap" option is deprecated', __FUNCTION__), E_USER_DEPRECATED); } $server = select_server_for_write($this->manager, $options);