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
bcae84ce
Commit
bcae84ce
authored
Apr 26, 2015
by
Jeremy Mikola
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PHPLIB-77: Use namespaced exceptions
parent
5b6f54e3
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
31 additions
and
16 deletions
+31
-16
Client.php
src/Client.php
+1
-2
Collection.php
src/Collection.php
+13
-13
Database.php
src/Database.php
+1
-1
RuntimeException.php
src/Exception/RuntimeException.php
+7
-0
UnexpectedValueException.php
src/Exception/UnexpectedValueException.php
+7
-0
IndexInput.php
src/Model/IndexInput.php
+2
-0
No files found.
src/Client.php
View file @
bcae84ce
...
@@ -7,10 +7,9 @@ use MongoDB\Driver\Cursor;
...
@@ -7,10 +7,9 @@ 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\UnexpectedValueException
;
use
MongoDB\Model\DatabaseInfoIterator
;
use
MongoDB\Model\DatabaseInfoIterator
;
use
MongoDB\Model\DatabaseInfoLegacyIterator
;
use
MongoDB\Model\DatabaseInfoLegacyIterator
;
use
stdClass
;
use
UnexpectedValueException
;
class
Client
class
Client
{
{
...
...
src/Collection.php
View file @
bcae84ce
...
@@ -163,7 +163,7 @@ class Collection
...
@@ -163,7 +163,7 @@ class Collection
foreach
(
$bulk
as
$n
=>
$op
)
{
foreach
(
$bulk
as
$n
=>
$op
)
{
foreach
(
$op
as
$opname
=>
$args
)
{
foreach
(
$op
as
$opname
=>
$args
)
{
if
(
!
isset
(
$args
[
0
]))
{
if
(
!
isset
(
$args
[
0
]))
{
throw
new
\
InvalidArgumentException
(
sprintf
(
"Missing argument#1 for '%s' (operation#%d)"
,
$opname
,
$n
));
throw
new
InvalidArgumentException
(
sprintf
(
"Missing argument#1 for '%s' (operation#%d)"
,
$opname
,
$n
));
}
}
switch
(
$opname
)
{
switch
(
$opname
)
{
...
@@ -173,7 +173,7 @@ class Collection
...
@@ -173,7 +173,7 @@ class Collection
case
"updateMany"
:
case
"updateMany"
:
if
(
!
isset
(
$args
[
1
]))
{
if
(
!
isset
(
$args
[
1
]))
{
throw
new
\
InvalidArgumentException
(
sprintf
(
"Missing argument#2 for '%s' (operation#%d)"
,
$opname
,
$n
));
throw
new
InvalidArgumentException
(
sprintf
(
"Missing argument#2 for '%s' (operation#%d)"
,
$opname
,
$n
));
}
}
$options
=
array_merge
(
$this
->
getWriteOptions
(),
isset
(
$args
[
2
])
?
$args
[
2
]
:
array
(),
array
(
"limit"
=>
0
));
$options
=
array_merge
(
$this
->
getWriteOptions
(),
isset
(
$args
[
2
])
?
$args
[
2
]
:
array
(),
array
(
"limit"
=>
0
));
...
@@ -182,12 +182,12 @@ class Collection
...
@@ -182,12 +182,12 @@ class Collection
case
"updateOne"
:
case
"updateOne"
:
if
(
!
isset
(
$args
[
1
]))
{
if
(
!
isset
(
$args
[
1
]))
{
throw
new
\
InvalidArgumentException
(
sprintf
(
"Missing argument#2 for '%s' (operation#%d)"
,
$opname
,
$n
));
throw
new
InvalidArgumentException
(
sprintf
(
"Missing argument#2 for '%s' (operation#%d)"
,
$opname
,
$n
));
}
}
$options
=
array_merge
(
$this
->
getWriteOptions
(),
isset
(
$args
[
2
])
?
$args
[
2
]
:
array
(),
array
(
"limit"
=>
1
));
$options
=
array_merge
(
$this
->
getWriteOptions
(),
isset
(
$args
[
2
])
?
$args
[
2
]
:
array
(),
array
(
"limit"
=>
1
));
$firstKey
=
key
(
$args
[
1
]);
$firstKey
=
key
(
$args
[
1
]);
if
(
!
isset
(
$firstKey
[
0
])
||
$firstKey
[
0
]
!=
'$'
)
{
if
(
!
isset
(
$firstKey
[
0
])
||
$firstKey
[
0
]
!=
'$'
)
{
throw
new
\
InvalidArgumentException
(
"First key in
\$
update must be a
\$
operator"
);
throw
new
InvalidArgumentException
(
"First key in
\$
update must be a
\$
operator"
);
}
}
$bulk
->
update
(
$args
[
0
],
$args
[
1
],
$options
);
$bulk
->
update
(
$args
[
0
],
$args
[
1
],
$options
);
...
@@ -195,12 +195,12 @@ class Collection
...
@@ -195,12 +195,12 @@ class Collection
case
"replaceOne"
:
case
"replaceOne"
:
if
(
!
isset
(
$args
[
1
]))
{
if
(
!
isset
(
$args
[
1
]))
{
throw
new
\
InvalidArgumentException
(
sprintf
(
"Missing argument#2 for '%s' (operation#%d)"
,
$opname
,
$n
));
throw
new
InvalidArgumentException
(
sprintf
(
"Missing argument#2 for '%s' (operation#%d)"
,
$opname
,
$n
));
}
}
$options
=
array_merge
(
$this
->
getWriteOptions
(),
isset
(
$args
[
2
])
?
$args
[
2
]
:
array
(),
array
(
"limit"
=>
1
));
$options
=
array_merge
(
$this
->
getWriteOptions
(),
isset
(
$args
[
2
])
?
$args
[
2
]
:
array
(),
array
(
"limit"
=>
1
));
$firstKey
=
key
(
$args
[
1
]);
$firstKey
=
key
(
$args
[
1
]);
if
(
isset
(
$firstKey
[
0
])
&&
$firstKey
[
0
]
==
'$'
)
{
if
(
isset
(
$firstKey
[
0
])
&&
$firstKey
[
0
]
==
'$'
)
{
throw
new
\
InvalidArgumentException
(
"First key in
\$
update must NOT be a
\$
operator"
);
throw
new
InvalidArgumentException
(
"First key in
\$
update must NOT be a
\$
operator"
);
}
}
$bulk
->
update
(
$args
[
0
],
$args
[
1
],
$options
);
$bulk
->
update
(
$args
[
0
],
$args
[
1
],
$options
);
...
@@ -217,7 +217,7 @@ class Collection
...
@@ -217,7 +217,7 @@ class Collection
break
;
break
;
default
:
default
:
throw
new
\
InvalidArgumentException
(
sprintf
(
"Unknown operation type called '%s' (operation#%d)"
,
$opname
,
$n
));
throw
new
InvalidArgumentException
(
sprintf
(
"Unknown operation type called '%s' (operation#%d)"
,
$opname
,
$n
));
}
}
}
}
}
}
...
@@ -521,7 +521,7 @@ class Collection
...
@@ -521,7 +521,7 @@ class Collection
{
{
$firstKey
=
key
(
$replacement
);
$firstKey
=
key
(
$replacement
);
if
(
isset
(
$firstKey
[
0
])
&&
$firstKey
[
0
]
==
'$'
)
{
if
(
isset
(
$firstKey
[
0
])
&&
$firstKey
[
0
]
==
'$'
)
{
throw
new
\
InvalidArgumentException
(
"First key in
\$
replacement must NOT be a
\$
operator"
);
throw
new
InvalidArgumentException
(
"First key in
\$
replacement must NOT be a
\$
operator"
);
}
}
$options
=
array_merge
(
$this
->
getFindOneAndReplaceOptions
(),
$options
);
$options
=
array_merge
(
$this
->
getFindOneAndReplaceOptions
(),
$options
);
...
@@ -559,7 +559,7 @@ class Collection
...
@@ -559,7 +559,7 @@ class Collection
{
{
$firstKey
=
key
(
$update
);
$firstKey
=
key
(
$update
);
if
(
!
isset
(
$firstKey
[
0
])
||
$firstKey
[
0
]
!=
'$'
)
{
if
(
!
isset
(
$firstKey
[
0
])
||
$firstKey
[
0
]
!=
'$'
)
{
throw
new
\
InvalidArgumentException
(
"First key in
\$
update must be a
\$
operator"
);
throw
new
InvalidArgumentException
(
"First key in
\$
update must be a
\$
operator"
);
}
}
$options
=
array_merge
(
$this
->
getFindOneAndUpdateOptions
(),
$options
);
$options
=
array_merge
(
$this
->
getFindOneAndUpdateOptions
(),
$options
);
...
@@ -1036,7 +1036,7 @@ class Collection
...
@@ -1036,7 +1036,7 @@ class Collection
{
{
$firstKey
=
key
(
$update
);
$firstKey
=
key
(
$update
);
if
(
isset
(
$firstKey
[
0
])
&&
$firstKey
[
0
]
==
'$'
)
{
if
(
isset
(
$firstKey
[
0
])
&&
$firstKey
[
0
]
==
'$'
)
{
throw
new
\
InvalidArgumentException
(
"First key in
\$
update must NOT be a
\$
operator"
);
throw
new
InvalidArgumentException
(
"First key in
\$
update must NOT be a
\$
operator"
);
}
}
$wr
=
$this
->
_update
(
$filter
,
$update
,
$options
);
$wr
=
$this
->
_update
(
$filter
,
$update
,
$options
);
...
@@ -1078,7 +1078,7 @@ class Collection
...
@@ -1078,7 +1078,7 @@ class Collection
{
{
$firstKey
=
key
(
$update
);
$firstKey
=
key
(
$update
);
if
(
!
isset
(
$firstKey
[
0
])
||
$firstKey
[
0
]
!=
'$'
)
{
if
(
!
isset
(
$firstKey
[
0
])
||
$firstKey
[
0
]
!=
'$'
)
{
throw
new
\
InvalidArgumentException
(
"First key in
\$
update must be a
\$
operator"
);
throw
new
InvalidArgumentException
(
"First key in
\$
update must be a
\$
operator"
);
}
}
$wr
=
$this
->
_update
(
$filter
,
$update
,
$options
);
$wr
=
$this
->
_update
(
$filter
,
$update
,
$options
);
...
@@ -1134,10 +1134,10 @@ class Collection
...
@@ -1134,10 +1134,10 @@ class Collection
final
protected
function
_generateCommandException
(
$doc
)
final
protected
function
_generateCommandException
(
$doc
)
{
{
if
(
$doc
[
"errmsg"
])
{
if
(
$doc
[
"errmsg"
])
{
return
new
Exception
(
$doc
[
"errmsg"
]);
return
new
Runtime
Exception
(
$doc
[
"errmsg"
]);
}
}
var_dump
(
$doc
);
var_dump
(
$doc
);
return
new
\
Exception
(
"FIXME: Unknown error"
);
return
new
Runtime
Exception
(
"FIXME: Unknown error"
);
}
}
/**
/**
...
...
src/Database.php
View file @
bcae84ce
...
@@ -10,10 +10,10 @@ use MongoDB\Driver\Query;
...
@@ -10,10 +10,10 @@ use MongoDB\Driver\Query;
use
MongoDB\Driver\ReadPreference
;
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\Model\CollectionInfoIterator
;
use
MongoDB\Model\CollectionInfoIterator
;
use
MongoDB\Model\CollectionInfoCommandIterator
;
use
MongoDB\Model\CollectionInfoCommandIterator
;
use
MongoDB\Model\CollectionInfoLegacyIterator
;
use
MongoDB\Model\CollectionInfoLegacyIterator
;
use
InvalidArgumentException
;
class
Database
class
Database
{
{
...
...
src/Exception/RuntimeException.php
0 → 100644
View file @
bcae84ce
<?php
namespace
MongoDB\Exception
;
class
RuntimeException
extends
\RuntimeException
implements
Exception
{
}
src/Exception/UnexpectedValueException.php
0 → 100644
View file @
bcae84ce
<?php
namespace
MongoDB\Exception
;
class
UnexpectedValueException
extends
\UnexpectedValueException
implements
Exception
{
}
src/Model/IndexInput.php
View file @
bcae84ce
...
@@ -3,6 +3,8 @@
...
@@ -3,6 +3,8 @@
namespace
MongoDB\Model
;
namespace
MongoDB\Model
;
use
BSON\Serializable
;
use
BSON\Serializable
;
use
MongoDB\Exception\InvalidArgumentException
;
use
MongoDB\Exception\UnexpectedTypeException
;
/**
/**
* Index input model class.
* Index input model class.
...
...
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