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
0102fc8c
Commit
0102fc8c
authored
Dec 10, 2014
by
Hannes Magnusson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PHP-1332: Throw InvalidArgumentException on argument errors
parent
114d8f58
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
11 deletions
+11
-11
Collection.php
src/Collection.php
+11
-11
No files found.
src/Collection.php
View file @
0102fc8c
...
...
@@ -201,7 +201,7 @@ class Collection {
foreach
(
$bulk
as
$n
=>
$op
)
{
foreach
(
$op
as
$opname
=>
$args
)
{
if
(
!
isset
(
$args
[
0
]))
{
throw
\Runtime
Exception
(
sprintf
(
"Missing argument#1 for '%s' (operation#%d)"
,
$opname
,
$n
));
throw
new
\InvalidArgument
Exception
(
sprintf
(
"Missing argument#1 for '%s' (operation#%d)"
,
$opname
,
$n
));
}
switch
(
$opname
)
{
...
...
@@ -211,7 +211,7 @@ class Collection {
case
"updateMany"
:
if
(
!
isset
(
$args
[
1
]))
{
throw
\Runtime
Exception
(
sprintf
(
"Missing argument#2 for '%s' (operation#%d)"
,
$opname
,
$n
));
throw
new
\InvalidArgument
Exception
(
sprintf
(
"Missing argument#2 for '%s' (operation#%d)"
,
$opname
,
$n
));
}
$options
=
array_merge
(
$this
->
getWriteOptions
(),
isset
(
$args
[
2
])
?
$args
[
2
]
:
array
(),
array
(
"limit"
=>
0
));
...
...
@@ -220,11 +220,11 @@ class Collection {
case
"updateOne"
:
if
(
!
isset
(
$args
[
1
]))
{
throw
\Runtime
Exception
(
sprintf
(
"Missing argument#2 for '%s' (operation#%d)"
,
$opname
,
$n
));
throw
new
\InvalidArgument
Exception
(
sprintf
(
"Missing argument#2 for '%s' (operation#%d)"
,
$opname
,
$n
));
}
$options
=
array_merge
(
$this
->
getWriteOptions
(),
isset
(
$args
[
2
])
?
$args
[
2
]
:
array
(),
array
(
"limit"
=>
1
));
if
(
key
(
$args
[
1
])[
0
]
!=
'$'
)
{
throw
new
\
Runtime
Exception
(
"First key in
\$
update must be a
\$
operator"
);
throw
new
\
InvalidArgument
Exception
(
"First key in
\$
update must be a
\$
operator"
);
}
$batch
->
update
(
$args
[
0
],
$args
[
1
],
$options
);
...
...
@@ -232,11 +232,11 @@ class Collection {
case
"replaceOne"
:
if
(
!
isset
(
$args
[
1
]))
{
throw
\Runtime
Exception
(
sprintf
(
"Missing argument#2 for '%s' (operation#%d)"
,
$opname
,
$n
));
throw
new
\InvalidArgument
Exception
(
sprintf
(
"Missing argument#2 for '%s' (operation#%d)"
,
$opname
,
$n
));
}
$options
=
array_merge
(
$this
->
getWriteOptions
(),
isset
(
$args
[
2
])
?
$args
[
2
]
:
array
(),
array
(
"limit"
=>
1
));
if
(
key
(
$args
[
1
])[
0
]
==
'$'
)
{
throw
new
\
Runtime
Exception
(
"First key in
\$
update must NOT be a
\$
operator"
);
throw
new
\
InvalidArgument
Exception
(
"First key in
\$
update must NOT be a
\$
operator"
);
}
$batch
->
update
(
$args
[
0
],
$args
[
1
],
$options
);
...
...
@@ -253,7 +253,7 @@ class Collection {
break
;
default
:
throw
\Runtime
Exception
(
sprintf
(
"Unknown operation type called '%s' (operation#%d)"
,
$opname
,
$n
));
throw
new
\InvalidArgument
Exception
(
sprintf
(
"Unknown operation type called '%s' (operation#%d)"
,
$opname
,
$n
));
}
}
}
...
...
@@ -297,7 +297,7 @@ class Collection {
}
/* }}} */
function
replaceOne
(
array
$filter
,
array
$update
,
array
$options
=
array
())
{
/* {{{ */
if
(
key
(
$update
)[
0
]
==
'$'
)
{
throw
new
\
Runtime
Exception
(
"First key in
\$
update must NOT be a
\$
operator"
);
throw
new
\
InvalidArgument
Exception
(
"First key in
\$
update must NOT be a
\$
operator"
);
}
$wr
=
$this
->
_update
(
$filter
,
$update
,
$options
);
...
...
@@ -305,7 +305,7 @@ class Collection {
}
/* }}} */
function
updateOne
(
array
$filter
,
array
$update
,
array
$options
=
array
())
{
/* {{{ */
if
(
key
(
$update
)[
0
]
!=
'$'
)
{
throw
new
\
Runtime
Exception
(
"First key in
\$
update must be a
\$
operator"
);
throw
new
\
InvalidArgument
Exception
(
"First key in
\$
update must be a
\$
operator"
);
}
$wr
=
$this
->
_update
(
$filter
,
$update
,
$options
);
...
...
@@ -503,7 +503,7 @@ class Collection {
function
findOneAndReplace
(
array
$filter
,
array
$replacement
,
array
$options
=
array
())
{
/* {{{ */
if
(
key
(
$replacement
)[
0
]
==
'$'
)
{
throw
new
\
Runtime
Exception
(
"First key in
\$
replacement must NOT be a
\$
operator"
);
throw
new
\
InvalidArgument
Exception
(
"First key in
\$
replacement must NOT be a
\$
operator"
);
}
$options
=
array_merge
(
$this
->
getFindOneAndReplaceOptions
(),
$options
);
...
...
@@ -566,7 +566,7 @@ class Collection {
function
findOneAndUpdate
(
array
$filter
,
array
$update
,
array
$options
=
array
())
{
/* {{{ */
if
(
key
(
$update
)[
0
]
!=
'$'
)
{
throw
new
\
Runtime
Exception
(
"First key in
\$
update must be a
\$
operator"
);
throw
new
\
InvalidArgument
Exception
(
"First key in
\$
update must be a
\$
operator"
);
}
$options
=
array_merge
(
$this
->
getFindOneAndUpdateOptions
(),
$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