Completed
Push — master ( 53b41d...ee831b )
by Andreas
06:29
created
lib/Mongo/MongoCollection.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -816,6 +816,9 @@
 block discarded – undo
816 816
         return $options;
817 817
     }
818 818
 
819
+    /**
820
+     * @param string $name
821
+     */
819 822
     private function checkCollectionName($name)
820 823
     {
821 824
         if (empty($name)) {
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -127,14 +127,14 @@  discard block
 block discarded – undo
127 127
      */
128 128
     public function aggregate(array $pipeline, array $op = [])
129 129
     {
130
-        if (! TypeConverter::isNumericArray($pipeline)) {
130
+        if ( ! TypeConverter::isNumericArray($pipeline)) {
131 131
             $pipeline = [];
132 132
             $options = [];
133 133
 
134 134
             $i = 0;
135 135
             foreach (func_get_args() as $operator) {
136 136
                 $i++;
137
-                if (! is_array($operator)) {
137
+                if ( ! is_array($operator)) {
138 138
                     trigger_error("Argument $i is not an array", E_WARNING);
139 139
                     return;
140 140
                 }
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
         ];
178 178
 
179 179
         // Convert cursor option
180
-        if (! isset($options['cursor'])) {
180
+        if ( ! isset($options['cursor'])) {
181 181
             $options['cursor'] = true;
182 182
         }
183 183
 
@@ -263,12 +263,12 @@  discard block
 block discarded – undo
263 263
      */
264 264
     public function insert(&$a, array $options = [])
265 265
     {
266
-        if (! $this->ensureDocumentHasMongoId($a)) {
266
+        if ( ! $this->ensureDocumentHasMongoId($a)) {
267 267
             trigger_error(sprintf('%s expects parameter %d to be an array or object, %s given', __METHOD__, 1, gettype($a)), E_USER_WARNING);
268 268
             return;
269 269
         }
270 270
 
271
-        if (! count((array)$a)) {
271
+        if ( ! count((array) $a)) {
272 272
             throw new \MongoException('document must be an array or object');
273 273
         }
274 274
 
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
             ExceptionConverter::toLegacy($e);
291 291
         }
292 292
 
293
-        if (! $result->isAcknowledged()) {
293
+        if ( ! $result->isAcknowledged()) {
294 294
             return true;
295 295
         }
296 296
 
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
 
322 322
         foreach ($a as $key => $item) {
323 323
             try {
324
-                if (! $this->ensureDocumentHasMongoId($a[$key])) {
324
+                if ( ! $this->ensureDocumentHasMongoId($a[$key])) {
325 325
                     if ($continueOnError) {
326 326
                         unset($a[$key]);
327 327
                     } else {
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
             ExceptionConverter::toLegacy($e);
346 346
         }
347 347
 
348
-        if (! $result->isAcknowledged()) {
348
+        if ( ! $result->isAcknowledged()) {
349 349
             return true;
350 350
         }
351 351
 
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
      * @throws MongoCursorException
370 370
      * @return boolean
371 371
      */
372
-    public function update(array $criteria , array $newobj, array $options = [])
372
+    public function update(array $criteria, array $newobj, array $options = [])
373 373
     {
374 374
         $multiple = isset($options['multiple']) ? $options['multiple'] : false;
375 375
         $method = $multiple ? 'updateMany' : 'updateOne';
@@ -397,7 +397,7 @@  discard block
 block discarded – undo
397 397
             ExceptionConverter::toLegacy($e);
398 398
         }
399 399
 
400
-        if (! $result->isAcknowledged()) {
400
+        if ( ! $result->isAcknowledged()) {
401 401
             return true;
402 402
         }
403 403
 
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
      */
425 425
     public function remove(array $criteria = [], array $options = [])
426 426
     {
427
-        $multiple = isset($options['justOne']) ? !$options['justOne'] : true;
427
+        $multiple = isset($options['justOne']) ? ! $options['justOne'] : true;
428 428
         $method = $multiple ? 'deleteMany' : 'deleteOne';
429 429
 
430 430
         try {
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
             ExceptionConverter::toLegacy($e);
438 438
         }
439 439
 
440
-        if (! $result->isAcknowledged()) {
440
+        if ( ! $result->isAcknowledged()) {
441 441
             return true;
442 442
         }
443 443
 
@@ -561,7 +561,7 @@  discard block
 block discarded – undo
561 561
      */
562 562
     public function createIndex(array $keys, array $options = [])
563 563
     {
564
-        if (! is_array($keys) || ! count($keys)) {
564
+        if ( ! is_array($keys) || ! count($keys)) {
565 565
             throw new MongoException('keys cannot be empty');
566 566
         }
567 567
 
@@ -571,7 +571,7 @@  discard block
 block discarded – undo
571 571
         $indexes = $this->collection->listIndexes();
572 572
         foreach ($indexes as $index) {
573 573
 
574
-            if (! empty($options['name']) && $index->getName() === $options['name']) {
574
+            if ( ! empty($options['name']) && $index->getName() === $options['name']) {
575 575
                 throw new \MongoDuplicateKeyException();
576 576
             }
577 577
 
@@ -732,13 +732,13 @@  discard block
 block discarded – undo
732 732
         if ($document_or_id instanceof \MongoId) {
733 733
             $id = $document_or_id;
734 734
         } elseif (is_object($document_or_id)) {
735
-            if (! isset($document_or_id->_id)) {
735
+            if ( ! isset($document_or_id->_id)) {
736 736
                 return null;
737 737
             }
738 738
 
739 739
             $id = $document_or_id->_id;
740 740
         } elseif (is_array($document_or_id)) {
741
-            if (! isset($document_or_id['_id'])) {
741
+            if ( ! isset($document_or_id['_id'])) {
742 742
                 return null;
743 743
             }
744 744
 
@@ -781,14 +781,14 @@  discard block
 block discarded – undo
781 781
         $command = [
782 782
             'group' => [
783 783
                 'ns' => $this->name,
784
-                '$reduce' => (string)$reduce,
784
+                '$reduce' => (string) $reduce,
785 785
                 'initial' => $initial,
786 786
                 'cond' => $condition,
787 787
             ],
788 788
         ];
789 789
 
790 790
         if ($keys instanceof MongoCode) {
791
-            $command['group']['$keyf'] = (string)$keys;
791
+            $command['group']['$keyf'] = (string) $keys;
792 792
         } else {
793 793
             $command['group']['key'] = $keys;
794 794
         }
@@ -797,7 +797,7 @@  discard block
 block discarded – undo
797 797
         }
798 798
         if (array_key_exists('finalize', $condition)) {
799 799
             if ($condition['finalize'] instanceof MongoCode) {
800
-                $condition['finalize'] = (string)$condition['finalize'];
800
+                $condition['finalize'] = (string) $condition['finalize'];
801 801
             }
802 802
             $command['group']['finalize'] = $condition['finalize'];
803 803
         }
@@ -851,11 +851,11 @@  discard block
 block discarded – undo
851 851
             $options['w'] = ($options['safe']) ? 1 : 0;
852 852
         }
853 853
 
854
-        if (isset($options['wtimeout']) && !isset($options['wTimeoutMS'])) {
854
+        if (isset($options['wtimeout']) && ! isset($options['wTimeoutMS'])) {
855 855
             $options['wTimeoutMS'] = $options['wtimeout'];
856 856
         }
857 857
 
858
-        if (isset($options['w']) || !isset($options['wTimeoutMS'])) {
858
+        if (isset($options['w']) || ! isset($options['wTimeoutMS'])) {
859 859
             $collectionWriteConcern = $this->getWriteConcern();
860 860
             $writeConcern = $this->createWriteConcernFromParameters(
861 861
                 isset($options['w']) ? $options['w'] : $collectionWriteConcern['w'],
@@ -891,7 +891,7 @@  discard block
 block discarded – undo
891 891
             if (empty($document)) {
892 892
                 throw new \MongoException('document cannot be empty');
893 893
             }
894
-            if (! isset($document['_id'])) {
894
+            if ( ! isset($document['_id'])) {
895 895
                 $document['_id'] = new \MongoId();
896 896
             }
897 897
 
@@ -902,7 +902,7 @@  discard block
 block discarded – undo
902 902
             if (empty((array) $document)) {
903 903
                 throw new \MongoException('document cannot be empty');
904 904
             }
905
-            if (! isset($document->_id)) {
905
+            if ( ! isset($document->_id)) {
906 906
                 $document->_id = new \MongoId();
907 907
             }
908 908
 
Please login to merge, or discard this patch.
lib/Mongo/MongoDB.php 1 patch
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -816,6 +816,9 @@
 block discarded – undo
816 816
         return $options;
817 817
     }
818 818
 
819
+    /**
820
+     * @param string $name
821
+     */
819 822
     private function checkCollectionName($name)
820 823
     {
821 824
         if (empty($name)) {
Please login to merge, or discard this patch.
lib/Mongo/MongoGridFS.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -241,10 +241,10 @@  discard block
 block discarded – undo
241 241
             ];
242 242
 
243 243
             $handle = fopen($filename, 'r');
244
-            if (! $handle) {
244
+            if ( ! $handle) {
245 245
                 throw new MongoGridFSException('could not open file: ' . $filename);
246 246
             }
247
-        } elseif (! is_resource($filename)) {
247
+        } elseif ( ! is_resource($filename)) {
248 248
             throw new \Exception('first argument must be a string or stream resource');
249 249
         } else {
250 250
             $handle = $filename;
@@ -266,10 +266,10 @@  discard block
 block discarded – undo
266 266
 
267 267
         // Add length and MD5 if they were not present before
268 268
         $update = [];
269
-        if (! isset($record['length'])) {
269
+        if ( ! isset($record['length'])) {
270 270
             $update['length'] = $length;
271 271
         }
272
-        if (! isset($record['md5'])) {
272
+        if ( ! isset($record['md5'])) {
273 273
             try {
274 274
                 $update['md5'] = $this->getMd5ForFile($file['_id']);
275 275
             } catch (MongoException $e) {
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
         if (count($update)) {
281 281
             try {
282 282
                 $result = $this->update(['_id' => $file['_id']], ['$set' => $update]);
283
-                if (! $this->isOKResult($result)) {
283
+                if ( ! $this->isOKResult($result)) {
284 284
                     throw new MongoGridFSException('Error updating file record');
285 285
                 }
286 286
             } catch (MongoException $e) {
@@ -304,10 +304,10 @@  discard block
 block discarded – undo
304 304
      */
305 305
     public function storeUpload($name, array $metadata = [])
306 306
     {
307
-        if (! isset($_FILES[$name]) || $_FILES[$name]['error'] !== UPLOAD_ERR_OK) {
307
+        if ( ! isset($_FILES[$name]) || $_FILES[$name]['error'] !== UPLOAD_ERR_OK) {
308 308
             throw new MongoGridFSException("Could not find uploaded file $name");
309 309
         }
310
-        if (! isset($_FILES[$name]['tmp_name'])) {
310
+        if ( ! isset($_FILES[$name]['tmp_name'])) {
311 311
             throw new MongoGridFSException("Couldn't find tmp_name in the \$_FILES array. Are you sure the upload worked?");
312 312
         }
313 313
 
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
 
358 358
         $result = $this->chunks->insert($chunk);
359 359
 
360
-        if (! $this->isOKResult($result)) {
360
+        if ( ! $this->isOKResult($result)) {
361 361
             throw new \MongoException('error inserting chunk');
362 362
         }
363 363
 
@@ -399,7 +399,7 @@  discard block
 block discarded – undo
399 399
         $chunkSize = $record['chunkSize'];
400 400
 
401 401
         rewind($handle);
402
-        while (! feof($handle)) {
402
+        while ( ! feof($handle)) {
403 403
             $data = stream_get_contents($handle, $chunkSize);
404 404
             $this->insertChunk($fileId, $data, $i++);
405 405
             $written += strlen($data);
@@ -426,7 +426,7 @@  discard block
 block discarded – undo
426 426
 
427 427
         $result = $this->insert($record, $options);
428 428
 
429
-        if (! $this->isOKResult($result)) {
429
+        if ( ! $this->isOKResult($result)) {
430 430
             throw new \MongoException('error inserting file');
431 431
         }
432 432
 
Please login to merge, or discard this patch.
lib/Mongo/MongoGridFSCursor.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -65,6 +65,6 @@
 block discarded – undo
65 65
     public function key()
66 66
     {
67 67
         $file = $this->current();
68
-        return ($file !== null) ? (string)$file->file['_id'] : null;
68
+        return ($file !== null) ? (string) $file->file['_id'] : null;
69 69
     }
70 70
 }
Please login to merge, or discard this patch.