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: 7 additions & 4 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
use Rector\DeadCode\Rector\ClassLike\RemoveAnnotationRector;
use Rector\Php70\Rector\StmtsAwareInterface\IfIssetToCoalescingRector;
use Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector;
use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector;
use Rector\Php80\Rector\Class_\StringableForToStringRector;
use Rector\Php80\Rector\Switch_\ChangeSwitchToMatchRector;
use Rector\Renaming\Rector\Cast\RenameCastRector;
use Rector\Renaming\ValueObject\RenameCast;
Expand All @@ -18,11 +20,8 @@
__DIR__ . '/tests',
__DIR__ . '/tools',
])
->withPhpSets(php74: true)
->withPhpSets(php80: true)
->withComposerBased(phpunit: true)
->withRules([
ChangeSwitchToMatchRector::class,
])
// All classes are public API by default, unless marked with @internal.
->withConfiguredRule(RemoveAnnotationRector::class, ['api'])
// Fix PHP 8.5 deprecations
Expand All @@ -42,6 +41,10 @@
ChangeSwitchToMatchRector::class => [
__DIR__ . '/tests/SpecTests/Operation.php',
],
ClassPropertyAssignToConstructorPromotionRector::class,
StringableForToStringRector::class => [
__DIR__ . '/src/Model/IndexInput.php',
],
])
// phpcs:enable
->withImportNames(importNames: false, removeUnusedImports: true);
3 changes: 2 additions & 1 deletion src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,14 @@
use MongoDB\Operation\ListDatabases;
use MongoDB\Operation\Watch;
use stdClass;
use Stringable;
use Throwable;

use function array_diff_key;
use function is_array;
use function is_string;

class Client
class Client implements Stringable
{
public const DEFAULT_URI = 'mongodb://127.0.0.1/';

Expand Down
3 changes: 2 additions & 1 deletion src/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
use MongoDB\Operation\UpdateSearchIndex;
use MongoDB\Operation\Watch;
use stdClass;
use Stringable;

use function array_diff_key;
use function array_intersect_key;
Expand All @@ -78,7 +79,7 @@
use function is_bool;
use function strlen;

class Collection
class Collection implements Stringable
{
private const DEFAULT_TYPE_MAP = [
'array' => BSONArray::class,
Expand Down
3 changes: 2 additions & 1 deletion src/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,14 @@
use MongoDB\Operation\RenameCollection;
use MongoDB\Operation\Watch;
use stdClass;
use Stringable;
use Throwable;

use function is_array;
use function is_bool;
use function strlen;

class Database
class Database implements Stringable
{
private const DEFAULT_TYPE_MAP = [
'array' => BSONArray::class,
Expand Down
3 changes: 2 additions & 1 deletion src/Model/IndexInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

use ArrayAccess;
use MongoDB\Exception\BadMethodCallException;
use Stringable;

use function array_key_exists;
use function array_search;
Expand All @@ -38,7 +39,7 @@
* @see https://mongodb.com/docs/manual/reference/method/db.collection.createIndex/
* @template-implements ArrayAccess<string, mixed>
*/
class IndexInfo implements ArrayAccess
class IndexInfo implements ArrayAccess, Stringable
{
/** @param array $info Index info */
public function __construct(private array $info)
Expand Down
3 changes: 2 additions & 1 deletion src/Model/IndexInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use MongoDB\BSON\Serializable;
use MongoDB\Exception\InvalidArgumentException;
use stdClass;
use Stringable;

use function is_float;
use function is_int;
Expand All @@ -38,7 +39,7 @@
* @see https://github.com/mongodb/specifications/blob/master/source/enumerate-indexes.rst
* @see https://mongodb.com/docs/manual/reference/method/db.collection.createIndex/
*/
final class IndexInput implements Serializable
final class IndexInput implements Serializable, Stringable
{
/**
* @param array $index Index specification
Expand Down
2 changes: 1 addition & 1 deletion tests/Model/BSONIteratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class BSONIteratorTest extends TestCase
#[DataProvider('provideTypeMapOptionsAndExpectedDocuments')]
public function testValidValues(?array $typeMap, array $expectedDocuments): void
{
$binaryString = implode(array_map(
$binaryString = implode('', array_map(
Copy link
Member

Choose a reason for hiding this comment

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

implode() suggests this alternative syntax is still supported, provided the separator string is empty and named arguments aren't utilized. No objection here, but I'm curious what prompted this change. Was it tooling?

Copy link
Member Author

Choose a reason for hiding this comment

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

That's prompted by rector. I expect the alternative syntax could be deprecated one day.

fn ($input) => (string) Document::fromPHP($input),
[
['_id' => 1, 'x' => ['foo' => 'bar']],
Expand Down