Skip to content

Commit 8b90915

Browse files
committed
Add type hints to all class properties
1 parent fcd0d78 commit 8b90915

File tree

85 files changed

+1250
-12
lines changed

Some content is hidden

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

85 files changed

+1250
-12
lines changed

phpcs.xml.dist

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
<!-- Exclude sniffs that require newer PHP versions -->
2020
<!-- Available with PHP 7.0 -->
2121
<exclude name="SlevomatCodingStandard.TypeHints.DeclareStrictTypes" />
22-
<!-- In addition to requiring PHP 7.0, this sniff will cause a significant amount of BC breaks. Proceed with caution! -->
23-
<exclude name="SlevomatCodingStandard.TypeHints.TypeHintDeclaration" />
2422
<exclude name="SlevomatCodingStandard.Exceptions.ReferenceThrowableOnly" />
2523
<exclude name="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperator" />
2624

@@ -90,6 +88,24 @@
9088
</properties>
9189
</rule>
9290

91+
<!-- Only enable some checks regarding type hints -->
92+
<!-- In addition to requiring PHP 7.0, this sniff will cause a significant amount of BC breaks. Proceed with caution! -->
93+
<rule ref="SlevomatCodingStandard.TypeHints.TypeHintDeclaration">
94+
<!-- Traversable type hints often end up as mixed[], so we skip them for now -->
95+
<exclude name="SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingTraversablePropertyTypeHintSpecification" />
96+
<exclude name="SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingTraversableParameterTypeHintSpecification" />
97+
<exclude name="SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingTraversableReturnTypeHintSpecification" />
98+
99+
<!-- Will cause BC breaks to method signatures - disabled for now -->
100+
<exclude name="SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint" />
101+
<exclude name="SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingReturnTypeHint" />
102+
103+
<properties>
104+
<property name="enableObjectTypeHint" value="true" />
105+
<property name="enableEachParameterAndReturnInspection" value="false" />
106+
</properties>
107+
</rule>
108+
93109
<rule ref="PSR1.Methods.CamelCapsMethodName.NotCamelCaps">
94110
<exclude-pattern>/src/GridFS/StreamWrapper</exclude-pattern>
95111
<exclude-pattern>/tests/DocumentationExamplesTest.php</exclude-pattern>

src/BulkWriteResult.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,19 @@
2525
*/
2626
class BulkWriteResult
2727
{
28+
/**
29+
* @var WriteResult
30+
*/
2831
private $writeResult;
32+
33+
/**
34+
* @var mixed[]
35+
*/
2936
private $insertedIds;
37+
38+
/**
39+
* @var boolean
40+
*/
3041
private $isAcknowledged;
3142

3243
/**

src/ChangeStream.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,35 @@ class ChangeStream implements Iterator
4242
*/
4343
const CURSOR_NOT_FOUND = 43;
4444

45+
/**
46+
* @var array
47+
*/
4548
private static $nonResumableErrorCodes = [
4649
136, // CappedPositionLost
4750
237, // CursorKilled
4851
11601, // Interrupted
4952
];
5053

54+
/**
55+
* @var callable
56+
*/
5157
private $resumeCallable;
58+
59+
/**
60+
* @var ChangeStreamIterator
61+
*/
5262
private $iterator;
63+
64+
/**
65+
* @var integer
66+
*/
5367
private $key = 0;
5468

5569
/**
5670
* Whether the change stream has advanced to its first result. This is used
5771
* to determine whether $key should be incremented after an iteration event.
72+
*
73+
* @var boolean
5874
*/
5975
private $hasAdvanced = false;
6076

src/Client.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,53 @@
3737

3838
class Client
3939
{
40+
/**
41+
* @var array
42+
*/
4043
private static $defaultTypeMap = [
4144
'array' => BSONArray::class,
4245
'document' => BSONDocument::class,
4346
'root' => BSONDocument::class,
4447
];
48+
49+
/**
50+
* @var integer
51+
*/
4552
private static $wireVersionForReadConcern = 4;
53+
54+
/**
55+
* @var integer
56+
*/
4657
private static $wireVersionForWritableCommandWriteConcern = 5;
4758

59+
/**
60+
* @var Manager
61+
*/
4862
private $manager;
63+
64+
/**
65+
* @var ReadConcern
66+
*/
4967
private $readConcern;
68+
69+
/**
70+
* @var ReadPreference
71+
*/
5072
private $readPreference;
73+
74+
/**
75+
* @var string
76+
*/
5177
private $uri;
78+
79+
/**
80+
* @var array
81+
*/
5282
private $typeMap;
83+
84+
/**
85+
* @var WriteConcern
86+
*/
5387
private $writeConcern;
5488

5589
/**

src/Collection.php

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,22 +66,68 @@
6666

6767
class Collection
6868
{
69+
/**
70+
* @var array
71+
*/
6972
private static $defaultTypeMap = [
7073
'array' => BSONArray::class,
7174
'document' => BSONDocument::class,
7275
'root' => BSONDocument::class,
7376
];
77+
78+
/**
79+
* @var integer
80+
*/
7481
private static $wireVersionForFindAndModifyWriteConcern = 4;
82+
83+
/**
84+
* @var integer
85+
*/
7586
private static $wireVersionForReadConcern = 4;
87+
88+
/**
89+
* @var integer
90+
*/
7691
private static $wireVersionForWritableCommandWriteConcern = 5;
92+
93+
/**
94+
* @var integer
95+
*/
7796
private static $wireVersionForReadConcernWithWriteStage = 8;
7897

98+
/**
99+
* @var string
100+
*/
79101
private $collectionName;
102+
103+
/**
104+
* @var string
105+
*/
80106
private $databaseName;
107+
108+
/**
109+
* @var Manager
110+
*/
81111
private $manager;
112+
113+
/**
114+
* @var ReadConcern
115+
*/
82116
private $readConcern;
117+
118+
/**
119+
* @var ReadPreference
120+
*/
83121
private $readPreference;
122+
123+
/**
124+
* @var array
125+
*/
84126
private $typeMap;
127+
128+
/**
129+
* @var WriteConcern
130+
*/
85131
private $writeConcern;
86132

87133
/**

src/Database.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,58 @@
4444

4545
class Database
4646
{
47+
/**
48+
* @var array
49+
*/
4750
private static $defaultTypeMap = [
4851
'array' => BSONArray::class,
4952
'document' => BSONDocument::class,
5053
'root' => BSONDocument::class,
5154
];
55+
56+
/**
57+
* @var integer
58+
*/
5259
private static $wireVersionForReadConcern = 4;
60+
61+
/**
62+
* @var integer
63+
*/
5364
private static $wireVersionForWritableCommandWriteConcern = 5;
65+
66+
/**
67+
* @var integer
68+
*/
5469
private static $wireVersionForReadConcernWithWriteStage = 8;
5570

71+
/**
72+
* @var string
73+
*/
5674
private $databaseName;
75+
76+
/**
77+
* @var Manager
78+
*/
5779
private $manager;
80+
81+
/**
82+
* @var ReadConcern
83+
*/
5884
private $readConcern;
85+
86+
/**
87+
* @var ReadPreference
88+
*/
5989
private $readPreference;
90+
91+
/**
92+
* @var array
93+
*/
6094
private $typeMap;
95+
96+
/**
97+
* @var WriteConcern
98+
*/
6199
private $writeConcern;
62100

63101
/**

src/DeleteResult.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,16 @@
2525
*/
2626
class DeleteResult
2727
{
28+
/**
29+
* @var WriteResult
30+
*/
2831
private $writeResult;
29-
private $isAcknowledged;
3032

3133
/**
32-
* @param WriteResult $writeResult
34+
* @var boolean
3335
*/
36+
private $isAcknowledged;
37+
3438
public function __construct(WriteResult $writeResult)
3539
{
3640
$this->writeResult = $writeResult;

src/GridFS/Bucket.php

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,24 +62,78 @@
6262
*/
6363
class Bucket
6464
{
65+
/**
66+
* @var string
67+
*/
6568
private static $defaultBucketName = 'fs';
69+
70+
/**
71+
* @var integer
72+
*/
6673
private static $defaultChunkSizeBytes = 261120;
74+
75+
/**
76+
* @var array
77+
*/
6778
private static $defaultTypeMap = [
6879
'array' => BSONArray::class,
6980
'document' => BSONDocument::class,
7081
'root' => BSONDocument::class,
7182
];
83+
84+
/**
85+
* @var string
86+
*/
7287
private static $streamWrapperProtocol = 'gridfs';
7388

89+
/**
90+
* @var CollectionWrapper
91+
*/
7492
private $collectionWrapper;
93+
94+
/**
95+
* @var string
96+
*/
7597
private $databaseName;
98+
99+
/**
100+
* @var Manager
101+
*/
76102
private $manager;
103+
104+
/**
105+
* @var string
106+
*/
77107
private $bucketName;
108+
109+
/**
110+
* @var boolean
111+
*/
78112
private $disableMD5;
113+
114+
/**
115+
* @var integer
116+
*/
79117
private $chunkSizeBytes;
118+
119+
/**
120+
* @var ReadConcern
121+
*/
80122
private $readConcern;
123+
124+
/**
125+
* @var ReadPreference
126+
*/
81127
private $readPreference;
128+
129+
/**
130+
* @var array
131+
*/
82132
private $typeMap;
133+
134+
/**
135+
* @var WriteConcern
136+
*/
83137
private $writeConcern;
84138

85139
/**

src/GridFS/CollectionWrapper.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,29 @@
3434
*/
3535
class CollectionWrapper
3636
{
37+
/**
38+
* @var string
39+
*/
3740
private $bucketName;
41+
42+
/**
43+
* @var Collection
44+
*/
3845
private $chunksCollection;
46+
47+
/**
48+
* @var string
49+
*/
3950
private $databaseName;
51+
52+
/**
53+
* @var boolean
54+
*/
4055
private $checkedIndexes = false;
56+
57+
/**
58+
* @var Collection
59+
*/
4160
private $filesCollection;
4261

4362
/**

0 commit comments

Comments
 (0)