Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mongo-php-library
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sinan
mongo-php-library
Commits
8f646a38
Commit
8f646a38
authored
Jan 11, 2016
by
Jeremy Mikola
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PHPLIB-141: Replace InvalidArgumentTypeException with a factory method
parent
74af87db
Hide whitespace changes
Inline
Side-by-side
Showing
51 changed files
with
199 additions
and
211 deletions
+199
-211
Client.php
src/Client.php
+2
-1
Collection.php
src/Collection.php
+4
-5
Database.php
src/Database.php
+4
-5
InvalidArgumentException.php
src/Exception/InvalidArgumentException.php
+12
-0
InvalidArgumentTypeException.php
src/Exception/InvalidArgumentTypeException.php
+0
-11
IndexInput.php
src/Model/IndexInput.php
+5
-5
Aggregate.php
src/Operation/Aggregate.php
+9
-10
BulkWrite.php
src/Operation/BulkWrite.php
+11
-12
Count.php
src/Operation/Count.php
+7
-8
CreateCollection.php
src/Operation/CreateCollection.php
+11
-12
CreateIndexes.php
src/Operation/CreateIndexes.php
+1
-2
DatabaseCommand.php
src/Operation/DatabaseCommand.php
+3
-4
Delete.php
src/Operation/Delete.php
+2
-3
Distinct.php
src/Operation/Distinct.php
+4
-5
Find.php
src/Operation/Find.php
+16
-17
FindAndModify.php
src/Operation/FindAndModify.php
+10
-11
FindOne.php
src/Operation/FindOne.php
+1
-1
FindOneAndDelete.php
src/Operation/FindOneAndDelete.php
+2
-3
FindOneAndReplace.php
src/Operation/FindOneAndReplace.php
+4
-5
FindOneAndUpdate.php
src/Operation/FindOneAndUpdate.php
+4
-5
InsertMany.php
src/Operation/InsertMany.php
+4
-5
InsertOne.php
src/Operation/InsertOne.php
+4
-4
ListCollections.php
src/Operation/ListCollections.php
+5
-3
ListDatabases.php
src/Operation/ListDatabases.php
+3
-1
ListIndexes.php
src/Operation/ListIndexes.php
+3
-1
ReplaceOne.php
src/Operation/ReplaceOne.php
+1
-2
Update.php
src/Operation/Update.php
+6
-7
UpdateMany.php
src/Operation/UpdateMany.php
+1
-2
UpdateOne.php
src/Operation/UpdateOne.php
+1
-2
functions.php
src/functions.php
+5
-5
CollectionFunctionalTest.php
tests/Collection/CollectionFunctionalTest.php
+1
-1
DatabaseFunctionalTest.php
tests/Database/DatabaseFunctionalTest.php
+2
-2
IndexInputTest.php
tests/Model/IndexInputTest.php
+4
-4
AggregateTest.php
tests/Operation/AggregateTest.php
+1
-1
BulkWriteTest.php
tests/Operation/BulkWriteTest.php
+13
-13
CountTest.php
tests/Operation/CountTest.php
+2
-2
CreateIndexesTest.php
tests/Operation/CreateIndexesTest.php
+1
-1
DatabaseCommandTest.php
tests/Operation/DatabaseCommandTest.php
+2
-2
DeleteTest.php
tests/Operation/DeleteTest.php
+2
-2
DistinctTest.php
tests/Operation/DistinctTest.php
+2
-2
FindAndModifyTest.php
tests/Operation/FindAndModifyTest.php
+1
-1
FindOneAndDeleteTest.php
tests/Operation/FindOneAndDeleteTest.php
+2
-2
FindOneAndReplaceTest.php
tests/Operation/FindOneAndReplaceTest.php
+3
-3
FindOneAndUpdateTest.php
tests/Operation/FindOneAndUpdateTest.php
+3
-3
FindTest.php
tests/Operation/FindTest.php
+2
-2
InsertManyTest.php
tests/Operation/InsertManyTest.php
+2
-2
InsertOneTest.php
tests/Operation/InsertOneTest.php
+2
-2
ReplaceOneTest.php
tests/Operation/ReplaceOneTest.php
+2
-2
UpdateManyTest.php
tests/Operation/UpdateManyTest.php
+2
-2
UpdateOneTest.php
tests/Operation/UpdateOneTest.php
+2
-2
UpdateTest.php
tests/Operation/UpdateTest.php
+3
-3
No files found.
src/Client.php
View file @
8f646a38
...
@@ -7,6 +7,7 @@ use MongoDB\Driver\Cursor;
...
@@ -7,6 +7,7 @@ use MongoDB\Driver\Cursor;
use
MongoDB\Driver\Manager
;
use
MongoDB\Driver\Manager
;
use
MongoDB\Driver\ReadPreference
;
use
MongoDB\Driver\ReadPreference
;
use
MongoDB\Driver\WriteConcern
;
use
MongoDB\Driver\WriteConcern
;
use
MongoDB\Exception\InvalidArgumentException
;
use
MongoDB\Model\DatabaseInfoIterator
;
use
MongoDB\Model\DatabaseInfoIterator
;
use
MongoDB\Operation\DropDatabase
;
use
MongoDB\Operation\DropDatabase
;
use
MongoDB\Operation\ListDatabases
;
use
MongoDB\Operation\ListDatabases
;
...
@@ -49,7 +50,7 @@ class Client
...
@@ -49,7 +50,7 @@ class Client
];
];
if
(
isset
(
$driverOptions
[
'typeMap'
])
&&
!
is_array
(
$driverOptions
[
'typeMap'
]))
{
if
(
isset
(
$driverOptions
[
'typeMap'
])
&&
!
is_array
(
$driverOptions
[
'typeMap'
]))
{
throw
new
InvalidArgumentTypeException
(
'"typeMap" driver option'
,
$driverOptions
[
'typeMap'
],
'array'
);
throw
InvalidArgumentException
::
invalidType
(
'"typeMap" driver option'
,
$driverOptions
[
'typeMap'
],
'array'
);
}
}
$this
->
manager
=
new
Manager
(
$uri
,
$uriOptions
,
$driverOptions
);
$this
->
manager
=
new
Manager
(
$uri
,
$uriOptions
,
$driverOptions
);
...
...
src/Collection.php
View file @
8f646a38
...
@@ -10,7 +10,6 @@ use MongoDB\Driver\ReadPreference;
...
@@ -10,7 +10,6 @@ use MongoDB\Driver\ReadPreference;
use
MongoDB\Driver\Server
;
use
MongoDB\Driver\Server
;
use
MongoDB\Driver\WriteConcern
;
use
MongoDB\Driver\WriteConcern
;
use
MongoDB\Exception\InvalidArgumentException
;
use
MongoDB\Exception\InvalidArgumentException
;
use
MongoDB\Exception\InvalidArgumentTypeException
;
use
MongoDB\Model\IndexInfoIterator
;
use
MongoDB\Model\IndexInfoIterator
;
use
MongoDB\Model\IndexInput
;
use
MongoDB\Model\IndexInput
;
use
MongoDB\Operation\Aggregate
;
use
MongoDB\Operation\Aggregate
;
...
@@ -85,19 +84,19 @@ class Collection
...
@@ -85,19 +84,19 @@ class Collection
$this
->
collectionName
=
$parts
[
1
];
$this
->
collectionName
=
$parts
[
1
];
if
(
isset
(
$options
[
'readConcern'
])
&&
!
$options
[
'readConcern'
]
instanceof
ReadConcern
)
{
if
(
isset
(
$options
[
'readConcern'
])
&&
!
$options
[
'readConcern'
]
instanceof
ReadConcern
)
{
throw
new
InvalidArgumentTypeException
(
'"readConcern" option'
,
$options
[
'readConcern'
],
'MongoDB\Driver\ReadConcern'
);
throw
InvalidArgumentException
::
invalidType
(
'"readConcern" option'
,
$options
[
'readConcern'
],
'MongoDB\Driver\ReadConcern'
);
}
}
if
(
isset
(
$options
[
'readPreference'
])
&&
!
$options
[
'readPreference'
]
instanceof
ReadPreference
)
{
if
(
isset
(
$options
[
'readPreference'
])
&&
!
$options
[
'readPreference'
]
instanceof
ReadPreference
)
{
throw
new
InvalidArgumentTypeException
(
'"readPreference" option'
,
$options
[
'readPreference'
],
'MongoDB\Driver\ReadPreference'
);
throw
InvalidArgumentException
::
invalidType
(
'"readPreference" option'
,
$options
[
'readPreference'
],
'MongoDB\Driver\ReadPreference'
);
}
}
if
(
isset
(
$options
[
'typeMap'
])
&&
!
is_array
(
$options
[
'typeMap'
]))
{
if
(
isset
(
$options
[
'typeMap'
])
&&
!
is_array
(
$options
[
'typeMap'
]))
{
throw
new
InvalidArgumentTypeException
(
'"typeMap" option'
,
$options
[
'typeMap'
],
'array'
);
throw
InvalidArgumentException
::
invalidType
(
'"typeMap" option'
,
$options
[
'typeMap'
],
'array'
);
}
}
if
(
isset
(
$options
[
'writeConcern'
])
&&
!
$options
[
'writeConcern'
]
instanceof
WriteConcern
)
{
if
(
isset
(
$options
[
'writeConcern'
])
&&
!
$options
[
'writeConcern'
]
instanceof
WriteConcern
)
{
throw
new
InvalidArgumentTypeException
(
'"writeConcern" option'
,
$options
[
'writeConcern'
],
'MongoDB\Driver\WriteConcern'
);
throw
InvalidArgumentException
::
invalidType
(
'"writeConcern" option'
,
$options
[
'writeConcern'
],
'MongoDB\Driver\WriteConcern'
);
}
}
$this
->
manager
=
$manager
;
$this
->
manager
=
$manager
;
...
...
src/Database.php
View file @
8f646a38
...
@@ -11,7 +11,6 @@ use MongoDB\Driver\ReadPreference;
...
@@ -11,7 +11,6 @@ use MongoDB\Driver\ReadPreference;
use
MongoDB\Driver\Server
;
use
MongoDB\Driver\Server
;
use
MongoDB\Driver\WriteConcern
;
use
MongoDB\Driver\WriteConcern
;
use
MongoDB\Exception\InvalidArgumentException
;
use
MongoDB\Exception\InvalidArgumentException
;
use
MongoDB\Exception\InvalidArgumentTypeException
;
use
MongoDB\Model\CollectionInfoIterator
;
use
MongoDB\Model\CollectionInfoIterator
;
use
MongoDB\Operation\CreateCollection
;
use
MongoDB\Operation\CreateCollection
;
use
MongoDB\Operation\DatabaseCommand
;
use
MongoDB\Operation\DatabaseCommand
;
...
@@ -62,19 +61,19 @@ class Database
...
@@ -62,19 +61,19 @@ class Database
}
}
if
(
isset
(
$options
[
'readConcern'
])
&&
!
$options
[
'readConcern'
]
instanceof
ReadConcern
)
{
if
(
isset
(
$options
[
'readConcern'
])
&&
!
$options
[
'readConcern'
]
instanceof
ReadConcern
)
{
throw
new
InvalidArgumentTypeException
(
'"readConcern" option'
,
$options
[
'readConcern'
],
'MongoDB\Driver\ReadConcern'
);
throw
InvalidArgumentException
::
invalidType
(
'"readConcern" option'
,
$options
[
'readConcern'
],
'MongoDB\Driver\ReadConcern'
);
}
}
if
(
isset
(
$options
[
'readPreference'
])
&&
!
$options
[
'readPreference'
]
instanceof
ReadPreference
)
{
if
(
isset
(
$options
[
'readPreference'
])
&&
!
$options
[
'readPreference'
]
instanceof
ReadPreference
)
{
throw
new
InvalidArgumentTypeException
(
'"readPreference" option'
,
$options
[
'readPreference'
],
'MongoDB\Driver\ReadPreference'
);
throw
InvalidArgumentException
::
invalidType
(
'"readPreference" option'
,
$options
[
'readPreference'
],
'MongoDB\Driver\ReadPreference'
);
}
}
if
(
isset
(
$options
[
'typeMap'
])
&&
!
is_array
(
$options
[
'typeMap'
]))
{
if
(
isset
(
$options
[
'typeMap'
])
&&
!
is_array
(
$options
[
'typeMap'
]))
{
throw
new
InvalidArgumentTypeException
(
'"typeMap" option'
,
$options
[
'typeMap'
],
'array'
);
throw
InvalidArgumentException
::
invalidType
(
'"typeMap" option'
,
$options
[
'typeMap'
],
'array'
);
}
}
if
(
isset
(
$options
[
'writeConcern'
])
&&
!
$options
[
'writeConcern'
]
instanceof
WriteConcern
)
{
if
(
isset
(
$options
[
'writeConcern'
])
&&
!
$options
[
'writeConcern'
]
instanceof
WriteConcern
)
{
throw
new
InvalidArgumentTypeException
(
'"writeConcern" option'
,
$options
[
'writeConcern'
],
'MongoDB\Driver\WriteConcern'
);
throw
InvalidArgumentException
::
invalidType
(
'"writeConcern" option'
,
$options
[
'writeConcern'
],
'MongoDB\Driver\WriteConcern'
);
}
}
$this
->
manager
=
$manager
;
$this
->
manager
=
$manager
;
...
...
src/Exception/InvalidArgumentException.php
View file @
8f646a38
...
@@ -4,4 +4,16 @@ namespace MongoDB\Exception;
...
@@ -4,4 +4,16 @@ namespace MongoDB\Exception;
class
InvalidArgumentException
extends
\MongoDB\Driver\Exception\InvalidArgumentException
implements
Exception
class
InvalidArgumentException
extends
\MongoDB\Driver\Exception\InvalidArgumentException
implements
Exception
{
{
/**
* Thrown when an argument or option has an invalid type.
*
* @param string $name Name of the argument or option
* @param mixed $value Actual value (used to derive the type)
* @param string $expectedType Expected type
* @return self
*/
public
static
function
invalidType
(
$name
,
$value
,
$expectedType
)
{
return
new
static
(
sprintf
(
'Expected %s to have type "%s" but found "%s"'
,
$name
,
$expectedType
,
is_object
(
$value
)
?
get_class
(
$value
)
:
gettype
(
$value
)));
}
}
}
src/Exception/InvalidArgumentTypeException.php
deleted
100644 → 0
View file @
74af87db
<?php
namespace
MongoDB\Exception
;
class
InvalidArgumentTypeException
extends
InvalidArgumentException
{
public
function
__construct
(
$name
,
$value
,
$expectedType
)
{
parent
::
__construct
(
sprintf
(
'Expected %s to have type "%s" but found "%s"'
,
$name
,
$expectedType
,
is_object
(
$value
)
?
get_class
(
$value
)
:
gettype
(
$value
)));
}
}
src/Model/IndexInput.php
View file @
8f646a38
...
@@ -4,7 +4,6 @@ namespace MongoDB\Model;
...
@@ -4,7 +4,6 @@ namespace MongoDB\Model;
use
MongoDB\BSON\Serializable
;
use
MongoDB\BSON\Serializable
;
use
MongoDB\Exception\InvalidArgumentException
;
use
MongoDB\Exception\InvalidArgumentException
;
use
MongoDB\Exception\InvalidArgumentTypeException
;
/**
/**
* Index input model class.
* Index input model class.
...
@@ -24,6 +23,7 @@ class IndexInput implements Serializable
...
@@ -24,6 +23,7 @@ class IndexInput implements Serializable
* Constructor.
* Constructor.
*
*
* @param array $index Index specification
* @param array $index Index specification
* @throws InvalidArgumentException
*/
*/
public
function
__construct
(
array
$index
)
public
function
__construct
(
array
$index
)
{
{
...
@@ -32,12 +32,12 @@ class IndexInput implements Serializable
...
@@ -32,12 +32,12 @@ class IndexInput implements Serializable
}
}
if
(
!
is_array
(
$index
[
'key'
])
&&
!
is_object
(
$index
[
'key'
]))
{
if
(
!
is_array
(
$index
[
'key'
])
&&
!
is_object
(
$index
[
'key'
]))
{
throw
new
InvalidArgumentTypeException
(
'"key" option'
,
$index
[
'key'
],
'array or object'
);
throw
InvalidArgumentException
::
invalidType
(
'"key" option'
,
$index
[
'key'
],
'array or object'
);
}
}
foreach
(
$index
[
'key'
]
as
$fieldName
=>
$order
)
{
foreach
(
$index
[
'key'
]
as
$fieldName
=>
$order
)
{
if
(
!
is_int
(
$order
)
&&
!
is_float
(
$order
)
&&
!
is_string
(
$order
))
{
if
(
!
is_int
(
$order
)
&&
!
is_float
(
$order
)
&&
!
is_string
(
$order
))
{
throw
new
InvalidArgumentTypeException
(
sprintf
(
'order value for "%s" field within "key" option'
,
$fieldName
),
$order
,
'numeric or string'
);
throw
InvalidArgumentException
::
invalidType
(
sprintf
(
'order value for "%s" field within "key" option'
,
$fieldName
),
$order
,
'numeric or string'
);
}
}
}
}
...
@@ -46,7 +46,7 @@ class IndexInput implements Serializable
...
@@ -46,7 +46,7 @@ class IndexInput implements Serializable
}
}
if
(
!
is_string
(
$index
[
'ns'
]))
{
if
(
!
is_string
(
$index
[
'ns'
]))
{
throw
new
InvalidArgumentTypeException
(
'"ns" option'
,
$index
[
'ns'
],
'string'
);
throw
InvalidArgumentException
::
invalidType
(
'"ns" option'
,
$index
[
'ns'
],
'string'
);
}
}
if
(
!
isset
(
$index
[
'name'
]))
{
if
(
!
isset
(
$index
[
'name'
]))
{
...
@@ -54,7 +54,7 @@ class IndexInput implements Serializable
...
@@ -54,7 +54,7 @@ class IndexInput implements Serializable
}
}
if
(
!
is_string
(
$index
[
'name'
]))
{
if
(
!
is_string
(
$index
[
'name'
]))
{
throw
new
InvalidArgumentTypeException
(
'"name" option'
,
$index
[
'name'
],
'string'
);
throw
InvalidArgumentException
::
invalidType
(
'"name" option'
,
$index
[
'name'
],
'string'
);
}
}
$this
->
index
=
$index
;
$this
->
index
=
$index
;
...
...
src/Operation/Aggregate.php
View file @
8f646a38
...
@@ -7,7 +7,6 @@ use MongoDB\Driver\ReadConcern;
...
@@ -7,7 +7,6 @@ use MongoDB\Driver\ReadConcern;
use
MongoDB\Driver\ReadPreference
;
use
MongoDB\Driver\ReadPreference
;
use
MongoDB\Driver\Server
;
use
MongoDB\Driver\Server
;
use
MongoDB\Exception\InvalidArgumentException
;
use
MongoDB\Exception\InvalidArgumentException
;
use
MongoDB\Exception\InvalidArgumentTypeException
;
use
MongoDB\Exception\UnexpectedValueException
;
use
MongoDB\Exception\UnexpectedValueException
;
use
ArrayIterator
;
use
ArrayIterator
;
use
stdClass
;
use
stdClass
;
...
@@ -95,7 +94,7 @@ class Aggregate implements Executable
...
@@ -95,7 +94,7 @@ class Aggregate implements Executable
}
}
if
(
!
is_array
(
$operation
)
&&
!
is_object
(
$operation
))
{
if
(
!
is_array
(
$operation
)
&&
!
is_object
(
$operation
))
{
throw
new
InvalidArgumentTypeException
(
sprintf
(
'$pipeline[%d]'
,
$i
),
$operation
,
'array or object'
);
throw
InvalidArgumentException
::
invalidType
(
sprintf
(
'$pipeline[%d]'
,
$i
),
$operation
,
'array or object'
);
}
}
$expectedIndex
+=
1
;
$expectedIndex
+=
1
;
...
@@ -107,35 +106,35 @@ class Aggregate implements Executable
...
@@ -107,35 +106,35 @@ class Aggregate implements Executable
];
];
if
(
!
is_bool
(
$options
[
'allowDiskUse'
]))
{
if
(
!
is_bool
(
$options
[
'allowDiskUse'
]))
{
throw
new
InvalidArgumentTypeException
(
'"allowDiskUse" option'
,
$options
[
'allowDiskUse'
],
'boolean'
);
throw
InvalidArgumentException
::
invalidType
(
'"allowDiskUse" option'
,
$options
[
'allowDiskUse'
],
'boolean'
);
}
}
if
(
isset
(
$options
[
'batchSize'
])
&&
!
is_integer
(
$options
[
'batchSize'
]))
{
if
(
isset
(
$options
[
'batchSize'
])
&&
!
is_integer
(
$options
[
'batchSize'
]))
{
throw
new
InvalidArgumentTypeException
(
'"batchSize" option'
,
$options
[
'batchSize'
],
'integer'
);
throw
InvalidArgumentException
::
invalidType
(
'"batchSize" option'
,
$options
[
'batchSize'
],
'integer'
);
}
}
if
(
isset
(
$options
[
'bypassDocumentValidation'
])
&&
!
is_bool
(
$options
[
'bypassDocumentValidation'
]))
{
if
(
isset
(
$options
[
'bypassDocumentValidation'
])
&&
!
is_bool
(
$options
[
'bypassDocumentValidation'
]))
{
throw
new
InvalidArgumentTypeException
(
'"bypassDocumentValidation" option'
,
$options
[
'bypassDocumentValidation'
],
'boolean'
);
throw
InvalidArgumentException
::
invalidType
(
'"bypassDocumentValidation" option'
,
$options
[
'bypassDocumentValidation'
],
'boolean'
);
}
}
if
(
isset
(
$options
[
'maxTimeMS'
])
&&
!
is_integer
(
$options
[
'maxTimeMS'
]))
{
if
(
isset
(
$options
[
'maxTimeMS'
])
&&
!
is_integer
(
$options
[
'maxTimeMS'
]))
{
throw
new
InvalidArgumentTypeException
(
'"maxTimeMS" option'
,
$options
[
'maxTimeMS'
],
'integer'
);
throw
InvalidArgumentException
::
invalidType
(
'"maxTimeMS" option'
,
$options
[
'maxTimeMS'
],
'integer'
);
}
}
if
(
isset
(
$options
[
'readConcern'
])
&&
!
$options
[
'readConcern'
]
instanceof
ReadConcern
)
{
if
(
isset
(
$options
[
'readConcern'
])
&&
!
$options
[
'readConcern'
]
instanceof
ReadConcern
)
{
throw
new
InvalidArgumentTypeException
(
'"readConcern" option'
,
$options
[
'readConcern'
],
'MongoDB\Driver\ReadConcern'
);
throw
InvalidArgumentException
::
invalidType
(
'"readConcern" option'
,
$options
[
'readConcern'
],
'MongoDB\Driver\ReadConcern'
);
}
}
if
(
isset
(
$options
[
'readPreference'
])
&&
!
$options
[
'readPreference'
]
instanceof
ReadPreference
)
{
if
(
isset
(
$options
[
'readPreference'
])
&&
!
$options
[
'readPreference'
]
instanceof
ReadPreference
)
{
throw
new
InvalidArgumentTypeException
(
'"readPreference" option'
,
$options
[
'readPreference'
],
'MongoDB\Driver\ReadPreference'
);
throw
InvalidArgumentException
::
invalidType
(
'"readPreference" option'
,
$options
[
'readPreference'
],
'MongoDB\Driver\ReadPreference'
);
}
}
if
(
isset
(
$options
[
'typeMap'
])
&&
!
is_array
(
$options
[
'typeMap'
]))
{
if
(
isset
(
$options
[
'typeMap'
])
&&
!
is_array
(
$options
[
'typeMap'
]))
{
throw
new
InvalidArgumentTypeException
(
'"typeMap" option'
,
$options
[
'typeMap'
],
'array'
);
throw
InvalidArgumentException
::
invalidType
(
'"typeMap" option'
,
$options
[
'typeMap'
],
'array'
);
}
}
if
(
!
is_bool
(
$options
[
'useCursor'
]))
{
if
(
!
is_bool
(
$options
[
'useCursor'
]))
{
throw
new
InvalidArgumentTypeException
(
'"useCursor" option'
,
$options
[
'useCursor'
],
'boolean'
);
throw
InvalidArgumentException
::
invalidType
(
'"useCursor" option'
,
$options
[
'useCursor'
],
'boolean'
);
}
}
if
(
isset
(
$options
[
'batchSize'
])
&&
!
$options
[
'useCursor'
])
{
if
(
isset
(
$options
[
'batchSize'
])
&&
!
$options
[
'useCursor'
])
{
...
...
src/Operation/BulkWrite.php
View file @
8f646a38
...
@@ -7,7 +7,6 @@ use MongoDB\Driver\BulkWrite as Bulk;
...
@@ -7,7 +7,6 @@ use MongoDB\Driver\BulkWrite as Bulk;
use
MongoDB\Driver\Server
;
use
MongoDB\Driver\Server
;
use
MongoDB\Driver\WriteConcern
;
use
MongoDB\Driver\WriteConcern
;
use
MongoDB\Exception\InvalidArgumentException
;
use
MongoDB\Exception\InvalidArgumentException
;
use
MongoDB\Exception\InvalidArgumentTypeException
;
/**
/**
* Operation for executing multiple write operations.
* Operation for executing multiple write operations.
...
@@ -85,7 +84,7 @@ class BulkWrite implements Executable
...
@@ -85,7 +84,7 @@ class BulkWrite implements Executable
}
}
if
(
!
is_array
(
$operation
))
{
if
(
!
is_array
(
$operation
))
{
throw
new
InvalidArgumentTypeException
(
sprintf
(
'$operations[%d]'
,
$i
),
$operation
,
'array'
);
throw
InvalidArgumentException
::
invalidType
(
sprintf
(
'$operations[%d]'
,
$i
),
$operation
,
'array'
);
}
}
if
(
count
(
$operation
)
!==
1
)
{
if
(
count
(
$operation
)
!==
1
)
{
...
@@ -100,7 +99,7 @@ class BulkWrite implements Executable
...
@@ -100,7 +99,7 @@ class BulkWrite implements Executable
}
}
if
(
!
is_array
(
$args
[
0
])
&&
!
is_object
(
$args
[
0
]))
{
if
(
!
is_array
(
$args
[
0
])
&&
!
is_object
(
$args
[
0
]))
{
throw
new
InvalidArgumentTypeException
(
sprintf
(
'$operations[%d]["%s"][0]'
,
$i
,
$type
),
$args
[
0
],
'array or object'
);
throw
InvalidArgumentException
::
invalidType
(
sprintf
(
'$operations[%d]["%s"][0]'
,
$i
,
$type
),
$args
[
0
],
'array or object'
);
}
}
switch
(
$type
)
{
switch
(
$type
)
{
...
@@ -119,7 +118,7 @@ class BulkWrite implements Executable
...
@@ -119,7 +118,7 @@ class BulkWrite implements Executable
}
}
if
(
!
is_array
(
$args
[
1
])
&&
!
is_object
(
$args
[
1
]))
{
if
(
!
is_array
(
$args
[
1
])
&&
!
is_object
(
$args
[
1
]))
{
throw
new
InvalidArgumentTypeException
(
sprintf
(
'$operations[%d]["%s"][1]'
,
$i
,
$type
),
$args
[
1
],
'array or object'
);
throw
InvalidArgumentException
::
invalidType
(
sprintf
(
'$operations[%d]["%s"][1]'
,
$i
,
$type
),
$args
[
1
],
'array or object'
);
}
}
if
(
\MongoDB\is_first_key_operator
(
$args
[
1
]))
{
if
(
\MongoDB\is_first_key_operator
(
$args
[
1
]))
{
...
@@ -131,14 +130,14 @@ class BulkWrite implements Executable
...
@@ -131,14 +130,14 @@ class BulkWrite implements Executable
}
}
if
(
!
is_array
(
$args
[
2
]))
{
if
(
!
is_array
(
$args
[
2
]))
{
throw
new
InvalidArgumentTypeException
(
sprintf
(
'$operations[%d]["%s"][2]'
,
$i
,
$type
),
$args
[
2
],
'array'
);
throw
InvalidArgumentException
::
invalidType
(
sprintf
(
'$operations[%d]["%s"][2]'
,
$i
,
$type
),
$args
[
2
],
'array'
);
}
}
$args
[
2
][
'multi'
]
=
false
;
$args
[
2
][
'multi'
]
=
false
;
$args
[
2
]
+=
[
'upsert'
=>
false
];
$args
[
2
]
+=
[
'upsert'
=>
false
];
if
(
!
is_bool
(
$args
[
2
][
'upsert'
]))
{
if
(
!
is_bool
(
$args
[
2
][
'upsert'
]))
{
throw
new
InvalidArgumentTypeException
(
sprintf
(
'$operations[%d]["%s"][2]["upsert"]'
,
$i
,
$type
),
$args
[
2
][
'upsert'
],
'boolean'
);
throw
InvalidArgumentException
::
invalidType
(
sprintf
(
'$operations[%d]["%s"][2]["upsert"]'
,
$i
,
$type
),
$args
[
2
][
'upsert'
],
'boolean'
);
}
}
$operations
[
$i
][
$type
][
2
]
=
$args
[
2
];
$operations
[
$i
][
$type
][
2
]
=
$args
[
2
];
...
@@ -152,7 +151,7 @@ class BulkWrite implements Executable
...
@@ -152,7 +151,7 @@ class BulkWrite implements Executable
}
}
if
(
!
is_array
(
$args
[
1
])
&&
!
is_object
(
$args
[
1
]))
{
if
(
!
is_array
(
$args
[
1
])
&&
!
is_object
(
$args
[
1
]))
{
throw
new
InvalidArgumentTypeException
(
sprintf
(
'$operations[%d]["%s"][1]'
,
$i
,
$type
),
$args
[
1
],
'array or object'
);
throw
InvalidArgumentException
::
invalidType
(
sprintf
(
'$operations[%d]["%s"][1]'
,
$i
,
$type
),
$args
[
1
],
'array or object'
);
}
}
if
(
!
\MongoDB\is_first_key_operator
(
$args
[
1
]))
{
if
(
!
\MongoDB\is_first_key_operator
(
$args
[
1
]))
{
...
@@ -164,14 +163,14 @@ class BulkWrite implements Executable
...
@@ -164,14 +163,14 @@ class BulkWrite implements Executable
}
}
if
(
!
is_array
(
$args
[
2
]))
{
if
(
!
is_array
(
$args
[
2
]))
{
throw
new
InvalidArgumentTypeException
(
sprintf
(
'$operations[%d]["%s"][2]'
,
$i
,
$type
),
$args
[
2
],
'array'
);
throw
InvalidArgumentException
::
invalidType
(
sprintf
(
'$operations[%d]["%s"][2]'
,
$i
,
$type
),
$args
[
2
],
'array'
);
}
}
$args
[
2
][
'multi'
]
=
(
$type
===
self
::
UPDATE_MANY
);
$args
[
2
][
'multi'
]
=
(
$type
===
self
::
UPDATE_MANY
);
$args
[
2
]
+=
[
'upsert'
=>
false
];
$args
[
2
]
+=
[
'upsert'
=>
false
];
if
(
!
is_bool
(
$args
[
2
][
'upsert'
]))
{
if
(
!
is_bool
(
$args
[
2
][
'upsert'
]))
{
throw
new
InvalidArgumentTypeException
(
sprintf
(
'$operations[%d]["%s"][2]["upsert"]'
,
$i
,
$type
),
$args
[
2
][
'upsert'
],
'boolean'
);
throw
InvalidArgumentException
::
invalidType
(
sprintf
(
'$operations[%d]["%s"][2]["upsert"]'
,
$i
,
$type
),
$args
[
2
][
'upsert'
],
'boolean'
);
}
}
$operations
[
$i
][
$type
][
2
]
=
$args
[
2
];
$operations
[
$i
][
$type
][
2
]
=
$args
[
2
];
...
@@ -188,15 +187,15 @@ class BulkWrite implements Executable
...
@@ -188,15 +187,15 @@ class BulkWrite implements Executable
$options
+=
[
'ordered'
=>
true
];
$options
+=
[
'ordered'
=>
true
];
if
(
isset
(
$options
[
'bypassDocumentValidation'
])
&&
!
is_bool
(
$options
[
'bypassDocumentValidation'
]))
{
if
(
isset
(
$options
[
'bypassDocumentValidation'
])
&&
!
is_bool
(
$options
[
'bypassDocumentValidation'
]))
{
throw
new
InvalidArgumentTypeException
(
'"bypassDocumentValidation" option'
,
$options
[
'bypassDocumentValidation'
],
'boolean'
);
throw
InvalidArgumentException
::
invalidType
(
'"bypassDocumentValidation" option'
,
$options
[
'bypassDocumentValidation'
],
'boolean'
);
}
}
if
(
!
is_bool
(
$options
[
'ordered'
]))
{
if
(
!
is_bool
(
$options
[
'ordered'
]))
{
throw
new
InvalidArgumentTypeException
(
'"ordered" option'
,
$options
[
'ordered'
],
'boolean'
);
throw
InvalidArgumentException
::
invalidType
(
'"ordered" option'
,
$options
[
'ordered'
],
'boolean'
);
}
}
if
(
isset
(
$options
[
'writeConcern'
])
&&
!
$options
[
'writeConcern'
]
instanceof
WriteConcern
)
{
if
(
isset
(
$options
[
'writeConcern'
])
&&
!
$options
[
'writeConcern'
]
instanceof
WriteConcern
)
{
throw
new
InvalidArgumentTypeException
(
'"writeConcern" option'
,
$options
[
'writeConcern'
],
'MongoDB\Driver\WriteConcern'
);
throw
InvalidArgumentException
::
invalidType
(
'"writeConcern" option'
,
$options
[
'writeConcern'
],
'MongoDB\Driver\WriteConcern'
);
}
}
$this
->
databaseName
=
(
string
)
$databaseName
;
$this
->
databaseName
=
(
string
)
$databaseName
;
...
...
src/Operation/Count.php
View file @
8f646a38
...
@@ -7,7 +7,6 @@ use MongoDB\Driver\ReadConcern;
...
@@ -7,7 +7,6 @@ use MongoDB\Driver\ReadConcern;
use
MongoDB\Driver\ReadPreference
;
use
MongoDB\Driver\ReadPreference
;
use
MongoDB\Driver\Server
;
use
MongoDB\Driver\Server
;
use
MongoDB\Exception\InvalidArgumentException
;
use
MongoDB\Exception\InvalidArgumentException
;
use
MongoDB\Exception\InvalidArgumentTypeException
;
use
MongoDB\Exception\UnexpectedValueException
;
use
MongoDB\Exception\UnexpectedValueException
;
/**
/**
...
@@ -58,7 +57,7 @@ class Count implements Executable
...
@@ -58,7 +57,7 @@ class Count implements Executable
public
function
__construct
(
$databaseName
,
$collectionName
,
$filter
=
[],
array
$options
=
[])
public
function
__construct
(
$databaseName
,
$collectionName
,
$filter
=
[],
array
$options
=
[])
{
{
if
(
!
is_array
(
$filter
)
&&
!
is_object
(
$filter
))
{
if
(
!
is_array
(
$filter
)
&&
!
is_object
(
$filter
))
{
throw
new
InvalidArgumentTypeException
(
'$filter'
,
$filter
,
'array or object'
);
throw
InvalidArgumentException
::
invalidType
(
'$filter'
,
$filter
,
'array or object'
);
}
}
if
(
isset
(
$options
[
'hint'
]))
{
if
(
isset
(
$options
[
'hint'
]))
{
...
@@ -67,28 +66,28 @@ class Count implements Executable
...
@@ -67,28 +66,28 @@ class Count implements Executable
}
}
if
(
!
is_string
(
$options
[
'hint'
]))
{
if
(
!
is_string
(
$options
[
'hint'
]))
{
throw
new
InvalidArgumentTypeException
(
'"hint" option'
,
$options
[
'hint'
],
'string or array or object'
);
throw
InvalidArgumentException
::
invalidType
(
'"hint" option'
,
$options
[
'hint'
],
'string or array or object'
);
}
}
}
}
if
(
isset
(
$options
[
'limit'
])
&&
!
is_integer
(
$options
[
'limit'
]))
{
if
(
isset
(
$options
[
'limit'
])
&&
!
is_integer
(
$options
[
'limit'
]))
{
throw
new
InvalidArgumentTypeException
(
'"limit" option'
,
$options
[
'limit'
],
'integer'
);
throw
InvalidArgumentException
::
invalidType
(
'"limit" option'
,
$options
[
'limit'
],
'integer'
);
}
}
if
(
isset
(
$options
[
'maxTimeMS'
])
&&
!
is_integer
(
$options
[
'maxTimeMS'
]))
{
if
(
isset
(
$options
[
'maxTimeMS'
])
&&
!
is_integer
(
$options
[
'maxTimeMS'
]))
{
throw
new
InvalidArgumentTypeException
(
'"maxTimeMS" option'
,
$options
[
'maxTimeMS'
],
'integer'
);
throw
InvalidArgumentException
::
invalidType
(
'"maxTimeMS" option'
,
$options
[
'maxTimeMS'
],
'integer'
);
}
}
if
(
isset
(
$options
[
'readConcern'
])
&&
!
$options
[
'readConcern'
]
instanceof
ReadConcern
)
{
if
(
isset
(
$options
[
'readConcern'
])
&&
!
$options
[
'readConcern'
]
instanceof
ReadConcern
)
{
throw
new
InvalidArgumentTypeException
(
'"readConcern" option'
,
$options
[
'readConcern'
],
'MongoDB\Driver\ReadConcern'
);
throw
InvalidArgumentException
::
invalidType
(
'"readConcern" option'
,
$options
[
'readConcern'
],
'MongoDB\Driver\ReadConcern'
);
}
}
if
(
isset
(
$options
[
'readPreference'
])
&&
!
$options
[
'readPreference'
]
instanceof
ReadPreference
)
{
if
(
isset
(
$options
[
'readPreference'
])
&&
!
$options
[
'readPreference'
]
instanceof
ReadPreference
)
{
throw
new
InvalidArgumentTypeException
(
'"readPreference" option'
,
$options
[
'readPreference'
],
'MongoDB\Driver\ReadPreference'
);
throw
InvalidArgumentException
::
invalidType
(
'"readPreference" option'
,
$options
[
'readPreference'
],
'MongoDB\Driver\ReadPreference'
);
}
}
if
(
isset
(
$options
[
'skip'
])
&&
!
is_integer
(
$options
[
'skip'
]))
{
if
(
isset
(
$options
[
'skip'
])
&&
!
is_integer
(
$options
[
'skip'
]))
{
throw
new
InvalidArgumentTypeException
(
'"skip" option'
,
$options
[
'skip'
],
'integer'
);
throw
InvalidArgumentException
::
invalidType
(
'"skip" option'
,
$options
[
'skip'
],
'integer'
);
}
}
$this
->
databaseName
=
(
string
)
$databaseName
;
$this
->
databaseName
=
(
string
)
$databaseName
;
...
...
src/Operation/CreateCollection.php
View file @
8f646a38
...
@@ -5,7 +5,6 @@ namespace MongoDB\Operation;
...
@@ -5,7 +5,6 @@ namespace MongoDB\Operation;
use
MongoDB\Driver\Command
;
use
MongoDB\Driver\Command
;
use
MongoDB\Driver\Server
;
use
MongoDB\Driver\Server
;
use
MongoDB\Exception\InvalidArgumentException
;
use
MongoDB\Exception\InvalidArgumentException
;
use
MongoDB\Exception\InvalidArgumentTypeException
;
/**
/**
* Operation for the create command.
* Operation for the create command.
...
@@ -68,47 +67,47 @@ class CreateCollection implements Executable
...
@@ -68,47 +67,47 @@ class CreateCollection implements Executable
public
function
__construct
(
$databaseName
,
$collectionName
,
array
$options
=
[])
public
function
__construct
(
$databaseName
,
$collectionName
,
array
$options
=
[])
{
{
if
(
isset
(
$options
[
'autoIndexId'
])
&&
!
is_bool
(
$options
[
'autoIndexId'
]))
{
if
(
isset
(
$options
[
'autoIndexId'
])
&&
!
is_bool
(
$options
[
'autoIndexId'
]))
{
throw
new
InvalidArgumentTypeException
(
'"autoIndexId" option'
,
$options
[
'autoIndexId'
],
'boolean'
);
throw
InvalidArgumentException
::
invalidType
(
'"autoIndexId" option'
,
$options
[
'autoIndexId'
],
'boolean'
);
}
}
if
(
isset
(
$options
[
'capped'
])
&&
!
is_bool
(
$options
[
'capped'
]))
{
if
(
isset
(
$options
[
'capped'
])
&&
!
is_bool
(
$options
[
'capped'
]))
{
throw
new
InvalidArgumentTypeException
(
'"capped" option'
,
$options
[
'capped'
],
'boolean'
);
throw
InvalidArgumentException
::
invalidType
(
'"capped" option'
,
$options
[
'capped'
],
'boolean'
);
}
}
if
(
isset
(
$options
[
'flags'
])
&&
!
is_integer
(
$options
[
'flags'
]))
{
if
(
isset
(
$options
[
'flags'
])
&&
!
is_integer
(
$options
[
'flags'
]))
{
throw
new
InvalidArgumentTypeException
(
'"flags" option'
,
$options
[
'flags'
],
'integer'
);
throw
InvalidArgumentException
::
invalidType
(
'"flags" option'
,
$options
[
'flags'
],
'integer'
);
}
}
if
(
isset
(
$options
[
'indexOptionDefaults'
])
&&
!
is_array
(
$options
[
'indexOptionDefaults'
])
&&
!
is_object
(
$options
[
'indexOptionDefaults'
]))
{
if
(
isset
(
$options
[
'indexOptionDefaults'
])
&&
!
is_array
(
$options
[
'indexOptionDefaults'
])
&&
!
is_object
(
$options
[
'indexOptionDefaults'
]))
{
throw
new
InvalidArgumentTypeException
(
'"indexOptionDefaults" option'
,
$options
[
'indexOptionDefaults'
],
'array or object'
);
throw
InvalidArgumentException
::
invalidType
(
'"indexOptionDefaults" option'
,
$options
[
'indexOptionDefaults'
],
'array or object'
);
}
}
if
(
isset
(
$options
[
'max'
])
&&
!
is_integer
(
$options
[
'max'
]))
{
if
(
isset
(
$options
[
'max'
])
&&
!
is_integer
(
$options
[
'max'
]))
{
throw
new
InvalidArgumentTypeException
(
'"max" option'
,
$options
[
'max'
],
'integer'
);
throw
InvalidArgumentException
::
invalidType
(
'"max" option'
,
$options
[
'max'
],
'integer'
);
}
}
if
(
isset
(
$options
[
'maxTimeMS'
])
&&
!
is_integer
(
$options
[
'maxTimeMS'
]))
{
if
(
isset
(
$options
[
'maxTimeMS'
])
&&
!
is_integer
(
$options
[
'maxTimeMS'
]))
{
throw
new
InvalidArgumentTypeException
(
'"maxTimeMS" option'
,
$options
[
'maxTimeMS'
],
'integer'
);
throw
InvalidArgumentException
::
invalidType
(
'"maxTimeMS" option'
,
$options
[
'maxTimeMS'
],
'integer'
);
}
}
if
(
isset
(
$options
[
'size'
])
&&
!
is_integer
(
$options
[
'size'
]))
{
if
(
isset
(
$options
[
'size'
])
&&
!
is_integer
(
$options
[
'size'
]))
{
throw
new
InvalidArgumentTypeException
(
'"size" option'
,
$options
[
'size'
],
'integer'
);
throw
InvalidArgumentException
::
invalidType
(
'"size" option'
,
$options
[
'size'
],
'integer'
);
}
}
if
(
isset
(
$options
[
'storageEngine'
])
&&
!
is_array
(
$options
[
'storageEngine'
])
&&
!
is_object
(
$options
[
'storageEngine'
]))
{
if
(
isset
(
$options
[
'storageEngine'
])
&&
!
is_array
(
$options
[
'storageEngine'
])
&&
!
is_object
(
$options
[
'storageEngine'
]))
{
throw
new
InvalidArgumentTypeException
(
'"storageEngine" option'
,
$options
[
'storageEngine'
],
'array or object'
);
throw
InvalidArgumentException
::
invalidType
(
'"storageEngine" option'
,
$options
[
'storageEngine'
],
'array or object'
);
}
}
if
(
isset
(
$options
[
'validationAction'
])
&&
!
is_string
(
$options
[
'validationAction'
]))
{
if
(
isset
(
$options
[
'validationAction'
])
&&
!
is_string
(
$options
[
'validationAction'
]))
{
throw
new
InvalidArgumentTypeException
(
'"validationAction" option'
,
$options
[
'validationAction'
],
'string'
);
throw
InvalidArgumentException
::
invalidType
(
'"validationAction" option'
,
$options
[
'validationAction'
],
'string'
);
}
}
if
(
isset
(
$options
[
'validationLevel'
])
&&
!
is_string
(
$options
[
'validationLevel'
]))
{
if
(
isset
(
$options
[
'validationLevel'
])
&&
!
is_string
(
$options
[
'validationLevel'
]))
{
throw
new
InvalidArgumentTypeException
(
'"validationLevel" option'
,
$options
[
'validationLevel'
],
'string'
);
throw
InvalidArgumentException
::
invalidType
(
'"validationLevel" option'
,
$options
[
'validationLevel'
],
'string'
);
}
}
if
(
isset
(
$options
[
'validator'
])
&&
!
is_array
(
$options
[
'validator'
])
&&
!
is_object
(
$options
[
'validator'
]))
{
if
(
isset
(
$options
[
'validator'
])
&&
!
is_array
(
$options
[
'validator'
])
&&
!
is_object
(
$options
[
'validator'
]))
{
throw
new
InvalidArgumentTypeException
(
'"validator" option'
,
$options
[
'validator'
],
'array or object'
);
throw
InvalidArgumentException
::
invalidType
(
'"validator" option'
,
$options
[
'validator'
],
'array or object'
);
}
}
$this
->
databaseName
=
(
string
)
$databaseName
;
$this
->
databaseName
=
(
string
)
$databaseName
;
...
...
src/Operation/CreateIndexes.php
View file @
8f646a38
...
@@ -7,7 +7,6 @@ use MongoDB\Driver\Server;
...
@@ -7,7 +7,6 @@ use MongoDB\Driver\Server;
use
MongoDB\Driver\BulkWrite
as
Bulk
;
use
MongoDB\Driver\BulkWrite
as
Bulk
;
use
MongoDB\Driver\WriteConcern
;
use
MongoDB\Driver\WriteConcern
;
use
MongoDB\Exception\InvalidArgumentException
;
use
MongoDB\Exception\InvalidArgumentException
;
use
MongoDB\Exception\InvalidArgumentTypeException
;
use
MongoDB\Model\IndexInput
;
use
MongoDB\Model\IndexInput
;
/**
/**
...
@@ -48,7 +47,7 @@ class CreateIndexes implements Executable
...
@@ -48,7 +47,7 @@ class CreateIndexes implements Executable
}
}
if
(
!
is_array
(
$index
))
{
if
(
!
is_array
(
$index
))
{
throw
new
InvalidArgumentTypeException
(
sprintf
(
'$index[%d]'
,
$i
),
$index
,
'array'
);
throw
InvalidArgumentException
::
invalidType
(
sprintf
(
'$index[%d]'
,
$i
),
$index
,
'array'
);
}
}
if
(
!
isset
(
$index
[
'ns'
]))
{
if
(
!
isset
(
$index
[
'ns'
]))
{
...
...
src/Operation/DatabaseCommand.php
View file @
8f646a38
...
@@ -6,7 +6,6 @@ use MongoDB\Driver\Command;
...
@@ -6,7 +6,6 @@ use MongoDB\Driver\Command;
use
MongoDB\Driver\ReadPreference
;
use
MongoDB\Driver\ReadPreference
;
use
MongoDB\Driver\Server
;
use
MongoDB\Driver\Server
;
use
MongoDB\Exception\InvalidArgumentException
;
use
MongoDB\Exception\InvalidArgumentException
;
use
MongoDB\Exception\InvalidArgumentTypeException
;
/**
/**
* Operation for executing a database command.
* Operation for executing a database command.
...
@@ -42,15 +41,15 @@ class DatabaseCommand implements Executable
...
@@ -42,15 +41,15 @@ class DatabaseCommand implements Executable
public
function
__construct
(
$databaseName
,
$command
,
array
$options
=
[])
public
function
__construct
(
$databaseName
,
$command
,
array
$options
=
[])
{
{
if
(
!
is_array
(
$command
)
&&
!
is_object
(
$command
))
{
if
(
!
is_array
(
$command
)
&&
!
is_object
(
$command
))
{
throw
new
InvalidArgumentTypeException
(
'$command'
,
$command
,
'array or object'
);
throw
InvalidArgumentException
::
invalidType
(
'$command'
,
$command
,
'array or object'
);
}
}
if
(
isset
(
$options
[
'readPreference'
])
&&
!
$options
[
'readPreference'
]
instanceof
ReadPreference
)
{
if
(
isset
(
$options
[
'readPreference'
])
&&
!
$options
[
'readPreference'
]
instanceof
ReadPreference
)
{
throw
new
InvalidArgumentTypeException
(
'"readPreference" option'
,
$options
[
'readPreference'
],
'MongoDB\Driver\ReadPreference'
);
throw
InvalidArgumentException
::
invalidType
(
'"readPreference" option'
,
$options
[
'readPreference'
],
'MongoDB\Driver\ReadPreference'
);
}
}
if
(
isset
(
$options
[
'typeMap'
])
&&
!
is_array
(
$options
[
'typeMap'
]))
{
if
(
isset
(
$options
[
'typeMap'
])
&&
!
is_array
(
$options
[
'typeMap'
]))
{
throw
new
InvalidArgumentTypeException
(
'"typeMap" option'
,
$options
[
'typeMap'
],
'array'
);
throw
InvalidArgumentException
::
invalidType
(
'"typeMap" option'
,
$options
[
'typeMap'
],
'array'
);
}
}
$this
->
databaseName
=
(
string
)
$databaseName
;
$this
->
databaseName
=
(
string
)
$databaseName
;
...
...
src/Operation/Delete.php
View file @
8f646a38
...
@@ -7,7 +7,6 @@ use MongoDB\Driver\BulkWrite as Bulk;
...
@@ -7,7 +7,6 @@ use MongoDB\Driver\BulkWrite as Bulk;
use
MongoDB\Driver\Server
;
use
MongoDB\Driver\Server
;
use
MongoDB\Driver\WriteConcern
;
use
MongoDB\Driver\WriteConcern
;
use
MongoDB\Exception\InvalidArgumentException
;
use
MongoDB\Exception\InvalidArgumentException
;
use
MongoDB\Exception\InvalidArgumentTypeException
;
/**
/**
* Operation for the delete command.
* Operation for the delete command.
...
@@ -45,7 +44,7 @@ class Delete implements Executable
...
@@ -45,7 +44,7 @@ class Delete implements Executable
public
function
__construct
(
$databaseName
,
$collectionName
,
$filter
,
$limit
,
array
$options
=
[])
public
function
__construct
(
$databaseName
,
$collectionName
,
$filter
,
$limit
,
array
$options
=
[])
{
{
if
(
!
is_array
(
$filter
)
&&
!
is_object
(
$filter
))
{
if
(
!
is_array
(
$filter
)
&&
!
is_object
(
$filter
))
{
throw
new
InvalidArgumentTypeException
(
'$filter'
,
$filter
,
'array or object'
);
throw
InvalidArgumentException
::
invalidType
(
'$filter'
,
$filter
,
'array or object'
);
}
}
if
(
$limit
!==
0
&&
$limit
!==
1
)
{
if
(
$limit
!==
0
&&
$limit
!==
1
)
{
...
@@ -53,7 +52,7 @@ class Delete implements Executable
...
@@ -53,7 +52,7 @@ class Delete implements Executable
}
}
if
(
isset
(
$options
[
'writeConcern'
])
&&
!
$options
[
'writeConcern'
]
instanceof
WriteConcern
)
{
if
(
isset
(
$options
[
'writeConcern'
])
&&
!
$options
[
'writeConcern'
]
instanceof
WriteConcern
)
{
throw
new
InvalidArgumentTypeException
(
'"writeConcern" option'
,
$options
[
'writeConcern'
],
'MongoDB\Driver\WriteConcern'
);
throw
InvalidArgumentException
::
invalidType
(
'"writeConcern" option'
,
$options
[
'writeConcern'
],
'MongoDB\Driver\WriteConcern'
);
}
}
$this
->
databaseName
=
(
string
)
$databaseName
;
$this
->
databaseName
=
(
string
)
$databaseName
;
...
...
src/Operation/Distinct.php
View file @
8f646a38
...
@@ -7,7 +7,6 @@ use MongoDB\Driver\ReadConcern;
...
@@ -7,7 +7,6 @@ use MongoDB\Driver\ReadConcern;
use
MongoDB\Driver\ReadPreference
;
use
MongoDB\Driver\ReadPreference
;
use
MongoDB\Driver\Server
;
use
MongoDB\Driver\Server
;
use
MongoDB\Exception\InvalidArgumentException
;
use
MongoDB\Exception\InvalidArgumentException
;
use
MongoDB\Exception\InvalidArgumentTypeException
;
use
MongoDB\Exception\UnexpectedValueException
;
use
MongoDB\Exception\UnexpectedValueException
;
/**
/**
...
@@ -52,19 +51,19 @@ class Distinct implements Executable
...
@@ -52,19 +51,19 @@ class Distinct implements Executable
public
function
__construct
(
$databaseName
,
$collectionName
,
$fieldName
,
$filter
=
[],
array
$options
=
[])
public
function
__construct
(
$databaseName
,
$collectionName
,
$fieldName
,
$filter
=
[],
array
$options
=
[])
{
{
if
(
!
is_array
(
$filter
)
&&
!
is_object
(
$filter
))
{
if
(
!
is_array
(
$filter
)
&&
!
is_object
(
$filter
))
{
throw
new
InvalidArgumentTypeException
(
'$filter'
,
$filter
,
'array or object'
);
throw
InvalidArgumentException
::
invalidType
(
'$filter'
,
$filter
,
'array or object'
);
}
}
if
(
isset
(
$options
[
'maxTimeMS'
])
&&
!
is_integer
(
$options
[
'maxTimeMS'
]))
{
if
(
isset
(
$options
[
'maxTimeMS'
])
&&
!
is_integer
(
$options
[
'maxTimeMS'
]))
{
throw
new
InvalidArgumentTypeException
(
'"maxTimeMS" option'
,
$options
[
'maxTimeMS'
],
'integer'
);
throw
InvalidArgumentException
::
invalidType
(
'"maxTimeMS" option'
,
$options
[
'maxTimeMS'
],
'integer'
);
}
}
if
(
isset
(
$options
[
'readConcern'
])
&&
!
$options
[
'readConcern'
]
instanceof
ReadConcern
)
{
if
(
isset
(
$options
[
'readConcern'
])
&&
!
$options
[
'readConcern'
]
instanceof
ReadConcern
)
{
throw
new
InvalidArgumentTypeException
(
'"readConcern" option'
,
$options
[
'readConcern'
],
'MongoDB\Driver\ReadConcern'
);
throw
InvalidArgumentException
::
invalidType
(
'"readConcern" option'
,
$options
[
'readConcern'
],
'MongoDB\Driver\ReadConcern'
);
}
}
if
(
isset
(
$options
[
'readPreference'
])
&&
!
$options
[
'readPreference'
]
instanceof
ReadPreference
)
{
if
(
isset
(
$options
[
'readPreference'
])
&&
!
$options
[
'readPreference'
]
instanceof
ReadPreference
)
{
throw
new
InvalidArgumentTypeException
(
'"readPreference" option'
,
$options
[
'readPreference'
],
'MongoDB\Driver\ReadPreference'
);
throw
InvalidArgumentException
::
invalidType
(
'"readPreference" option'
,
$options
[
'readPreference'
],
'MongoDB\Driver\ReadPreference'
);
}
}
$this
->
databaseName
=
(
string
)
$databaseName
;
$this
->
databaseName
=
(
string
)
$databaseName
;
...
...
src/Operation/Find.php
View file @
8f646a38
...
@@ -7,7 +7,6 @@ use MongoDB\Driver\ReadConcern;
...
@@ -7,7 +7,6 @@ use MongoDB\Driver\ReadConcern;
use
MongoDB\Driver\ReadPreference
;
use
MongoDB\Driver\ReadPreference
;
use
MongoDB\Driver\Server
;
use
MongoDB\Driver\Server
;
use
MongoDB\Exception\InvalidArgumentException
;
use
MongoDB\Exception\InvalidArgumentException
;
use
MongoDB\Exception\InvalidArgumentTypeException
;
use
MongoDB\Exception\RuntimeException
;
use
MongoDB\Exception\RuntimeException
;
use
MongoDB\Exception\UnexpectedValueException
;
use
MongoDB\Exception\UnexpectedValueException
;
...
@@ -91,24 +90,24 @@ class Find implements Executable
...
@@ -91,24 +90,24 @@ class Find implements Executable
public
function
__construct
(
$databaseName
,
$collectionName
,
$filter
,
array
$options
=
[])
public
function
__construct
(
$databaseName
,
$collectionName
,
$filter
,
array
$options
=
[])
{
{
if
(
!
is_array
(
$filter
)
&&
!
is_object
(
$filter
))
{
if
(
!
is_array
(
$filter
)
&&
!
is_object
(
$filter
))
{
throw
new
InvalidArgumentTypeException
(
'$filter'
,
$filter
,
'array or object'
);
throw
InvalidArgumentException
::
invalidType
(
'$filter'
,
$filter
,
'array or object'
);
}
}
if
(
isset
(
$options
[
'allowPartialResults'
])
&&
!
is_bool
(
$options
[
'allowPartialResults'
]))
{
if
(
isset
(
$options
[
'allowPartialResults'
])
&&
!
is_bool
(
$options
[
'allowPartialResults'
]))
{
throw
new
InvalidArgumentTypeException
(
'"allowPartialResults" option'
,
$options
[
'allowPartialResults'
],
'boolean'
);
throw
InvalidArgumentException
::
invalidType
(
'"allowPartialResults" option'
,
$options
[
'allowPartialResults'
],
'boolean'
);
}
}
if
(
isset
(
$options
[
'batchSize'
])
&&
!
is_integer
(
$options
[
'batchSize'
]))
{
if
(
isset
(
$options
[
'batchSize'
])
&&
!
is_integer
(
$options
[
'batchSize'
]))
{
throw
new
InvalidArgumentTypeException
(
'"batchSize" option'
,
$options
[
'batchSize'
],
'integer'
);
throw
InvalidArgumentException
::
invalidType
(
'"batchSize" option'
,
$options
[
'batchSize'
],
'integer'
);
}
}
if
(
isset
(
$options
[
'comment'
])
&&
!
is_string
(
$options
[
'comment'
]))
{
if
(
isset
(
$options
[
'comment'
])
&&
!
is_string
(
$options
[
'comment'
]))
{
throw
new
InvalidArgumentTypeException
(
'"comment" option'
,
$options
[
'comment'
],
'comment'
);
throw
InvalidArgumentException
::
invalidType
(
'"comment" option'
,
$options
[
'comment'
],
'comment'
);
}
}
if
(
isset
(
$options
[
'cursorType'
]))
{
if
(
isset
(
$options
[
'cursorType'
]))
{
if
(
!
is_integer
(
$options
[
'cursorType'
]))
{
if
(
!
is_integer
(
$options
[
'cursorType'
]))
{
throw
new
InvalidArgumentTypeException
(
'"cursorType" option'
,
$options
[
'cursorType'
],
'integer'
);
throw
InvalidArgumentException
::
invalidType
(
'"cursorType" option'
,
$options
[
'cursorType'
],
'integer'
);
}
}
if
(
$options
[
'cursorType'
]
!==
self
::
NON_TAILABLE
&&
if
(
$options
[
'cursorType'
]
!==
self
::
NON_TAILABLE
&&
...
@@ -119,47 +118,47 @@ class Find implements Executable
...
@@ -119,47 +118,47 @@ class Find implements Executable
}
}
if
(
isset
(
$options
[
'limit'
])
&&
!
is_integer
(
$options
[
'limit'
]))
{
if
(
isset
(
$options
[
'limit'
])
&&
!
is_integer
(
$options
[
'limit'
]))
{
throw
new
InvalidArgumentTypeException
(
'"limit" option'
,
$options
[
'limit'
],
'integer'
);
throw
InvalidArgumentException
::
invalidType
(
'"limit" option'
,
$options
[
'limit'
],
'integer'
);
}
}
if
(
isset
(
$options
[
'maxTimeMS'
])
&&
!
is_integer
(
$options
[
'maxTimeMS'
]))
{
if
(
isset
(
$options
[
'maxTimeMS'
])
&&
!
is_integer
(
$options
[
'maxTimeMS'
]))
{
throw
new
InvalidArgumentTypeException
(
'"maxTimeMS" option'
,
$options
[
'maxTimeMS'
],
'integer'
);
throw
InvalidArgumentException
::
invalidType
(
'"maxTimeMS" option'
,
$options
[
'maxTimeMS'
],
'integer'
);
}
}
if
(
isset
(
$options
[
'modifiers'
])
&&
!
is_array
(
$options
[
'modifiers'
])
&&
!
is_object
(
$options
[
'modifiers'
]))
{
if
(
isset
(
$options
[
'modifiers'
])
&&
!
is_array
(
$options
[
'modifiers'
])
&&
!
is_object
(
$options
[
'modifiers'
]))
{
throw
new
InvalidArgumentTypeException
(
'"modifiers" option'
,
$options
[
'modifiers'
],
'array or object'
);
throw
InvalidArgumentException
::
invalidType
(
'"modifiers" option'
,
$options
[
'modifiers'
],
'array or object'
);
}
}
if
(
isset
(
$options
[
'noCursorTimeout'
])
&&
!
is_bool
(
$options
[
'noCursorTimeout'
]))
{
if
(
isset
(
$options
[
'noCursorTimeout'
])
&&
!
is_bool
(
$options
[
'noCursorTimeout'
]))
{
throw
new
InvalidArgumentTypeException
(
'"noCursorTimeout" option'
,
$options
[
'noCursorTimeout'
],
'boolean'
);
throw
InvalidArgumentException
::
invalidType
(
'"noCursorTimeout" option'
,
$options
[
'noCursorTimeout'
],
'boolean'
);
}
}
if
(
isset
(
$options
[
'oplogReplay'
])
&&
!
is_bool
(
$options
[
'oplogReplay'
]))
{
if
(
isset
(
$options
[
'oplogReplay'
])
&&
!
is_bool
(
$options
[
'oplogReplay'
]))
{
throw
new
InvalidArgumentTypeException
(
'"oplogReplay" option'
,
$options
[
'oplogReplay'
],
'boolean'
);
throw
InvalidArgumentException
::
invalidType
(
'"oplogReplay" option'
,
$options
[
'oplogReplay'
],
'boolean'
);
}
}
if
(
isset
(
$options
[
'projection'
])
&&
!
is_array
(
$options
[
'projection'
])
&&
!
is_object
(
$options
[
'projection'
]))
{
if
(
isset
(
$options
[
'projection'
])
&&
!
is_array
(
$options
[
'projection'
])
&&
!
is_object
(
$options
[
'projection'
]))
{
throw
new
InvalidArgumentTypeException
(
'"projection" option'
,
$options
[
'projection'
],
'array or object'
);
throw
InvalidArgumentException
::
invalidType
(
'"projection" option'
,
$options
[
'projection'
],
'array or object'
);
}
}
if
(
isset
(
$options
[
'readConcern'
])
&&
!
$options
[
'readConcern'
]
instanceof
ReadConcern
)
{
if
(
isset
(
$options
[
'readConcern'
])
&&
!
$options
[
'readConcern'
]
instanceof
ReadConcern
)
{
throw
new
InvalidArgumentTypeException
(
'"readConcern" option'
,
$options
[
'readConcern'
],
'MongoDB\Driver\ReadConcern'
);
throw
InvalidArgumentException
::
invalidType
(
'"readConcern" option'
,
$options
[
'readConcern'
],
'MongoDB\Driver\ReadConcern'
);
}
}
if
(
isset
(
$options
[
'readPreference'
])
&&
!
$options
[
'readPreference'
]
instanceof
ReadPreference
)
{
if
(
isset
(
$options
[
'readPreference'
])
&&
!
$options
[
'readPreference'
]
instanceof
ReadPreference
)
{
throw
new
InvalidArgumentTypeException
(
'"readPreference" option'
,
$options
[
'readPreference'
],
'MongoDB\Driver\ReadPreference'
);
throw
InvalidArgumentException
::
invalidType
(
'"readPreference" option'
,
$options
[
'readPreference'
],
'MongoDB\Driver\ReadPreference'
);
}
}
if
(
isset
(
$options
[
'skip'
])
&&
!
is_integer
(
$options
[
'skip'
]))
{
if
(
isset
(
$options
[
'skip'
])
&&
!
is_integer
(
$options
[
'skip'
]))
{
throw
new
InvalidArgumentTypeException
(
'"skip" option'
,
$options
[
'skip'
],
'integer'
);
throw
InvalidArgumentException
::
invalidType
(
'"skip" option'
,
$options
[
'skip'
],
'integer'
);
}
}
if
(
isset
(
$options
[
'sort'
])
&&
!
is_array
(
$options
[
'sort'
])
&&
!
is_object
(
$options
[
'sort'
]))
{
if
(
isset
(
$options
[
'sort'
])
&&
!
is_array
(
$options
[
'sort'
])
&&
!
is_object
(
$options
[
'sort'
]))
{
throw
new
InvalidArgumentTypeException
(
'"sort" option'
,
$options
[
'sort'
],
'array or object'
);
throw
InvalidArgumentException
::
invalidType
(
'"sort" option'
,
$options
[
'sort'
],
'array or object'
);
}
}
if
(
isset
(
$options
[
'typeMap'
])
&&
!
is_array
(
$options
[
'typeMap'
]))
{
if
(
isset
(
$options
[
'typeMap'
])
&&
!
is_array
(
$options
[
'typeMap'
]))
{
throw
new
InvalidArgumentTypeException
(
'"typeMap" option'
,
$options
[
'typeMap'
],
'array'
);
throw
InvalidArgumentException
::
invalidType
(
'"typeMap" option'
,
$options
[
'typeMap'
],
'array'
);
}
}
$this
->
databaseName
=
(
string
)
$databaseName
;
$this
->
databaseName
=
(
string
)
$databaseName
;
...
...
src/Operation/FindAndModify.php
View file @
8f646a38
...
@@ -6,7 +6,6 @@ use MongoDB\Driver\Command;
...
@@ -6,7 +6,6 @@ use MongoDB\Driver\Command;
use
MongoDB\Driver\Server
;
use
MongoDB\Driver\Server
;
use
MongoDB\Driver\WriteConcern
;
use
MongoDB\Driver\WriteConcern
;
use
MongoDB\Exception\InvalidArgumentException
;
use
MongoDB\Exception\InvalidArgumentException
;
use
MongoDB\Exception\InvalidArgumentTypeException
;
use
MongoDB\Exception\UnexpectedValueException
;
use
MongoDB\Exception\UnexpectedValueException
;
/**
/**
...
@@ -77,43 +76,43 @@ class FindAndModify implements Executable
...
@@ -77,43 +76,43 @@ class FindAndModify implements Executable
];
];
if
(
isset
(
$options
[
'bypassDocumentValidation'
])
&&
!
is_bool
(
$options
[
'bypassDocumentValidation'
]))
{
if
(
isset
(
$options
[
'bypassDocumentValidation'
])
&&
!
is_bool
(
$options
[
'bypassDocumentValidation'
]))
{
throw
new
InvalidArgumentTypeException
(
'"bypassDocumentValidation" option'
,
$options
[
'bypassDocumentValidation'
],
'boolean'
);
throw
InvalidArgumentException
::
invalidType
(
'"bypassDocumentValidation" option'
,
$options
[
'bypassDocumentValidation'
],
'boolean'
);
}
}
if
(
isset
(
$options
[
'fields'
])
&&
!
is_array
(
$options
[
'fields'
])
&&
!
is_object
(
$options
[
'fields'
]))
{
if
(
isset
(
$options
[
'fields'
])
&&
!
is_array
(
$options
[
'fields'
])
&&
!
is_object
(
$options
[
'fields'
]))
{
throw
new
InvalidArgumentTypeException
(
'"fields" option'
,
$options
[
'fields'
],
'array or object'
);
throw
InvalidArgumentException
::
invalidType
(
'"fields" option'
,
$options
[
'fields'
],
'array or object'
);
}
}
if
(
isset
(
$options
[
'maxTimeMS'
])
&&
!
is_integer
(
$options
[
'maxTimeMS'
]))
{
if
(
isset
(
$options
[
'maxTimeMS'
])
&&
!
is_integer
(
$options
[
'maxTimeMS'
]))
{
throw
new
InvalidArgumentTypeException
(
'"maxTimeMS" option'
,
$options
[
'maxTimeMS'
],
'integer'
);
throw
InvalidArgumentException
::
invalidType
(
'"maxTimeMS" option'
,
$options
[
'maxTimeMS'
],
'integer'
);
}
}
if
(
!
is_bool
(
$options
[
'new'
]))
{
if
(
!
is_bool
(
$options
[
'new'
]))
{
throw
new
InvalidArgumentTypeException
(
'"new" option'
,
$options
[
'new'
],
'boolean'
);
throw
InvalidArgumentException
::
invalidType
(
'"new" option'
,
$options
[
'new'
],
'boolean'
);
}
}
if
(
isset
(
$options
[
'query'
])
&&
!
is_array
(
$options
[
'query'
])
&&
!
is_object
(
$options
[
'query'
]))
{
if
(
isset
(
$options
[
'query'
])
&&
!
is_array
(
$options
[
'query'
])
&&
!
is_object
(
$options
[
'query'
]))
{
throw
new
InvalidArgumentTypeException
(
'"query" option'
,
$options
[
'query'
],
'array or object'
);
throw
InvalidArgumentException
::
invalidType
(
'"query" option'
,
$options
[
'query'
],
'array or object'
);
}
}
if
(
!
is_bool
(
$options
[
'remove'
]))
{
if
(
!
is_bool
(
$options
[
'remove'
]))
{
throw
new
InvalidArgumentTypeException
(
'"remove" option'
,
$options
[
'remove'
],
'boolean'
);
throw
InvalidArgumentException
::
invalidType
(
'"remove" option'
,
$options
[
'remove'
],
'boolean'
);
}
}
if
(
isset
(
$options
[
'sort'
])
&&
!
is_array
(
$options
[
'sort'
])
&&
!
is_object
(
$options
[
'sort'
]))
{
if
(
isset
(
$options
[
'sort'
])
&&
!
is_array
(
$options
[
'sort'
])
&&
!
is_object
(
$options
[
'sort'
]))
{
throw
new
InvalidArgumentTypeException
(
'"sort" option'
,
$options
[
'sort'
],
'array or object'
);
throw
InvalidArgumentException
::
invalidType
(
'"sort" option'
,
$options
[
'sort'
],
'array or object'
);
}
}
if
(
isset
(
$options
[
'update'
])
&&
!
is_array
(
$options
[
'update'
])
&&
!
is_object
(
$options
[
'update'
]))
{
if
(
isset
(
$options
[
'update'
])
&&
!
is_array
(
$options
[
'update'
])
&&
!
is_object
(
$options
[
'update'
]))
{
throw
new
InvalidArgumentTypeException
(
'"update" option'
,
$options
[
'update'
],
'array or object'
);
throw
InvalidArgumentException
::
invalidType
(
'"update" option'
,
$options
[
'update'
],
'array or object'
);
}
}
if
(
isset
(
$options
[
'writeConcern'
])
&&
!
$options
[
'writeConcern'
]
instanceof
WriteConcern
)
{
if
(
isset
(
$options
[
'writeConcern'
])
&&
!
$options
[
'writeConcern'
]
instanceof
WriteConcern
)
{
throw
new
InvalidArgumentTypeException
(
'"writeConcern" option'
,
$options
[
'writeConcern'
],
'MongoDB\Driver\WriteConcern'
);
throw
InvalidArgumentException
::
invalidType
(
'"writeConcern" option'
,
$options
[
'writeConcern'
],
'MongoDB\Driver\WriteConcern'
);
}
}
if
(
!
is_bool
(
$options
[
'upsert'
]))
{
if
(
!
is_bool
(
$options
[
'upsert'
]))
{
throw
new
InvalidArgumentTypeException
(
'"upsert" option'
,
$options
[
'upsert'
],
'boolean'
);
throw
InvalidArgumentException
::
invalidType
(
'"upsert" option'
,
$options
[
'upsert'
],
'boolean'
);
}
}
if
(
!
(
isset
(
$options
[
'update'
])
xor
$options
[
'remove'
]))
{
if
(
!
(
isset
(
$options
[
'update'
])
xor
$options
[
'remove'
]))
{
...
...
src/Operation/FindOne.php
View file @
8f646a38
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
namespace
MongoDB\Operation
;
namespace
MongoDB\Operation
;
use
MongoDB\Driver\Server
;
use
MongoDB\Driver\Server
;
use
MongoDB\Exception\InvalidArgument
Type
Exception
;
use
MongoDB\Exception\InvalidArgumentException
;
/**
/**
* Operation for finding a single document with the find command.
* Operation for finding a single document with the find command.
...
...
src/Operation/FindOneAndDelete.php
View file @
8f646a38
...
@@ -5,7 +5,6 @@ namespace MongoDB\Operation;
...
@@ -5,7 +5,6 @@ namespace MongoDB\Operation;
use
MongoDB\Driver\Command
;
use
MongoDB\Driver\Command
;
use
MongoDB\Driver\Server
;
use
MongoDB\Driver\Server
;
use
MongoDB\Exception\InvalidArgumentException
;
use
MongoDB\Exception\InvalidArgumentException
;
use
MongoDB\Exception\InvalidArgumentTypeException
;
/**
/**
* Operation for deleting a document with the findAndModify command.
* Operation for deleting a document with the findAndModify command.
...
@@ -44,11 +43,11 @@ class FindOneAndDelete implements Executable
...
@@ -44,11 +43,11 @@ class FindOneAndDelete implements Executable
public
function
__construct
(
$databaseName
,
$collectionName
,
$filter
,
array
$options
=
[])
public
function
__construct
(
$databaseName
,
$collectionName
,
$filter
,
array
$options
=
[])
{
{
if
(
!
is_array
(
$filter
)
&&
!
is_object
(
$filter
))
{
if
(
!
is_array
(
$filter
)
&&
!
is_object
(
$filter
))
{
throw
new
InvalidArgumentTypeException
(
'$filter'
,
$filter
,
'array or object'
);
throw
InvalidArgumentException
::
invalidType
(
'$filter'
,
$filter
,
'array or object'
);
}
}
if
(
isset
(
$options
[
'projection'
])
&&
!
is_array
(
$options
[
'projection'
])
&&
!
is_object
(
$options
[
'projection'
]))
{
if
(
isset
(
$options
[
'projection'
])
&&
!
is_array
(
$options
[
'projection'
])
&&
!
is_object
(
$options
[
'projection'
]))
{
throw
new
InvalidArgumentTypeException
(
'"projection" option'
,
$options
[
'projection'
],
'array or object'
);
throw
InvalidArgumentException
::
invalidType
(
'"projection" option'
,
$options
[
'projection'
],
'array or object'
);
}
}
if
(
isset
(
$options
[
'projection'
]))
{
if
(
isset
(
$options
[
'projection'
]))
{
...
...
src/Operation/FindOneAndReplace.php
View file @
8f646a38
...
@@ -5,7 +5,6 @@ namespace MongoDB\Operation;
...
@@ -5,7 +5,6 @@ namespace MongoDB\Operation;
use
MongoDB\Driver\Command
;
use
MongoDB\Driver\Command
;
use
MongoDB\Driver\Server
;
use
MongoDB\Driver\Server
;
use
MongoDB\Exception\InvalidArgumentException
;
use
MongoDB\Exception\InvalidArgumentException
;
use
MongoDB\Exception\InvalidArgumentTypeException
;
/**
/**
* Operation for replacing a document with the findAndModify command.
* Operation for replacing a document with the findAndModify command.
...
@@ -58,11 +57,11 @@ class FindOneAndReplace implements Executable
...
@@ -58,11 +57,11 @@ class FindOneAndReplace implements Executable
public
function
__construct
(
$databaseName
,
$collectionName
,
$filter
,
$replacement
,
array
$options
=
[])
public
function
__construct
(
$databaseName
,
$collectionName
,
$filter
,
$replacement
,
array
$options
=
[])
{
{
if
(
!
is_array
(
$filter
)
&&
!
is_object
(
$filter
))
{
if
(
!
is_array
(
$filter
)
&&
!
is_object
(
$filter
))
{
throw
new
InvalidArgumentTypeException
(
'$filter'
,
$filter
,
'array or object'
);
throw
InvalidArgumentException
::
invalidType
(
'$filter'
,
$filter
,
'array or object'
);
}
}
if
(
!
is_array
(
$replacement
)
&&
!
is_object
(
$replacement
))
{
if
(
!
is_array
(
$replacement
)
&&
!
is_object
(
$replacement
))
{
throw
new
InvalidArgumentTypeException
(
'$replacement'
,
$replacement
,
'array or object'
);
throw
InvalidArgumentException
::
invalidType
(
'$replacement'
,
$replacement
,
'array or object'
);
}
}
if
(
\MongoDB\is_first_key_operator
(
$replacement
))
{
if
(
\MongoDB\is_first_key_operator
(
$replacement
))
{
...
@@ -75,11 +74,11 @@ class FindOneAndReplace implements Executable
...
@@ -75,11 +74,11 @@ class FindOneAndReplace implements Executable
];
];
if
(
isset
(
$options
[
'projection'
])
&&
!
is_array
(
$options
[
'projection'
])
&&
!
is_object
(
$options
[
'projection'
]))
{
if
(
isset
(
$options
[
'projection'
])
&&
!
is_array
(
$options
[
'projection'
])
&&
!
is_object
(
$options
[
'projection'
]))
{
throw
new
InvalidArgumentTypeException
(
'"projection" option'
,
$options
[
'projection'
],
'array or object'
);
throw
InvalidArgumentException
::
invalidType
(
'"projection" option'
,
$options
[
'projection'
],
'array or object'
);
}
}
if
(
!
is_integer
(
$options
[
'returnDocument'
]))
{
if
(
!
is_integer
(
$options
[
'returnDocument'
]))
{
throw
new
InvalidArgumentTypeException
(
'"returnDocument" option'
,
$options
[
'returnDocument'
],
'integer'
);
throw
InvalidArgumentException
::
invalidType
(
'"returnDocument" option'
,
$options
[
'returnDocument'
],
'integer'
);
}
}
if
(
$options
[
'returnDocument'
]
!==
self
::
RETURN_DOCUMENT_AFTER
&&
if
(
$options
[
'returnDocument'
]
!==
self
::
RETURN_DOCUMENT_AFTER
&&
...
...
src/Operation/FindOneAndUpdate.php
View file @
8f646a38
...
@@ -5,7 +5,6 @@ namespace MongoDB\Operation;
...
@@ -5,7 +5,6 @@ namespace MongoDB\Operation;
use
MongoDB\Driver\Command
;
use
MongoDB\Driver\Command
;
use
MongoDB\Driver\Server
;
use
MongoDB\Driver\Server
;
use
MongoDB\Exception\InvalidArgumentException
;
use
MongoDB\Exception\InvalidArgumentException
;
use
MongoDB\Exception\InvalidArgumentTypeException
;
/**
/**
* Operation for updating a document with the findAndModify command.
* Operation for updating a document with the findAndModify command.
...
@@ -58,11 +57,11 @@ class FindOneAndUpdate implements Executable
...
@@ -58,11 +57,11 @@ class FindOneAndUpdate implements Executable
public
function
__construct
(
$databaseName
,
$collectionName
,
$filter
,
$update
,
array
$options
=
[])
public
function
__construct
(
$databaseName
,
$collectionName
,
$filter
,
$update
,
array
$options
=
[])
{
{
if
(
!
is_array
(
$filter
)
&&
!
is_object
(
$filter
))
{
if
(
!
is_array
(
$filter
)
&&
!
is_object
(
$filter
))
{
throw
new
InvalidArgumentTypeException
(
'$filter'
,
$filter
,
'array or object'
);
throw
InvalidArgumentException
::
invalidType
(
'$filter'
,
$filter
,
'array or object'
);
}
}
if
(
!
is_array
(
$update
)
&&
!
is_object
(
$update
))
{
if
(
!
is_array
(
$update
)
&&
!
is_object
(
$update
))
{
throw
new
InvalidArgumentTypeException
(
'$update'
,
$update
,
'array or object'
);
throw
InvalidArgumentException
::
invalidType
(
'$update'
,
$update
,
'array or object'
);
}
}
if
(
!
\MongoDB\is_first_key_operator
(
$update
))
{
if
(
!
\MongoDB\is_first_key_operator
(
$update
))
{
...
@@ -75,11 +74,11 @@ class FindOneAndUpdate implements Executable
...
@@ -75,11 +74,11 @@ class FindOneAndUpdate implements Executable
];
];
if
(
isset
(
$options
[
'projection'
])
&&
!
is_array
(
$options
[
'projection'
])
&&
!
is_object
(
$options
[
'projection'
]))
{
if
(
isset
(
$options
[
'projection'
])
&&
!
is_array
(
$options
[
'projection'
])
&&
!
is_object
(
$options
[
'projection'
]))
{
throw
new
InvalidArgumentTypeException
(
'"projection" option'
,
$options
[
'projection'
],
'array or object'
);
throw
InvalidArgumentException
::
invalidType
(
'"projection" option'
,
$options
[
'projection'
],
'array or object'
);
}
}
if
(
!
is_integer
(
$options
[
'returnDocument'
]))
{
if
(
!
is_integer
(
$options
[
'returnDocument'
]))
{
throw
new
InvalidArgumentTypeException
(
'"returnDocument" option'
,
$options
[
'returnDocument'
],
'integer'
);
throw
InvalidArgumentException
::
invalidType
(
'"returnDocument" option'
,
$options
[
'returnDocument'
],
'integer'
);
}
}
if
(
$options
[
'returnDocument'
]
!==
self
::
RETURN_DOCUMENT_AFTER
&&
if
(
$options
[
'returnDocument'
]
!==
self
::
RETURN_DOCUMENT_AFTER
&&
...
...
src/Operation/InsertMany.php
View file @
8f646a38
...
@@ -7,7 +7,6 @@ use MongoDB\Driver\BulkWrite as Bulk;
...
@@ -7,7 +7,6 @@ use MongoDB\Driver\BulkWrite as Bulk;
use
MongoDB\Driver\Server
;
use
MongoDB\Driver\Server
;
use
MongoDB\Driver\WriteConcern
;
use
MongoDB\Driver\WriteConcern
;
use
MongoDB\Exception\InvalidArgumentException
;
use
MongoDB\Exception\InvalidArgumentException
;
use
MongoDB\Exception\InvalidArgumentTypeException
;
/**
/**
* Operation for inserting multiple documents with the insert command.
* Operation for inserting multiple documents with the insert command.
...
@@ -59,7 +58,7 @@ class InsertMany implements Executable
...
@@ -59,7 +58,7 @@ class InsertMany implements Executable
}
}
if
(
!
is_array
(
$document
)
&&
!
is_object
(
$document
))
{
if
(
!
is_array
(
$document
)
&&
!
is_object
(
$document
))
{
throw
new
InvalidArgumentTypeException
(
sprintf
(
'$documents[%d]'
,
$i
),
$document
,
'array or object'
);
throw
InvalidArgumentException
::
invalidType
(
sprintf
(
'$documents[%d]'
,
$i
),
$document
,
'array or object'
);
}
}
$expectedIndex
+=
1
;
$expectedIndex
+=
1
;
...
@@ -68,15 +67,15 @@ class InsertMany implements Executable
...
@@ -68,15 +67,15 @@ class InsertMany implements Executable
$options
+=
[
'ordered'
=>
true
];
$options
+=
[
'ordered'
=>
true
];
if
(
isset
(
$options
[
'bypassDocumentValidation'
])
&&
!
is_bool
(
$options
[
'bypassDocumentValidation'
]))
{
if
(
isset
(
$options
[
'bypassDocumentValidation'
])
&&
!
is_bool
(
$options
[
'bypassDocumentValidation'
]))
{
throw
new
InvalidArgumentTypeException
(
'"bypassDocumentValidation" option'
,
$options
[
'bypassDocumentValidation'
],
'boolean'
);
throw
InvalidArgumentException
::
invalidType
(
'"bypassDocumentValidation" option'
,
$options
[
'bypassDocumentValidation'
],
'boolean'
);
}
}
if
(
!
is_bool
(
$options
[
'ordered'
]))
{
if
(
!
is_bool
(
$options
[
'ordered'
]))
{
throw
new
InvalidArgumentTypeException
(
'"ordered" option'
,
$options
[
'ordered'
],
'boolean'
);
throw
InvalidArgumentException
::
invalidType
(
'"ordered" option'
,
$options
[
'ordered'
],
'boolean'
);
}
}
if
(
isset
(
$options
[
'writeConcern'
])
&&
!
$options
[
'writeConcern'
]
instanceof
WriteConcern
)
{
if
(
isset
(
$options
[
'writeConcern'
])
&&
!
$options
[
'writeConcern'
]
instanceof
WriteConcern
)
{
throw
new
InvalidArgumentTypeException
(
'"writeConcern" option'
,
$options
[
'writeConcern'
],
'MongoDB\Driver\WriteConcern'
);
throw
InvalidArgumentException
::
invalidType
(
'"writeConcern" option'
,
$options
[
'writeConcern'
],
'MongoDB\Driver\WriteConcern'
);
}
}
$this
->
databaseName
=
(
string
)
$databaseName
;
$this
->
databaseName
=
(
string
)
$databaseName
;
...
...
src/Operation/InsertOne.php
View file @
8f646a38
...
@@ -6,7 +6,7 @@ use MongoDB\InsertOneResult;
...
@@ -6,7 +6,7 @@ use MongoDB\InsertOneResult;
use
MongoDB\Driver\BulkWrite
as
Bulk
;
use
MongoDB\Driver\BulkWrite
as
Bulk
;
use
MongoDB\Driver\Server
;
use
MongoDB\Driver\Server
;
use
MongoDB\Driver\WriteConcern
;
use
MongoDB\Driver\WriteConcern
;
use
MongoDB\Exception\InvalidArgument
Type
Exception
;
use
MongoDB\Exception\InvalidArgumentException
;
/**
/**
* Operation for inserting a single document with the insert command.
* Operation for inserting a single document with the insert command.
...
@@ -43,15 +43,15 @@ class InsertOne implements Executable
...
@@ -43,15 +43,15 @@ class InsertOne implements Executable
public
function
__construct
(
$databaseName
,
$collectionName
,
$document
,
array
$options
=
[])
public
function
__construct
(
$databaseName
,
$collectionName
,
$document
,
array
$options
=
[])
{
{
if
(
!
is_array
(
$document
)
&&
!
is_object
(
$document
))
{
if
(
!
is_array
(
$document
)
&&
!
is_object
(
$document
))
{
throw
new
InvalidArgumentTypeException
(
'$document'
,
$document
,
'array or object'
);
throw
InvalidArgumentException
::
invalidType
(
'$document'
,
$document
,
'array or object'
);
}
}
if
(
isset
(
$options
[
'bypassDocumentValidation'
])
&&
!
is_bool
(
$options
[
'bypassDocumentValidation'
]))
{
if
(
isset
(
$options
[
'bypassDocumentValidation'
])
&&
!
is_bool
(
$options
[
'bypassDocumentValidation'
]))
{
throw
new
InvalidArgumentTypeException
(
'"bypassDocumentValidation" option'
,
$options
[
'bypassDocumentValidation'
],
'boolean'
);
throw
InvalidArgumentException
::
invalidType
(
'"bypassDocumentValidation" option'
,
$options
[
'bypassDocumentValidation'
],
'boolean'
);
}
}
if
(
isset
(
$options
[
'writeConcern'
])
&&
!
$options
[
'writeConcern'
]
instanceof
WriteConcern
)
{
if
(
isset
(
$options
[
'writeConcern'
])
&&
!
$options
[
'writeConcern'
]
instanceof
WriteConcern
)
{
throw
new
InvalidArgumentTypeException
(
'"writeConcern" option'
,
$options
[
'writeConcern'
],
'MongoDB\Driver\WriteConcern'
);
throw
InvalidArgumentException
::
invalidType
(
'"writeConcern" option'
,
$options
[
'writeConcern'
],
'MongoDB\Driver\WriteConcern'
);
}
}
$this
->
databaseName
=
(
string
)
$databaseName
;
$this
->
databaseName
=
(
string
)
$databaseName
;
...
...
src/Operation/ListCollections.php
View file @
8f646a38
...
@@ -6,6 +6,7 @@ use MongoDB\Driver\Command;
...
@@ -6,6 +6,7 @@ use MongoDB\Driver\Command;
use
MongoDB\Driver\Query
;
use
MongoDB\Driver\Query
;
use
MongoDB\Driver\Server
;
use
MongoDB\Driver\Server
;
use
MongoDB\Exception\RuntimeException
;
use
MongoDB\Exception\RuntimeException
;
use
MongoDB\Exception\InvalidArgumentException
;
use
MongoDB\Model\CollectionInfoCommandIterator
;
use
MongoDB\Model\CollectionInfoCommandIterator
;
use
MongoDB\Model\CollectionInfoIterator
;
use
MongoDB\Model\CollectionInfoIterator
;
use
MongoDB\Model\CollectionInfoLegacyIterator
;
use
MongoDB\Model\CollectionInfoLegacyIterator
;
...
@@ -36,15 +37,16 @@ class ListCollections implements Executable
...
@@ -36,15 +37,16 @@ class ListCollections implements Executable
*
*
* @param string $databaseName Database name
* @param string $databaseName Database name
* @param array $options Command options
* @param array $options Command options
* @throws InvalidArgumentException
*/
*/
public
function
__construct
(
$databaseName
,
array
$options
=
[])
public
function
__construct
(
$databaseName
,
array
$options
=
[])
{
{
if
(
isset
(
$options
[
'filter'
])
&&
!
is_array
(
$options
[
'filter'
])
&&
!
is_object
(
$options
[
'filter'
]))
{
if
(
isset
(
$options
[
'filter'
])
&&
!
is_array
(
$options
[
'filter'
])
&&
!
is_object
(
$options
[
'filter'
]))
{
throw
new
InvalidArgumentTypeException
(
'"filter" option'
,
$options
[
'filter'
],
'array or object'
);
throw
InvalidArgumentException
::
invalidType
(
'"filter" option'
,
$options
[
'filter'
],
'array or object'
);
}
}
if
(
isset
(
$options
[
'maxTimeMS'
])
&&
!
is_integer
(
$options
[
'maxTimeMS'
]))
{
if
(
isset
(
$options
[
'maxTimeMS'
])
&&
!
is_integer
(
$options
[
'maxTimeMS'
]))
{
throw
new
InvalidArgumentTypeException
(
'"maxTimeMS" option'
,
$options
[
'maxTimeMS'
],
'integer'
);
throw
InvalidArgumentException
::
invalidType
(
'"maxTimeMS" option'
,
$options
[
'maxTimeMS'
],
'integer'
);
}
}
$this
->
databaseName
=
(
string
)
$databaseName
;
$this
->
databaseName
=
(
string
)
$databaseName
;
...
@@ -104,7 +106,7 @@ class ListCollections implements Executable
...
@@ -104,7 +106,7 @@ class ListCollections implements Executable
if
(
array_key_exists
(
'name'
,
$filter
))
{
if
(
array_key_exists
(
'name'
,
$filter
))
{
if
(
!
is_string
(
$filter
[
'name'
]))
{
if
(
!
is_string
(
$filter
[
'name'
]))
{
throw
new
InvalidArgumentTypeException
(
'filter name for MongoDB <3.0'
,
$filter
[
'name'
],
'string'
);
throw
InvalidArgumentException
::
invalidType
(
'filter name for MongoDB <3.0'
,
$filter
[
'name'
],
'string'
);
}
}
$filter
[
'name'
]
=
$this
->
databaseName
.
'.'
.
$filter
[
'name'
];
$filter
[
'name'
]
=
$this
->
databaseName
.
'.'
.
$filter
[
'name'
];
...
...
src/Operation/ListDatabases.php
View file @
8f646a38
...
@@ -4,6 +4,7 @@ namespace MongoDB\Operation;
...
@@ -4,6 +4,7 @@ namespace MongoDB\Operation;
use
MongoDB\Driver\Command
;
use
MongoDB\Driver\Command
;
use
MongoDB\Driver\Server
;
use
MongoDB\Driver\Server
;
use
MongoDB\Exception\InvalidArgumentException
;
use
MongoDB\Exception\UnexpectedValueException
;
use
MongoDB\Exception\UnexpectedValueException
;
use
MongoDB\Model\DatabaseInfoIterator
;
use
MongoDB\Model\DatabaseInfoIterator
;
use
MongoDB\Model\DatabaseInfoLegacyIterator
;
use
MongoDB\Model\DatabaseInfoLegacyIterator
;
...
@@ -28,11 +29,12 @@ class ListDatabases implements Executable
...
@@ -28,11 +29,12 @@ class ListDatabases implements Executable
* run.
* run.
*
*
* @param array $options Command options
* @param array $options Command options
* @throws InvalidArgumentException
*/
*/
public
function
__construct
(
array
$options
=
[])
public
function
__construct
(
array
$options
=
[])
{
{
if
(
isset
(
$options
[
'maxTimeMS'
])
&&
!
is_integer
(
$options
[
'maxTimeMS'
]))
{
if
(
isset
(
$options
[
'maxTimeMS'
])
&&
!
is_integer
(
$options
[
'maxTimeMS'
]))
{
throw
new
InvalidArgumentTypeException
(
'"maxTimeMS" option'
,
$options
[
'maxTimeMS'
],
'integer'
);
throw
InvalidArgumentException
::
invalidType
(
'"maxTimeMS" option'
,
$options
[
'maxTimeMS'
],
'integer'
);
}
}
$this
->
options
=
$options
;
$this
->
options
=
$options
;
...
...
src/Operation/ListIndexes.php
View file @
8f646a38
...
@@ -6,6 +6,7 @@ use MongoDB\Driver\Command;
...
@@ -6,6 +6,7 @@ use MongoDB\Driver\Command;
use
MongoDB\Driver\Query
;
use
MongoDB\Driver\Query
;
use
MongoDB\Driver\Server
;
use
MongoDB\Driver\Server
;
use
MongoDB\Driver\Exception\RuntimeException
;
use
MongoDB\Driver\Exception\RuntimeException
;
use
MongoDB\Exception\InvalidArgumentException
;
use
MongoDB\Model\IndexInfoIterator
;
use
MongoDB\Model\IndexInfoIterator
;
use
MongoDB\Model\IndexInfoIteratorIterator
;
use
MongoDB\Model\IndexInfoIteratorIterator
;
use
EmptyIterator
;
use
EmptyIterator
;
...
@@ -38,11 +39,12 @@ class ListIndexes implements Executable
...
@@ -38,11 +39,12 @@ class ListIndexes implements Executable
* @param string $databaseName Database name
* @param string $databaseName Database name
* @param string $collectionName Collection name
* @param string $collectionName Collection name
* @param array $options Command options
* @param array $options Command options
* @throws InvalidArgumentException
*/
*/
public
function
__construct
(
$databaseName
,
$collectionName
,
array
$options
=
[])
public
function
__construct
(
$databaseName
,
$collectionName
,
array
$options
=
[])
{
{
if
(
isset
(
$options
[
'maxTimeMS'
])
&&
!
is_integer
(
$options
[
'maxTimeMS'
]))
{
if
(
isset
(
$options
[
'maxTimeMS'
])
&&
!
is_integer
(
$options
[
'maxTimeMS'
]))
{
throw
new
InvalidArgumentTypeException
(
'"maxTimeMS" option'
,
$options
[
'maxTimeMS'
],
'integer'
);
throw
InvalidArgumentException
::
invalidType
(
'"maxTimeMS" option'
,
$options
[
'maxTimeMS'
],
'integer'
);
}
}
$this
->
databaseName
=
(
string
)
$databaseName
;
$this
->
databaseName
=
(
string
)
$databaseName
;
...
...
src/Operation/ReplaceOne.php
View file @
8f646a38
...
@@ -5,7 +5,6 @@ namespace MongoDB\Operation;
...
@@ -5,7 +5,6 @@ namespace MongoDB\Operation;
use
MongoDB\UpdateResult
;
use
MongoDB\UpdateResult
;
use
MongoDB\Driver\Server
;
use
MongoDB\Driver\Server
;
use
MongoDB\Exception\InvalidArgumentException
;
use
MongoDB\Exception\InvalidArgumentException
;
use
MongoDB\Exception\InvalidArgumentTypeException
;
/**
/**
* Operation for replacing a single document with the update command.
* Operation for replacing a single document with the update command.
...
@@ -41,7 +40,7 @@ class ReplaceOne implements Executable
...
@@ -41,7 +40,7 @@ class ReplaceOne implements Executable
public
function
__construct
(
$databaseName
,
$collectionName
,
$filter
,
$replacement
,
array
$options
=
[])
public
function
__construct
(
$databaseName
,
$collectionName
,
$filter
,
$replacement
,
array
$options
=
[])
{
{
if
(
!
is_array
(
$replacement
)
&&
!
is_object
(
$replacement
))
{
if
(
!
is_array
(
$replacement
)
&&
!
is_object
(
$replacement
))
{
throw
new
InvalidArgumentTypeException
(
'$replacement'
,
$replacement
,
'array or object'
);
throw
InvalidArgumentException
::
invalidType
(
'$replacement'
,
$replacement
,
'array or object'
);
}
}
if
(
\MongoDB\is_first_key_operator
(
$replacement
))
{
if
(
\MongoDB\is_first_key_operator
(
$replacement
))
{
...
...
src/Operation/Update.php
View file @
8f646a38
...
@@ -7,7 +7,6 @@ use MongoDB\Driver\BulkWrite as Bulk;
...
@@ -7,7 +7,6 @@ use MongoDB\Driver\BulkWrite as Bulk;
use
MongoDB\Driver\Server
;
use
MongoDB\Driver\Server
;
use
MongoDB\Driver\WriteConcern
;
use
MongoDB\Driver\WriteConcern
;
use
MongoDB\Exception\InvalidArgumentException
;
use
MongoDB\Exception\InvalidArgumentException
;
use
MongoDB\Exception\InvalidArgumentTypeException
;
/**
/**
* Operation for the update command.
* Operation for the update command.
...
@@ -56,11 +55,11 @@ class Update implements Executable
...
@@ -56,11 +55,11 @@ class Update implements Executable
public
function
__construct
(
$databaseName
,
$collectionName
,
$filter
,
$update
,
array
$options
=
[])
public
function
__construct
(
$databaseName
,
$collectionName
,
$filter
,
$update
,
array
$options
=
[])
{
{
if
(
!
is_array
(
$filter
)
&&
!
is_object
(
$filter
))
{
if
(
!
is_array
(
$filter
)
&&
!
is_object
(
$filter
))
{
throw
new
InvalidArgumentTypeException
(
'$filter'
,
$filter
,
'array or object'
);
throw
InvalidArgumentException
::
invalidType
(
'$filter'
,
$filter
,
'array or object'
);
}
}
if
(
!
is_array
(
$update
)
&&
!
is_object
(
$update
))
{
if
(
!
is_array
(
$update
)
&&
!
is_object
(
$update
))
{
throw
new
InvalidArgumentTypeException
(
'$update'
,
$filter
,
'array or object'
);
throw
InvalidArgumentException
::
invalidType
(
'$update'
,
$filter
,
'array or object'
);
}
}
$options
+=
[
$options
+=
[
...
@@ -69,11 +68,11 @@ class Update implements Executable
...
@@ -69,11 +68,11 @@ class Update implements Executable
];
];
if
(
isset
(
$options
[
'bypassDocumentValidation'
])
&&
!
is_bool
(
$options
[
'bypassDocumentValidation'
]))
{
if
(
isset
(
$options
[
'bypassDocumentValidation'
])
&&
!
is_bool
(
$options
[
'bypassDocumentValidation'
]))
{
throw
new
InvalidArgumentTypeException
(
'"bypassDocumentValidation" option'
,
$options
[
'bypassDocumentValidation'
],
'boolean'
);
throw
InvalidArgumentException
::
invalidType
(
'"bypassDocumentValidation" option'
,
$options
[
'bypassDocumentValidation'
],
'boolean'
);
}
}
if
(
!
is_bool
(
$options
[
'multi'
]))
{
if
(
!
is_bool
(
$options
[
'multi'
]))
{
throw
new
InvalidArgumentTypeException
(
'"multi" option'
,
$options
[
'multi'
],
'boolean'
);
throw
InvalidArgumentException
::
invalidType
(
'"multi" option'
,
$options
[
'multi'
],
'boolean'
);
}
}
if
(
$options
[
'multi'
]
&&
!
\MongoDB\is_first_key_operator
(
$update
))
{
if
(
$options
[
'multi'
]
&&
!
\MongoDB\is_first_key_operator
(
$update
))
{
...
@@ -81,11 +80,11 @@ class Update implements Executable
...
@@ -81,11 +80,11 @@ class Update implements Executable
}
}
if
(
!
is_bool
(
$options
[
'upsert'
]))
{
if
(
!
is_bool
(
$options
[
'upsert'
]))
{
throw
new
InvalidArgumentTypeException
(
'"upsert" option'
,
$options
[
'upsert'
],
'boolean'
);
throw
InvalidArgumentException
::
invalidType
(
'"upsert" option'
,
$options
[
'upsert'
],
'boolean'
);
}
}
if
(
isset
(
$options
[
'writeConcern'
])
&&
!
$options
[
'writeConcern'
]
instanceof
WriteConcern
)
{
if
(
isset
(
$options
[
'writeConcern'
])
&&
!
$options
[
'writeConcern'
]
instanceof
WriteConcern
)
{
throw
new
InvalidArgumentTypeException
(
'"writeConcern" option'
,
$options
[
'writeConcern'
],
'MongoDB\Driver\WriteConcern'
);
throw
InvalidArgumentException
::
invalidType
(
'"writeConcern" option'
,
$options
[
'writeConcern'
],
'MongoDB\Driver\WriteConcern'
);
}
}
$this
->
databaseName
=
(
string
)
$databaseName
;
$this
->
databaseName
=
(
string
)
$databaseName
;
...
...
src/Operation/UpdateMany.php
View file @
8f646a38
...
@@ -5,7 +5,6 @@ namespace MongoDB\Operation;
...
@@ -5,7 +5,6 @@ namespace MongoDB\Operation;
use
MongoDB\UpdateResult
;
use
MongoDB\UpdateResult
;
use
MongoDB\Driver\Server
;
use
MongoDB\Driver\Server
;
use
MongoDB\Exception\InvalidArgumentException
;
use
MongoDB\Exception\InvalidArgumentException
;
use
MongoDB\Exception\InvalidArgumentTypeException
;
/**
/**
* Operation for updating multiple documents with the update command.
* Operation for updating multiple documents with the update command.
...
@@ -41,7 +40,7 @@ class UpdateMany implements Executable
...
@@ -41,7 +40,7 @@ class UpdateMany implements Executable
public
function
__construct
(
$databaseName
,
$collectionName
,
$filter
,
$update
,
array
$options
=
[])
public
function
__construct
(
$databaseName
,
$collectionName
,
$filter
,
$update
,
array
$options
=
[])
{
{
if
(
!
is_array
(
$update
)
&&
!
is_object
(
$update
))
{
if
(
!
is_array
(
$update
)
&&
!
is_object
(
$update
))
{
throw
new
InvalidArgumentTypeException
(
'$update'
,
$update
,
'array or object'
);
throw
InvalidArgumentException
::
invalidType
(
'$update'
,
$update
,
'array or object'
);
}
}
if
(
!
\MongoDB\is_first_key_operator
(
$update
))
{
if
(
!
\MongoDB\is_first_key_operator
(
$update
))
{
...
...
src/Operation/UpdateOne.php
View file @
8f646a38
...
@@ -5,7 +5,6 @@ namespace MongoDB\Operation;
...
@@ -5,7 +5,6 @@ namespace MongoDB\Operation;
use
MongoDB\UpdateResult
;
use
MongoDB\UpdateResult
;
use
MongoDB\Driver\Server
;
use
MongoDB\Driver\Server
;
use
MongoDB\Exception\InvalidArgumentException
;
use
MongoDB\Exception\InvalidArgumentException
;
use
MongoDB\Exception\InvalidArgumentTypeException
;
/**
/**
* Operation for updating a single document with the update command.
* Operation for updating a single document with the update command.
...
@@ -41,7 +40,7 @@ class UpdateOne implements Executable
...
@@ -41,7 +40,7 @@ class UpdateOne implements Executable
public
function
__construct
(
$databaseName
,
$collectionName
,
$filter
,
$update
,
array
$options
=
[])
public
function
__construct
(
$databaseName
,
$collectionName
,
$filter
,
$update
,
array
$options
=
[])
{
{
if
(
!
is_array
(
$update
)
&&
!
is_object
(
$update
))
{
if
(
!
is_array
(
$update
)
&&
!
is_object
(
$update
))
{
throw
new
InvalidArgumentTypeException
(
'$update'
,
$update
,
'array or object'
);
throw
InvalidArgumentException
::
invalidType
(
'$update'
,
$update
,
'array or object'
);
}
}
if
(
!
\MongoDB\is_first_key_operator
(
$update
))
{
if
(
!
\MongoDB\is_first_key_operator
(
$update
))
{
...
...
src/functions.php
View file @
8f646a38
...
@@ -5,7 +5,7 @@ namespace MongoDB;
...
@@ -5,7 +5,7 @@ namespace MongoDB;
use
MongoDB\BSON\Serializable
;
use
MongoDB\BSON\Serializable
;
use
MongoDB\Driver\ReadConcern
;
use
MongoDB\Driver\ReadConcern
;
use
MongoDB\Driver\Server
;
use
MongoDB\Driver\Server
;
use
MongoDB\Exception\InvalidArgument
Type
Exception
;
use
MongoDB\Exception\InvalidArgumentException
;
use
stdClass
;
use
stdClass
;
/**
/**
...
@@ -36,7 +36,7 @@ function extract_id_from_inserted_document($document)
...
@@ -36,7 +36,7 @@ function extract_id_from_inserted_document($document)
* @param array|object $document Document containing fields mapped to values,
* @param array|object $document Document containing fields mapped to values,
* which denote order or an index type
* which denote order or an index type
* @return string
* @return string
* @throws InvalidArgument
Type
Exception
* @throws InvalidArgumentException
*/
*/
function
generate_index_name
(
$document
)
function
generate_index_name
(
$document
)
{
{
...
@@ -45,7 +45,7 @@ function generate_index_name($document)
...
@@ -45,7 +45,7 @@ function generate_index_name($document)
}
}
if
(
!
is_array
(
$document
))
{
if
(
!
is_array
(
$document
))
{
throw
new
InvalidArgumentTypeException
(
'$document'
,
$document
,
'array or object'
);
throw
InvalidArgumentException
::
invalidType
(
'$document'
,
$document
,
'array or object'
);
}
}
$name
=
''
;
$name
=
''
;
...
@@ -65,7 +65,7 @@ function generate_index_name($document)
...
@@ -65,7 +65,7 @@ function generate_index_name($document)
* @internal
* @internal
* @param array|object $document Update or replacement document
* @param array|object $document Update or replacement document
* @return boolean
* @return boolean
* @throws InvalidArgument
Type
Exception
* @throws InvalidArgumentException
*/
*/
function
is_first_key_operator
(
$document
)
function
is_first_key_operator
(
$document
)
{
{
...
@@ -74,7 +74,7 @@ function is_first_key_operator($document)
...
@@ -74,7 +74,7 @@ function is_first_key_operator($document)
}
}
if
(
!
is_array
(
$document
))
{
if
(
!
is_array
(
$document
))
{
throw
new
InvalidArgumentTypeException
(
'$document'
,
$document
,
'array or object'
);
throw
InvalidArgumentException
::
invalidType
(
'$document'
,
$document
,
'array or object'
);
}
}
$firstKey
=
(
string
)
key
(
$document
);
$firstKey
=
(
string
)
key
(
$document
);
...
...
tests/Collection/CollectionFunctionalTest.php
View file @
8f646a38
...
@@ -35,7 +35,7 @@ class CollectionFunctionalTest extends FunctionalTestCase
...
@@ -35,7 +35,7 @@ class CollectionFunctionalTest extends FunctionalTestCase
}
}
/**
/**
* @expectedException MongoDB\Exception\InvalidArgument
Type
Exception
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidConstructorOptions
* @dataProvider provideInvalidConstructorOptions
*/
*/
public
function
testConstructorOptionTypeChecks
(
array
$options
)
public
function
testConstructorOptionTypeChecks
(
array
$options
)
...
...
tests/Database/DatabaseFunctionalTest.php
View file @
8f646a38
...
@@ -32,7 +32,7 @@ class DatabaseFunctionalTest extends FunctionalTestCase
...
@@ -32,7 +32,7 @@ class DatabaseFunctionalTest extends FunctionalTestCase
}
}
/**
/**
* @expectedException MongoDB\Exception\InvalidArgument
Type
Exception
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidConstructorOptions
* @dataProvider provideInvalidConstructorOptions
*/
*/
public
function
testConstructorOptionTypeChecks
(
array
$options
)
public
function
testConstructorOptionTypeChecks
(
array
$options
)
...
@@ -102,7 +102,7 @@ class DatabaseFunctionalTest extends FunctionalTestCase
...
@@ -102,7 +102,7 @@ class DatabaseFunctionalTest extends FunctionalTestCase
}
}
/**
/**
* @expectedException MongoDB\Exception\InvalidArgument
Type
Exception
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidDocumentValues
* @dataProvider provideInvalidDocumentValues
*/
*/
public
function
testCommandCommandArgumentTypeCheck
(
$command
)
public
function
testCommandCommandArgumentTypeCheck
(
$command
)
...
...
tests/Model/IndexInputTest.php
View file @
8f646a38
...
@@ -17,7 +17,7 @@ class IndexInputTest extends TestCase
...
@@ -17,7 +17,7 @@ class IndexInputTest extends TestCase
}
}
/**
/**
* @expectedException MongoDB\Exception\InvalidArgument
Type
Exception
* @expectedException MongoDB\Exception\InvalidArgumentException
*/
*/
public
function
testConstructorShouldRequireKeyToBeArrayOrObject
()
public
function
testConstructorShouldRequireKeyToBeArrayOrObject
()
{
{
...
@@ -25,7 +25,7 @@ class IndexInputTest extends TestCase
...
@@ -25,7 +25,7 @@ class IndexInputTest extends TestCase
}
}
/**
/**
* @expectedException MongoDB\Exception\InvalidArgument
Type
Exception
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidFieldOrderValues
* @dataProvider provideInvalidFieldOrderValues
*/
*/
public
function
testConstructorShouldRequireKeyFieldOrderToBeNumericOrString
(
$order
)
public
function
testConstructorShouldRequireKeyFieldOrderToBeNumericOrString
(
$order
)
...
@@ -47,7 +47,7 @@ class IndexInputTest extends TestCase
...
@@ -47,7 +47,7 @@ class IndexInputTest extends TestCase
}
}
/**
/**
* @expectedException MongoDB\Exception\InvalidArgument
Type
Exception
* @expectedException MongoDB\Exception\InvalidArgumentException
*/
*/
public
function
testConstructorShouldRequireNamespaceToBeString
()
public
function
testConstructorShouldRequireNamespaceToBeString
()
{
{
...
@@ -55,7 +55,7 @@ class IndexInputTest extends TestCase
...
@@ -55,7 +55,7 @@ class IndexInputTest extends TestCase
}
}
/**
/**
* @expectedException MongoDB\Exception\InvalidArgument
Type
Exception
* @expectedException MongoDB\Exception\InvalidArgumentException
*/
*/
public
function
testConstructorShouldRequireNameToBeString
()
public
function
testConstructorShouldRequireNameToBeString
()
{
{
...
...
tests/Operation/AggregateTest.php
View file @
8f646a38
...
@@ -25,7 +25,7 @@ class AggregateTest extends TestCase
...
@@ -25,7 +25,7 @@ class AggregateTest extends TestCase
}
}
/**
/**
* @expectedException MongoDB\Exception\InvalidArgument
Type
Exception
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidConstructorOptions
* @dataProvider provideInvalidConstructorOptions
*/
*/
public
function
testConstructorOptionTypeChecks
(
array
$options
)
public
function
testConstructorOptionTypeChecks
(
array
$options
)
...
...
tests/Operation/BulkWriteTest.php
View file @
8f646a38
...
@@ -63,7 +63,7 @@ class BulkWriteTest extends TestCase
...
@@ -63,7 +63,7 @@ class BulkWriteTest extends TestCase
}
}
/**
/**
* @expectedException MongoDB\Exception\InvalidArgument
Type
Exception
* @expectedException MongoDB\Exception\InvalidArgumentException
* @expectedExceptionMessageRegExp /Expected \$operations\[0\]\["insertOne"\]\[0\] to have type "array or object" but found "[\w ]+"/
* @expectedExceptionMessageRegExp /Expected \$operations\[0\]\["insertOne"\]\[0\] to have type "array or object" but found "[\w ]+"/
* @dataProvider provideInvalidDocumentValues
* @dataProvider provideInvalidDocumentValues
*/
*/
...
@@ -86,7 +86,7 @@ class BulkWriteTest extends TestCase
...
@@ -86,7 +86,7 @@ class BulkWriteTest extends TestCase
}
}
/**
/**
* @expectedException MongoDB\Exception\InvalidArgument
Type
Exception
* @expectedException MongoDB\Exception\InvalidArgumentException
* @expectedExceptionMessageRegExp /Expected \$operations\[0\]\["deleteMany"\]\[0\] to have type "array or object" but found "[\w ]+"/
* @expectedExceptionMessageRegExp /Expected \$operations\[0\]\["deleteMany"\]\[0\] to have type "array or object" but found "[\w ]+"/
* @dataProvider provideInvalidDocumentValues
* @dataProvider provideInvalidDocumentValues
*/
*/
...
@@ -109,7 +109,7 @@ class BulkWriteTest extends TestCase
...
@@ -109,7 +109,7 @@ class BulkWriteTest extends TestCase
}
}
/**
/**
* @expectedException MongoDB\Exception\InvalidArgument
Type
Exception
* @expectedException MongoDB\Exception\InvalidArgumentException
* @expectedExceptionMessageRegExp /Expected \$operations\[0\]\["deleteOne"\]\[0\] to have type "array or object" but found "[\w ]+"/
* @expectedExceptionMessageRegExp /Expected \$operations\[0\]\["deleteOne"\]\[0\] to have type "array or object" but found "[\w ]+"/
* @dataProvider provideInvalidDocumentValues
* @dataProvider provideInvalidDocumentValues
*/
*/
...
@@ -132,7 +132,7 @@ class BulkWriteTest extends TestCase
...
@@ -132,7 +132,7 @@ class BulkWriteTest extends TestCase
}
}
/**
/**
* @expectedException MongoDB\Exception\InvalidArgument
Type
Exception
* @expectedException MongoDB\Exception\InvalidArgumentException
* @expectedExceptionMessageRegExp /Expected \$operations\[0\]\["replaceOne"\]\[0\] to have type "array or object" but found "[\w ]+"/
* @expectedExceptionMessageRegExp /Expected \$operations\[0\]\["replaceOne"\]\[0\] to have type "array or object" but found "[\w ]+"/
* @dataProvider provideInvalidDocumentValues
* @dataProvider provideInvalidDocumentValues
*/
*/
...
@@ -155,7 +155,7 @@ class BulkWriteTest extends TestCase
...
@@ -155,7 +155,7 @@ class BulkWriteTest extends TestCase
}
}
/**
/**
* @expectedException MongoDB\Exception\InvalidArgument
Type
Exception
* @expectedException MongoDB\Exception\InvalidArgumentException
* @expectedExceptionMessageRegExp /Expected \$operations\[0\]\["replaceOne"\]\[1\] to have type "array or object" but found "[\w ]+"/
* @expectedExceptionMessageRegExp /Expected \$operations\[0\]\["replaceOne"\]\[1\] to have type "array or object" but found "[\w ]+"/
* @dataProvider provideInvalidDocumentValues
* @dataProvider provideInvalidDocumentValues
*/
*/
...
@@ -178,7 +178,7 @@ class BulkWriteTest extends TestCase
...
@@ -178,7 +178,7 @@ class BulkWriteTest extends TestCase
}
}
/**
/**
* @expectedException MongoDB\Exception\InvalidArgument
Type
Exception
* @expectedException MongoDB\Exception\InvalidArgumentException
* @expectedExceptionMessageRegExp /Expected \$operations\[0\]\["replaceOne"\]\[2\]\["upsert"\] to have type "boolean" but found "[\w ]+"/
* @expectedExceptionMessageRegExp /Expected \$operations\[0\]\["replaceOne"\]\[2\]\["upsert"\] to have type "boolean" but found "[\w ]+"/
* @dataProvider provideInvalidBooleanValues
* @dataProvider provideInvalidBooleanValues
*/
*/
...
@@ -201,7 +201,7 @@ class BulkWriteTest extends TestCase
...
@@ -201,7 +201,7 @@ class BulkWriteTest extends TestCase
}
}
/**
/**
* @expectedException MongoDB\Exception\InvalidArgument
Type
Exception
* @expectedException MongoDB\Exception\InvalidArgumentException
* @expectedExceptionMessageRegExp /Expected \$operations\[0\]\["updateMany"\]\[0\] to have type "array or object" but found "[\w ]+"/
* @expectedExceptionMessageRegExp /Expected \$operations\[0\]\["updateMany"\]\[0\] to have type "array or object" but found "[\w ]+"/
* @dataProvider provideInvalidDocumentValues
* @dataProvider provideInvalidDocumentValues
*/
*/
...
@@ -224,7 +224,7 @@ class BulkWriteTest extends TestCase
...
@@ -224,7 +224,7 @@ class BulkWriteTest extends TestCase
}
}
/**
/**
* @expectedException MongoDB\Exception\InvalidArgument
Type
Exception
* @expectedException MongoDB\Exception\InvalidArgumentException
* @expectedExceptionMessageRegExp /Expected \$operations\[0\]\["updateMany"\]\[1\] to have type "array or object" but found "[\w ]+"/
* @expectedExceptionMessageRegExp /Expected \$operations\[0\]\["updateMany"\]\[1\] to have type "array or object" but found "[\w ]+"/
* @dataProvider provideInvalidDocumentValues
* @dataProvider provideInvalidDocumentValues
*/
*/
...
@@ -247,7 +247,7 @@ class BulkWriteTest extends TestCase
...
@@ -247,7 +247,7 @@ class BulkWriteTest extends TestCase
}
}
/**
/**
* @expectedException MongoDB\Exception\InvalidArgument
Type
Exception
* @expectedException MongoDB\Exception\InvalidArgumentException
* @expectedExceptionMessageRegExp /Expected \$operations\[0\]\["updateMany"\]\[2\]\["upsert"\] to have type "boolean" but found "[\w ]+"/
* @expectedExceptionMessageRegExp /Expected \$operations\[0\]\["updateMany"\]\[2\]\["upsert"\] to have type "boolean" but found "[\w ]+"/
* @dataProvider provideInvalidBooleanValues
* @dataProvider provideInvalidBooleanValues
*/
*/
...
@@ -270,7 +270,7 @@ class BulkWriteTest extends TestCase
...
@@ -270,7 +270,7 @@ class BulkWriteTest extends TestCase
}
}
/**
/**
* @expectedException MongoDB\Exception\InvalidArgument
Type
Exception
* @expectedException MongoDB\Exception\InvalidArgumentException
* @expectedExceptionMessageRegExp /Expected \$operations\[0\]\["updateOne"\]\[0\] to have type "array or object" but found "[\w ]+"/
* @expectedExceptionMessageRegExp /Expected \$operations\[0\]\["updateOne"\]\[0\] to have type "array or object" but found "[\w ]+"/
* @dataProvider provideInvalidDocumentValues
* @dataProvider provideInvalidDocumentValues
*/
*/
...
@@ -293,7 +293,7 @@ class BulkWriteTest extends TestCase
...
@@ -293,7 +293,7 @@ class BulkWriteTest extends TestCase
}
}
/**
/**
* @expectedException MongoDB\Exception\InvalidArgument
Type
Exception
* @expectedException MongoDB\Exception\InvalidArgumentException
* @expectedExceptionMessageRegExp /Expected \$operations\[0\]\["updateOne"\]\[1\] to have type "array or object" but found "[\w ]+"/
* @expectedExceptionMessageRegExp /Expected \$operations\[0\]\["updateOne"\]\[1\] to have type "array or object" but found "[\w ]+"/
* @dataProvider provideInvalidDocumentValues
* @dataProvider provideInvalidDocumentValues
*/
*/
...
@@ -316,7 +316,7 @@ class BulkWriteTest extends TestCase
...
@@ -316,7 +316,7 @@ class BulkWriteTest extends TestCase
}
}
/**
/**
* @expectedException MongoDB\Exception\InvalidArgument
Type
Exception
* @expectedException MongoDB\Exception\InvalidArgumentException
* @expectedExceptionMessageRegExp /Expected \$operations\[0\]\["updateOne"\]\[2\]\["upsert"\] to have type "boolean" but found "[\w ]+"/
* @expectedExceptionMessageRegExp /Expected \$operations\[0\]\["updateOne"\]\[2\]\["upsert"\] to have type "boolean" but found "[\w ]+"/
* @dataProvider provideInvalidBooleanValues
* @dataProvider provideInvalidBooleanValues
*/
*/
...
@@ -328,7 +328,7 @@ class BulkWriteTest extends TestCase
...
@@ -328,7 +328,7 @@ class BulkWriteTest extends TestCase
}
}
/**
/**
* @expectedException MongoDB\Exception\InvalidArgument
Type
Exception
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidConstructorOptions
* @dataProvider provideInvalidConstructorOptions
*/
*/
public
function
testConstructorOptionTypeChecks
(
array
$options
)
public
function
testConstructorOptionTypeChecks
(
array
$options
)
...
...
tests/Operation/CountTest.php
View file @
8f646a38
...
@@ -7,7 +7,7 @@ use MongoDB\Operation\Count;
...
@@ -7,7 +7,7 @@ use MongoDB\Operation\Count;
class
CountTest
extends
TestCase
class
CountTest
extends
TestCase
{
{
/**
/**
* @expectedException MongoDB\Exception\InvalidArgument
Type
Exception
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidDocumentValues
* @dataProvider provideInvalidDocumentValues
*/
*/
public
function
testConstructorFilterArgumentTypeCheck
(
$filter
)
public
function
testConstructorFilterArgumentTypeCheck
(
$filter
)
...
@@ -16,7 +16,7 @@ class CountTest extends TestCase
...
@@ -16,7 +16,7 @@ class CountTest extends TestCase
}
}
/**
/**
* @expectedException MongoDB\Exception\InvalidArgument
Type
Exception
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidConstructorOptions
* @dataProvider provideInvalidConstructorOptions
*/
*/
public
function
testConstructorOptionTypeChecks
(
array
$options
)
public
function
testConstructorOptionTypeChecks
(
array
$options
)
...
...
tests/Operation/CreateIndexesTest.php
View file @
8f646a38
...
@@ -25,7 +25,7 @@ class CreateIndexesTest extends TestCase
...
@@ -25,7 +25,7 @@ class CreateIndexesTest extends TestCase
}
}
/**
/**
* @expectedException MongoDB\Exception\InvalidArgument
Type
Exception
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidIndexSpecificationTypes
* @dataProvider provideInvalidIndexSpecificationTypes
*/
*/
public
function
testCreateIndexesRequiresIndexSpecificationsToBeAnArray
(
$index
)
public
function
testCreateIndexesRequiresIndexSpecificationsToBeAnArray
(
$index
)
...
...
tests/Operation/DatabaseCommandTest.php
View file @
8f646a38
...
@@ -7,7 +7,7 @@ use MongoDB\Operation\DatabaseCommand;
...
@@ -7,7 +7,7 @@ use MongoDB\Operation\DatabaseCommand;
class
DatabaseCommandTest
extends
TestCase
class
DatabaseCommandTest
extends
TestCase
{
{
/**
/**
* @expectedException MongoDB\Exception\InvalidArgument
Type
Exception
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidDocumentValues
* @dataProvider provideInvalidDocumentValues
*/
*/
public
function
testConstructorCommandArgumentTypeCheck
(
$command
)
public
function
testConstructorCommandArgumentTypeCheck
(
$command
)
...
@@ -16,7 +16,7 @@ class DatabaseCommandTest extends TestCase
...
@@ -16,7 +16,7 @@ class DatabaseCommandTest extends TestCase
}
}
/**
/**
* @expectedException MongoDB\Exception\InvalidArgument
Type
Exception
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidConstructorOptions
* @dataProvider provideInvalidConstructorOptions
*/
*/
public
function
testConstructorOptionTypeChecks
(
array
$options
)
public
function
testConstructorOptionTypeChecks
(
array
$options
)
...
...
tests/Operation/DeleteTest.php
View file @
8f646a38
...
@@ -7,7 +7,7 @@ use MongoDB\Operation\Delete;
...
@@ -7,7 +7,7 @@ use MongoDB\Operation\Delete;
class
DeleteTest
extends
TestCase
class
DeleteTest
extends
TestCase
{
{
/**
/**
* @expectedException MongoDB\Exception\InvalidArgument
Type
Exception
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidDocumentValues
* @dataProvider provideInvalidDocumentValues
*/
*/
public
function
testConstructorFilterArgumentTypeCheck
(
$filter
)
public
function
testConstructorFilterArgumentTypeCheck
(
$filter
)
...
@@ -31,7 +31,7 @@ class DeleteTest extends TestCase
...
@@ -31,7 +31,7 @@ class DeleteTest extends TestCase
}
}
/**
/**
* @expectedException MongoDB\Exception\InvalidArgument
Type
Exception
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidConstructorOptions
* @dataProvider provideInvalidConstructorOptions
*/
*/
public
function
testConstructorOptionTypeChecks
(
array
$options
)
public
function
testConstructorOptionTypeChecks
(
array
$options
)
...
...
tests/Operation/DistinctTest.php
View file @
8f646a38
...
@@ -7,7 +7,7 @@ use MongoDB\Operation\Distinct;
...
@@ -7,7 +7,7 @@ use MongoDB\Operation\Distinct;
class
DistinctTest
extends
TestCase
class
DistinctTest
extends
TestCase
{
{
/**
/**
* @expectedException MongoDB\Exception\InvalidArgument
Type
Exception
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidDocumentValues
* @dataProvider provideInvalidDocumentValues
*/
*/
public
function
testConstructorFilterArgumentTypeCheck
(
$filter
)
public
function
testConstructorFilterArgumentTypeCheck
(
$filter
)
...
@@ -16,7 +16,7 @@ class DistinctTest extends TestCase
...
@@ -16,7 +16,7 @@ class DistinctTest extends TestCase
}
}
/**
/**
* @expectedException MongoDB\Exception\InvalidArgument
Type
Exception
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidConstructorOptions
* @dataProvider provideInvalidConstructorOptions
*/
*/
public
function
testConstructorOptionTypeChecks
(
array
$options
)
public
function
testConstructorOptionTypeChecks
(
array
$options
)
...
...
tests/Operation/FindAndModifyTest.php
View file @
8f646a38
...
@@ -7,7 +7,7 @@ use MongoDB\Operation\FindAndModify;
...
@@ -7,7 +7,7 @@ use MongoDB\Operation\FindAndModify;
class
FindAndModifyTest
extends
TestCase
class
FindAndModifyTest
extends
TestCase
{
{
/**
/**
* @expectedException MongoDB\Exception\InvalidArgument
Type
Exception
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidConstructorOptions
* @dataProvider provideInvalidConstructorOptions
*/
*/
public
function
testConstructorOptionTypeChecks
(
array
$options
)
public
function
testConstructorOptionTypeChecks
(
array
$options
)
...
...
tests/Operation/FindOneAndDeleteTest.php
View file @
8f646a38
...
@@ -7,7 +7,7 @@ use MongoDB\Operation\FindOneAndDelete;
...
@@ -7,7 +7,7 @@ use MongoDB\Operation\FindOneAndDelete;
class
FindOneAndDeleteTest
extends
TestCase
class
FindOneAndDeleteTest
extends
TestCase
{
{
/**
/**
* @expectedException MongoDB\Exception\InvalidArgument
Type
Exception
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidDocumentValues
* @dataProvider provideInvalidDocumentValues
*/
*/
public
function
testConstructorFilterArgumentTypeCheck
(
$filter
)
public
function
testConstructorFilterArgumentTypeCheck
(
$filter
)
...
@@ -16,7 +16,7 @@ class FindOneAndDeleteTest extends TestCase
...
@@ -16,7 +16,7 @@ class FindOneAndDeleteTest extends TestCase
}
}
/**
/**
* @expectedException MongoDB\Exception\InvalidArgument
Type
Exception
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidConstructorOptions
* @dataProvider provideInvalidConstructorOptions
*/
*/
public
function
testConstructorOptionTypeChecks
(
array
$options
)
public
function
testConstructorOptionTypeChecks
(
array
$options
)
...
...
tests/Operation/FindOneAndReplaceTest.php
View file @
8f646a38
...
@@ -7,7 +7,7 @@ use MongoDB\Operation\FindOneAndReplace;
...
@@ -7,7 +7,7 @@ use MongoDB\Operation\FindOneAndReplace;
class
FindOneAndReplaceTest
extends
TestCase
class
FindOneAndReplaceTest
extends
TestCase
{
{
/**
/**
* @expectedException MongoDB\Exception\InvalidArgument
Type
Exception
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidDocumentValues
* @dataProvider provideInvalidDocumentValues
*/
*/
public
function
testConstructorFilterArgumentTypeCheck
(
$filter
)
public
function
testConstructorFilterArgumentTypeCheck
(
$filter
)
...
@@ -16,7 +16,7 @@ class FindOneAndReplaceTest extends TestCase
...
@@ -16,7 +16,7 @@ class FindOneAndReplaceTest extends TestCase
}
}
/**
/**
* @expectedException MongoDB\Exception\InvalidArgument
Type
Exception
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidDocumentValues
* @dataProvider provideInvalidDocumentValues
*/
*/
public
function
testConstructorReplacementArgumentTypeCheck
(
$replacement
)
public
function
testConstructorReplacementArgumentTypeCheck
(
$replacement
)
...
@@ -34,7 +34,7 @@ class FindOneAndReplaceTest extends TestCase
...
@@ -34,7 +34,7 @@ class FindOneAndReplaceTest extends TestCase
}
}
/**
/**
* @expectedException MongoDB\Exception\InvalidArgument
Type
Exception
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidConstructorOptions
* @dataProvider provideInvalidConstructorOptions
*/
*/
public
function
testConstructorOptionTypeChecks
(
array
$options
)
public
function
testConstructorOptionTypeChecks
(
array
$options
)
...
...
tests/Operation/FindOneAndUpdateTest.php
View file @
8f646a38
...
@@ -7,7 +7,7 @@ use MongoDB\Operation\FindOneAndUpdate;
...
@@ -7,7 +7,7 @@ use MongoDB\Operation\FindOneAndUpdate;
class
FindOneAndUpdateTest
extends
TestCase
class
FindOneAndUpdateTest
extends
TestCase
{
{
/**
/**
* @expectedException MongoDB\Exception\InvalidArgument
Type
Exception
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidDocumentValues
* @dataProvider provideInvalidDocumentValues
*/
*/
public
function
testConstructorFilterArgumentTypeCheck
(
$filter
)
public
function
testConstructorFilterArgumentTypeCheck
(
$filter
)
...
@@ -16,7 +16,7 @@ class FindOneAndUpdateTest extends TestCase
...
@@ -16,7 +16,7 @@ class FindOneAndUpdateTest extends TestCase
}
}
/**
/**
* @expectedException MongoDB\Exception\InvalidArgument
Type
Exception
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidDocumentValues
* @dataProvider provideInvalidDocumentValues
*/
*/
public
function
testConstructorUpdateArgumentTypeCheck
(
$update
)
public
function
testConstructorUpdateArgumentTypeCheck
(
$update
)
...
@@ -34,7 +34,7 @@ class FindOneAndUpdateTest extends TestCase
...
@@ -34,7 +34,7 @@ class FindOneAndUpdateTest extends TestCase
}
}
/**
/**
* @expectedException MongoDB\Exception\InvalidArgument
Type
Exception
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidConstructorOptions
* @dataProvider provideInvalidConstructorOptions
*/
*/
public
function
testConstructorOptionTypeChecks
(
array
$options
)
public
function
testConstructorOptionTypeChecks
(
array
$options
)
...
...
tests/Operation/FindTest.php
View file @
8f646a38
...
@@ -7,7 +7,7 @@ use MongoDB\Operation\Find;
...
@@ -7,7 +7,7 @@ use MongoDB\Operation\Find;
class
FindTest
extends
TestCase
class
FindTest
extends
TestCase
{
{
/**
/**
* @expectedException MongoDB\Exception\InvalidArgument
Type
Exception
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidDocumentValues
* @dataProvider provideInvalidDocumentValues
*/
*/
public
function
testConstructorFilterArgumentTypeCheck
(
$filter
)
public
function
testConstructorFilterArgumentTypeCheck
(
$filter
)
...
@@ -16,7 +16,7 @@ class FindTest extends TestCase
...
@@ -16,7 +16,7 @@ class FindTest extends TestCase
}
}
/**
/**
* @expectedException MongoDB\Exception\InvalidArgument
Type
Exception
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidConstructorOptions
* @dataProvider provideInvalidConstructorOptions
*/
*/
public
function
testConstructorOptionTypeChecks
(
array
$options
)
public
function
testConstructorOptionTypeChecks
(
array
$options
)
...
...
tests/Operation/InsertManyTest.php
View file @
8f646a38
...
@@ -25,7 +25,7 @@ class InsertManyTest extends TestCase
...
@@ -25,7 +25,7 @@ class InsertManyTest extends TestCase
}
}
/**
/**
* @expectedException MongoDB\Exception\InvalidArgument
Type
Exception
* @expectedException MongoDB\Exception\InvalidArgumentException
* @expectedExceptionMessageRegExp /Expected \$documents\[0\] to have type "array or object" but found "[\w ]+"/
* @expectedExceptionMessageRegExp /Expected \$documents\[0\] to have type "array or object" but found "[\w ]+"/
* @dataProvider provideInvalidDocumentValues
* @dataProvider provideInvalidDocumentValues
*/
*/
...
@@ -35,7 +35,7 @@ class InsertManyTest extends TestCase
...
@@ -35,7 +35,7 @@ class InsertManyTest extends TestCase
}
}
/**
/**
* @expectedException MongoDB\Exception\InvalidArgument
Type
Exception
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidConstructorOptions
* @dataProvider provideInvalidConstructorOptions
*/
*/
public
function
testConstructorOptionTypeChecks
(
array
$options
)
public
function
testConstructorOptionTypeChecks
(
array
$options
)
...
...
tests/Operation/InsertOneTest.php
View file @
8f646a38
...
@@ -7,7 +7,7 @@ use MongoDB\Operation\InsertOne;
...
@@ -7,7 +7,7 @@ use MongoDB\Operation\InsertOne;
class
InsertOneTest
extends
TestCase
class
InsertOneTest
extends
TestCase
{
{
/**
/**
* @expectedException MongoDB\Exception\InvalidArgument
Type
Exception
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidDocumentValues
* @dataProvider provideInvalidDocumentValues
*/
*/
public
function
testConstructorDocumentArgumentTypeCheck
(
$document
)
public
function
testConstructorDocumentArgumentTypeCheck
(
$document
)
...
@@ -16,7 +16,7 @@ class InsertOneTest extends TestCase
...
@@ -16,7 +16,7 @@ class InsertOneTest extends TestCase
}
}
/**
/**
* @expectedException MongoDB\Exception\InvalidArgument
Type
Exception
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidConstructorOptions
* @dataProvider provideInvalidConstructorOptions
*/
*/
public
function
testConstructorOptionTypeChecks
(
array
$options
)
public
function
testConstructorOptionTypeChecks
(
array
$options
)
...
...
tests/Operation/ReplaceOneTest.php
View file @
8f646a38
...
@@ -7,7 +7,7 @@ use MongoDB\Operation\ReplaceOne;
...
@@ -7,7 +7,7 @@ use MongoDB\Operation\ReplaceOne;
class
ReplaceOneTest
extends
TestCase
class
ReplaceOneTest
extends
TestCase
{
{
/**
/**
* @expectedException MongoDB\Exception\InvalidArgument
Type
Exception
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidDocumentValues
* @dataProvider provideInvalidDocumentValues
*/
*/
public
function
testConstructorFilterArgumentTypeCheck
(
$filter
)
public
function
testConstructorFilterArgumentTypeCheck
(
$filter
)
...
@@ -16,7 +16,7 @@ class ReplaceOneTest extends TestCase
...
@@ -16,7 +16,7 @@ class ReplaceOneTest extends TestCase
}
}
/**
/**
* @expectedException MongoDB\Exception\InvalidArgument
Type
Exception
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidDocumentValues
* @dataProvider provideInvalidDocumentValues
*/
*/
public
function
testConstructorReplacementArgumentTypeCheck
(
$replacement
)
public
function
testConstructorReplacementArgumentTypeCheck
(
$replacement
)
...
...
tests/Operation/UpdateManyTest.php
View file @
8f646a38
...
@@ -7,7 +7,7 @@ use MongoDB\Operation\UpdateMany;
...
@@ -7,7 +7,7 @@ use MongoDB\Operation\UpdateMany;
class
UpdateManyTest
extends
TestCase
class
UpdateManyTest
extends
TestCase
{
{
/**
/**
* @expectedException MongoDB\Exception\InvalidArgument
Type
Exception
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidDocumentValues
* @dataProvider provideInvalidDocumentValues
*/
*/
public
function
testConstructorFilterArgumentTypeCheck
(
$filter
)
public
function
testConstructorFilterArgumentTypeCheck
(
$filter
)
...
@@ -16,7 +16,7 @@ class UpdateManyTest extends TestCase
...
@@ -16,7 +16,7 @@ class UpdateManyTest extends TestCase
}
}
/**
/**
* @expectedException MongoDB\Exception\InvalidArgument
Type
Exception
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidDocumentValues
* @dataProvider provideInvalidDocumentValues
*/
*/
public
function
testConstructorUpdateArgumentTypeCheck
(
$update
)
public
function
testConstructorUpdateArgumentTypeCheck
(
$update
)
...
...
tests/Operation/UpdateOneTest.php
View file @
8f646a38
...
@@ -7,7 +7,7 @@ use MongoDB\Operation\UpdateOne;
...
@@ -7,7 +7,7 @@ use MongoDB\Operation\UpdateOne;
class
UpdateOneTest
extends
TestCase
class
UpdateOneTest
extends
TestCase
{
{
/**
/**
* @expectedException MongoDB\Exception\InvalidArgument
Type
Exception
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidDocumentValues
* @dataProvider provideInvalidDocumentValues
*/
*/
public
function
testConstructorFilterArgumentTypeCheck
(
$filter
)
public
function
testConstructorFilterArgumentTypeCheck
(
$filter
)
...
@@ -16,7 +16,7 @@ class UpdateOneTest extends TestCase
...
@@ -16,7 +16,7 @@ class UpdateOneTest extends TestCase
}
}
/**
/**
* @expectedException MongoDB\Exception\InvalidArgument
Type
Exception
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidDocumentValues
* @dataProvider provideInvalidDocumentValues
*/
*/
public
function
testConstructorUpdateArgumentTypeCheck
(
$update
)
public
function
testConstructorUpdateArgumentTypeCheck
(
$update
)
...
...
tests/Operation/UpdateTest.php
View file @
8f646a38
...
@@ -7,7 +7,7 @@ use MongoDB\Operation\Update;
...
@@ -7,7 +7,7 @@ use MongoDB\Operation\Update;
class
UpdateTest
extends
TestCase
class
UpdateTest
extends
TestCase
{
{
/**
/**
* @expectedException MongoDB\Exception\InvalidArgument
Type
Exception
* @expectedException MongoDB\Exception\InvalidArgumentException
* @expectedExceptionMessageRegExp /Expected \$filter to have type "array or object" but found "[\w ]+"/
* @expectedExceptionMessageRegExp /Expected \$filter to have type "array or object" but found "[\w ]+"/
* @dataProvider provideInvalidDocumentValues
* @dataProvider provideInvalidDocumentValues
*/
*/
...
@@ -17,7 +17,7 @@ class UpdateTest extends TestCase
...
@@ -17,7 +17,7 @@ class UpdateTest extends TestCase
}
}
/**
/**
* @expectedException MongoDB\Exception\InvalidArgument
Type
Exception
* @expectedException MongoDB\Exception\InvalidArgumentException
* @expectedExceptionMessageRegExp /Expected \$update to have type "array or object" but found "[\w ]+"/
* @expectedExceptionMessageRegExp /Expected \$update to have type "array or object" but found "[\w ]+"/
* @dataProvider provideInvalidDocumentValues
* @dataProvider provideInvalidDocumentValues
*/
*/
...
@@ -27,7 +27,7 @@ class UpdateTest extends TestCase
...
@@ -27,7 +27,7 @@ class UpdateTest extends TestCase
}
}
/**
/**
* @expectedException MongoDB\Exception\InvalidArgument
Type
Exception
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidConstructorOptions
* @dataProvider provideInvalidConstructorOptions
*/
*/
public
function
testConstructorOptionTypeChecks
(
array
$options
)
public
function
testConstructorOptionTypeChecks
(
array
$options
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment