@@ -55,7 +55,7 @@ |
||
55 | 55 | */ |
56 | 56 | protected function setWriteConcernFromParameters($wstring, $wtimeout = 0) |
57 | 57 | { |
58 | - if (! is_string($wstring) && ! is_int($wstring)) { |
|
58 | + if ( ! is_string($wstring) && ! is_int($wstring)) { |
|
59 | 59 | trigger_error("w for WriteConcern must be a string or integer", E_WARNING); |
60 | 60 | return false; |
61 | 61 | } |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | /** |
33 | 33 | * @var MongoDB |
34 | 34 | */ |
35 | - public $db = NULL; |
|
35 | + public $db = null; |
|
36 | 36 | |
37 | 37 | /** |
38 | 38 | * @var string |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | foreach (func_get_args() as $operator) { |
134 | 134 | $i++; |
135 | 135 | if (! is_array($operator)) { |
136 | - trigger_error("Argument $i is not an array", E_WARNING); |
|
136 | + trigger_error("argument $i is not an array", E_WARNING); |
|
137 | 137 | return; |
138 | 138 | } |
139 | 139 | |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | * @param bool $scan_data Only validate indices, not the base collection. |
235 | 235 | * @return array Returns the database's evaluation of this object. |
236 | 236 | */ |
237 | - public function validate($scan_data = FALSE) |
|
237 | + public function validate($scan_data = false) |
|
238 | 238 | { |
239 | 239 | $command = [ |
240 | 240 | 'validate' => $this->name, |
@@ -447,7 +447,7 @@ discard block |
||
447 | 447 | * @link http://www.php.net/manual/en/mongocollection.createindex.php |
448 | 448 | * @param array $keys Field or fields to use as index. |
449 | 449 | * @param array $options [optional] This parameter is an associative array of the form array("optionname" => <boolean>, ...). |
450 | - * @return array Returns the database response. |
|
450 | + * @return string|false Returns the database response. |
|
451 | 451 | * |
452 | 452 | * @todo This method does not yet return the correct result |
453 | 453 | */ |
@@ -547,7 +547,7 @@ discard block |
||
547 | 547 | * @throws MongoException if the inserted document is empty or if it contains zero-length keys. Attempting to insert an object with protected and private properties will cause a zero-length key error. |
548 | 548 | * @throws MongoCursorException if the "w" option is set and the write fails. |
549 | 549 | * @throws MongoCursorTimeoutException if the "w" option is set to a value greater than one and the operation takes longer than MongoCursor::$timeout milliseconds to complete. This does not kill the operation on the server, it is a client-side timeout. The operation in MongoCollection::$wtimeout is milliseconds. |
550 | - * @return array|boolean If w was set, returns an array containing the status of the save. |
|
550 | + * @return MongoDB\UpdateResult If w was set, returns an array containing the status of the save. |
|
551 | 551 | * Otherwise, returns a boolean representing if the array was not empty (an empty array will not be inserted). |
552 | 552 | */ |
553 | 553 | public function save($a, array $options = []) |
@@ -125,14 +125,14 @@ discard block |
||
125 | 125 | */ |
126 | 126 | public function aggregate(array $pipeline, array $op = []) |
127 | 127 | { |
128 | - if (! TypeConverter::isNumericArray($pipeline)) { |
|
128 | + if ( ! TypeConverter::isNumericArray($pipeline)) { |
|
129 | 129 | $pipeline = []; |
130 | 130 | $options = []; |
131 | 131 | |
132 | 132 | $i = 0; |
133 | 133 | foreach (func_get_args() as $operator) { |
134 | 134 | $i++; |
135 | - if (! is_array($operator)) { |
|
135 | + if ( ! is_array($operator)) { |
|
136 | 136 | trigger_error("Argument $i is not an array", E_WARNING); |
137 | 137 | return; |
138 | 138 | } |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | ]; |
171 | 171 | |
172 | 172 | // Convert cursor option |
173 | - if (! isset($options['cursor']) || $options['cursor'] === true || $options['cursor'] === []) { |
|
173 | + if ( ! isset($options['cursor']) || $options['cursor'] === true || $options['cursor'] === []) { |
|
174 | 174 | // Cursor option needs to be an object convert bools and empty arrays since those won't be handled by TypeConverter |
175 | 175 | $options['cursor'] = new \stdClass; |
176 | 176 | } |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | $this->convertWriteConcernOptions($options) |
263 | 263 | ); |
264 | 264 | |
265 | - if (! $result->isAcknowledged()) { |
|
265 | + if ( ! $result->isAcknowledged()) { |
|
266 | 266 | return true; |
267 | 267 | } |
268 | 268 | |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | $this->convertWriteConcernOptions($options) |
291 | 291 | ); |
292 | 292 | |
293 | - if (! $result->isAcknowledged()) { |
|
293 | + if ( ! $result->isAcknowledged()) { |
|
294 | 294 | return true; |
295 | 295 | } |
296 | 296 | |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | * @throws MongoCursorException |
315 | 315 | * @return boolean |
316 | 316 | */ |
317 | - public function update(array $criteria , array $newobj, array $options = []) |
|
317 | + public function update(array $criteria, array $newobj, array $options = []) |
|
318 | 318 | { |
319 | 319 | $multiple = isset($options['multiple']) ? $options['multiple'] : false; |
320 | 320 | $method = $multiple ? 'updateMany' : 'updateOne'; |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | $this->convertWriteConcernOptions($options) |
328 | 328 | ); |
329 | 329 | |
330 | - if (! $result->isAcknowledged()) { |
|
330 | + if ( ! $result->isAcknowledged()) { |
|
331 | 331 | return true; |
332 | 332 | } |
333 | 333 | |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | */ |
355 | 355 | public function remove(array $criteria = [], array $options = []) |
356 | 356 | { |
357 | - $multiple = isset($options['justOne']) ? !$options['justOne'] : false; |
|
357 | + $multiple = isset($options['justOne']) ? ! $options['justOne'] : false; |
|
358 | 358 | $method = $multiple ? 'deleteMany' : 'deleteOne'; |
359 | 359 | |
360 | 360 | return $this->collection->$method($criteria, $options); |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | */ |
371 | 371 | public function find(array $query = [], array $fields = []) |
372 | 372 | { |
373 | - $cursor = new MongoCursor($this->db->getConnection(), (string)$this, $query, $fields); |
|
373 | + $cursor = new MongoCursor($this->db->getConnection(), (string) $this, $query, $fields); |
|
374 | 374 | $cursor->setReadPreference($this->getReadPreference()); |
375 | 375 | |
376 | 376 | return $cursor; |
@@ -553,7 +553,7 @@ discard block |
||
553 | 553 | public function save($a, array $options = []) |
554 | 554 | { |
555 | 555 | if (is_object($a)) { |
556 | - $a = (array)$a; |
|
556 | + $a = (array) $a; |
|
557 | 557 | } |
558 | 558 | if ( ! array_key_exists('_id', $a)) { |
559 | 559 | $id = new \MongoId(); |
@@ -626,14 +626,14 @@ discard block |
||
626 | 626 | $command = [ |
627 | 627 | 'group' => [ |
628 | 628 | 'ns' => $this->name, |
629 | - '$reduce' => (string)$reduce, |
|
629 | + '$reduce' => (string) $reduce, |
|
630 | 630 | 'initial' => $initial, |
631 | 631 | 'cond' => $condition, |
632 | 632 | ], |
633 | 633 | ]; |
634 | 634 | |
635 | 635 | if ($keys instanceof MongoCode) { |
636 | - $command['group']['$keyf'] = (string)$keys; |
|
636 | + $command['group']['$keyf'] = (string) $keys; |
|
637 | 637 | } else { |
638 | 638 | $command['group']['key'] = $keys; |
639 | 639 | } |
@@ -642,7 +642,7 @@ discard block |
||
642 | 642 | } |
643 | 643 | if (array_key_exists('finalize', $condition)) { |
644 | 644 | if ($condition['finalize'] instanceof MongoCode) { |
645 | - $condition['finalize'] = (string)$condition['finalize']; |
|
645 | + $condition['finalize'] = (string) $condition['finalize']; |
|
646 | 646 | } |
647 | 647 | $command['group']['finalize'] = $condition['finalize']; |
648 | 648 | } |
@@ -694,11 +694,11 @@ discard block |
||
694 | 694 | $options['w'] = ($options['safe']) ? 1 : 0; |
695 | 695 | } |
696 | 696 | |
697 | - if (isset($options['wtimeout']) && !isset($options['wTimeoutMS'])) { |
|
697 | + if (isset($options['wtimeout']) && ! isset($options['wTimeoutMS'])) { |
|
698 | 698 | $options['wTimeoutMS'] = $options['wtimeout']; |
699 | 699 | } |
700 | 700 | |
701 | - if (isset($options['w']) || !isset($options['wTimeoutMS'])) { |
|
701 | + if (isset($options['w']) || ! isset($options['wTimeoutMS'])) { |
|
702 | 702 | $collectionWriteConcern = $this->getWriteConcern(); |
703 | 703 | $writeConcern = $this->createWriteConcernFromParameters( |
704 | 704 | isset($options['w']) ? $options['w'] : $collectionWriteConcern['w'], |
@@ -13,6 +13,7 @@ |
||
13 | 13 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
14 | 14 | */ |
15 | 15 | |
16 | -class MongoConnectionException extends MongoException { |
|
16 | +class MongoConnectionException extends MongoException |
|
17 | +{ |
|
17 | 18 | |
18 | 19 | } |
@@ -13,6 +13,7 @@ |
||
13 | 13 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
14 | 14 | */ |
15 | 15 | |
16 | -class MongoCursorException extends MongoException { |
|
16 | +class MongoCursorException extends MongoException |
|
17 | +{ |
|
17 | 18 | |
18 | 19 | } |
@@ -13,6 +13,7 @@ |
||
13 | 13 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
14 | 14 | */ |
15 | 15 | |
16 | -class MongoCursorTimeoutException extends MongoCursorException { |
|
16 | +class MongoCursorTimeoutException extends MongoCursorException |
|
17 | +{ |
|
17 | 18 | |
18 | 19 | } |
@@ -204,7 +204,7 @@ |
||
204 | 204 | * @param bool $backup_original_files [optional] <p>If original files should be backed up.</p> |
205 | 205 | * @return array <p>Returns db response.</p> |
206 | 206 | */ |
207 | - public function repair($preserve_cloned_files = FALSE, $backup_original_files = FALSE) |
|
207 | + public function repair($preserve_cloned_files = false, $backup_original_files = false) |
|
208 | 208 | { |
209 | 209 | return []; |
210 | 210 | } |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | |
133 | 133 | $collections = $this->db->listCollections($options); |
134 | 134 | |
135 | - $getCollectionInfo = function (CollectionInfo $collectionInfo) { |
|
135 | + $getCollectionInfo = function(CollectionInfo $collectionInfo) { |
|
136 | 136 | return [ |
137 | 137 | 'name' => $collectionInfo->getName(), |
138 | 138 | 'options' => $collectionInfo->getOptions(), |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | |
159 | 159 | $collections = $this->db->listCollections($options); |
160 | 160 | |
161 | - $getCollectionName = function (CollectionInfo $collectionInfo) { |
|
161 | + $getCollectionName = function(CollectionInfo $collectionInfo) { |
|
162 | 162 | return $collectionInfo->getName(); |
163 | 163 | }; |
164 | 164 | |
@@ -307,13 +307,13 @@ discard block |
||
307 | 307 | if ($document_or_id instanceof \MongoId) { |
308 | 308 | $id = $document_or_id; |
309 | 309 | } elseif (is_object($document_or_id)) { |
310 | - if (! isset($document_or_id->_id)) { |
|
310 | + if ( ! isset($document_or_id->_id)) { |
|
311 | 311 | return null; |
312 | 312 | } |
313 | 313 | |
314 | 314 | $id = $document_or_id->_id; |
315 | 315 | } elseif (is_array($document_or_id)) { |
316 | - if (! isset($document_or_id['_id'])) { |
|
316 | + if ( ! isset($document_or_id['_id'])) { |
|
317 | 317 | return null; |
318 | 318 | } |
319 | 319 |
@@ -77,7 +77,7 @@ |
||
77 | 77 | */ |
78 | 78 | public static function get($db, $ref) |
79 | 79 | { |
80 | - if (! static::isRef($ref)) { |
|
80 | + if ( ! static::isRef($ref)) { |
|
81 | 81 | return null; |
82 | 82 | } |
83 | 83 |
@@ -17,6 +17,7 @@ |
||
17 | 17 | * <p>(PECL mongo >= 1.5.0)</p> |
18 | 18 | * @link http://php.net/manual/en/class.mongoduplicatekeyexception.php |
19 | 19 | */ |
20 | -class MongoDuplicateKeyException extends MongoWriteConcernException { |
|
20 | +class MongoDuplicateKeyException extends MongoWriteConcernException |
|
21 | +{ |
|
21 | 22 | |
22 | 23 | } |
@@ -13,5 +13,6 @@ |
||
13 | 13 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
14 | 14 | */ |
15 | 15 | |
16 | -class MongoException extends Exception { |
|
16 | +class MongoException extends Exception |
|
17 | +{ |
|
17 | 18 | } |