Skip to content

Commit 368954a

Browse files
authored
PHPLIB-953 Make internal classes and Operation classes final (#1392)
* PHPLIB-953 Make internal classes final * Make all Operation classes final * Add UPGRADE-2.0
1 parent 0552779 commit 368954a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+61
-59
lines changed

UPGRADE-2.0.md

Lines changed: 2 additions & 0 deletions

src/Command/ListCollections.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
* @internal
3737
* @see https://mongodb.com/docs/manual/reference/command/listCollections/
3838
*/
39-
class ListCollections implements Executable
39+
final class ListCollections implements Executable
4040
{
4141
/**
4242
* Constructs a listCollections command.

src/Command/ListDatabases.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
* @internal
3838
* @see https://mongodb.com/docs/manual/reference/command/listDatabases/
3939
*/
40-
class ListDatabases implements Executable
40+
final class ListDatabases implements Executable
4141
{
4242
/**
4343
* Constructs a listDatabases command.

src/GridFS/CollectionWrapper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
*
4040
* @internal
4141
*/
42-
class CollectionWrapper
42+
final class CollectionWrapper
4343
{
4444
private Collection $chunksCollection;
4545

src/GridFS/ReadableStream.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
*
3939
* @internal
4040
*/
41-
class ReadableStream
41+
final class ReadableStream
4242
{
4343
private ?string $buffer = null;
4444

src/GridFS/StreamWrapper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
* @see Bucket::openDownloadStream()
5050
* @psalm-type ContextOptions = array{collectionWrapper: CollectionWrapper, file: object}|array{collectionWrapper: CollectionWrapper, filename: string, options: array}
5151
*/
52-
class StreamWrapper
52+
final class StreamWrapper
5353
{
5454
/** @var resource|null Stream context (set by PHP) */
5555
public $context;
@@ -89,7 +89,7 @@ public static function register(string $protocol = 'gridfs'): void
8989
stream_wrapper_unregister($protocol);
9090
}
9191

92-
stream_wrapper_register($protocol, static::class, STREAM_IS_URL);
92+
stream_wrapper_register($protocol, self::class, STREAM_IS_URL);
9393
}
9494

9595
/**

src/GridFS/WritableStream.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
*
3636
* @internal
3737
*/
38-
class WritableStream
38+
final class WritableStream
3939
{
4040
private const DEFAULT_CHUNK_SIZE_BYTES = 261120;
4141

src/Model/CachingIterator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
* @template TValue
4141
* @template-implements Iterator<TKey, TValue>
4242
*/
43-
class CachingIterator implements Countable, Iterator
43+
final class CachingIterator implements Countable, Iterator
4444
{
4545
private const FIELD_KEY = 0;
4646
private const FIELD_VALUE = 1;

src/Model/CallbackIterator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
* @template TCallbackValue
3535
* @template-implements Iterator<TKey, TCallbackValue>
3636
*/
37-
class CallbackIterator implements Iterator
37+
final class CallbackIterator implements Iterator
3838
{
3939
/** @var callable(TValue, TKey): TCallbackValue */
4040
private $callback;

src/Model/ChangeStreamIterator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
* @template TValue of array|object
5252
* @template-extends IteratorIterator<int, TValue, CursorInterface<int, TValue>&Iterator<int, TValue>>
5353
*/
54-
class ChangeStreamIterator extends IteratorIterator implements CommandSubscriber
54+
final class ChangeStreamIterator extends IteratorIterator implements CommandSubscriber
5555
{
5656
private int $batchPosition = 0;
5757

src/Model/CollectionInfoCommandIterator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
* @see https://mongodb.com/docs/manual/reference/command/listCollections/
3333
* @template-extends IteratorIterator<int, array, Traversable<int, array>>
3434
*/
35-
class CollectionInfoCommandIterator extends IteratorIterator implements CollectionInfoIterator
35+
final class CollectionInfoCommandIterator extends IteratorIterator implements CollectionInfoIterator
3636
{
3737
/** @param Traversable<int, array> $iterator */
3838
public function __construct(Traversable $iterator, private ?string $databaseName = null)

src/Model/DatabaseInfoLegacyIterator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
* @see \MongoDB\Client::listDatabases()
3333
* @see https://mongodb.com/docs/manual/reference/command/listDatabases/
3434
*/
35-
class DatabaseInfoLegacyIterator implements DatabaseInfoIterator
35+
final class DatabaseInfoLegacyIterator implements DatabaseInfoIterator
3636
{
3737
public function __construct(private array $databases)
3838
{

src/Model/IndexInfoIteratorIterator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
* @see https://mongodb.com/docs/manual/reference/system-collections/
3737
* @template-extends IteratorIterator<int, array, Traversable<int, array>>
3838
*/
39-
class IndexInfoIteratorIterator extends IteratorIterator implements IndexInfoIterator
39+
final class IndexInfoIteratorIterator extends IteratorIterator implements IndexInfoIterator
4040
{
4141
/** @param Traversable<int, array> $iterator */
4242
public function __construct(Traversable $iterator, private ?string $ns = null)

src/Model/IndexInput.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
* @see https://github.com/mongodb/specifications/blob/master/source/enumerate-indexes.rst
3939
* @see https://mongodb.com/docs/manual/reference/method/db.collection.createIndex/
4040
*/
41-
class IndexInput implements Serializable
41+
final class IndexInput implements Serializable
4242
{
4343
/**
4444
* @param array $index Index specification

src/Model/SearchIndexInput.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
* @see https://github.com/mongodb/specifications/blob/master/source/index-management/index-management.rst#search-indexes
3535
* @see https://mongodb.com/docs/manual/reference/method/db.collection.createSearchIndex/
3636
*/
37-
class SearchIndexInput implements Serializable
37+
final class SearchIndexInput implements Serializable
3838
{
3939
/**
4040
* @param array{definition: array|object, name?: string, type?: string} $index Search index specification

src/Operation/Aggregate.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
* @see \MongoDB\Collection::aggregate()
5050
* @see https://mongodb.com/docs/manual/reference/command/aggregate/
5151
*/
52-
class Aggregate implements Executable, Explainable
52+
final class Aggregate implements Executable, Explainable
5353
{
5454
private bool $isWrite;
5555

src/Operation/BulkWrite.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
*
4747
* @see \MongoDB\Collection::bulkWrite()
4848
*/
49-
class BulkWrite implements Executable
49+
final class BulkWrite implements Executable
5050
{
5151
public const DELETE_MANY = 'deleteMany';
5252
public const DELETE_ONE = 'deleteOne';

src/Operation/Count.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
* @see \MongoDB\Collection::count()
4242
* @see https://mongodb.com/docs/manual/reference/command/count/
4343
*/
44-
class Count implements Executable, Explainable
44+
final class Count implements Executable, Explainable
4545
{
4646
/**
4747
* Constructs a count command.

src/Operation/CountDocuments.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
* @see \MongoDB\Collection::countDocuments()
3838
* @see https://github.com/mongodb/specifications/blob/master/source/crud/crud.rst#countdocuments
3939
*/
40-
class CountDocuments implements Executable
40+
final class CountDocuments implements Executable
4141
{
4242
private array $aggregateOptions;
4343

src/Operation/CreateCollection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
* @see \MongoDB\Database::createCollection()
4242
* @see https://mongodb.com/docs/manual/reference/command/create/
4343
*/
44-
class CreateCollection implements Executable
44+
final class CreateCollection implements Executable
4545
{
4646
public const USE_POWER_OF_2_SIZES = 1;
4747
public const NO_PADDING = 2;

src/Operation/CreateEncryptedCollection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
* @see https://github.com/mongodb/specifications/blob/master/source/client-side-encryption/client-side-encryption.rst#create-encrypted-collection-helper
4949
* @see https://www.mongodb.com/docs/manual/core/queryable-encryption/fundamentals/manage-collections/
5050
*/
51-
class CreateEncryptedCollection implements Executable
51+
final class CreateEncryptedCollection implements Executable
5252
{
5353
private const WIRE_VERSION_FOR_QUERYABLE_ENCRYPTION_V2 = 21;
5454

src/Operation/CreateIndexes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
* @see \MongoDB\Collection::createIndexes()
4242
* @see https://mongodb.com/docs/manual/reference/command/createIndexes/
4343
*/
44-
class CreateIndexes implements Executable
44+
final class CreateIndexes implements Executable
4545
{
4646
private const WIRE_VERSION_FOR_COMMIT_QUORUM = 9;
4747

src/Operation/CreateSearchIndexes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
* @see \MongoDB\Collection::createSearchIndexes()
3838
* @see https://mongodb.com/docs/manual/reference/command/createSearchIndexes/
3939
*/
40-
class CreateSearchIndexes implements Executable
40+
final class CreateSearchIndexes implements Executable
4141
{
4242
private array $indexes = [];
4343

src/Operation/DatabaseCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
*
3333
* @see \MongoDB\Database::command()
3434
*/
35-
class DatabaseCommand implements Executable
35+
final class DatabaseCommand implements Executable
3636
{
3737
private Command $command;
3838

src/Operation/Delete.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
* @internal
4343
* @see https://mongodb.com/docs/manual/reference/command/delete/
4444
*/
45-
class Delete implements Executable, Explainable
45+
final class Delete implements Executable, Explainable
4646
{
4747
private const WIRE_VERSION_FOR_HINT = 9;
4848

src/Operation/DeleteMany.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
* @see \MongoDB\Collection::deleteOne()
3030
* @see https://mongodb.com/docs/manual/reference/command/delete/
3131
*/
32-
class DeleteMany implements Executable, Explainable
32+
final class DeleteMany implements Executable, Explainable
3333
{
3434
private Delete $delete;
3535

src/Operation/DeleteOne.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
* @see \MongoDB\Collection::deleteOne()
3030
* @see https://mongodb.com/docs/manual/reference/command/delete/
3131
*/
32-
class DeleteOne implements Executable, Explainable
32+
final class DeleteOne implements Executable, Explainable
3333
{
3434
private Delete $delete;
3535

src/Operation/Distinct.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
* @see \MongoDB\Collection::distinct()
4141
* @see https://mongodb.com/docs/manual/reference/command/distinct/
4242
*/
43-
class Distinct implements Executable, Explainable
43+
final class Distinct implements Executable, Explainable
4444
{
4545
/**
4646
* Constructs a distinct command.

src/Operation/DropCollection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
* @see \MongoDB\Database::dropCollection()
3737
* @see https://mongodb.com/docs/manual/reference/command/drop/
3838
*/
39-
class DropCollection implements Executable
39+
final class DropCollection implements Executable
4040
{
4141
private const ERROR_CODE_NAMESPACE_NOT_FOUND = 26;
4242

src/Operation/DropDatabase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
* @see \MongoDB\Database::drop()
3535
* @see https://mongodb.com/docs/manual/reference/command/dropDatabase/
3636
*/
37-
class DropDatabase implements Executable
37+
final class DropDatabase implements Executable
3838
{
3939
/**
4040
* Constructs a dropDatabase command.

src/Operation/DropEncryptedCollection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
* @see https://github.com/mongodb/specifications/blob/master/source/client-side-encryption/client-side-encryption.rst#drop-collection-helper
3838
* @see https://www.mongodb.com/docs/manual/core/queryable-encryption/fundamentals/manage-collections/
3939
*/
40-
class DropEncryptedCollection implements Executable
40+
final class DropEncryptedCollection implements Executable
4141
{
4242
private DropCollection $dropCollection;
4343

src/Operation/DropIndexes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
* @see \MongoDB\Collection::dropIndexes()
3636
* @see https://mongodb.com/docs/manual/reference/command/dropIndexes/
3737
*/
38-
class DropIndexes implements Executable
38+
final class DropIndexes implements Executable
3939
{
4040
/**
4141
* Constructs a dropIndexes command.

src/Operation/DropSearchIndex.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
* @see \MongoDB\Collection::dropSearchIndexes()
3131
* @see https://mongodb.com/docs/manual/reference/command/dropSearchIndexes/
3232
*/
33-
class DropSearchIndex implements Executable
33+
final class DropSearchIndex implements Executable
3434
{
3535
private const ERROR_CODE_NAMESPACE_NOT_FOUND = 26;
3636

src/Operation/EstimatedDocumentCount.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
* @see \MongoDB\Collection::estimatedDocumentCount()
3636
* @see https://mongodb.com/docs/manual/reference/command/count/
3737
*/
38-
class EstimatedDocumentCount implements Executable, Explainable
38+
final class EstimatedDocumentCount implements Executable, Explainable
3939
{
4040
private array $options;
4141

src/Operation/Explain.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
* @see \MongoDB\Collection::explain()
3636
* @see https://mongodb.com/docs/manual/reference/command/explain/
3737
*/
38-
class Explain implements Executable
38+
final class Explain implements Executable
3939
{
4040
public const VERBOSITY_ALL_PLANS = 'allPlansExecution';
4141
public const VERBOSITY_EXEC_STATS = 'executionStats';

src/Operation/Find.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
* @see https://mongodb.com/docs/manual/tutorial/query-documents/
4949
* @see https://mongodb.com/docs/manual/reference/operator/query-modifier/
5050
*/
51-
class Find implements Executable, Explainable
51+
final class Find implements Executable, Explainable
5252
{
5353
public const NON_TAILABLE = 1;
5454
public const TAILABLE = 2;

src/Operation/FindAndModify.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
* @internal
5252
* @see https://mongodb.com/docs/manual/reference/command/findAndModify/
5353
*/
54-
class FindAndModify implements Executable, Explainable
54+
final class FindAndModify implements Executable, Explainable
5555
{
5656
private const WIRE_VERSION_FOR_HINT = 9;
5757

src/Operation/FindOne.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
* @see https://mongodb.com/docs/manual/tutorial/query-documents/
3232
* @see https://mongodb.com/docs/manual/reference/operator/query-modifier/
3333
*/
34-
class FindOne implements Executable, Explainable
34+
final class FindOne implements Executable, Explainable
3535
{
3636
private Find $find;
3737

src/Operation/FindOneAndDelete.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
* @see \MongoDB\Collection::findOneAndDelete()
3131
* @see https://mongodb.com/docs/manual/reference/command/findAndModify/
3232
*/
33-
class FindOneAndDelete implements Executable, Explainable
33+
final class FindOneAndDelete implements Executable, Explainable
3434
{
3535
private FindAndModify $findAndModify;
3636

src/Operation/FindOneAndReplace.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
* @see \MongoDB\Collection::findOneAndReplace()
3636
* @see https://mongodb.com/docs/manual/reference/command/findAndModify/
3737
*/
38-
class FindOneAndReplace implements Executable, Explainable
38+
final class FindOneAndReplace implements Executable, Explainable
3939
{
4040
public const RETURN_DOCUMENT_BEFORE = 1;
4141
public const RETURN_DOCUMENT_AFTER = 2;

src/Operation/FindOneAndUpdate.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
* @see \MongoDB\Collection::findOneAndUpdate()
3535
* @see https://mongodb.com/docs/manual/reference/command/findAndModify/
3636
*/
37-
class FindOneAndUpdate implements Executable, Explainable
37+
final class FindOneAndUpdate implements Executable, Explainable
3838
{
3939
public const RETURN_DOCUMENT_BEFORE = 1;
4040
public const RETURN_DOCUMENT_AFTER = 2;

src/Operation/InsertMany.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
* @see \MongoDB\Collection::insertMany()
3939
* @see https://mongodb.com/docs/manual/reference/command/insert/
4040
*/
41-
class InsertMany implements Executable
41+
final class InsertMany implements Executable
4242
{
4343
/** @var list<object|array> */
4444
private array $documents;

src/Operation/InsertOne.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
* @see \MongoDB\Collection::insertOne()
3737
* @see https://mongodb.com/docs/manual/reference/command/insert/
3838
*/
39-
class InsertOne implements Executable
39+
final class InsertOne implements Executable
4040
{
4141
private array|object $document;
4242

0 commit comments

Comments
 (0)