Skip to content

Commit c674aac

Browse files
committed
PHPLIB-141: Remove InvalidArgumentTypeException in GridFS
1 parent 03e9dec commit c674aac

File tree

5 files changed

+13
-14
lines changed

5 files changed

+13
-14
lines changed

src/GridFS/Bucket.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use MongoDB\Driver\Cursor;
77
use MongoDB\Driver\Manager;
88
use MongoDB\Exception\GridFSFileNotFoundException;
9-
use MongoDB\Exception\InvalidArgumentTypeException;
9+
use MongoDB\Exception\InvalidArgumentException;
1010
use MongoDB\Operation\Find;
1111

1212
/**
@@ -51,19 +51,19 @@ public function __construct(Manager $manager, $databaseName, array $options = []
5151
];
5252

5353
if (isset($options['bucketName']) && ! is_string($options['bucketName'])) {
54-
throw new InvalidArgumentTypeException('"bucketName" option', $options['bucketName'], 'string');
54+
throw InvalidArgumentException::invalidType('"bucketName" option', $options['bucketName'], 'string');
5555
}
5656

5757
if (isset($options['chunkSizeBytes']) && ! is_integer($options['chunkSizeBytes'])) {
58-
throw new InvalidArgumentTypeException('"chunkSizeBytes" option', $options['chunkSizeBytes'], 'integer');
58+
throw InvalidArgumentException::invalidType('"chunkSizeBytes" option', $options['chunkSizeBytes'], 'integer');
5959
}
6060

6161
if (isset($options['readPreference']) && ! $options['readPreference'] instanceof ReadPreference) {
62-
throw new InvalidArgumentTypeException('"readPreference" option', $options['readPreference'], 'MongoDB\Driver\ReadPreference');
62+
throw InvalidArgumentException::invalidType('"readPreference" option', $options['readPreference'], 'MongoDB\Driver\ReadPreference');
6363
}
6464

6565
if (isset($options['writeConcern']) && ! $options['writeConcern'] instanceof WriteConcern) {
66-
throw new InvalidArgumentTypeException('"writeConcern" option', $options['writeConcern'], 'MongoDB\Driver\WriteConcern');
66+
throw InvalidArgumentException::invalidType('"writeConcern" option', $options['writeConcern'], 'MongoDB\Driver\WriteConcern');
6767
}
6868

6969
$this->databaseName = (string) $databaseName;

src/GridFS/GridFSCollectionsWrapper.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
use MongoDB\Driver\Manager;
77
use MongoDB\Driver\ReadPreference;
88
use MongoDB\Driver\WriteConcern;
9-
use MongoDB\Exception\InvalidArgumentTypeException;
109

1110
/**
1211
* GridFSCollectionsWrapper abstracts the GridFS files and chunks collections.

src/GridFS/GridFSUpload.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use MongoDB\BSON\ObjectId;
77
use MongoDB\BSON\UTCDateTime;
88
use MongoDB\Driver\Exception\Exception;
9-
use MongoDB\Exception\InvalidArgumentTypeException;
9+
use MongoDB\Exception\InvalidArgumentException;
1010

1111
/**
1212
* GridFSUpload abstracts the process of writing a GridFS file.
@@ -47,22 +47,22 @@ class GridFSUpload
4747
* @param GridFSCollectionsWrapper $collectionsWrapper GridFS collections wrapper
4848
* @param string $filename File name
4949
* @param array $options Upload options
50-
* @throws InvalidArgumentTypeException
50+
* @throws InvalidArgumentException
5151
*/
5252
public function __construct(GridFSCollectionsWrapper $collectionsWrapper, $filename, array $options = [])
5353
{
5454
$options += ['chunkSizeBytes' => 261120];
5555

5656
if (isset($options['aliases']) && ! \MongoDB\is_string_array($options['aliases'])) {
57-
throw new InvalidArgumentTypeException('"aliases" option', $options['aliases'], 'array of strings');
57+
throw InvalidArgumentException::invalidType('"aliases" option', $options['aliases'], 'array of strings');
5858
}
5959

6060
if (isset($options['contentType']) && ! is_string($options['contentType'])) {
61-
throw new InvalidArgumentTypeException('"contentType" option', $options['contentType'], 'string');
61+
throw InvalidArgumentException::invalidType('"contentType" option', $options['contentType'], 'string');
6262
}
6363

6464
if (isset($options['metadata']) && ! is_array($options['metadata']) && ! is_object($options['metadata'])) {
65-
throw new InvalidArgumentTypeException('"metadata" option', $options['metadata'], 'array or object');
65+
throw InvalidArgumentException::invalidType('"metadata" option', $options['metadata'], 'array or object');
6666
}
6767

6868
$this->chunkSize = $options['chunkSizeBytes'];
@@ -175,7 +175,7 @@ public function isEOF()
175175
public function uploadFromStream($source)
176176
{
177177
if ( ! is_resource($source) || get_resource_type($source) != "stream") {
178-
throw new InvalidArgumentTypeException('$stream', $source, 'resource');
178+
throw InvalidArgumentException::invalidType('$source', $source, 'resource');
179179
}
180180

181181
$streamMetadata = stream_get_meta_data($source);

tests/GridFS/BucketFunctionalTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class BucketFunctionalTest extends FunctionalTestCase
1111
{
1212

1313
/**
14-
* @expectedException MongoDB\Exception\InvalidArgumentTypeException
14+
* @expectedException MongoDB\Exception\InvalidArgumentException
1515
* @dataProvider provideInvalidConstructorOptions
1616
*/
1717
public function testConstructorOptionTypeChecks(array $options)

tests/GridFS/GridFSStreamTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ public function testProvidedMultipleReads($data)
222222
$download->close();
223223
}
224224
/**
225-
* @expectedException \MongoDB\Exception\InvalidArgumentTypeException
225+
* @expectedException \MongoDB\Exception\InvalidArgumentException
226226
* @dataProvider provideInvalidUploadConstructorOptions
227227
*/
228228
public function testUploadConstructorOptionTypeChecks(array $options)

0 commit comments

Comments
 (0)