-
Notifications
You must be signed in to change notification settings - Fork 266
PHPLIB-1227 Use void return types for operations without meaningful result document #1468
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,11 +54,7 @@ | |
use Throwable; | ||
|
||
use function is_array; | ||
use function sprintf; | ||
use function strlen; | ||
use function trigger_error; | ||
|
||
use const E_USER_DEPRECATED; | ||
|
||
class Database | ||
{ | ||
|
@@ -274,19 +270,12 @@ public function command(array|object $command, array $options = []): CursorInter | |
* @see CreateCollection::__construct() for supported options | ||
* @see https://github.com/mongodb/specifications/blob/master/source/client-side-encryption/client-side-encryption.rst#create-collection-helper | ||
* @see https://www.mongodb.com/docs/manual/core/queryable-encryption/fundamentals/manage-collections/ | ||
* @return array|object Command result document | ||
* @throws UnsupportedException if options are not supported by the selected server | ||
* @throws InvalidArgumentException for parameter/option parsing errors | ||
* @throws DriverRuntimeException for other driver errors (e.g. connection errors) | ||
*/ | ||
public function createCollection(string $collectionName, array $options = []): array|object | ||
public function createCollection(string $collectionName, array $options = []): void | ||
{ | ||
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)) { | ||
$options['writeConcern'] = $this->writeConcern; | ||
} | ||
|
@@ -301,7 +290,7 @@ public function createCollection(string $collectionName, array $options = []): a | |
|
||
$server = select_server_for_write($this->manager, $options); | ||
|
||
return $operation->execute($server); | ||
$operation->execute($server); | ||
} | ||
|
||
/** | ||
|
@@ -319,19 +308,13 @@ public function createCollection(string $collectionName, array $options = []): a | |
* getPrevious() and getEncryptedFields() methods, respectively. | ||
* | ||
* @see CreateCollection::__construct() for supported options | ||
* @return array A tuple containing the command result document from creating the collection and the modified "encryptedFields" option | ||
* @return array The modified "encryptedFields" option | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of a tuple, we return the 2nd element (the |
||
* @throws InvalidArgumentException for parameter/option parsing errors | ||
* @throws CreateEncryptedCollectionException for any errors creating data keys or creating the collection | ||
* @throws UnsupportedException if Queryable Encryption is not supported by the selected server | ||
*/ | ||
public function createEncryptedCollection(string $collectionName, ClientEncryption $clientEncryption, string $kmsProvider, ?array $masterKey, array $options): array | ||
{ | ||
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)) { | ||
$options['writeConcern'] = $this->writeConcern; | ||
} | ||
|
@@ -340,10 +323,10 @@ public function createEncryptedCollection(string $collectionName, ClientEncrypti | |
$server = select_server_for_write($this->manager, $options); | ||
|
||
try { | ||
$operation->createDataKeys($clientEncryption, $kmsProvider, $masterKey, $encryptedFields); | ||
$result = $operation->execute($server); | ||
$encryptedFields = $operation->createDataKeys($clientEncryption, $kmsProvider, $masterKey); | ||
$operation->execute($server); | ||
|
||
return [$result, $encryptedFields]; | ||
return $encryptedFields; | ||
} catch (Throwable $e) { | ||
throw new CreateEncryptedCollectionException($e, $encryptedFields ?? []); | ||
} | ||
|
@@ -354,19 +337,12 @@ public function createEncryptedCollection(string $collectionName, ClientEncrypti | |
* | ||
* @see DropDatabase::__construct() for supported options | ||
* @param array $options Additional options | ||
* @return array|object Command result document | ||
* @throws UnsupportedException if options are unsupported on the selected server | ||
* @throws InvalidArgumentException for parameter/option parsing errors | ||
* @throws DriverRuntimeException for other driver errors (e.g. connection errors) | ||
*/ | ||
public function drop(array $options = []): array|object | ||
public function drop(array $options = []): void | ||
{ | ||
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); | ||
|
||
if (! isset($options['writeConcern']) && ! is_in_transaction($options)) { | ||
|
@@ -375,7 +351,7 @@ public function drop(array $options = []): array|object | |
|
||
$operation = new DropDatabase($this->databaseName, $options); | ||
|
||
return $operation->execute($server); | ||
$operation->execute($server); | ||
} | ||
|
||
/** | ||
|
@@ -384,19 +360,12 @@ public function drop(array $options = []): array|object | |
* @see DropCollection::__construct() for supported options | ||
* @param string $collectionName Collection name | ||
* @param array $options Additional options | ||
* @return array|object Command result document | ||
* @throws UnsupportedException if options are unsupported on the selected server | ||
* @throws InvalidArgumentException for parameter/option parsing errors | ||
* @throws DriverRuntimeException for other driver errors (e.g. connection errors) | ||
*/ | ||
public function dropCollection(string $collectionName, array $options = []): array|object | ||
public function dropCollection(string $collectionName, array $options = []): void | ||
{ | ||
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); | ||
|
||
if (! isset($options['writeConcern']) && ! is_in_transaction($options)) { | ||
|
@@ -412,7 +381,7 @@ public function dropCollection(string $collectionName, array $options = []): arr | |
? new DropEncryptedCollection($this->databaseName, $collectionName, $options) | ||
: new DropCollection($this->databaseName, $collectionName, $options); | ||
|
||
return $operation->execute($server); | ||
$operation->execute($server); | ||
} | ||
|
||
/** | ||
|
@@ -534,21 +503,16 @@ public function modifyCollection(string $collectionName, array $collectionOption | |
* @param string $toCollectionName New name of the collection | ||
* @param string|null $toDatabaseName New database name of the collection. Defaults to the original database. | ||
* @param array $options Additional options | ||
* @return array|object Command result document | ||
* @throws UnsupportedException if options are unsupported on the selected server | ||
* @throws InvalidArgumentException for parameter/option parsing errors | ||
* @throws DriverRuntimeException for other driver errors (e.g. connection errors) | ||
*/ | ||
public function renameCollection(string $fromCollectionName, string $toCollectionName, ?string $toDatabaseName = null, array $options = []): array|object | ||
public function renameCollection(string $fromCollectionName, string $toCollectionName, ?string $toDatabaseName = null, array $options = []): void | ||
{ | ||
if (! isset($toDatabaseName)) { | ||
$toDatabaseName = $this->databaseName; | ||
} | ||
|
||
if (! isset($options['typeMap'])) { | ||
$options['typeMap'] = $this->typeMap; | ||
} | ||
|
||
$server = select_server_for_write($this->manager, $options); | ||
|
||
if (! isset($options['writeConcern']) && ! is_in_transaction($options)) { | ||
|
@@ -557,7 +521,7 @@ public function renameCollection(string $fromCollectionName, string $toCollectio | |
|
||
$operation = new RenameCollection($this->databaseName, $fromCollectionName, $toDatabaseName, $toCollectionName, $options); | ||
|
||
return $operation->execute($server); | ||
$operation->execute($server); | ||
} | ||
|
||
/** | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.