Skip to content

PHPLIB-797: Remove unused methods in UnsupportedException #1436

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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions UPGRADE-2.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
2 changes: 2 additions & 0 deletions src/Exception/BadMethodCallException.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class BadMethodCallException extends BaseBadMethodCallException implements Excep
*
* @param string $class Class name
* @return self
* @internal
*/
public static function classIsImmutable(string $class)
{
Expand All @@ -39,6 +40,7 @@ public static function classIsImmutable(string $class)
*
* @param string $method Method name
* @return self
* @internal
*/
public static function unacknowledgedWriteResultAccess(string $method)
{
Expand Down
3 changes: 3 additions & 0 deletions src/Exception/InvalidArgumentException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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
{
Expand All @@ -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<string> $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)
{
Expand Down
2 changes: 2 additions & 0 deletions src/Exception/ResumeTokenException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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()
{
Expand Down
70 changes: 4 additions & 66 deletions src/Exception/UnsupportedException.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,107 +19,45 @@

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.
*
* @return self
* @internal
*/
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.
*
* @return self
* @internal
*/
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.
*
* @return self
* @internal
*/
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.
*
* @return self
* @internal
*/
public static function writeConcernNotSupportedInTransaction()
{
Expand Down
5 changes: 5 additions & 0 deletions src/GridFS/Exception/CorruptFileException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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)
{
Expand All @@ -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)
{
Expand All @@ -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)
{
Expand Down
3 changes: 3 additions & 0 deletions src/GridFS/Exception/FileNotFoundException.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class FileNotFoundException extends RuntimeException
*
* @param string $filename Filename
* @return self
* @internal
*/
public static function byFilename(string $filename)
{
Expand All @@ -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)
{
Expand All @@ -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)
{
Expand Down
7 changes: 6 additions & 1 deletion src/GridFS/Exception/StreamException.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class StreamException extends RuntimeException
/**
* @param resource $source
* @param resource $destination
* @internal
*/
public static function downloadFromFilenameFailed(string $filename, $source, $destination): self
{
Expand All @@ -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
{
Expand All @@ -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);
Expand Down