Completed
Pull Request — master (#48)
by
unknown
03:20
created
lib/Mongo/MongoId.php 1 patch
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -200,7 +200,7 @@
 block discarded – undo
200 200
     }
201 201
 
202 202
     /**
203
-     * @param $id
203
+     * @param string|null $id
204 204
      * @throws MongoException
205 205
      */
206 206
     private function createObjectID($id)
Please login to merge, or discard this patch.
lib/Mongo/MongoClient.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -23,13 +23,13 @@  discard block
 block discarded – undo
23 23
 class MongoClient
24 24
 {
25 25
     const VERSION = '1.6.12';
26
-    const DEFAULT_HOST = "localhost" ;
27
-    const DEFAULT_PORT = 27017 ;
28
-    const RP_PRIMARY = "primary" ;
29
-    const RP_PRIMARY_PREFERRED = "primaryPreferred" ;
30
-    const RP_SECONDARY = "secondary" ;
31
-    const RP_SECONDARY_PREFERRED = "secondaryPreferred" ;
32
-    const RP_NEAREST = "nearest" ;
26
+    const DEFAULT_HOST = "localhost";
27
+    const DEFAULT_PORT = 27017;
28
+    const RP_PRIMARY = "primary";
29
+    const RP_PRIMARY_PREFERRED = "primaryPreferred";
30
+    const RP_SECONDARY = "secondary";
31
+    const RP_SECONDARY_PREFERRED = "secondaryPreferred";
32
+    const RP_NEAREST = "nearest";
33 33
 
34 34
     /**
35 35
      * @var bool
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
      * {@link http://www.php.net/manual/en/class.mongoint64.php MongoInt64} class. The latter is necessary on 32
199 199
      * bit platforms (and Windows).
200 200
      */
201
-    public function killCursor($server_hash , $id)
201
+    public function killCursor($server_hash, $id)
202 202
     {
203 203
 
204 204
     }
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -216,7 +216,7 @@
 block discarded – undo
216 216
      * @link http://www.php.net/manual/en/mongoclient.killcursor.php
217 217
      * @param string $server_hash The server hash that has the cursor.
218 218
      * @param int|MongoInt64 $id The ID of the cursor to kill.
219
-     * @return bool
219
+     * @return boolean|null
220 220
      */
221 221
     public function killCursor($server_hash , $id)
222 222
     {
Please login to merge, or discard this patch.
lib/Mongo/MongoResultException.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@
 block discarded – undo
25 25
      * http://php.net/manual/en/mongoresultexception.getdocument.php
26 26
      * @return array <p>The full result document as an array, including partial data if available and additional keys.</p>
27 27
      */
28
-    public function getDocument () {}
28
+    public function getDocument() {}
29 29
 
30 30
     public $document;
31 31
 
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,13 +18,16 @@
 block discarded – undo
18 18
  * @link http://php.net/manual/en/class.mongoresultexception.php#mongoresultexception.props.document
19 19
  *
20 20
  */
21
-class MongoResultException extends MongoException {
21
+class MongoResultException extends MongoException
22
+{
22 23
     /**
23 24
      * Retrieve the full result document
24 25
      * http://php.net/manual/en/mongoresultexception.getdocument.php
25 26
      * @return array <p>The full result document as an array, including partial data if available and additional keys.</p>
26 27
      */
27
-    public function getDocument () {}
28
+    public function getDocument ()
29
+    {
30
+}
28 31
 
29 32
     public $document;
30 33
 
Please login to merge, or discard this patch.
lib/Mongo/MongoBinData.php 1 patch
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,6 @@
 block discarded – undo
15 15
 
16 16
 use Alcaeus\MongoDbAdapter\TypeInterface;
17 17
 use MongoDB\BSON\Binary;
18
-use MongoDB\BSON\Type;
19 18
 
20 19
 class MongoBinData implements TypeInterface
21 20
 {
Please login to merge, or discard this patch.
lib/Alcaeus/MongoDbAdapter/AbstractCursor.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@
 block discarded – undo
72 72
     protected $readPreference = [];
73 73
 
74 74
     /**
75
-     * @return Cursor
75
+     * @return \Traversable
76 76
      */
77 77
     abstract protected function ensureCursor();
78 78
 
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -141,7 +141,7 @@
 block discarded – undo
141 141
      */
142 142
     public function next()
143 143
     {
144
-        if (!$this->startedIterating) {
144
+        if ( ! $this->startedIterating) {
145 145
             $this->ensureIterator();
146 146
             $this->startedIterating = true;
147 147
         } else {
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
@@ -201,7 +201,7 @@
 block discarded – undo
201 201
      * @link http://www.php.net/manual/en/mongocursor.hasnext.php
202 202
      * @throws MongoConnectionException
203 203
      * @throws MongoCursorTimeoutException
204
-     * @return bool Returns true if there is another element
204
+     * @return boolean|null Returns true if there is another element
205 205
      */
206 206
     public function hasNext()
207 207
     {
Please login to merge, or discard this patch.
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,6 @@
 block discarded – undo
15 15
 
16 16
 use Alcaeus\MongoDbAdapter\AbstractCursor;
17 17
 use MongoDB\Driver\Cursor;
18
-use MongoDB\Driver\ReadPreference;
19 18
 use MongoDB\Operation\Find;
20 19
 
21 20
 /**
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -394,7 +394,7 @@  discard block
 block discarded – undo
394 394
      */
395 395
     protected function convertCursorType()
396 396
     {
397
-        if (! $this->tailable) {
397
+        if ( ! $this->tailable) {
398 398
             return null;
399 399
         }
400 400
 
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
     protected function wrapTraversable(\Traversable $traversable)
436 436
     {
437 437
         foreach ($traversable as $key => $value) {
438
-            if (isset($value->_id) && ($value->_id instanceof \MongoDB\BSON\ObjectID || !is_object($value->_id))) {
438
+            if (isset($value->_id) && ($value->_id instanceof \MongoDB\BSON\ObjectID || ! is_object($value->_id))) {
439 439
                 $key = (string) $value->_id;
440 440
             }
441 441
             yield $key => $value;
Please login to merge, or discard this patch.
lib/Mongo/MongoGridFSFile.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -126,6 +126,9 @@
 block discarded – undo
126 126
         );
127 127
     }
128 128
 
129
+    /**
130
+     * @param resource $handle
131
+     */
129 132
     private function writeFromRessource($handle)
130 133
     {
131 134
 
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@
 block discarded – undo
75 75
             $filename = 'file';
76 76
         }
77 77
 
78
-        if (! $handle = fopen($filename, 'w')) {
78
+        if ( ! $handle = fopen($filename, 'w')) {
79 79
             trigger_error(E_ERROR, 'Can not open the destination file');
80 80
             return 0;
81 81
         }
Please login to merge, or discard this patch.
lib/Mongo/Mongo.php 2 patches
Doc Comments   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
      * Returns the address being used by this for slaveOkay reads
49 49
      *
50 50
      * @link http://php.net/manual/en/mongo.getslave.php
51
-     * @return bool The address of the secondary this connection is using for
51
+     * @return boolean|null The address of the secondary this connection is using for
52 52
      * reads. This returns NULL if this is not connected to a replica set or not yet
53 53
      * initialized.
54 54
      */
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
      * Get slaveOkay setting for this connection
62 62
      *
63 63
      * @link http://php.net/manual/en/mongo.getslaveokay.php
64
-     * @return bool Returns the value of slaveOkay for this instance.
64
+     * @return boolean|null Returns the value of slaveOkay for this instance.
65 65
      */
66 66
     public function getSlaveOkay()
67 67
     {
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
      *
74 74
      * @link http://www.php.net/manual/en/mongo.pairconnect.php
75 75
      * @throws MongoConnectionException
76
-     * @return boolean
76
+     * @return boolean|null
77 77
      *
78 78
      * @deprecated Pass a string of the form "mongodb://server1,server2" to the constructor instead of using this method.
79 79
      */
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
      *
100 100
      * @link http://php.net/manual/en/mongo.setslaveokay.php
101 101
      * @param bool $ok
102
-     * @return bool returns the former value of slaveOkay for this instance.
102
+     * @return boolean|null returns the former value of slaveOkay for this instance.
103 103
      */
104 104
     public function setSlaveOkay ($ok)
105 105
     {
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
      *
112 112
      * @link http://php.net/manual/en/mongo.setpoolsize.php
113 113
      * @param $size <p>The max number of connections future pools will be able to create. Negative numbers mean that the pool will spawn an infinite number of connections.</p>
114
-     * @return bool Returns the former value of pool size.
114
+     * @return boolean|null Returns the former value of pool size.
115 115
      * @deprecated Relying on this feature is highly discouraged. Please use MongoPool::setSize() instead.
116 116
      */
117 117
     public function setPoolSize($size)
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
      * @param string $username A username used to identify the connection.
127 127
      * @param string $password A password used to identify the connection.
128 128
      * @throws MongoConnectionException
129
-     * @return boolean If the connection was successful.
129
+     * @return boolean|null If the connection was successful.
130 130
      * @deprecated Pass array("persist" => $id) to the constructor instead of using this method.
131 131
      */
132 132
     public function persistConnect($username = "", $password = "")
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
      * @param string $username A username used to identify the connection.
142 142
      * @param string $password A password used to identify the connection.
143 143
      * @throws MongoConnectionException
144
-     * @return boolean If the connection was successful.
144
+     * @return boolean|null If the connection was successful.
145 145
      * @deprecated Pass "mongodb://server1,server2" and array("persist" => $id) to the constructor instead of using this method.
146 146
      */
147 147
     public function pairPersistConnect($username = "", $password = "")
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
      *
155 155
      * @link http://www.php.net/manual/en/mongo.connectutil.php
156 156
      * @throws MongoConnectionException
157
-     * @return boolean If the connection was successful.
157
+     * @return boolean|null If the connection was successful.
158 158
      */
159 159
     protected function connectUtil()
160 160
     {
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
      * Creates a database error on the database.
202 202
      *
203 203
      * @link http://www.php.net/manual/en/mongo.forceerror.php
204
-     * @return boolean The database response.
204
+     * @return boolean|null The database response.
205 205
      * @deprecated Use MongoDB::forceError() instead.
206 206
      */
207 207
     public function forceError()
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -101,7 +101,7 @@
 block discarded – undo
101 101
      * @param bool $ok
102 102
      * @return bool returns the former value of slaveOkay for this instance.
103 103
      */
104
-    public function setSlaveOkay ($ok)
104
+    public function setSlaveOkay($ok)
105 105
     {
106 106
         $this->notImplemented();
107 107
     }
Please login to merge, or discard this patch.
lib/Mongo/MongoCollection.php 3 patches
Upper-Lower-Casing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
     /**
33 33
      * @var MongoDB
34 34
      */
35
-    public $db = NULL;
35
+    public $db = null;
36 36
 
37 37
     /**
38 38
      * @var string
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
             foreach (func_get_args() as $operator) {
134 134
                 $i++;
135 135
                 if (! is_array($operator)) {
136
-                    trigger_error("Argument $i is not an array", E_WARNING);
136
+                    trigger_error("argument $i is not an array", E_WARNING);
137 137
                     return;
138 138
                 }
139 139
 
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
      * @param bool $scan_data Only validate indices, not the base collection.
235 235
      * @return array Returns the database's evaluation of this object.
236 236
      */
237
-    public function validate($scan_data = FALSE)
237
+    public function validate($scan_data = false)
238 238
     {
239 239
         $command = [
240 240
             'validate' => $this->name,
Please login to merge, or discard this 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.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -126,14 +126,14 @@  discard block
 block discarded – undo
126 126
      */
127 127
     public function aggregate(array $pipeline, array $op = [])
128 128
     {
129
-        if (! TypeConverter::isNumericArray($pipeline)) {
129
+        if ( ! TypeConverter::isNumericArray($pipeline)) {
130 130
             $pipeline = [];
131 131
             $options = [];
132 132
 
133 133
             $i = 0;
134 134
             foreach (func_get_args() as $operator) {
135 135
                 $i++;
136
-                if (! is_array($operator)) {
136
+                if ( ! is_array($operator)) {
137 137
                     trigger_error("Argument $i is not an array", E_WARNING);
138 138
                     return;
139 139
                 }
@@ -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,12 +262,12 @@  discard block
 block discarded – undo
262 262
      */
263 263
     public function insert(&$a, array $options = [])
264 264
     {
265
-        if (! $this->ensureDocumentHasMongoId($a)) {
265
+        if ( ! $this->ensureDocumentHasMongoId($a)) {
266 266
             trigger_error(sprintf('%s expects parameter %d to be an array or object, %s given', __METHOD__, 1, gettype($a)), E_USER_WARNING);
267 267
             return;
268 268
         }
269 269
 
270
-        if (! count((array)$a)) {
270
+        if ( ! count((array) $a)) {
271 271
             throw new \MongoException('document must be an array or object');
272 272
         }
273 273
 
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
             ExceptionConverter::toLegacy($e);
290 290
         }
291 291
 
292
-        if (! $result->isAcknowledged()) {
292
+        if ( ! $result->isAcknowledged()) {
293 293
             return true;
294 294
         }
295 295
 
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
 
321 321
         foreach ($a as $key => $item) {
322 322
             try {
323
-                if (! $this->ensureDocumentHasMongoId($a[$key])) {
323
+                if ( ! $this->ensureDocumentHasMongoId($a[$key])) {
324 324
                     if ($continueOnError) {
325 325
                         unset($a[$key]);
326 326
                     } else {
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
             ExceptionConverter::toLegacy($e);
345 345
         }
346 346
 
347
-        if (! $result->isAcknowledged()) {
347
+        if ( ! $result->isAcknowledged()) {
348 348
             return true;
349 349
         }
350 350
 
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
      * @throws MongoCursorException
369 369
      * @return boolean
370 370
      */
371
-    public function update(array $criteria , array $newobj, array $options = [])
371
+    public function update(array $criteria, array $newobj, array $options = [])
372 372
     {
373 373
         $multiple = isset($options['multiple']) ? $options['multiple'] : false;
374 374
         $method = $multiple ? 'updateMany' : 'updateOne';
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
             ExceptionConverter::toLegacy($e);
397 397
         }
398 398
 
399
-        if (! $result->isAcknowledged()) {
399
+        if ( ! $result->isAcknowledged()) {
400 400
             return true;
401 401
         }
402 402
 
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
      */
424 424
     public function remove(array $criteria = [], array $options = [])
425 425
     {
426
-        $multiple = isset($options['justOne']) ? !$options['justOne'] : true;
426
+        $multiple = isset($options['justOne']) ? ! $options['justOne'] : true;
427 427
         $method = $multiple ? 'deleteMany' : 'deleteOne';
428 428
 
429 429
         try {
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
             ExceptionConverter::toLegacy($e);
437 437
         }
438 438
 
439
-        if (! $result->isAcknowledged()) {
439
+        if ( ! $result->isAcknowledged()) {
440 440
             return true;
441 441
         }
442 442
 
@@ -501,7 +501,7 @@  discard block
 block discarded – undo
501 501
             } else {
502 502
                 $update = is_array($update) ? TypeConverter::fromLegacy($update) : [];
503 503
 
504
-                if (!\MongoDB\is_first_key_operator($update)) {
504
+                if ( ! \MongoDB\is_first_key_operator($update)) {
505 505
                     $update = ['$set' => $update];
506 506
                 }
507 507
 
@@ -575,7 +575,7 @@  discard block
 block discarded – undo
575 575
             $keys = (array) $keys;
576 576
         }
577 577
 
578
-        if (! is_array($keys) || ! count($keys)) {
578
+        if ( ! is_array($keys) || ! count($keys)) {
579 579
             throw new MongoException('keys cannot be empty');
580 580
         }
581 581
 
@@ -585,7 +585,7 @@  discard block
 block discarded – undo
585 585
         $indexes = $this->collection->listIndexes();
586 586
         foreach ($indexes as $index) {
587 587
 
588
-            if (! empty($options['name']) && $index->getName() === $options['name']) {
588
+            if ( ! empty($options['name']) && $index->getName() === $options['name']) {
589 589
                 throw new \MongoResultException(sprintf('index with name: %s already exists', $index->getName()));
590 590
             }
591 591
 
@@ -736,7 +736,7 @@  discard block
 block discarded – undo
736 736
             ExceptionConverter::toLegacy($e);
737 737
         }
738 738
 
739
-        if (!$result->isAcknowledged()) {
739
+        if ( ! $result->isAcknowledged()) {
740 740
             return true;
741 741
         }
742 742
 
@@ -762,13 +762,13 @@  discard block
 block discarded – undo
762 762
         if ($document_or_id instanceof \MongoId) {
763 763
             $id = $document_or_id;
764 764
         } elseif (is_object($document_or_id)) {
765
-            if (! isset($document_or_id->_id)) {
765
+            if ( ! isset($document_or_id->_id)) {
766 766
                 return null;
767 767
             }
768 768
 
769 769
             $id = $document_or_id->_id;
770 770
         } elseif (is_array($document_or_id)) {
771
-            if (! isset($document_or_id['_id'])) {
771
+            if ( ! isset($document_or_id['_id'])) {
772 772
                 return null;
773 773
             }
774 774
 
@@ -811,14 +811,14 @@  discard block
 block discarded – undo
811 811
         $command = [
812 812
             'group' => [
813 813
                 'ns' => $this->name,
814
-                '$reduce' => (string)$reduce,
814
+                '$reduce' => (string) $reduce,
815 815
                 'initial' => $initial,
816 816
                 'cond' => $condition,
817 817
             ],
818 818
         ];
819 819
 
820 820
         if ($keys instanceof MongoCode) {
821
-            $command['group']['$keyf'] = (string)$keys;
821
+            $command['group']['$keyf'] = (string) $keys;
822 822
         } else {
823 823
             $command['group']['key'] = $keys;
824 824
         }
@@ -827,7 +827,7 @@  discard block
 block discarded – undo
827 827
         }
828 828
         if (array_key_exists('finalize', $condition)) {
829 829
             if ($condition['finalize'] instanceof MongoCode) {
830
-                $condition['finalize'] = (string)$condition['finalize'];
830
+                $condition['finalize'] = (string) $condition['finalize'];
831 831
             }
832 832
             $command['group']['finalize'] = $condition['finalize'];
833 833
         }
@@ -881,11 +881,11 @@  discard block
 block discarded – undo
881 881
             $options['w'] = ($options['safe']) ? 1 : 0;
882 882
         }
883 883
 
884
-        if (isset($options['wtimeout']) && !isset($options['wTimeoutMS'])) {
884
+        if (isset($options['wtimeout']) && ! isset($options['wTimeoutMS'])) {
885 885
             $options['wTimeoutMS'] = $options['wtimeout'];
886 886
         }
887 887
 
888
-        if (isset($options['w']) || !isset($options['wTimeoutMS'])) {
888
+        if (isset($options['w']) || ! isset($options['wTimeoutMS'])) {
889 889
             $collectionWriteConcern = $this->getWriteConcern();
890 890
             $writeConcern = $this->createWriteConcernFromParameters(
891 891
                 isset($options['w']) ? $options['w'] : $collectionWriteConcern['w'],
@@ -921,7 +921,7 @@  discard block
 block discarded – undo
921 921
             if (empty($document)) {
922 922
                 throw new \MongoException('document cannot be empty');
923 923
             }
924
-            if (! isset($document['_id'])) {
924
+            if ( ! isset($document['_id'])) {
925 925
                 $document['_id'] = new \MongoId();
926 926
             }
927 927
 
@@ -932,7 +932,7 @@  discard block
 block discarded – undo
932 932
             if (empty((array) $document)) {
933 933
                 throw new \MongoException('document cannot be empty');
934 934
             }
935
-            if (! isset($document->_id)) {
935
+            if ( ! isset($document->_id)) {
936 936
                 $document->_id = new \MongoId();
937 937
             }
938 938
 
Please login to merge, or discard this patch.