Completed
Pull Request — master (#20)
by
unknown
02:47
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   +19 added lines, -19 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
                 }
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
         ];
177 177
 
178 178
         // Convert cursor option
179
-        if (! isset($options['cursor'])) {
179
+        if ( ! isset($options['cursor'])) {
180 180
             $options['cursor'] = true;
181 181
         }
182 182
 
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
      */
263 263
     public function insert($a, array $options = [])
264 264
     {
265
-        if (! count((array)$a)) {
265
+        if ( ! count((array) $a)) {
266 266
             throw new \MongoException('document must be an array or object');
267 267
         }
268 268
 
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
         }
277 277
 
278 278
 
279
-        if (! $result->isAcknowledged()) {
279
+        if ( ! $result->isAcknowledged()) {
280 280
             return true;
281 281
         }
282 282
 
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
             ExceptionConverter::toLegacy($e);
309 309
         }
310 310
 
311
-        if (! $result->isAcknowledged()) {
311
+        if ( ! $result->isAcknowledged()) {
312 312
             return true;
313 313
         }
314 314
 
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
      * @throws MongoCursorException
333 333
      * @return boolean
334 334
      */
335
-    public function update(array $criteria , array $newobj, array $options = [])
335
+    public function update(array $criteria, array $newobj, array $options = [])
336 336
     {
337 337
         $multiple = isset($options['multiple']) ? $options['multiple'] : false;
338 338
         $method = $multiple ? 'updateMany' : 'updateOne';
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
             ExceptionConverter::toLegacy($e);
350 350
         }
351 351
 
352
-        if (! $result->isAcknowledged()) {
352
+        if ( ! $result->isAcknowledged()) {
353 353
             return true;
354 354
         }
355 355
 
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
      */
377 377
     public function remove(array $criteria = [], array $options = [])
378 378
     {
379
-        $multiple = isset($options['justOne']) ? !$options['justOne'] : true;
379
+        $multiple = isset($options['justOne']) ? ! $options['justOne'] : true;
380 380
         $method = $multiple ? 'deleteMany' : 'deleteOne';
381 381
 
382 382
         try {
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
             ExceptionConverter::toLegacy($e);
390 390
         }
391 391
 
392
-        if (! $result->isAcknowledged()) {
392
+        if ( ! $result->isAcknowledged()) {
393 393
             return true;
394 394
         }
395 395
 
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
      */
519 519
     public function createIndex(array $keys, array $options = [])
520 520
     {
521
-        if (! is_array($keys) || ! count($keys)) {
521
+        if ( ! is_array($keys) || ! count($keys)) {
522 522
             throw new MongoException('keys cannot be empty');
523 523
         }
524 524
 
@@ -656,7 +656,7 @@  discard block
 block discarded – undo
656 656
         }
657 657
         $options['upsert'] = true;
658 658
 
659
-        if (! count($a)) {
659
+        if ( ! count($a)) {
660 660
             throw new MongoException('document can not be empty');
661 661
         }
662 662
 
@@ -675,13 +675,13 @@  discard block
 block discarded – undo
675 675
         if ($document_or_id instanceof \MongoId) {
676 676
             $id = $document_or_id;
677 677
         } elseif (is_object($document_or_id)) {
678
-            if (! isset($document_or_id->_id)) {
678
+            if ( ! isset($document_or_id->_id)) {
679 679
                 return null;
680 680
             }
681 681
 
682 682
             $id = $document_or_id->_id;
683 683
         } elseif (is_array($document_or_id)) {
684
-            if (! isset($document_or_id['_id'])) {
684
+            if ( ! isset($document_or_id['_id'])) {
685 685
                 return null;
686 686
             }
687 687
 
@@ -724,14 +724,14 @@  discard block
 block discarded – undo
724 724
         $command = [
725 725
             'group' => [
726 726
                 'ns' => $this->name,
727
-                '$reduce' => (string)$reduce,
727
+                '$reduce' => (string) $reduce,
728 728
                 'initial' => $initial,
729 729
                 'cond' => $condition,
730 730
             ],
731 731
         ];
732 732
 
733 733
         if ($keys instanceof MongoCode) {
734
-            $command['group']['$keyf'] = (string)$keys;
734
+            $command['group']['$keyf'] = (string) $keys;
735 735
         } else {
736 736
             $command['group']['key'] = $keys;
737 737
         }
@@ -740,7 +740,7 @@  discard block
 block discarded – undo
740 740
         }
741 741
         if (array_key_exists('finalize', $condition)) {
742 742
             if ($condition['finalize'] instanceof MongoCode) {
743
-                $condition['finalize'] = (string)$condition['finalize'];
743
+                $condition['finalize'] = (string) $condition['finalize'];
744 744
             }
745 745
             $command['group']['finalize'] = $condition['finalize'];
746 746
         }
@@ -794,11 +794,11 @@  discard block
 block discarded – undo
794 794
             $options['w'] = ($options['safe']) ? 1 : 0;
795 795
         }
796 796
 
797
-        if (isset($options['wtimeout']) && !isset($options['wTimeoutMS'])) {
797
+        if (isset($options['wtimeout']) && ! isset($options['wTimeoutMS'])) {
798 798
             $options['wTimeoutMS'] = $options['wtimeout'];
799 799
         }
800 800
 
801
-        if (isset($options['w']) || !isset($options['wTimeoutMS'])) {
801
+        if (isset($options['w']) || ! isset($options['wTimeoutMS'])) {
802 802
             $collectionWriteConcern = $this->getWriteConcern();
803 803
             $writeConcern = $this->createWriteConcernFromParameters(
804 804
                 isset($options['w']) ? $options['w'] : $collectionWriteConcern['w'],
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 2 patches
Doc Comments   +6 added lines, -7 removed lines patch added patch discarded remove patch
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
      * Delete a file from the database
81 81
      *
82 82
      * @link http://php.net/manual/en/mongogridfs.delete.php
83
-     * @param mixed $id _id of the file to remove
83
+     * @param MongoId $id _id of the file to remove
84 84
      * @return boolean Returns true if the remove was successfully sent to the database.
85 85
      */
86 86
     public function delete($id)
@@ -106,7 +106,6 @@  discard block
 block discarded – undo
106 106
      * @link http://php.net/manual/en/mongogridfs.find.php
107 107
      * @param array $query The query
108 108
      * @param array $fields Fields to return
109
-     * @param array $options Options for the find command
110 109
      * @return MongoGridFSCursor A MongoGridFSCursor
111 110
      */
112 111
     public function find(array $query = [], array $fields = [])
@@ -155,7 +154,7 @@  discard block
 block discarded – undo
155 154
      * @param string $filename The name of the file
156 155
      * @param array $extra Other metadata to add to the file saved
157 156
      * @param array $options An array of options for the insert operations executed against the chunks and files collections.
158
-     * @return mixed Returns the _id of the saved object
157
+     * @return MongoId Returns the _id of the saved object
159 158
      */
160 159
     public function put($filename, array $extra = [], array $options = [])
161 160
     {
@@ -190,7 +189,7 @@  discard block
 block discarded – undo
190 189
      * @param string $bytes A string of bytes to store
191 190
      * @param array $extra Other metadata to add to the file saved
192 191
      * @param array $options Options for the store. "safe": Check that this store succeeded
193
-     * @return mixed The _id of the object saved
192
+     * @return MongoId The _id of the object saved
194 193
      */
195 194
     public function storeBytes($bytes, array $extra = [], array $options = [])
196 195
     {
@@ -224,7 +223,7 @@  discard block
 block discarded – undo
224 223
      * @param string $filename The name of the file
225 224
      * @param array $extra Other metadata to add to the file saved
226 225
      * @param array $options Options for the store. "safe": Check that this store succeeded
227
-     * @return mixed Returns the _id of the saved object
226
+     * @return MongoId Returns the _id of the saved object
228 227
      * @throws MongoGridFSException
229 228
      * @throws Exception
230 229
      */
@@ -299,7 +298,7 @@  discard block
 block discarded – undo
299 298
      * @link http://www.php.net/manual/en/mongogridfs.storeupload.php
300 299
      * @param string $name The name attribute of the uploaded file, from <input type="file" name="something"/>.
301 300
      * @param array $metadata An array of extra fields for the uploaded file.
302
-     * @return mixed Returns the _id of the uploaded file.
301
+     * @return null|MongoId Returns the _id of the uploaded file.
303 302
      * @throws MongoGridFSException
304 303
      */
305 304
     public function storeUpload($name, array $metadata = [])
@@ -436,7 +435,7 @@  discard block
 block discarded – undo
436 435
     /**
437 436
      * Returns the MD5 string for a file previously stored to the database
438 437
      *
439
-     * @param $id
438
+     * @param MongoId $id
440 439
      * @return string
441 440
      */
442 441
     private function getMd5ForFile($id)
Please login to merge, or discard this 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.