From 5841238d45f78530bf4b83a95900a3e30c6da4ee Mon Sep 17 00:00:00 2001 From: Andreas Braun Date: Mon, 23 Sep 2024 13:19:34 +0200 Subject: [PATCH 1/4] PHPLIB-797: Remove unused methods in UnsupportedException --- src/Exception/UnsupportedException.php | 66 -------------------------- 1 file changed, 66 deletions(-) diff --git a/src/Exception/UnsupportedException.php b/src/Exception/UnsupportedException.php index 2bf910a09..2b13b4af6 100644 --- a/src/Exception/UnsupportedException.php +++ b/src/Exception/UnsupportedException.php @@ -19,42 +19,6 @@ class UnsupportedException extends RuntimeException { - /** - * Thrown when a command's allowDiskUse option is not supported by a server. - * - * @return self - */ - public static function allowDiskUseNotSupported() - { - return new self('The "allowDiskUse" option is not supported by the server executing this operation'); - } - - /** - * Thrown when array filters are not supported by a server. - * - * @deprecated 1.12 - * @todo Remove this in 2.0 (see: PHPLIB-797) - * - * @return self - */ - public static function arrayFiltersNotSupported() - { - return new self('Array filters are not supported by the server executing this operation'); - } - - /** - * Thrown when collations are not supported by a server. - * - * @deprecated 1.12 - * @todo Remove this in 2.0 (see: PHPLIB-797) - * - * @return self - */ - public static function collationNotSupported() - { - return new self('Collations are not supported by the server executing this operation'); - } - /** * Thrown when the commitQuorum option for createIndexes is not supported * by a server. @@ -66,16 +30,6 @@ public static function commitQuorumNotSupported() return new self('The "commitQuorum" option is not supported by the server executing this operation'); } - /** - * Thrown when explain is not supported by a server. - * - * @return self - */ - public static function explainNotSupported() - { - return new self('Explain is not supported by the server executing this operation'); - } - /** * Thrown when a command's hint option is not supported by a server. * @@ -86,16 +40,6 @@ public static function hintNotSupported() return new self('Hint is not supported by the server executing this operation'); } - /** - * Thrown when a command's readConcern option is not supported by a server. - * - * @return self - */ - public static function readConcernNotSupported() - { - return new self('Read concern is not supported by the server executing this command'); - } - /** * Thrown when a readConcern is used with a read operation in a transaction. * @@ -106,16 +50,6 @@ public static function readConcernNotSupportedInTransaction() return new self('The "readConcern" option cannot be specified within a transaction. Instead, specify it when starting the transaction.'); } - /** - * Thrown when a command's writeConcern option is not supported by a server. - * - * @return self - */ - public static function writeConcernNotSupported() - { - return new self('Write concern is not supported by the server executing this command'); - } - /** * Thrown when a writeConcern is used with a write operation in a transaction. * From 18b279a0c1aca18a3ff5db8ec9c8693c3d17074c Mon Sep 17 00:00:00 2001 From: Andreas Braun Date: Mon, 23 Sep 2024 13:22:10 +0200 Subject: [PATCH 2/4] Mark remaining methods as internal --- src/Exception/UnsupportedException.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Exception/UnsupportedException.php b/src/Exception/UnsupportedException.php index 2b13b4af6..2ad501051 100644 --- a/src/Exception/UnsupportedException.php +++ b/src/Exception/UnsupportedException.php @@ -24,6 +24,7 @@ class UnsupportedException extends RuntimeException * by a server. * * @return self + * @internal */ public static function commitQuorumNotSupported() { @@ -34,6 +35,7 @@ public static function commitQuorumNotSupported() * Thrown when a command's hint option is not supported by a server. * * @return self + * @internal */ public static function hintNotSupported() { @@ -44,6 +46,7 @@ public static function hintNotSupported() * Thrown when a readConcern is used with a read operation in a transaction. * * @return self + * @internal */ public static function readConcernNotSupportedInTransaction() { @@ -54,6 +57,7 @@ public static function readConcernNotSupportedInTransaction() * Thrown when a writeConcern is used with a write operation in a transaction. * * @return self + * @internal */ public static function writeConcernNotSupportedInTransaction() { From edcbc586857dab154761ac4331ca0ce081a05cf9 Mon Sep 17 00:00:00 2001 From: Andreas Braun Date: Mon, 23 Sep 2024 13:22:14 +0200 Subject: [PATCH 3/4] Add upgrade note --- UPGRADE-2.0.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/UPGRADE-2.0.md b/UPGRADE-2.0.md index 15af9de1c..2c131e24c 100644 --- a/UPGRADE-2.0.md +++ b/UPGRADE-2.0.md @@ -28,3 +28,18 @@ GridFS ```php $bucket->openUploadStream($fileId, ['metadata' => ['contentType' => 'image/png']]); ``` + +UnsupportedException method removals +------------------------------------ + +The following methods have been removed from the +`MongoDB\Exception\UnsupportedException` class: + * `allowDiskUseNotSupported` + * `arrayFiltersNotSupported` + * `collationNotSupported` + * `explainNotSupported` + * `readConcernNotSupported` + * `writeConcernNotSupported` + +The remaining methods have been marked as internal and may be removed in a +future minor version. Only the class itself is covered by the BC promise. From 66f76dd4e99e681125fc173fbff67b003e1381b5 Mon Sep 17 00:00:00 2001 From: Andreas Braun Date: Mon, 23 Sep 2024 13:55:06 +0200 Subject: [PATCH 4/4] Mark other exception factories as internal --- src/Exception/BadMethodCallException.php | 2 ++ src/Exception/InvalidArgumentException.php | 3 +++ src/Exception/ResumeTokenException.php | 2 ++ src/GridFS/Exception/CorruptFileException.php | 5 +++++ src/GridFS/Exception/FileNotFoundException.php | 3 +++ src/GridFS/Exception/StreamException.php | 7 ++++++- 6 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/Exception/BadMethodCallException.php b/src/Exception/BadMethodCallException.php index e1070982a..4595bb9d1 100644 --- a/src/Exception/BadMethodCallException.php +++ b/src/Exception/BadMethodCallException.php @@ -28,6 +28,7 @@ class BadMethodCallException extends BaseBadMethodCallException implements Excep * * @param string $class Class name * @return self + * @internal */ public static function classIsImmutable(string $class) { @@ -39,6 +40,7 @@ public static function classIsImmutable(string $class) * * @param string $method Method name * @return self + * @internal */ public static function unacknowledgedWriteResultAccess(string $method) { diff --git a/src/Exception/InvalidArgumentException.php b/src/Exception/InvalidArgumentException.php index 115f6a5c7..8a1b81ec2 100644 --- a/src/Exception/InvalidArgumentException.php +++ b/src/Exception/InvalidArgumentException.php @@ -29,6 +29,7 @@ class InvalidArgumentException extends DriverInvalidArgumentException implements Exception { + /** @internal */ public static function cannotCombineCodecAndTypeMap(): self { return new self('Cannot provide both "codec" and "typeMap" options'); @@ -39,6 +40,7 @@ public static function cannotCombineCodecAndTypeMap(): self * * @param string $name Name of the argument or option * @param mixed $value Actual value (used to derive the type) + * @internal */ public static function expectedDocumentType(string $name, mixed $value): self { @@ -52,6 +54,7 @@ public static function expectedDocumentType(string $name, mixed $value): self * @param mixed $value Actual value (used to derive the type) * @param string|list $expectedType Expected type as a string or an array containing one or more strings * @return self + * @internal */ public static function invalidType(string $name, mixed $value, string|array $expectedType) { diff --git a/src/Exception/ResumeTokenException.php b/src/Exception/ResumeTokenException.php index fc8808271..a73249cf9 100644 --- a/src/Exception/ResumeTokenException.php +++ b/src/Exception/ResumeTokenException.php @@ -27,6 +27,7 @@ class ResumeTokenException extends RuntimeException * * @param mixed $value Actual value (used to derive the type) * @return self + * @internal */ public static function invalidType(mixed $value) { @@ -37,6 +38,7 @@ public static function invalidType(mixed $value) * Thrown when a resume token is not found in a change document. * * @return self + * @internal */ public static function notFound() { diff --git a/src/GridFS/Exception/CorruptFileException.php b/src/GridFS/Exception/CorruptFileException.php index db1622908..34f89a6c0 100644 --- a/src/GridFS/Exception/CorruptFileException.php +++ b/src/GridFS/Exception/CorruptFileException.php @@ -25,6 +25,8 @@ class CorruptFileException extends RuntimeException { /** * Thrown when a chunk doesn't contain valid data. + * + * @internal */ public static function invalidChunkData(int $chunkIndex): self { @@ -36,6 +38,7 @@ public static function invalidChunkData(int $chunkIndex): self * * @param integer $expectedIndex Expected index number * @return self + * @internal */ public static function missingChunk(int $expectedIndex) { @@ -48,6 +51,7 @@ public static function missingChunk(int $expectedIndex) * @param integer $index Actual index number (i.e. "n" field) * @param integer $expectedIndex Expected index number * @return self + * @internal */ public static function unexpectedIndex(int $index, int $expectedIndex) { @@ -60,6 +64,7 @@ public static function unexpectedIndex(int $index, int $expectedIndex) * @param integer $size Actual size (i.e. "data" field length) * @param integer $expectedSize Expected size * @return self + * @internal */ public static function unexpectedSize(int $size, int $expectedSize) { diff --git a/src/GridFS/Exception/FileNotFoundException.php b/src/GridFS/Exception/FileNotFoundException.php index 99c6d854a..21b8871ca 100644 --- a/src/GridFS/Exception/FileNotFoundException.php +++ b/src/GridFS/Exception/FileNotFoundException.php @@ -29,6 +29,7 @@ class FileNotFoundException extends RuntimeException * * @param string $filename Filename * @return self + * @internal */ public static function byFilename(string $filename) { @@ -42,6 +43,7 @@ public static function byFilename(string $filename) * @param integer $revision Revision * @param string $namespace Namespace for the files collection * @return self + * @internal */ public static function byFilenameAndRevision(string $filename, int $revision, string $namespace) { @@ -54,6 +56,7 @@ public static function byFilenameAndRevision(string $filename, int $revision, st * @param mixed $id File ID * @param string $namespace Namespace for the files collection * @return self + * @internal */ public static function byId(mixed $id, string $namespace) { diff --git a/src/GridFS/Exception/StreamException.php b/src/GridFS/Exception/StreamException.php index 880182588..3fd75ca8c 100644 --- a/src/GridFS/Exception/StreamException.php +++ b/src/GridFS/Exception/StreamException.php @@ -13,6 +13,7 @@ class StreamException extends RuntimeException /** * @param resource $source * @param resource $destination + * @internal */ public static function downloadFromFilenameFailed(string $filename, $source, $destination): self { @@ -25,6 +26,7 @@ public static function downloadFromFilenameFailed(string $filename, $source, $de /** * @param resource $source * @param resource $destination + * @internal */ public static function downloadFromIdFailed(mixed $id, $source, $destination): self { @@ -35,7 +37,10 @@ public static function downloadFromIdFailed(mixed $id, $source, $destination): s return new self(sprintf('Downloading file from "%s" to "%s" failed. GridFS identifier: "%s"', $sourceMetadata['uri'], $destinationMetadata['uri'], $idString)); } - /** @param resource $source */ + /** + * @param resource $source + * @internal + */ public static function uploadFailed(string $filename, $source, string $destinationUri): self { $sourceMetadata = stream_get_meta_data($source);