Skip to content

Commit 081e9da

Browse files
authored
PHPLIB-797: Remove unused methods in UnsupportedException (#1436)
* PHPLIB-797: Remove unused methods in UnsupportedException * Mark remaining methods as internal * Add upgrade note * Mark other exception factories as internal
1 parent 809b69a commit 081e9da

8 files changed

+40
-67
lines changed

UPGRADE-2.0.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,18 @@ GridFS
2828
```php
2929
$bucket->openUploadStream($fileId, ['metadata' => ['contentType' => 'image/png']]);
3030
```
31+
32+
UnsupportedException method removals
33+
------------------------------------
34+
35+
The following methods have been removed from the
36+
`MongoDB\Exception\UnsupportedException` class:
37+
* `allowDiskUseNotSupported`
38+
* `arrayFiltersNotSupported`
39+
* `collationNotSupported`
40+
* `explainNotSupported`
41+
* `readConcernNotSupported`
42+
* `writeConcernNotSupported`
43+
44+
The remaining methods have been marked as internal and may be removed in a
45+
future minor version. Only the class itself is covered by the BC promise.

src/Exception/BadMethodCallException.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class BadMethodCallException extends BaseBadMethodCallException implements Excep
2828
*
2929
* @param string $class Class name
3030
* @return self
31+
* @internal
3132
*/
3233
public static function classIsImmutable(string $class)
3334
{
@@ -39,6 +40,7 @@ public static function classIsImmutable(string $class)
3940
*
4041
* @param string $method Method name
4142
* @return self
43+
* @internal
4244
*/
4345
public static function unacknowledgedWriteResultAccess(string $method)
4446
{

src/Exception/InvalidArgumentException.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
class InvalidArgumentException extends DriverInvalidArgumentException implements Exception
3131
{
32+
/** @internal */
3233
public static function cannotCombineCodecAndTypeMap(): self
3334
{
3435
return new self('Cannot provide both "codec" and "typeMap" options');
@@ -39,6 +40,7 @@ public static function cannotCombineCodecAndTypeMap(): self
3940
*
4041
* @param string $name Name of the argument or option
4142
* @param mixed $value Actual value (used to derive the type)
43+
* @internal
4244
*/
4345
public static function expectedDocumentType(string $name, mixed $value): self
4446
{
@@ -52,6 +54,7 @@ public static function expectedDocumentType(string $name, mixed $value): self
5254
* @param mixed $value Actual value (used to derive the type)
5355
* @param string|list<string> $expectedType Expected type as a string or an array containing one or more strings
5456
* @return self
57+
* @internal
5558
*/
5659
public static function invalidType(string $name, mixed $value, string|array $expectedType)
5760
{

src/Exception/ResumeTokenException.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class ResumeTokenException extends RuntimeException
2727
*
2828
* @param mixed $value Actual value (used to derive the type)
2929
* @return self
30+
* @internal
3031
*/
3132
public static function invalidType(mixed $value)
3233
{
@@ -37,6 +38,7 @@ public static function invalidType(mixed $value)
3738
* Thrown when a resume token is not found in a change document.
3839
*
3940
* @return self
41+
* @internal
4042
*/
4143
public static function notFound()
4244
{

src/Exception/UnsupportedException.php

Lines changed: 4 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -19,107 +19,45 @@
1919

2020
class UnsupportedException extends RuntimeException
2121
{
22-
/**
23-
* Thrown when a command's allowDiskUse option is not supported by a server.
24-
*
25-
* @return self
26-
*/
27-
public static function allowDiskUseNotSupported()
28-
{
29-
return new self('The "allowDiskUse" option is not supported by the server executing this operation');
30-
}
31-
32-
/**
33-
* Thrown when array filters are not supported by a server.
34-
*
35-
* @deprecated 1.12
36-
* @todo Remove this in 2.0 (see: PHPLIB-797)
37-
*
38-
* @return self
39-
*/
40-
public static function arrayFiltersNotSupported()
41-
{
42-
return new self('Array filters are not supported by the server executing this operation');
43-
}
44-
45-
/**
46-
* Thrown when collations are not supported by a server.
47-
*
48-
* @deprecated 1.12
49-
* @todo Remove this in 2.0 (see: PHPLIB-797)
50-
*
51-
* @return self
52-
*/
53-
public static function collationNotSupported()
54-
{
55-
return new self('Collations are not supported by the server executing this operation');
56-
}
57-
5822
/**
5923
* Thrown when the commitQuorum option for createIndexes is not supported
6024
* by a server.
6125
*
6226
* @return self
27+
* @internal
6328
*/
6429
public static function commitQuorumNotSupported()
6530
{
6631
return new self('The "commitQuorum" option is not supported by the server executing this operation');
6732
}
6833

69-
/**
70-
* Thrown when explain is not supported by a server.
71-
*
72-
* @return self
73-
*/
74-
public static function explainNotSupported()
75-
{
76-
return new self('Explain is not supported by the server executing this operation');
77-
}
78-
7934
/**
8035
* Thrown when a command's hint option is not supported by a server.
8136
*
8237
* @return self
38+
* @internal
8339
*/
8440
public static function hintNotSupported()
8541
{
8642
return new self('Hint is not supported by the server executing this operation');
8743
}
8844

89-
/**
90-
* Thrown when a command's readConcern option is not supported by a server.
91-
*
92-
* @return self
93-
*/
94-
public static function readConcernNotSupported()
95-
{
96-
return new self('Read concern is not supported by the server executing this command');
97-
}
98-
9945
/**
10046
* Thrown when a readConcern is used with a read operation in a transaction.
10147
*
10248
* @return self
49+
* @internal
10350
*/
10451
public static function readConcernNotSupportedInTransaction()
10552
{
10653
return new self('The "readConcern" option cannot be specified within a transaction. Instead, specify it when starting the transaction.');
10754
}
10855

109-
/**
110-
* Thrown when a command's writeConcern option is not supported by a server.
111-
*
112-
* @return self
113-
*/
114-
public static function writeConcernNotSupported()
115-
{
116-
return new self('Write concern is not supported by the server executing this command');
117-
}
118-
11956
/**
12057
* Thrown when a writeConcern is used with a write operation in a transaction.
12158
*
12259
* @return self
60+
* @internal
12361
*/
12462
public static function writeConcernNotSupportedInTransaction()
12563
{

src/GridFS/Exception/CorruptFileException.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ class CorruptFileException extends RuntimeException
2525
{
2626
/**
2727
* Thrown when a chunk doesn't contain valid data.
28+
*
29+
* @internal
2830
*/
2931
public static function invalidChunkData(int $chunkIndex): self
3032
{
@@ -36,6 +38,7 @@ public static function invalidChunkData(int $chunkIndex): self
3638
*
3739
* @param integer $expectedIndex Expected index number
3840
* @return self
41+
* @internal
3942
*/
4043
public static function missingChunk(int $expectedIndex)
4144
{
@@ -48,6 +51,7 @@ public static function missingChunk(int $expectedIndex)
4851
* @param integer $index Actual index number (i.e. "n" field)
4952
* @param integer $expectedIndex Expected index number
5053
* @return self
54+
* @internal
5155
*/
5256
public static function unexpectedIndex(int $index, int $expectedIndex)
5357
{
@@ -60,6 +64,7 @@ public static function unexpectedIndex(int $index, int $expectedIndex)
6064
* @param integer $size Actual size (i.e. "data" field length)
6165
* @param integer $expectedSize Expected size
6266
* @return self
67+
* @internal
6368
*/
6469
public static function unexpectedSize(int $size, int $expectedSize)
6570
{

src/GridFS/Exception/FileNotFoundException.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class FileNotFoundException extends RuntimeException
2929
*
3030
* @param string $filename Filename
3131
* @return self
32+
* @internal
3233
*/
3334
public static function byFilename(string $filename)
3435
{
@@ -42,6 +43,7 @@ public static function byFilename(string $filename)
4243
* @param integer $revision Revision
4344
* @param string $namespace Namespace for the files collection
4445
* @return self
46+
* @internal
4547
*/
4648
public static function byFilenameAndRevision(string $filename, int $revision, string $namespace)
4749
{
@@ -54,6 +56,7 @@ public static function byFilenameAndRevision(string $filename, int $revision, st
5456
* @param mixed $id File ID
5557
* @param string $namespace Namespace for the files collection
5658
* @return self
59+
* @internal
5760
*/
5861
public static function byId(mixed $id, string $namespace)
5962
{

src/GridFS/Exception/StreamException.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class StreamException extends RuntimeException
1313
/**
1414
* @param resource $source
1515
* @param resource $destination
16+
* @internal
1617
*/
1718
public static function downloadFromFilenameFailed(string $filename, $source, $destination): self
1819
{
@@ -25,6 +26,7 @@ public static function downloadFromFilenameFailed(string $filename, $source, $de
2526
/**
2627
* @param resource $source
2728
* @param resource $destination
29+
* @internal
2830
*/
2931
public static function downloadFromIdFailed(mixed $id, $source, $destination): self
3032
{
@@ -35,7 +37,10 @@ public static function downloadFromIdFailed(mixed $id, $source, $destination): s
3537
return new self(sprintf('Downloading file from "%s" to "%s" failed. GridFS identifier: "%s"', $sourceMetadata['uri'], $destinationMetadata['uri'], $idString));
3638
}
3739

38-
/** @param resource $source */
40+
/**
41+
* @param resource $source
42+
* @internal
43+
*/
3944
public static function uploadFailed(string $filename, $source, string $destinationUri): self
4045
{
4146
$sourceMetadata = stream_get_meta_data($source);

0 commit comments

Comments
 (0)