Skip to content
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
11 changes: 11 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,17 @@ possible it can be added to the baseline using `set-baseline`:
$ vendor/bin/psalm --set-baseline=psalm-baseline.xml
```

## Automatic code refactoring

The library uses [rector](https://getrector.com/) to refactor the code for new features.
To run automatic refactoring, use the `rector` command:

```
$ vendor/bin/rector
```

New rules can be added to the `rector.php` configuration file.

## Documentation

Documentation for the library lives in the `docs/` directory and is built with
Expand Down
6 changes: 4 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
"symfony/polyfill-php80": "^1.27"
},
"require-dev": {
"squizlabs/php_codesniffer": "^3.7",
"doctrine/coding-standard": "^11.1",
"rector/rector": "^0.16.0",
"squizlabs/php_codesniffer": "^3.7",
"symfony/phpunit-bridge": "^5.2",
"vimeo/psalm": "^4.28"
},
Expand All @@ -39,6 +40,7 @@
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
},
"sort-packages": true
}
}
23 changes: 23 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

use Rector\Config\RectorConfig;
use Rector\DeadCode\Rector\ClassLike\RemoveAnnotationRector;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->paths([
__DIR__ . '/examples',
__DIR__ . '/src',
__DIR__ . '/tests',
__DIR__ . '/tools',
]);

/**
* All classes are public API by default, unless marked with @internal.
*/
$rectorConfig->ruleWithConfiguration(RemoveAnnotationRector::class, ['api']);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think PHPLIB does this, but is there any harm of removing @api from method annotations as well?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are no @api left.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm aware this removed everything that was in PHPLIB. I was just asking if it made sense to add a rule to remove method block annotations as well. I assume not, but was asking more to get a better understanding of how these rules are used.

Presumably, there's no need for even this rule to exist going forward (running at again would be a NOP) -- so I might be misunderstanding the purpose of collecting these rules in the rector configuration.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The purpose of leaving these rules in place in the configuration file is to impose them on new developments or pending branches. If, for example, a developer forgets or ignores that @api annotations are no longer used, this will be corrected automatically before the code review.


// define sets of rules
// $rectorConfig->sets([
// LevelSetList::UP_TO_PHP_72
// ]);
};
5 changes: 2 additions & 3 deletions src/ChangeStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,10 @@
/**
* Iterator for a change stream.
*
* @psalm-type ResumeCallable = callable(array|object|null, bool): ChangeStreamIterator
*
* @api
* @see \MongoDB\Collection::watch()
* @see https://mongodb.com/docs/manual/reference/method/db.watch/#mongodb-method-db.watch
*
* @psalm-type ResumeCallable = callable(array|object|null, bool): ChangeStreamIterator
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CS fix: Incorrect order of annotations groups.

*/
class ChangeStream implements Iterator
{
Expand Down
2 changes: 0 additions & 2 deletions src/GridFS/Bucket.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@
/**
* Bucket provides a public API for interacting with the GridFS files and chunks
* collections.
*
* @api
*/
class Bucket
{
Expand Down
1 change: 0 additions & 1 deletion src/MapReduceResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
* output method (e.g. inline, collection) via the IteratorAggregate interface.
* It also provides access to command statistics.
*
* @api
* @see \MongoDB\Collection::mapReduce()
* @see https://mongodb.com/docs/manual/reference/command/mapReduce/
*/
Expand Down
2 changes: 0 additions & 2 deletions src/Model/BSONArray.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
*
* The internal data will be filtered through array_values() during BSON
* serialization to ensure that it becomes a BSON array.
*
* @api
*/
class BSONArray extends ArrayObject implements JsonSerializable, Serializable, Unserializable
{
Expand Down
2 changes: 0 additions & 2 deletions src/Model/BSONDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
*
* The internal data will be cast to an object during BSON serialization to
* ensure that it becomes a BSON document.
*
* @api
*/
class BSONDocument extends ArrayObject implements JsonSerializable, Serializable, Unserializable
{
Expand Down
1 change: 0 additions & 1 deletion src/Model/CollectionInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
* command or, for legacy servers, queries on the "system.namespaces"
* collection. It provides methods to access options for the collection.
*
* @api
* @see \MongoDB\Database::listCollections()
* @see https://github.com/mongodb/specifications/blob/master/source/enumerate-collections.rst
*/
Expand Down
1 change: 0 additions & 1 deletion src/Model/CollectionInfoIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
*
* This iterator is used for enumerating collections in a database.
*
* @api
* @see \MongoDB\Database::listCollections()
*/
interface CollectionInfoIterator extends Iterator
Expand Down
1 change: 0 additions & 1 deletion src/Model/DatabaseInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
* This class models the database information returned by the listDatabases
* command. It provides methods to access common database properties.
*
* @api
* @see \MongoDB\Client::listDatabases()
* @see https://mongodb.com/docs/manual/reference/command/listDatabases/
*/
Expand Down
1 change: 0 additions & 1 deletion src/Model/DatabaseInfoIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
*
* This iterator is used for enumerating databases on a server.
*
* @api
* @see \MongoDB\Client::listDatabases()
*/
interface DatabaseInfoIterator extends Iterator
Expand Down
1 change: 0 additions & 1 deletion src/Model/IndexInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
* For information on keys and index options, see the referenced
* db.collection.createIndex() documentation.
*
* @api
* @see \MongoDB\Collection::listIndexes()
* @see https://github.com/mongodb/specifications/blob/master/source/enumerate-indexes.rst
* @see https://mongodb.com/docs/manual/reference/method/db.collection.createIndex/
Expand Down
1 change: 0 additions & 1 deletion src/Model/IndexInfoIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
*
* This iterator is used for enumerating indexes in a collection.
*
* @api
* @see \MongoDB\Collection::listIndexes()
*/
interface IndexInfoIterator extends Iterator
Expand Down
1 change: 0 additions & 1 deletion src/Operation/Aggregate.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
/**
* Operation for the aggregate command.
*
* @api
* @see \MongoDB\Collection::aggregate()
* @see https://mongodb.com/docs/manual/reference/command/aggregate/
*/
Expand Down
1 change: 0 additions & 1 deletion src/Operation/BulkWrite.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
/**
* Operation for executing multiple write operations.
*
* @api
* @see \MongoDB\Collection::bulkWrite()
*/
class BulkWrite implements Executable
Expand Down
1 change: 0 additions & 1 deletion src/Operation/Count.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
/**
* Operation for the count command.
*
* @api
* @see \MongoDB\Collection::count()
* @see https://mongodb.com/docs/manual/reference/command/count/
*/
Expand Down
1 change: 0 additions & 1 deletion src/Operation/CountDocuments.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
/**
* Operation for obtaining an exact count of documents in a collection
*
* @api
* @see \MongoDB\Collection::countDocuments()
* @see https://github.com/mongodb/specifications/blob/master/source/crud/crud.rst#countdocuments
*/
Expand Down
1 change: 0 additions & 1 deletion src/Operation/CreateCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
/**
* Operation for the create command.
*
* @api
* @see \MongoDB\Database::createCollection()
* @see https://mongodb.com/docs/manual/reference/command/create/
*/
Expand Down
1 change: 0 additions & 1 deletion src/Operation/CreateIndexes.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
/**
* Operation for the createIndexes command.
*
* @api
* @see \MongoDB\Collection::createIndex()
* @see \MongoDB\Collection::createIndexes()
* @see https://mongodb.com/docs/manual/reference/command/createIndexes/
Expand Down
1 change: 0 additions & 1 deletion src/Operation/DatabaseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
/**
* Operation for executing a database command.
*
* @api
* @see \MongoDB\Database::command()
*/
class DatabaseCommand implements Executable
Expand Down
1 change: 0 additions & 1 deletion src/Operation/DeleteMany.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
/**
* Operation for deleting multiple document with the delete command.
*
* @api
* @see \MongoDB\Collection::deleteOne()
* @see https://mongodb.com/docs/manual/reference/command/delete/
*/
Expand Down
1 change: 0 additions & 1 deletion src/Operation/DeleteOne.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
/**
* Operation for deleting a single document with the delete command.
*
* @api
* @see \MongoDB\Collection::deleteOne()
* @see https://mongodb.com/docs/manual/reference/command/delete/
*/
Expand Down
1 change: 0 additions & 1 deletion src/Operation/Distinct.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
/**
* Operation for the distinct command.
*
* @api
* @see \MongoDB\Collection::distinct()
* @see https://mongodb.com/docs/manual/reference/command/distinct/
*/
Expand Down
1 change: 0 additions & 1 deletion src/Operation/DropCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
/**
* Operation for the drop command.
*
* @api
* @see \MongoDB\Collection::drop()
* @see \MongoDB\Database::dropCollection()
* @see https://mongodb.com/docs/manual/reference/command/drop/
Expand Down
1 change: 0 additions & 1 deletion src/Operation/DropDatabase.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
/**
* Operation for the dropDatabase command.
*
* @api
* @see \MongoDB\Client::dropDatabase()
* @see \MongoDB\Database::drop()
* @see https://mongodb.com/docs/manual/reference/command/dropDatabase/
Expand Down
1 change: 0 additions & 1 deletion src/Operation/DropIndexes.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
/**
* Operation for the dropIndexes command.
*
* @api
* @see \MongoDB\Collection::dropIndexes()
* @see https://mongodb.com/docs/manual/reference/command/dropIndexes/
*/
Expand Down
1 change: 0 additions & 1 deletion src/Operation/EstimatedDocumentCount.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
/**
* Operation for obtaining an estimated count of documents in a collection
*
* @api
* @see \MongoDB\Collection::estimatedDocumentCount()
* @see https://mongodb.com/docs/manual/reference/command/count/
*/
Expand Down
1 change: 0 additions & 1 deletion src/Operation/Explain.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
/**
* Operation for the explain command.
*
* @api
* @see \MongoDB\Collection::explain()
* @see https://mongodb.com/docs/manual/reference/command/explain/
*/
Expand Down
1 change: 0 additions & 1 deletion src/Operation/Find.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
/**
* Operation for the find command.
*
* @api
* @see \MongoDB\Collection::find()
* @see https://mongodb.com/docs/manual/tutorial/query-documents/
* @see https://mongodb.com/docs/manual/reference/operator/query-modifier/
Expand Down
1 change: 0 additions & 1 deletion src/Operation/FindOne.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
/**
* Operation for finding a single document with the find command.
*
* @api
* @see \MongoDB\Collection::findOne()
* @see https://mongodb.com/docs/manual/tutorial/query-documents/
* @see https://mongodb.com/docs/manual/reference/operator/query-modifier/
Expand Down
1 change: 0 additions & 1 deletion src/Operation/FindOneAndDelete.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
/**
* Operation for deleting a document with the findAndModify command.
*
* @api
* @see \MongoDB\Collection::findOneAndDelete()
* @see https://mongodb.com/docs/manual/reference/command/findAndModify/
*/
Expand Down
1 change: 0 additions & 1 deletion src/Operation/FindOneAndReplace.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
/**
* Operation for replacing a document with the findAndModify command.
*
* @api
* @see \MongoDB\Collection::findOneAndReplace()
* @see https://mongodb.com/docs/manual/reference/command/findAndModify/
*/
Expand Down
1 change: 0 additions & 1 deletion src/Operation/FindOneAndUpdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
/**
* Operation for updating a document with the findAndModify command.
*
* @api
* @see \MongoDB\Collection::findOneAndUpdate()
* @see https://mongodb.com/docs/manual/reference/command/findAndModify/
*/
Expand Down
1 change: 0 additions & 1 deletion src/Operation/InsertMany.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
/**
* Operation for inserting multiple documents with the insert command.
*
* @api
* @see \MongoDB\Collection::insertMany()
* @see https://mongodb.com/docs/manual/reference/command/insert/
*/
Expand Down
1 change: 0 additions & 1 deletion src/Operation/InsertOne.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
/**
* Operation for inserting a single document with the insert command.
*
* @api
* @see \MongoDB\Collection::insertOne()
* @see https://mongodb.com/docs/manual/reference/command/insert/
*/
Expand Down
1 change: 0 additions & 1 deletion src/Operation/ListCollectionNames.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
/**
* Operation for the listCollectionNames helper.
*
* @api
* @see \MongoDB\Database::listCollectionNames()
* @see https://mongodb.com/docs/manual/reference/command/listCollections/
*/
Expand Down
1 change: 0 additions & 1 deletion src/Operation/ListCollections.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
/**
* Operation for the listCollections command.
*
* @api
* @see \MongoDB\Database::listCollections()
* @see https://mongodb.com/docs/manual/reference/command/listCollections/
*/
Expand Down
1 change: 0 additions & 1 deletion src/Operation/ListDatabaseNames.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
/**
* Operation for the ListDatabases command, returning only database names.
*
* @api
* @see \MongoDB\Client::listDatabaseNames()
* @see https://mongodb.com/docs/manual/reference/command/listDatabases/#mongodb-dbcommand-dbcmd.listDatabases
*/
Expand Down
1 change: 0 additions & 1 deletion src/Operation/ListDatabases.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
/**
* Operation for the ListDatabases command.
*
* @api
* @see \MongoDB\Client::listDatabases()
* @see https://mongodb.com/docs/manual/reference/command/listDatabases/#mongodb-dbcommand-dbcmd.listDatabases`
*/
Expand Down
1 change: 0 additions & 1 deletion src/Operation/ListIndexes.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
/**
* Operation for the listIndexes command.
*
* @api
* @see \MongoDB\Collection::listIndexes()
* @see https://mongodb.com/docs/manual/reference/command/listIndexes/
*/
Expand Down
1 change: 0 additions & 1 deletion src/Operation/MapReduce.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
/**
* Operation for the mapReduce command.
*
* @api
* @see \MongoDB\Collection::mapReduce()
* @see https://mongodb.com/docs/manual/reference/command/mapReduce/
*/
Expand Down
1 change: 0 additions & 1 deletion src/Operation/ModifyCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
/**
* Operation for the collMod command.
*
* @api
* @see \MongoDB\Database::modifyCollection()
* @see https://mongodb.com/docs/manual/reference/command/collMod/
*/
Expand Down
1 change: 0 additions & 1 deletion src/Operation/RenameCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
/**
* Operation for the renameCollection command.
*
* @api
* @see \MongoDB\Collection::rename()
* @see \MongoDB\Database::renameCollection()
* @see https://mongodb.com/docs/manual/reference/command/renameCollection/
Expand Down
Loading