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
86ff7317
Unverified
Commit
86ff7317
authored
Nov 11, 2019
by
Andreas Braun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PHPLIB-494: Fix validation of options with default values
parent
fca04ae1
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
9 deletions
+13
-9
Client.php
src/Client.php
+1
-1
Bucket.php
src/GridFS/Bucket.php
+4
-4
WritableStream.php
src/GridFS/WritableStream.php
+3
-3
Watch.php
src/Operation/Watch.php
+5
-1
No files found.
src/Client.php
View file @
86ff7317
...
...
@@ -95,7 +95,7 @@ class Client
{
$driverOptions
+=
[
'typeMap'
=>
self
::
$defaultTypeMap
];
if
(
isset
(
$driverOptions
[
'typeMap'
])
&&
!
is_array
(
$driverOptions
[
'typeMap'
]))
{
if
(
!
is_array
(
$driverOptions
[
'typeMap'
]))
{
throw
InvalidArgumentException
::
invalidType
(
'"typeMap" driver option'
,
$driverOptions
[
'typeMap'
],
'array'
);
}
...
...
src/GridFS/Bucket.php
View file @
86ff7317
...
...
@@ -143,19 +143,19 @@ class Bucket
'disableMD5'
=>
false
,
];
if
(
isset
(
$options
[
'bucketName'
])
&&
!
is_string
(
$options
[
'bucketName'
]))
{
if
(
!
is_string
(
$options
[
'bucketName'
]))
{
throw
InvalidArgumentException
::
invalidType
(
'"bucketName" option'
,
$options
[
'bucketName'
],
'string'
);
}
if
(
isset
(
$options
[
'chunkSizeBytes'
])
&&
!
is_integer
(
$options
[
'chunkSizeBytes'
]))
{
if
(
!
is_integer
(
$options
[
'chunkSizeBytes'
]))
{
throw
InvalidArgumentException
::
invalidType
(
'"chunkSizeBytes" option'
,
$options
[
'chunkSizeBytes'
],
'integer'
);
}
if
(
isset
(
$options
[
'chunkSizeBytes'
])
&&
$options
[
'chunkSizeBytes'
]
<
1
)
{
if
(
$options
[
'chunkSizeBytes'
]
<
1
)
{
throw
new
InvalidArgumentException
(
sprintf
(
'Expected "chunkSizeBytes" option to be >= 1, %d given'
,
$options
[
'chunkSizeBytes'
]));
}
if
(
isset
(
$options
[
'disableMD5'
])
&&
!
is_bool
(
$options
[
'disableMD5'
]))
{
if
(
!
is_bool
(
$options
[
'disableMD5'
]))
{
throw
InvalidArgumentException
::
invalidType
(
'"disableMD5" option'
,
$options
[
'disableMD5'
],
'boolean'
);
}
...
...
src/GridFS/WritableStream.php
View file @
86ff7317
...
...
@@ -114,15 +114,15 @@ class WritableStream
throw
InvalidArgumentException
::
invalidType
(
'"aliases" option'
,
$options
[
'aliases'
],
'array of strings'
);
}
if
(
isset
(
$options
[
'chunkSizeBytes'
])
&&
!
is_integer
(
$options
[
'chunkSizeBytes'
]))
{
if
(
!
is_integer
(
$options
[
'chunkSizeBytes'
]))
{
throw
InvalidArgumentException
::
invalidType
(
'"chunkSizeBytes" option'
,
$options
[
'chunkSizeBytes'
],
'integer'
);
}
if
(
isset
(
$options
[
'chunkSizeBytes'
])
&&
$options
[
'chunkSizeBytes'
]
<
1
)
{
if
(
$options
[
'chunkSizeBytes'
]
<
1
)
{
throw
new
InvalidArgumentException
(
sprintf
(
'Expected "chunkSizeBytes" option to be >= 1, %d given'
,
$options
[
'chunkSizeBytes'
]));
}
if
(
isset
(
$options
[
'disableMD5'
])
&&
!
is_bool
(
$options
[
'disableMD5'
]))
{
if
(
!
is_bool
(
$options
[
'disableMD5'
]))
{
throw
InvalidArgumentException
::
invalidType
(
'"disableMD5" option'
,
$options
[
'disableMD5'
],
'boolean'
);
}
...
...
src/Operation/Watch.php
View file @
86ff7317
...
...
@@ -178,10 +178,14 @@ class Watch implements Executable, /* @internal */ CommandSubscriber
'readPreference'
=>
new
ReadPreference
(
ReadPreference
::
RP_PRIMARY
),
];
if
(
isset
(
$options
[
'fullDocument'
])
&&
!
is_string
(
$options
[
'fullDocument'
]))
{
if
(
!
is_string
(
$options
[
'fullDocument'
]))
{
throw
InvalidArgumentException
::
invalidType
(
'"fullDocument" option'
,
$options
[
'fullDocument'
],
'string'
);
}
if
(
!
$options
[
'readPreference'
]
instanceof
ReadPreference
)
{
throw
InvalidArgumentException
::
invalidType
(
'"readPreference" option'
,
$options
[
'readPreference'
],
ReadPreference
::
class
);
}
if
(
isset
(
$options
[
'resumeAfter'
])
&&
!
is_array
(
$options
[
'resumeAfter'
])
&&
!
is_object
(
$options
[
'resumeAfter'
]))
{
throw
InvalidArgumentException
::
invalidType
(
'"resumeAfter" option'
,
$options
[
'resumeAfter'
],
'array or object'
);
}
...
...
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