Completed
Pull Request — master (#163)
by Bernhard
03:23
created
lib/Mongo/MongoLog.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -119,7 +119,7 @@
 block discarded – undo
119 119
      * <ul>
120 120
      * @return boolean Returns <b>TRUE</b> on success or <b>FALSE</b> on failure.
121 121
      */
122
-    public static function setCallback(callable $log_function )
122
+    public static function setCallback(callable $log_function)
123 123
     {
124 124
         self::$callback = $log_function;
125 125
         return true;
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.
lib/Mongo/functions.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 
16 16
 use Alcaeus\MongoDbAdapter\TypeConverter;
17 17
 
18
-if (! function_exists('bson_decode')) {
18
+if ( ! function_exists('bson_decode')) {
19 19
     /**
20 20
      * Deserializes a BSON object into a PHP array
21 21
      *
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
     }
29 29
 }
30 30
 
31
-if (! function_exists('bson_encode')) {
31
+if ( ! function_exists('bson_encode')) {
32 32
     /**
33 33
      * Serializes a PHP variable into a BSON string
34 34
      *
Please login to merge, or discard this patch.
lib/Mongo/MongoClient.php 2 patches
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.
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
      * @link http://www.php.net/manual/en/mongoclient.killcursor.php
235 235
      * @param string $server_hash The server hash that has the cursor.
236 236
      * @param int|MongoInt64 $id The ID of the cursor to kill.
237
-     * @return bool
237
+     * @return boolean|null
238 238
      */
239 239
     public function killCursor($server_hash , $id)
240 240
     {
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
     }
343 343
 
344 344
     /**
345
-     * @return array
345
+     * @return string[]
346 346
      */
347 347
     function __sleep()
348 348
     {
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
     }
353 353
 
354 354
     /**
355
-     * @param $server
355
+     * @param string $server
356 356
      * @return array
357 357
      */
358 358
     private function extractUrlOptions($server)
Please login to merge, or discard this patch.
lib/Mongo/MongoDB.php 4 patches
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.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -540,7 +540,8 @@
 block discarded – undo
540 540
      * @param bool $includeSystemCollections
541 541
      * @return Closure
542 542
      */
543
-    private function getSystemCollectionFilterClosure($includeSystemCollections = false) {
543
+    private function getSystemCollectionFilterClosure($includeSystemCollections = false)
544
+    {
544 545
         return function (CollectionInfo $collectionInfo) use ($includeSystemCollections) {
545 546
             return $includeSystemCollections || ! preg_match('#^system\.#', $collectionInfo->getName());
546 547
         };
Please login to merge, or discard this patch.
Doc Comments   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -511,6 +511,9 @@  discard block
 block discarded – undo
511 511
         }
512 512
     }
513 513
 
514
+    /**
515
+     * @param string $name
516
+     */
514 517
     private function checkDatabaseName($name)
515 518
     {
516 519
         if (empty($name)) {
@@ -543,7 +546,7 @@  discard block
 block discarded – undo
543 546
     }
544 547
 
545 548
     /**
546
-     * @return array
549
+     * @return string[]
547 550
      */
548 551
     public function __sleep()
549 552
     {
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -258,7 +258,7 @@
 block discarded – undo
258 258
      * @param bool $backup_original_files [optional] <p>If original files should be backed up.</p>
259 259
      * @return array <p>Returns db response.</p>
260 260
      */
261
-    public function repair($preserve_cloned_files = FALSE, $backup_original_files = FALSE)
261
+    public function repair($preserve_cloned_files = false, $backup_original_files = false)
262 262
     {
263 263
         $command = [
264 264
             'repairDatabase' => 1,
Please login to merge, or discard this patch.
lib/Alcaeus/MongoDbAdapter/AbstractCursor.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
     ];
81 81
 
82 82
     /**
83
-     * @return Cursor
83
+     * @return \Traversable
84 84
      */
85 85
     abstract protected function ensureCursor();
86 86
 
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
     }
378 378
 
379 379
     /**
380
-     * @return array
380
+     * @return string[]
381 381
      */
382 382
     public function __sleep()
383 383
     {
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
      */
161 161
     public function next()
162 162
     {
163
-        if (! $this->startedIterating) {
163
+        if ( ! $this->startedIterating) {
164 164
             $this->ensureIterator();
165 165
             $this->startedIterating = true;
166 166
         } else {
@@ -402,7 +402,7 @@  discard block
 block discarded – undo
402 402
      */
403 403
     protected function storeIteratorState()
404 404
     {
405
-        if (! $this->startedIterating) {
405
+        if ( ! $this->startedIterating) {
406 406
             $this->current = null;
407 407
             $this->key = null;
408 408
             $this->valid = false;
Please login to merge, or discard this patch.
lib/Mongo/MongoCommandCursor.php 1 patch
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -102,7 +102,7 @@
 block discarded – undo
102 102
     }
103 103
 
104 104
     /**
105
-     * @return array
105
+     * @return string[]
106 106
      */
107 107
     public function __sleep()
108 108
     {
Please login to merge, or discard this patch.
lib/Mongo/MongoGridFS.php 2 patches
Doc Comments   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -105,7 +105,6 @@  discard block
 block discarded – undo
105 105
      * @link http://php.net/manual/en/mongogridfs.find.php
106 106
      * @param array $query The query
107 107
      * @param array $fields Fields to return
108
-     * @param array $options Options for the find command
109 108
      * @return MongoGridFSCursor A MongoGridFSCursor
110 109
      */
111 110
     public function find(array $query = [], array $fields = [])
@@ -446,7 +445,7 @@  discard block
 block discarded – undo
446 445
     }
447 446
 
448 447
     /**
449
-     * @return array
448
+     * @return string[]
450 449
      */
451 450
     public function __sleep()
452 451
     {
Please login to merge, or discard this 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/MongoCursor.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -102,7 +102,7 @@
 block discarded – undo
102 102
     }
103 103
 
104 104
     /**
105
-     * @return array
105
+     * @return string[]
106 106
      */
107 107
     public function __sleep()
108 108
     {
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
      */
222 222
     public function hasNext()
223 223
     {
224
-        if (! $this->startedIterating) {
224
+        if ( ! $this->startedIterating) {
225 225
             $this->ensureIterator();
226 226
             $this->startedIterating = true;
227 227
             $this->storeIteratorState();
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
      */
406 406
     protected function convertCursorType()
407 407
     {
408
-        if (! $this->tailable) {
408
+        if ( ! $this->tailable) {
409 409
             return null;
410 410
         }
411 411
 
@@ -446,7 +446,7 @@  discard block
 block discarded – undo
446 446
     protected function wrapTraversable(\Traversable $traversable)
447 447
     {
448 448
         foreach ($traversable as $key => $value) {
449
-            if (isset($value->_id) && ($value->_id instanceof \MongoDB\BSON\ObjectID || !is_object($value->_id))) {
449
+            if (isset($value->_id) && ($value->_id instanceof \MongoDB\BSON\ObjectID || ! is_object($value->_id))) {
450 450
                 $key = (string) $value->_id;
451 451
             }
452 452
             yield $key => $value;
Please login to merge, or discard this patch.
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,6 @@
 block discarded – undo
21 21
 use Alcaeus\MongoDbAdapter\TypeConverter;
22 22
 use Alcaeus\MongoDbAdapter\ExceptionConverter;
23 23
 use MongoDB\Driver\Cursor;
24
-use MongoDB\Driver\ReadPreference;
25 24
 use MongoDB\Operation\Find;
26 25
 
27 26
 /**
Please login to merge, or discard this patch.