Skip to content

Commit 9480f99

Browse files
committed
Merge pull request #696
2 parents 98fcbea + 86ff731 commit 9480f99

16 files changed

+69
-46
lines changed

src/Client.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public function __construct($uri = 'mongodb://127.0.0.1/', array $uriOptions = [
9595
{
9696
$driverOptions += ['typeMap' => self::$defaultTypeMap];
9797

98-
if (isset($driverOptions['typeMap']) && ! is_array($driverOptions['typeMap'])) {
98+
if (! is_array($driverOptions['typeMap'])) {
9999
throw InvalidArgumentException::invalidType('"typeMap" driver option', $driverOptions['typeMap'], 'array');
100100
}
101101

src/GridFS/Bucket.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,19 +143,19 @@ public function __construct(Manager $manager, $databaseName, array $options = []
143143
'disableMD5' => false,
144144
];
145145

146-
if (isset($options['bucketName']) && ! is_string($options['bucketName'])) {
146+
if (! is_string($options['bucketName'])) {
147147
throw InvalidArgumentException::invalidType('"bucketName" option', $options['bucketName'], 'string');
148148
}
149149

150-
if (isset($options['chunkSizeBytes']) && ! is_integer($options['chunkSizeBytes'])) {
150+
if (! is_integer($options['chunkSizeBytes'])) {
151151
throw InvalidArgumentException::invalidType('"chunkSizeBytes" option', $options['chunkSizeBytes'], 'integer');
152152
}
153153

154-
if (isset($options['chunkSizeBytes']) && $options['chunkSizeBytes'] < 1) {
154+
if ($options['chunkSizeBytes'] < 1) {
155155
throw new InvalidArgumentException(sprintf('Expected "chunkSizeBytes" option to be >= 1, %d given', $options['chunkSizeBytes']));
156156
}
157157

158-
if (isset($options['disableMD5']) && ! is_bool($options['disableMD5'])) {
158+
if (! is_bool($options['disableMD5'])) {
159159
throw InvalidArgumentException::invalidType('"disableMD5" option', $options['disableMD5'], 'boolean');
160160
}
161161

src/GridFS/WritableStream.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,15 +114,15 @@ public function __construct(CollectionWrapper $collectionWrapper, $filename, arr
114114
throw InvalidArgumentException::invalidType('"aliases" option', $options['aliases'], 'array of strings');
115115
}
116116

117-
if (isset($options['chunkSizeBytes']) && ! is_integer($options['chunkSizeBytes'])) {
117+
if (! is_integer($options['chunkSizeBytes'])) {
118118
throw InvalidArgumentException::invalidType('"chunkSizeBytes" option', $options['chunkSizeBytes'], 'integer');
119119
}
120120

121-
if (isset($options['chunkSizeBytes']) && $options['chunkSizeBytes'] < 1) {
121+
if ($options['chunkSizeBytes'] < 1) {
122122
throw new InvalidArgumentException(sprintf('Expected "chunkSizeBytes" option to be >= 1, %d given', $options['chunkSizeBytes']));
123123
}
124124

125-
if (isset($options['disableMD5']) && ! is_bool($options['disableMD5'])) {
125+
if (! is_bool($options['disableMD5'])) {
126126
throw InvalidArgumentException::invalidType('"disableMD5" option', $options['disableMD5'], 'boolean');
127127
}
128128

src/Operation/Watch.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,14 @@ public function __construct(Manager $manager, $databaseName, $collectionName, ar
178178
'readPreference' => new ReadPreference(ReadPreference::RP_PRIMARY),
179179
];
180180

181-
if (isset($options['fullDocument']) && ! is_string($options['fullDocument'])) {
181+
if (! is_string($options['fullDocument'])) {
182182
throw InvalidArgumentException::invalidType('"fullDocument" option', $options['fullDocument'], 'string');
183183
}
184184

185+
if (! $options['readPreference'] instanceof ReadPreference) {
186+
throw InvalidArgumentException::invalidType('"readPreference" option', $options['readPreference'], ReadPreference::class);
187+
}
188+
185189
if (isset($options['resumeAfter']) && ! is_array($options['resumeAfter']) && ! is_object($options['resumeAfter'])) {
186190
throw InvalidArgumentException::invalidType('"resumeAfter" option', $options['resumeAfter'], 'array or object');
187191
}

tests/ClientTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function provideInvalidConstructorDriverOptions()
3333
{
3434
$options = [];
3535

36-
foreach ($this->getInvalidArrayValues() as $value) {
36+
foreach ($this->getInvalidArrayValues(true) as $value) {
3737
$options[][] = ['typeMap' => $value];
3838
}
3939

tests/GridFS/BucketFunctionalTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,15 @@ public function provideInvalidConstructorOptions()
6262
{
6363
$options = [];
6464

65-
foreach ($this->getInvalidStringValues() as $value) {
65+
foreach ($this->getInvalidStringValues(true) as $value) {
6666
$options[][] = ['bucketName' => $value];
6767
}
6868

69-
foreach ($this->getInvalidIntegerValues() as $value) {
69+
foreach ($this->getInvalidIntegerValues(true) as $value) {
7070
$options[][] = ['chunkSizeBytes' => $value];
7171
}
7272

73-
foreach ($this->getInvalidBooleanValues() as $value) {
73+
foreach ($this->getInvalidBooleanValues(true) as $value) {
7474
$options[][] = ['disableMD5' => $value];
7575
}
7676

tests/GridFS/WritableStreamFunctionalTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ public function provideInvalidConstructorOptions()
5050
{
5151
$options = [];
5252

53-
foreach ($this->getInvalidIntegerValues() as $value) {
53+
foreach ($this->getInvalidIntegerValues(true) as $value) {
5454
$options[][] = ['chunkSizeBytes' => $value];
5555
}
5656

57-
foreach ($this->getInvalidBooleanValues() as $value) {
57+
foreach ($this->getInvalidBooleanValues(true) as $value) {
5858
$options[][] = ['disableMD5' => $value];
5959
}
6060

tests/Operation/AggregateTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function provideInvalidConstructorOptions()
2727
{
2828
$options = [];
2929

30-
foreach ($this->getInvalidBooleanValues() as $value) {
30+
foreach ($this->getInvalidBooleanValues(true) as $value) {
3131
$options[][] = ['allowDiskUse' => $value];
3232
}
3333

@@ -79,7 +79,7 @@ public function provideInvalidConstructorOptions()
7979
$options[][] = ['typeMap' => $value];
8080
}
8181

82-
foreach ($this->getInvalidBooleanValues() as $value) {
82+
foreach ($this->getInvalidBooleanValues(true) as $value) {
8383
$options[][] = ['useCursor' => $value];
8484
}
8585

tests/Operation/BulkWriteTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ public function provideInvalidConstructorOptions()
412412
$options[][] = ['bypassDocumentValidation' => $value];
413413
}
414414

415-
foreach ($this->getInvalidBooleanValues() as $value) {
415+
foreach ($this->getInvalidBooleanValues(true) as $value) {
416416
$options[][] = ['ordered' => $value];
417417
}
418418

tests/Operation/FindAndModifyTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ public function provideInvalidConstructorOptions()
4040
$options[][] = ['maxTimeMS' => $value];
4141
}
4242

43-
foreach ($this->getInvalidBooleanValues() as $value) {
43+
foreach ($this->getInvalidBooleanValues(true) as $value) {
4444
$options[][] = ['new' => $value];
4545
}
4646

4747
foreach ($this->getInvalidDocumentValues() as $value) {
4848
$options[][] = ['query' => $value];
4949
}
5050

51-
foreach ($this->getInvalidBooleanValues() as $value) {
51+
foreach ($this->getInvalidBooleanValues(true) as $value) {
5252
$options[][] = ['remove' => $value];
5353
}
5454

@@ -68,7 +68,7 @@ public function provideInvalidConstructorOptions()
6868
$options[][] = ['update' => $value];
6969
}
7070

71-
foreach ($this->getInvalidBooleanValues() as $value) {
71+
foreach ($this->getInvalidBooleanValues(true) as $value) {
7272
$options[][] = ['upsert' => $value];
7373
}
7474

0 commit comments

Comments
 (0)