Skip to content

PHPLIB-953 Make internal classes and Operation classes final #1392

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 4 commits into from
Sep 17, 2024
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
2 changes: 2 additions & 0 deletions UPGRADE-2.0.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
UPGRADE FROM 1.x to 2.0
========================

* Classes in the namespace `MongoDB\Operation\` are `final`.

GridFS
------

Expand Down
2 changes: 1 addition & 1 deletion src/Command/ListCollections.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
* @internal
* @see https://mongodb.com/docs/manual/reference/command/listCollections/
*/
class ListCollections implements Executable
final class ListCollections implements Executable
{
/**
* Constructs a listCollections command.
Expand Down
2 changes: 1 addition & 1 deletion src/Command/ListDatabases.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* @internal
* @see https://mongodb.com/docs/manual/reference/command/listDatabases/
*/
class ListDatabases implements Executable
final class ListDatabases implements Executable
{
/**
* Constructs a listDatabases command.
Expand Down
2 changes: 1 addition & 1 deletion src/GridFS/CollectionWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
*
* @internal
*/
class CollectionWrapper
final class CollectionWrapper
{
private Collection $chunksCollection;

Expand Down
2 changes: 1 addition & 1 deletion src/GridFS/ReadableStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
*
* @internal
*/
class ReadableStream
final class ReadableStream
{
private ?string $buffer = null;

Expand Down
4 changes: 2 additions & 2 deletions src/GridFS/StreamWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
* @see Bucket::openDownloadStream()
* @psalm-type ContextOptions = array{collectionWrapper: CollectionWrapper, file: object}|array{collectionWrapper: CollectionWrapper, filename: string, options: array}
*/
class StreamWrapper
final class StreamWrapper
{
/** @var resource|null Stream context (set by PHP) */
public $context;
Expand Down Expand Up @@ -89,7 +89,7 @@ public static function register(string $protocol = 'gridfs'): void
stream_wrapper_unregister($protocol);
}

stream_wrapper_register($protocol, static::class, STREAM_IS_URL);
stream_wrapper_register($protocol, self::class, STREAM_IS_URL);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/GridFS/WritableStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
*
* @internal
*/
class WritableStream
final class WritableStream
{
private const DEFAULT_CHUNK_SIZE_BYTES = 261120;

Expand Down
2 changes: 1 addition & 1 deletion src/Model/CachingIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
* @template TValue
* @template-implements Iterator<TKey, TValue>
*/
class CachingIterator implements Countable, Iterator
final class CachingIterator implements Countable, Iterator
{
private const FIELD_KEY = 0;
private const FIELD_VALUE = 1;
Expand Down
2 changes: 1 addition & 1 deletion src/Model/CallbackIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* @template TCallbackValue
* @template-implements Iterator<TKey, TCallbackValue>
*/
class CallbackIterator implements Iterator
final class CallbackIterator implements Iterator
{
/** @var callable(TValue, TKey): TCallbackValue */
private $callback;
Expand Down
2 changes: 1 addition & 1 deletion src/Model/ChangeStreamIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
* @template TValue of array|object
* @template-extends IteratorIterator<int, TValue, CursorInterface<int, TValue>&Iterator<int, TValue>>
*/
class ChangeStreamIterator extends IteratorIterator implements CommandSubscriber
final class ChangeStreamIterator extends IteratorIterator implements CommandSubscriber
{
private int $batchPosition = 0;

Expand Down
2 changes: 1 addition & 1 deletion src/Model/CollectionInfoCommandIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* @see https://mongodb.com/docs/manual/reference/command/listCollections/
* @template-extends IteratorIterator<int, array, Traversable<int, array>>
*/
class CollectionInfoCommandIterator extends IteratorIterator implements CollectionInfoIterator
final class CollectionInfoCommandIterator extends IteratorIterator implements CollectionInfoIterator
{
/** @param Traversable<int, array> $iterator */
public function __construct(Traversable $iterator, private ?string $databaseName = null)
Expand Down
2 changes: 1 addition & 1 deletion src/Model/DatabaseInfoLegacyIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* @see \MongoDB\Client::listDatabases()
* @see https://mongodb.com/docs/manual/reference/command/listDatabases/
*/
class DatabaseInfoLegacyIterator implements DatabaseInfoIterator
final class DatabaseInfoLegacyIterator implements DatabaseInfoIterator
{
public function __construct(private array $databases)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Model/IndexInfoIteratorIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
* @see https://mongodb.com/docs/manual/reference/system-collections/
* @template-extends IteratorIterator<int, array, Traversable<int, array>>
*/
class IndexInfoIteratorIterator extends IteratorIterator implements IndexInfoIterator
final class IndexInfoIteratorIterator extends IteratorIterator implements IndexInfoIterator
{
/** @param Traversable<int, array> $iterator */
public function __construct(Traversable $iterator, private ?string $ns = null)
Expand Down
2 changes: 1 addition & 1 deletion src/Model/IndexInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
* @see https://github.com/mongodb/specifications/blob/master/source/enumerate-indexes.rst
* @see https://mongodb.com/docs/manual/reference/method/db.collection.createIndex/
*/
class IndexInput implements Serializable
final class IndexInput implements Serializable
{
/**
* @param array $index Index specification
Expand Down
2 changes: 1 addition & 1 deletion src/Model/SearchIndexInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* @see https://github.com/mongodb/specifications/blob/master/source/index-management/index-management.rst#search-indexes
* @see https://mongodb.com/docs/manual/reference/method/db.collection.createSearchIndex/
*/
class SearchIndexInput implements Serializable
final class SearchIndexInput implements Serializable
{
/**
* @param array{definition: array|object, name?: string, type?: string} $index Search index specification
Expand Down
2 changes: 1 addition & 1 deletion src/Operation/Aggregate.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
* @see \MongoDB\Collection::aggregate()
* @see https://mongodb.com/docs/manual/reference/command/aggregate/
*/
class Aggregate implements Executable, Explainable
final class Aggregate implements Executable, Explainable
{
private bool $isWrite;

Expand Down
2 changes: 1 addition & 1 deletion src/Operation/BulkWrite.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
*
* @see \MongoDB\Collection::bulkWrite()
*/
class BulkWrite implements Executable
final class BulkWrite implements Executable
{
public const DELETE_MANY = 'deleteMany';
public const DELETE_ONE = 'deleteOne';
Expand Down
2 changes: 1 addition & 1 deletion src/Operation/Count.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
* @see \MongoDB\Collection::count()
* @see https://mongodb.com/docs/manual/reference/command/count/
*/
class Count implements Executable, Explainable
final class Count implements Executable, Explainable
{
/**
* Constructs a count command.
Expand Down
2 changes: 1 addition & 1 deletion src/Operation/CountDocuments.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* @see \MongoDB\Collection::countDocuments()
* @see https://github.com/mongodb/specifications/blob/master/source/crud/crud.rst#countdocuments
*/
class CountDocuments implements Executable
final class CountDocuments implements Executable
{
private array $aggregateOptions;

Expand Down
2 changes: 1 addition & 1 deletion src/Operation/CreateCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
* @see \MongoDB\Database::createCollection()
* @see https://mongodb.com/docs/manual/reference/command/create/
*/
class CreateCollection implements Executable
final class CreateCollection implements Executable
{
public const USE_POWER_OF_2_SIZES = 1;
public const NO_PADDING = 2;
Expand Down
2 changes: 1 addition & 1 deletion src/Operation/CreateEncryptedCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
* @see https://github.com/mongodb/specifications/blob/master/source/client-side-encryption/client-side-encryption.rst#create-encrypted-collection-helper
* @see https://www.mongodb.com/docs/manual/core/queryable-encryption/fundamentals/manage-collections/
*/
class CreateEncryptedCollection implements Executable
final class CreateEncryptedCollection implements Executable
{
private const WIRE_VERSION_FOR_QUERYABLE_ENCRYPTION_V2 = 21;

Expand Down
2 changes: 1 addition & 1 deletion src/Operation/CreateIndexes.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
* @see \MongoDB\Collection::createIndexes()
* @see https://mongodb.com/docs/manual/reference/command/createIndexes/
*/
class CreateIndexes implements Executable
final class CreateIndexes implements Executable
{
private const WIRE_VERSION_FOR_COMMIT_QUORUM = 9;

Expand Down
2 changes: 1 addition & 1 deletion src/Operation/CreateSearchIndexes.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* @see \MongoDB\Collection::createSearchIndexes()
* @see https://mongodb.com/docs/manual/reference/command/createSearchIndexes/
*/
class CreateSearchIndexes implements Executable
final class CreateSearchIndexes implements Executable
{
private array $indexes = [];

Expand Down
2 changes: 1 addition & 1 deletion src/Operation/DatabaseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
*
* @see \MongoDB\Database::command()
*/
class DatabaseCommand implements Executable
final class DatabaseCommand implements Executable
{
private Command $command;

Expand Down
2 changes: 1 addition & 1 deletion src/Operation/Delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
* @internal
* @see https://mongodb.com/docs/manual/reference/command/delete/
*/
class Delete implements Executable, Explainable
final class Delete implements Executable, Explainable
{
private const WIRE_VERSION_FOR_HINT = 9;

Expand Down
2 changes: 1 addition & 1 deletion src/Operation/DeleteMany.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* @see \MongoDB\Collection::deleteOne()
* @see https://mongodb.com/docs/manual/reference/command/delete/
*/
class DeleteMany implements Executable, Explainable
final class DeleteMany implements Executable, Explainable
{
private Delete $delete;

Expand Down
2 changes: 1 addition & 1 deletion src/Operation/DeleteOne.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* @see \MongoDB\Collection::deleteOne()
* @see https://mongodb.com/docs/manual/reference/command/delete/
*/
class DeleteOne implements Executable, Explainable
final class DeleteOne implements Executable, Explainable
{
private Delete $delete;

Expand Down
2 changes: 1 addition & 1 deletion src/Operation/Distinct.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
* @see \MongoDB\Collection::distinct()
* @see https://mongodb.com/docs/manual/reference/command/distinct/
*/
class Distinct implements Executable, Explainable
final class Distinct implements Executable, Explainable
{
/**
* Constructs a distinct command.
Expand Down
2 changes: 1 addition & 1 deletion src/Operation/DropCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
* @see \MongoDB\Database::dropCollection()
* @see https://mongodb.com/docs/manual/reference/command/drop/
*/
class DropCollection implements Executable
final class DropCollection implements Executable
{
private const ERROR_CODE_NAMESPACE_NOT_FOUND = 26;

Expand Down
2 changes: 1 addition & 1 deletion src/Operation/DropDatabase.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* @see \MongoDB\Database::drop()
* @see https://mongodb.com/docs/manual/reference/command/dropDatabase/
*/
class DropDatabase implements Executable
final class DropDatabase implements Executable
{
/**
* Constructs a dropDatabase command.
Expand Down
2 changes: 1 addition & 1 deletion src/Operation/DropEncryptedCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* @see https://github.com/mongodb/specifications/blob/master/source/client-side-encryption/client-side-encryption.rst#drop-collection-helper
* @see https://www.mongodb.com/docs/manual/core/queryable-encryption/fundamentals/manage-collections/
*/
class DropEncryptedCollection implements Executable
final class DropEncryptedCollection implements Executable
{
private DropCollection $dropCollection;

Expand Down
2 changes: 1 addition & 1 deletion src/Operation/DropIndexes.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
* @see \MongoDB\Collection::dropIndexes()
* @see https://mongodb.com/docs/manual/reference/command/dropIndexes/
*/
class DropIndexes implements Executable
final class DropIndexes implements Executable
{
/**
* Constructs a dropIndexes command.
Expand Down
2 changes: 1 addition & 1 deletion src/Operation/DropSearchIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
* @see \MongoDB\Collection::dropSearchIndexes()
* @see https://mongodb.com/docs/manual/reference/command/dropSearchIndexes/
*/
class DropSearchIndex implements Executable
final class DropSearchIndex implements Executable
{
private const ERROR_CODE_NAMESPACE_NOT_FOUND = 26;

Expand Down
2 changes: 1 addition & 1 deletion src/Operation/EstimatedDocumentCount.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
* @see \MongoDB\Collection::estimatedDocumentCount()
* @see https://mongodb.com/docs/manual/reference/command/count/
*/
class EstimatedDocumentCount implements Executable, Explainable
final class EstimatedDocumentCount implements Executable, Explainable
{
private array $options;

Expand Down
2 changes: 1 addition & 1 deletion src/Operation/Explain.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
* @see \MongoDB\Collection::explain()
* @see https://mongodb.com/docs/manual/reference/command/explain/
*/
class Explain implements Executable
final class Explain implements Executable
{
public const VERBOSITY_ALL_PLANS = 'allPlansExecution';
public const VERBOSITY_EXEC_STATS = 'executionStats';
Expand Down
2 changes: 1 addition & 1 deletion src/Operation/Find.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
* @see https://mongodb.com/docs/manual/tutorial/query-documents/
* @see https://mongodb.com/docs/manual/reference/operator/query-modifier/
*/
class Find implements Executable, Explainable
final class Find implements Executable, Explainable
{
public const NON_TAILABLE = 1;
public const TAILABLE = 2;
Expand Down
2 changes: 1 addition & 1 deletion src/Operation/FindAndModify.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
* @internal
* @see https://mongodb.com/docs/manual/reference/command/findAndModify/
*/
class FindAndModify implements Executable, Explainable
final class FindAndModify implements Executable, Explainable
{
private const WIRE_VERSION_FOR_HINT = 9;

Expand Down
2 changes: 1 addition & 1 deletion src/Operation/FindOne.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
* @see https://mongodb.com/docs/manual/tutorial/query-documents/
* @see https://mongodb.com/docs/manual/reference/operator/query-modifier/
*/
class FindOne implements Executable, Explainable
final class FindOne implements Executable, Explainable
{
private Find $find;

Expand Down
2 changes: 1 addition & 1 deletion src/Operation/FindOneAndDelete.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
* @see \MongoDB\Collection::findOneAndDelete()
* @see https://mongodb.com/docs/manual/reference/command/findAndModify/
*/
class FindOneAndDelete implements Executable, Explainable
final class FindOneAndDelete implements Executable, Explainable
{
private FindAndModify $findAndModify;

Expand Down
2 changes: 1 addition & 1 deletion src/Operation/FindOneAndReplace.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
* @see \MongoDB\Collection::findOneAndReplace()
* @see https://mongodb.com/docs/manual/reference/command/findAndModify/
*/
class FindOneAndReplace implements Executable, Explainable
final class FindOneAndReplace implements Executable, Explainable
{
public const RETURN_DOCUMENT_BEFORE = 1;
public const RETURN_DOCUMENT_AFTER = 2;
Expand Down
2 changes: 1 addition & 1 deletion src/Operation/FindOneAndUpdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* @see \MongoDB\Collection::findOneAndUpdate()
* @see https://mongodb.com/docs/manual/reference/command/findAndModify/
*/
class FindOneAndUpdate implements Executable, Explainable
final class FindOneAndUpdate implements Executable, Explainable
{
public const RETURN_DOCUMENT_BEFORE = 1;
public const RETURN_DOCUMENT_AFTER = 2;
Expand Down
2 changes: 1 addition & 1 deletion src/Operation/InsertMany.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
* @see \MongoDB\Collection::insertMany()
* @see https://mongodb.com/docs/manual/reference/command/insert/
*/
class InsertMany implements Executable
final class InsertMany implements Executable
{
/** @var list<object|array> */
private array $documents;
Expand Down
2 changes: 1 addition & 1 deletion src/Operation/InsertOne.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
* @see \MongoDB\Collection::insertOne()
* @see https://mongodb.com/docs/manual/reference/command/insert/
*/
class InsertOne implements Executable
final class InsertOne implements Executable
{
private array|object $document;

Expand Down
Loading