Completed
Pull Request — master (#74)
by Andreas
03:46
created
lib/Mongo/MongoWriteBatch.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
     public function add($item)
77 77
     {
78 78
         if (is_object($item)) {
79
-            $item = (array)$item;
79
+            $item = (array) $item;
80 80
         }
81 81
 
82 82
         $this->validate($item);
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
     final public function execute(array $writeOptions = [])
96 96
     {
97 97
         $writeOptions += $this->writeOptions;
98
-        if (! count($this->items)) {
98
+        if ( ! count($this->items)) {
99 99
             return ['ok' => true];
100 100
         }
101 101
 
@@ -152,19 +152,19 @@  discard block
 block discarded – undo
152 152
     {
153 153
         switch ($this->batchType) {
154 154
             case self::COMMAND_UPDATE:
155
-                if (! isset($item['q'])) {
155
+                if ( ! isset($item['q'])) {
156 156
                     throw new Exception("Expected $item to contain 'q' key");
157 157
                 }
158
-                if (! isset($item['u'])) {
158
+                if ( ! isset($item['u'])) {
159 159
                     throw new Exception("Expected $item to contain 'u' key");
160 160
                 }
161 161
                 break;
162 162
 
163 163
             case self::COMMAND_DELETE:
164
-                if (! isset($item['q'])) {
164
+                if ( ! isset($item['q'])) {
165 165
                     throw new Exception("Expected $item to contain 'q' key");
166 166
                 }
167
-                if (! isset($item['limit'])) {
167
+                if ( ! isset($item['limit'])) {
168 168
                     throw new Exception("Expected $item to contain 'limit' key");
169 169
                 }
170 170
                 break;
Please login to merge, or discard this patch.
lib/Alcaeus/MongoDbAdapter/AbstractCursor.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
      */
119 119
     public function current()
120 120
     {
121
-        if (! $this->startedIterating) {
121
+        if ( ! $this->startedIterating) {
122 122
             return null;
123 123
         }
124 124
 
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
      */
138 138
     public function key()
139 139
     {
140
-        if (! $this->startedIterating) {
140
+        if ( ! $this->startedIterating) {
141 141
             return null;
142 142
         }
143 143
 
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
      */
154 154
     public function next()
155 155
     {
156
-        if (! $this->startedIterating) {
156
+        if ( ! $this->startedIterating) {
157 157
             $this->ensureIterator();
158 158
             $this->startedIterating = true;
159 159
         } else {
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
      */
187 187
     public function valid()
188 188
     {
189
-        if (! $this->startedIterating) {
189
+        if ( ! $this->startedIterating) {
190 190
             return false;
191 191
         }
192 192
 
Please login to merge, or discard this patch.
lib/Mongo/MongoClient.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -28,13 +28,13 @@  discard block
 block discarded – undo
28 28
     use Helper\WriteConcern;
29 29
 
30 30
     const VERSION = '1.6.12';
31
-    const DEFAULT_HOST = "localhost" ;
32
-    const DEFAULT_PORT = 27017 ;
33
-    const RP_PRIMARY = "primary" ;
34
-    const RP_PRIMARY_PREFERRED = "primaryPreferred" ;
35
-    const RP_SECONDARY = "secondary" ;
36
-    const RP_SECONDARY_PREFERRED = "secondaryPreferred" ;
37
-    const RP_NEAREST = "nearest" ;
31
+    const DEFAULT_HOST = "localhost";
32
+    const DEFAULT_PORT = 27017;
33
+    const RP_PRIMARY = "primary";
34
+    const RP_PRIMARY_PREFERRED = "primaryPreferred";
35
+    const RP_SECONDARY = "secondary";
36
+    const RP_SECONDARY_PREFERRED = "secondaryPreferred";
37
+    const RP_NEAREST = "nearest";
38 38
 
39 39
     /**
40 40
      * @var bool
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 
85 85
         $this->server = $server;
86 86
         if (false === strpos($this->server, 'mongodb://')) {
87
-            $this->server = 'mongodb://'.$this->server;
87
+            $this->server = 'mongodb://' . $this->server;
88 88
         }
89 89
         $this->client = new Client($this->server, $options, $driverOptions);
90 90
         $info = $this->client->__debugInfo();
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
      * @param int|MongoInt64 $id The ID of the cursor to kill.
231 231
      * @return bool
232 232
      */
233
-    public function killCursor($server_hash , $id)
233
+    public function killCursor($server_hash, $id)
234 234
     {
235 235
         $this->notImplemented();
236 236
     }
Please login to merge, or discard this patch.
lib/Mongo/MongoDB.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
             throw ExceptionConverter::toLegacy($e);
139 139
         }
140 140
 
141
-        $getCollectionInfo = function (CollectionInfo $collectionInfo) {
141
+        $getCollectionInfo = function(CollectionInfo $collectionInfo) {
142 142
             return [
143 143
                 'name' => $collectionInfo->getName(),
144 144
                 'options' => $collectionInfo->getOptions(),
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
             throw ExceptionConverter::toLegacy($e);
176 176
         }
177 177
 
178
-        $getCollectionName = function (CollectionInfo $collectionInfo) {
178
+        $getCollectionName = function(CollectionInfo $collectionInfo) {
179 179
             return $collectionInfo->getName();
180 180
         };
181 181
 
@@ -344,13 +344,13 @@  discard block
 block discarded – undo
344 344
         if ($document_or_id instanceof \MongoId) {
345 345
             $id = $document_or_id;
346 346
         } elseif (is_object($document_or_id)) {
347
-            if (! isset($document_or_id->_id)) {
347
+            if ( ! isset($document_or_id->_id)) {
348 348
                 $id = $document_or_id;
349 349
             } else {
350 350
                 $id = $document_or_id->_id;
351 351
             }
352 352
         } elseif (is_array($document_or_id)) {
353
-            if (! isset($document_or_id['_id'])) {
353
+            if ( ! isset($document_or_id['_id'])) {
354 354
                 return null;
355 355
             }
356 356
 
@@ -541,7 +541,7 @@  discard block
 block discarded – undo
541 541
      * @return Closure
542 542
      */
543 543
     private function getSystemCollectionFilterClosure($includeSystemCollections = false) {
544
-        return function (CollectionInfo $collectionInfo) use ($includeSystemCollections) {
544
+        return function(CollectionInfo $collectionInfo) use ($includeSystemCollections) {
545 545
             return $includeSystemCollections || ! preg_match('#^system\.#', $collectionInfo->getName());
546 546
         };
547 547
     }
Please login to merge, or discard this patch.
lib/Mongo/MongoGridFS.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
      */
128 128
     public function findOne($query = [], array $fields = [], array $options = [])
129 129
     {
130
-        if (! is_array($query)) {
130
+        if ( ! is_array($query)) {
131 131
             $query = ['filename' => (string) $query];
132 132
         }
133 133
 
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
         try {
204 204
             $file = $this->insertFile($record, $options);
205 205
         } catch (MongoException $e) {
206
-            throw new MongoGridFSException('Could not store file: '. $e->getMessage(), 0, $e);
206
+            throw new MongoGridFSException('Could not store file: ' . $e->getMessage(), 0, $e);
207 207
         }
208 208
 
209 209
         try {
@@ -240,10 +240,10 @@  discard block
 block discarded – undo
240 240
             ];
241 241
 
242 242
             $handle = fopen($filename, 'r');
243
-            if (! $handle) {
243
+            if ( ! $handle) {
244 244
                 throw new MongoGridFSException('could not open file: ' . $filename);
245 245
             }
246
-        } elseif (! is_resource($filename)) {
246
+        } elseif ( ! is_resource($filename)) {
247 247
             throw new \Exception('first argument must be a string or stream resource');
248 248
         } else {
249 249
             $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'] = $md5;
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('Could not store file');
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
 
@@ -402,7 +402,7 @@  discard block
 block discarded – undo
402 402
         $hash = hash_init('md5');
403 403
 
404 404
         rewind($handle);
405
-        while (! feof($handle)) {
405
+        while ( ! feof($handle)) {
406 406
             $data = stream_get_contents($handle, $chunkSize);
407 407
             hash_update($hash, $data);
408 408
             $this->insertChunk($fileId, $data, $i++);
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
 
433 433
         $result = $this->insert($record, $options);
434 434
 
435
-        if (! $this->isOKResult($result)) {
435
+        if ( ! $this->isOKResult($result)) {
436 436
             throw new \MongoException('error inserting file');
437 437
         }
438 438
 
Please login to merge, or discard this patch.
lib/Mongo/MongoId.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@
 block discarded – undo
48 48
     {
49 49
         if ($value instanceof ObjectID || $value instanceof MongoId) {
50 50
             return true;
51
-        } elseif (! is_string($value)) {
51
+        } elseif ( ! is_string($value)) {
52 52
             return false;
53 53
         }
54 54
 
Please login to merge, or discard this patch.
lib/Mongo/MongoCollection.php 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -130,14 +130,14 @@  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
             $pipeline = [];
135 135
             $options = [];
136 136
 
137 137
             $i = 0;
138 138
             foreach (func_get_args() as $operator) {
139 139
                 $i++;
140
-                if (! is_array($operator)) {
140
+                if ( ! is_array($operator)) {
141 141
                     trigger_error("Argument $i is not an array", E_WARNING);
142 142
                     return;
143 143
                 }
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
                 'waitedMS' => 0,
170 170
             ];
171 171
         } catch (\MongoDB\Driver\Exception\Exception $e) {
172
-            throw ExceptionConverter::toLegacy($e,'MongoResultException');
172
+            throw ExceptionConverter::toLegacy($e, 'MongoResultException');
173 173
         }
174 174
     }
175 175
 
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
         ];
191 191
 
192 192
         // Convert cursor option
193
-        if (! isset($options['cursor'])) {
193
+        if ( ! isset($options['cursor'])) {
194 194
             $options['cursor'] = new \stdClass();
195 195
         }
196 196
 
@@ -276,12 +276,12 @@  discard block
 block discarded – undo
276 276
      */
277 277
     public function insert(&$a, array $options = [])
278 278
     {
279
-        if (! $this->ensureDocumentHasMongoId($a)) {
279
+        if ( ! $this->ensureDocumentHasMongoId($a)) {
280 280
             trigger_error(sprintf('%s(): expects parameter %d to be an array or object, %s given', __METHOD__, 1, gettype($a)), E_USER_WARNING);
281 281
             return;
282 282
         }
283 283
 
284
-        if (! count((array)$a)) {
284
+        if ( ! count((array) $a)) {
285 285
             throw new \MongoException('document must be an array or object');
286 286
         }
287 287
 
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
             throw ExceptionConverter::toLegacy($e);
295 295
         }
296 296
 
297
-        if (! $result->isAcknowledged()) {
297
+        if ( ! $result->isAcknowledged()) {
298 298
             return true;
299 299
         }
300 300
 
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
 
326 326
         foreach ($a as $key => $item) {
327 327
             try {
328
-                if (! $this->ensureDocumentHasMongoId($a[$key])) {
328
+                if ( ! $this->ensureDocumentHasMongoId($a[$key])) {
329 329
                     if ($continueOnError) {
330 330
                         unset($a[$key]);
331 331
                     } else {
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
             throw ExceptionConverter::toLegacy($e, 'MongoResultException');
350 350
         }
351 351
 
352
-        if (! $result->isAcknowledged()) {
352
+        if ( ! $result->isAcknowledged()) {
353 353
             return true;
354 354
         }
355 355
 
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
      * @throws MongoCursorException
374 374
      * @return boolean
375 375
      */
376
-    public function update(array $criteria , array $newobj, array $options = [])
376
+    public function update(array $criteria, array $newobj, array $options = [])
377 377
     {
378 378
         $multiple = isset($options['multiple']) ? $options['multiple'] : false;
379 379
         $isReplace = ! \MongoDB\is_first_key_operator($newobj);
@@ -397,7 +397,7 @@  discard block
 block discarded – undo
397 397
             throw 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
             throw ExceptionConverter::toLegacy($e);
438 438
         }
439 439
 
440
-        if (! $result->isAcknowledged()) {
440
+        if ( ! $result->isAcknowledged()) {
441 441
             return true;
442 442
         }
443 443
 
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
 
510 510
                 $options['projection'] = is_array($fields) ? TypeConverter::fromLegacy($fields) : [];
511 511
 
512
-                if (! \MongoDB\is_first_key_operator($update)) {
512
+                if ( ! \MongoDB\is_first_key_operator($update)) {
513 513
                     $document = $this->collection->findOneAndReplace($query, $update, $options);
514 514
                 } else {
515 515
                     $document = $this->collection->findOneAndUpdate($query, $update, $options);
@@ -540,7 +540,7 @@  discard block
 block discarded – undo
540 540
     public function findOne($query = [], array $fields = [], array $options = [])
541 541
     {
542 542
         // Can't typehint for array since MongoGridFS extends and accepts strings
543
-        if (! is_array($query)) {
543
+        if ( ! is_array($query)) {
544 544
             trigger_error(sprintf('MongoCollection::findOne(): expects parameter 1 to be an array or object, %s given', gettype($query)), E_WARNING);
545 545
             return;
546 546
         }
@@ -580,11 +580,11 @@  discard block
 block discarded – undo
580 580
             $keys = (array) $keys;
581 581
         }
582 582
 
583
-        if (! is_array($keys) || ! count($keys)) {
583
+        if ( ! is_array($keys) || ! count($keys)) {
584 584
             throw new MongoException('index specification has no elements');
585 585
         }
586 586
 
587
-        if (! isset($options['name'])) {
587
+        if ( ! isset($options['name'])) {
588 588
             $options['name'] = \MongoDB\generate_index_name($keys);
589 589
         }
590 590
 
@@ -619,14 +619,14 @@  discard block
 block discarded – undo
619 619
         }
620 620
 
621 621
         $result = [
622
-            'createdCollectionAutomatically' => !$collectionExists,
622
+            'createdCollectionAutomatically' => ! $collectionExists,
623 623
             'numIndexesBefore' => $indexCount,
624 624
             'numIndexesAfter' => $indexCount,
625 625
             'note' => 'all indexes already exist',
626 626
             'ok' => 1.0,
627 627
         ];
628 628
 
629
-        if (! $indexExists) {
629
+        if ( ! $indexExists) {
630 630
             $result['numIndexesAfter']++;
631 631
             unset($result['note']);
632 632
         }
@@ -659,7 +659,7 @@  discard block
 block discarded – undo
659 659
     {
660 660
         if (is_string($keys)) {
661 661
             $indexName = $keys;
662
-            if (! preg_match('#_-?1$#', $indexName)) {
662
+            if ( ! preg_match('#_-?1$#', $indexName)) {
663 663
                 $indexName .= '_1';
664 664
             }
665 665
         } elseif (is_array($keys)) {
@@ -755,7 +755,7 @@  discard block
 block discarded – undo
755 755
                 $this->convertWriteConcernOptions($options)
756 756
             );
757 757
 
758
-            if (! $result->isAcknowledged()) {
758
+            if ( ! $result->isAcknowledged()) {
759 759
                 return true;
760 760
             }
761 761
 
@@ -789,13 +789,13 @@  discard block
 block discarded – undo
789 789
         if ($document_or_id instanceof \MongoId) {
790 790
             $id = $document_or_id;
791 791
         } elseif (is_object($document_or_id)) {
792
-            if (! isset($document_or_id->_id)) {
792
+            if ( ! isset($document_or_id->_id)) {
793 793
                 return null;
794 794
             }
795 795
 
796 796
             $id = $document_or_id->_id;
797 797
         } elseif (is_array($document_or_id)) {
798
-            if (! isset($document_or_id['_id'])) {
798
+            if ( ! isset($document_or_id['_id'])) {
799 799
                 return null;
800 800
             }
801 801
 
@@ -838,14 +838,14 @@  discard block
 block discarded – undo
838 838
         $command = [
839 839
             'group' => [
840 840
                 'ns' => $this->name,
841
-                '$reduce' => (string)$reduce,
841
+                '$reduce' => (string) $reduce,
842 842
                 'initial' => $initial,
843 843
                 'cond' => $condition,
844 844
             ],
845 845
         ];
846 846
 
847 847
         if ($keys instanceof MongoCode) {
848
-            $command['group']['$keyf'] = (string)$keys;
848
+            $command['group']['$keyf'] = (string) $keys;
849 849
         } else {
850 850
             $command['group']['key'] = $keys;
851 851
         }
@@ -854,7 +854,7 @@  discard block
 block discarded – undo
854 854
         }
855 855
         if (array_key_exists('finalize', $condition)) {
856 856
             if ($condition['finalize'] instanceof MongoCode) {
857
-                $condition['finalize'] = (string)$condition['finalize'];
857
+                $condition['finalize'] = (string) $condition['finalize'];
858 858
             }
859 859
             $command['group']['finalize'] = $condition['finalize'];
860 860
         }
@@ -908,11 +908,11 @@  discard block
 block discarded – undo
908 908
             $options['w'] = ($options['safe']) ? 1 : 0;
909 909
         }
910 910
 
911
-        if (isset($options['wtimeout']) && !isset($options['wTimeoutMS'])) {
911
+        if (isset($options['wtimeout']) && ! isset($options['wTimeoutMS'])) {
912 912
             $options['wTimeoutMS'] = $options['wtimeout'];
913 913
         }
914 914
 
915
-        if (isset($options['w']) || !isset($options['wTimeoutMS'])) {
915
+        if (isset($options['w']) || ! isset($options['wTimeoutMS'])) {
916 916
             $collectionWriteConcern = $this->getWriteConcern();
917 917
             $writeConcern = $this->createWriteConcernFromParameters(
918 918
                 isset($options['w']) ? $options['w'] : $collectionWriteConcern['w'],
@@ -945,7 +945,7 @@  discard block
 block discarded – undo
945 945
         };
946 946
 
947 947
         if (is_array($document)) {
948
-            if (! isset($document['_id'])) {
948
+            if ( ! isset($document['_id'])) {
949 949
                 $document['_id'] = new \MongoId();
950 950
             }
951 951
 
@@ -955,12 +955,12 @@  discard block
 block discarded – undo
955 955
         } elseif (is_object($document)) {
956 956
             $reflectionObject = new \ReflectionObject($document);
957 957
             foreach ($reflectionObject->getProperties() as $property) {
958
-                if (! $property->isPublic()) {
958
+                if ( ! $property->isPublic()) {
959 959
                     throw new \MongoException('zero-length keys are not allowed, did you use $ with double quotes?');
960 960
                 }
961 961
             }
962 962
 
963
-            if (! isset($document->_id)) {
963
+            if ( ! isset($document->_id)) {
964 964
                 $document->_id = new \MongoId();
965 965
             }
966 966
 
Please login to merge, or discard this patch.