Completed
Pull Request — master (#159)
by
unknown
04:33
created
lib/Mongo/MongoCollection.php 2 patches
Doc Comments   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1018,6 +1018,9 @@  discard block
 block discarded – undo
1018 1018
         return null;
1019 1019
     }
1020 1020
 
1021
+    /**
1022
+     * @param string $name
1023
+     */
1021 1024
     private function checkCollectionName($name)
1022 1025
     {
1023 1026
         if (empty($name)) {
@@ -1028,7 +1031,7 @@  discard block
 block discarded – undo
1028 1031
     }
1029 1032
 
1030 1033
     /**
1031
-     * @return array
1034
+     * @return string[]
1032 1035
      */
1033 1036
     public function __sleep()
1034 1037
     {
Please login to merge, or discard this patch.
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
      */
131 131
     public function aggregate(array $pipeline, array $op = [])
132 132
     {
133
-        if (! TypeConverter::isNumericArray($pipeline)) {
133
+        if ( ! TypeConverter::isNumericArray($pipeline)) {
134 134
             $operators = func_get_args();
135 135
             $pipeline = [];
136 136
             $options = [];
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
             $i = 0;
139 139
             foreach ($operators as $operator) {
140 140
                 $i++;
141
-                if (! is_array($operator)) {
141
+                if ( ! is_array($operator)) {
142 142
                     trigger_error("Argument $i is not an array", E_USER_WARNING);
143 143
                     return;
144 144
                 }
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
                 'waitedMS' => 0,
171 171
             ];
172 172
         } catch (\MongoDB\Driver\Exception\Exception $e) {
173
-            throw ExceptionConverter::toLegacy($e,'MongoResultException');
173
+            throw ExceptionConverter::toLegacy($e, 'MongoResultException');
174 174
         }
175 175
     }
176 176
 
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
         ];
192 192
 
193 193
         // Convert cursor option
194
-        if (! isset($options['cursor'])) {
194
+        if ( ! isset($options['cursor'])) {
195 195
             $options['cursor'] = new \stdClass();
196 196
         }
197 197
 
@@ -277,12 +277,12 @@  discard block
 block discarded – undo
277 277
      */
278 278
     public function insert($a, array $options = [])
279 279
     {
280
-        if (! $this->ensureDocumentHasMongoId($a)) {
280
+        if ( ! $this->ensureDocumentHasMongoId($a)) {
281 281
             trigger_error(sprintf('%s(): expects parameter %d to be an array or object, %s given', __METHOD__, 1, gettype($a)), E_USER_WARNING);
282 282
             return;
283 283
         }
284 284
 
285
-        if (! count((array)$a)) {
285
+        if ( ! count((array) $a)) {
286 286
             throw new \MongoException('document must be an array or object');
287 287
         }
288 288
 
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
             throw ExceptionConverter::toLegacy($e);
296 296
         }
297 297
 
298
-        if (! $result->isAcknowledged()) {
298
+        if ( ! $result->isAcknowledged()) {
299 299
             return true;
300 300
         }
301 301
 
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
 
327 327
         foreach ($a as $key => $item) {
328 328
             try {
329
-                if (! $this->ensureDocumentHasMongoId($a[$key])) {
329
+                if ( ! $this->ensureDocumentHasMongoId($a[$key])) {
330 330
                     if ($continueOnError) {
331 331
                         unset($a[$key]);
332 332
                     } else {
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
             throw ExceptionConverter::toLegacy($e, 'MongoResultException');
351 351
         }
352 352
 
353
-        if (! $result->isAcknowledged()) {
353
+        if ( ! $result->isAcknowledged()) {
354 354
             return true;
355 355
         }
356 356
 
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
      * @throws MongoCursorException
375 375
      * @return boolean
376 376
      */
377
-    public function update(array $criteria , array $newobj, array $options = [])
377
+    public function update(array $criteria, array $newobj, array $options = [])
378 378
     {
379 379
         $multiple = isset($options['multiple']) ? $options['multiple'] : false;
380 380
         $isReplace = ! \MongoDB\is_first_key_operator($newobj);
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
             throw ExceptionConverter::toLegacy($e);
399 399
         }
400 400
 
401
-        if (! $result->isAcknowledged()) {
401
+        if ( ! $result->isAcknowledged()) {
402 402
             return true;
403 403
         }
404 404
 
@@ -425,7 +425,7 @@  discard block
 block discarded – undo
425 425
      */
426 426
     public function remove(array $criteria = [], array $options = [])
427 427
     {
428
-        $multiple = isset($options['justOne']) ? !$options['justOne'] : true;
428
+        $multiple = isset($options['justOne']) ? ! $options['justOne'] : true;
429 429
         $method = $multiple ? 'deleteMany' : 'deleteOne';
430 430
 
431 431
         try {
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
             throw ExceptionConverter::toLegacy($e);
439 439
         }
440 440
 
441
-        if (! $result->isAcknowledged()) {
441
+        if ( ! $result->isAcknowledged()) {
442 442
             return true;
443 443
         }
444 444
 
@@ -516,7 +516,7 @@  discard block
 block discarded – undo
516 516
 
517 517
                 $options['projection'] = TypeConverter::convertProjection($fields);
518 518
 
519
-                if (! \MongoDB\is_first_key_operator($update)) {
519
+                if ( ! \MongoDB\is_first_key_operator($update)) {
520 520
                     $document = $this->collection->findOneAndReplace($query, $update, $options);
521 521
                 } else {
522 522
                     $document = $this->collection->findOneAndUpdate($query, $update, $options);
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
     public function findOne($query = [], array $fields = [], array $options = [])
548 548
     {
549 549
         // Can't typehint for array since MongoGridFS extends and accepts strings
550
-        if (! is_array($query)) {
550
+        if ( ! is_array($query)) {
551 551
             trigger_error(sprintf('MongoCollection::findOne(): expects parameter 1 to be an array or object, %s given', gettype($query)), E_USER_WARNING);
552 552
             return;
553 553
         }
@@ -587,11 +587,11 @@  discard block
 block discarded – undo
587 587
             $keys = (array) $keys;
588 588
         }
589 589
 
590
-        if (! is_array($keys) || ! count($keys)) {
590
+        if ( ! is_array($keys) || ! count($keys)) {
591 591
             throw new MongoException('index specification has no elements');
592 592
         }
593 593
 
594
-        if (! isset($options['name'])) {
594
+        if ( ! isset($options['name'])) {
595 595
             $options['name'] = \MongoDB\generate_index_name($keys);
596 596
         }
597 597
 
@@ -626,14 +626,14 @@  discard block
 block discarded – undo
626 626
         }
627 627
 
628 628
         $result = [
629
-            'createdCollectionAutomatically' => !$collectionExists,
629
+            'createdCollectionAutomatically' => ! $collectionExists,
630 630
             'numIndexesBefore' => $indexCount,
631 631
             'numIndexesAfter' => $indexCount,
632 632
             'note' => 'all indexes already exist',
633 633
             'ok' => 1.0,
634 634
         ];
635 635
 
636
-        if (! $indexExists) {
636
+        if ( ! $indexExists) {
637 637
             $result['numIndexesAfter']++;
638 638
             unset($result['note']);
639 639
         }
@@ -666,7 +666,7 @@  discard block
 block discarded – undo
666 666
     {
667 667
         if (is_string($keys)) {
668 668
             $indexName = $keys;
669
-            if (! preg_match('#_-?1$#', $indexName)) {
669
+            if ( ! preg_match('#_-?1$#', $indexName)) {
670 670
                 $indexName .= '_1';
671 671
             }
672 672
         } elseif (is_array($keys)) {
@@ -729,7 +729,7 @@  discard block
 block discarded – undo
729 729
             ];
730 730
 
731 731
             foreach ($additionalKeys as $key) {
732
-                if (! isset($indexInfo[$key])) {
732
+                if ( ! isset($indexInfo[$key])) {
733 733
                     continue;
734 734
                 }
735 735
 
@@ -754,7 +754,7 @@  discard block
 block discarded – undo
754 754
     {
755 755
         try {
756 756
             // Handle legacy mode - limit and skip as second and third parameters, respectively
757
-            if (! is_array($options)) {
757
+            if ( ! is_array($options)) {
758 758
                 $limit = $options;
759 759
                 $options = [];
760 760
 
@@ -801,7 +801,7 @@  discard block
 block discarded – undo
801 801
                 $this->convertWriteConcernOptions($options)
802 802
             );
803 803
 
804
-            if (! $result->isAcknowledged()) {
804
+            if ( ! $result->isAcknowledged()) {
805 805
                 return true;
806 806
             }
807 807
 
@@ -835,13 +835,13 @@  discard block
 block discarded – undo
835 835
         if ($document_or_id instanceof \MongoId) {
836 836
             $id = $document_or_id;
837 837
         } elseif (is_object($document_or_id)) {
838
-            if (! isset($document_or_id->_id)) {
838
+            if ( ! isset($document_or_id->_id)) {
839 839
                 return null;
840 840
             }
841 841
 
842 842
             $id = $document_or_id->_id;
843 843
         } elseif (is_array($document_or_id)) {
844
-            if (! isset($document_or_id['_id'])) {
844
+            if ( ! isset($document_or_id['_id'])) {
845 845
                 return null;
846 846
             }
847 847
 
@@ -884,14 +884,14 @@  discard block
 block discarded – undo
884 884
         $command = [
885 885
             'group' => [
886 886
                 'ns' => $this->name,
887
-                '$reduce' => (string)$reduce,
887
+                '$reduce' => (string) $reduce,
888 888
                 'initial' => $initial,
889 889
                 'cond' => $condition,
890 890
             ],
891 891
         ];
892 892
 
893 893
         if ($keys instanceof MongoCode) {
894
-            $command['group']['$keyf'] = (string)$keys;
894
+            $command['group']['$keyf'] = (string) $keys;
895 895
         } else {
896 896
             $command['group']['key'] = $keys;
897 897
         }
@@ -900,7 +900,7 @@  discard block
 block discarded – undo
900 900
         }
901 901
         if (array_key_exists('finalize', $condition)) {
902 902
             if ($condition['finalize'] instanceof MongoCode) {
903
-                $condition['finalize'] = (string)$condition['finalize'];
903
+                $condition['finalize'] = (string) $condition['finalize'];
904 904
             }
905 905
             $command['group']['finalize'] = $condition['finalize'];
906 906
         }
@@ -954,11 +954,11 @@  discard block
 block discarded – undo
954 954
             $options['w'] = ($options['safe']) ? 1 : 0;
955 955
         }
956 956
 
957
-        if (isset($options['wtimeout']) && !isset($options['wTimeoutMS'])) {
957
+        if (isset($options['wtimeout']) && ! isset($options['wTimeoutMS'])) {
958 958
             $options['wTimeoutMS'] = $options['wtimeout'];
959 959
         }
960 960
 
961
-        if (isset($options['w']) || !isset($options['wTimeoutMS'])) {
961
+        if (isset($options['w']) || ! isset($options['wTimeoutMS'])) {
962 962
             $collectionWriteConcern = $this->getWriteConcern();
963 963
             $writeConcern = $this->createWriteConcernFromParameters(
964 964
                 isset($options['w']) ? $options['w'] : $collectionWriteConcern['w'],
@@ -991,7 +991,7 @@  discard block
 block discarded – undo
991 991
         };
992 992
 
993 993
         if (is_array($document)) {
994
-            if (! isset($document['_id'])) {
994
+            if ( ! isset($document['_id'])) {
995 995
                 $document['_id'] = new \MongoId();
996 996
             }
997 997
 
@@ -1001,12 +1001,12 @@  discard block
 block discarded – undo
1001 1001
         } elseif (is_object($document)) {
1002 1002
             $reflectionObject = new \ReflectionObject($document);
1003 1003
             foreach ($reflectionObject->getProperties() as $property) {
1004
-                if (! $property->isPublic()) {
1004
+                if ( ! $property->isPublic()) {
1005 1005
                     throw new \MongoException('zero-length keys are not allowed, did you use $ with double quotes?');
1006 1006
                 }
1007 1007
             }
1008 1008
 
1009
-            if (! isset($document->_id)) {
1009
+            if ( ! isset($document->_id)) {
1010 1010
                 $document->_id = new \MongoId();
1011 1011
             }
1012 1012
 
Please login to merge, or discard this patch.