Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 14d6d65

Browse files
committed
Modernise code for PHP 7.4
This uses rector and phpcbf to automatically fix issues
1 parent 7530dca commit 14d6d65

File tree

175 files changed

+972
-1393
lines changed

Some content is hidden

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

175 files changed

+972
-1393
lines changed

‎examples/bulk.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ function toJSON(object $document): string
6868
['x' => 10], // Document
6969
],
7070
],
71-
]
71+
],
7272
);
7373

7474
$cursor = $collection->find([]);

‎examples/command_logger.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function commandFailed(CommandFailedEvent $event): void
6969

7070
$collection->updateMany(
7171
['x' => ['$gt' => 1]],
72-
['$set' => ['y' => 1]]
72+
['$set' => ['y' => 1]],
7373
);
7474

7575
$cursor = $collection->find([], ['batchSize' => 2]);

‎examples/persistable.php‎

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,12 @@
1616

1717
class PersistableEntry implements Persistable
1818
{
19-
/** @var ObjectId */
20-
private $id;
19+
private ObjectId $id;
2120

22-
/** @var string */
23-
public $name;
21+
public string $name;
2422

2523
/** @var array<PersistableEmail> */
26-
public $emails = [];
24+
public array$emails = [];
2725

2826
public function __construct(string $name)
2927
{
@@ -65,11 +63,9 @@ public function bsonUnserialize(array $data): void
6563

6664
class PersistableEmail implements Persistable
6765
{
68-
/** @var string */
69-
public $type;
66+
public string $type;
7067

71-
/** @var string */
72-
public $address;
68+
public string $address;
7369

7470
public function __construct(string $type, string $address)
7571
{

‎examples/typemap.php‎

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,12 @@
1616

1717
class TypeMapEntry implements Unserializable
1818
{
19-
/** @var ObjectId */
20-
private $id;
19+
private ObjectId $id;
2120

22-
/** @var string */
23-
private $name;
21+
private string $name;
2422

2523
/** @var array<TypeMapEmail> */
26-
private $emails;
24+
private array$emails;
2725

2826
private function __construct()
2927
{
@@ -64,11 +62,9 @@ public function bsonUnserialize(array $data): void
6462

6563
class TypeMapEmail implements Unserializable
6664
{
67-
/** @var string */
68-
private $type;
65+
private string $type;
6966

70-
/** @var string */
71-
private $address;
67+
private string $address;
7268

7369
private function __construct()
7470
{

‎examples/with_transaction.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ function toJSON(object $document): string
3737
['x' => 2],
3838
['x' => 3],
3939
],
40-
['session' => $session]
40+
['session' => $session],
4141
);
4242

4343
$collection->updateMany(
4444
['x' => ['$gt' => 1]],
4545
['$set' => ['y' => 1]],
46-
['session' => $session]
46+
['session' => $session],
4747
);
4848
};
4949

‎phpcs.xml.dist‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<file>rector.php</file>
1818

1919
<!-- Target minimum supported PHP version -->
20-
<config name="php_version" value="70200"/>
20+
<config name="php_version" value="70400"/>
2121

2222
<!-- ****************************************** -->
2323
<!-- Import rules from doctrine/coding-standard -->
@@ -112,8 +112,6 @@
112112

113113
<rule ref="SlevomatCodingStandard.TypeHints.PropertyTypeHint">
114114
<properties>
115-
<!-- Requires PHP 7.4 -->
116-
<property name="enableNativeTypeHint" value="false" />
117115
<!-- Requires PHP 8.0 -->
118116
<property name="enableMixedTypeHint" value="false" />
119117
<!-- Requires PHP 8.0 -->

‎rector.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
]);
1616

1717
// Modernize code
18-
$rectorConfig->sets([LevelSetList::UP_TO_PHP_72]);
18+
$rectorConfig->sets([LevelSetList::UP_TO_PHP_74]);
1919

2020
$rectorConfig->skip([
2121
// Falsely detect unassigned variables in code paths stopped by PHPUnit\Framework\Assert::markTestSkipped()

‎src/BulkWriteResult.php‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,11 @@
2525
*/
2626
class BulkWriteResult
2727
{
28-
/** @var WriteResult */
29-
private $writeResult;
28+
private WriteResult $writeResult;
3029

31-
/** @var array */
32-
private $insertedIds;
30+
private array $insertedIds;
3331

34-
/** @var boolean */
35-
private $isAcknowledged;
32+
private bool $isAcknowledged;
3633

3734
public function __construct(WriteResult $writeResult, array $insertedIds)
3835
{

‎src/ChangeStream.php‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,13 @@ class ChangeStream implements Iterator
7474
/** @var ChangeStreamIterator */
7575
private $iterator;
7676

77-
/** @var integer */
78-
private $key = 0;
77+
private int $key = 0;
7978

8079
/**
8180
* Whether the change stream has advanced to its first result. This is used
8281
* to determine whether $key should be incremented after an iteration event.
83-
*
84-
* @var boolean
8582
*/
86-
private $hasAdvanced = false;
83+
private bool$hasAdvanced = false;
8784

8885
/**
8986
* @internal

‎src/Client.php‎

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,26 +54,19 @@ class Client
5454

5555
private const HANDSHAKE_SEPARATOR = '/';
5656

57-
/** @var string|null */
58-
private static $version;
57+
private static ?string $version = null;
5958

60-
/** @var Manager */
61-
private $manager;
59+
private Manager $manager;
6260

63-
/** @var ReadConcern */
64-
private $readConcern;
61+
private ReadConcern $readConcern;
6562

66-
/** @var ReadPreference */
67-
private $readPreference;
63+
private ReadPreference $readPreference;
6864

69-
/** @var string */
70-
private $uri;
65+
private string $uri;
7166

72-
/** @var array */
73-
private $typeMap;
67+
private array $typeMap;
7468

75-
/** @var WriteConcern */
76-
private $writeConcern;
69+
private WriteConcern $writeConcern;
7770

7871
/**
7972
* Constructs a new Client instance.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /