Completed
Pull Request — master (#16)
by Andreas
03:04
created
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.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -377,7 +377,7 @@
 block discarded – undo
377 377
      */
378 378
     protected function convertCursorType()
379 379
     {
380
-        if (! $this->tailable) {
380
+        if (!$this->tailable) {
381 381
             return null;
382 382
         }
383 383
 
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.
lib/Alcaeus/MongoDbAdapter/Helper/WriteConcern.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@
 block discarded – undo
55 55
      */
56 56
     protected function setWriteConcernFromParameters($wstring, $wtimeout = 0)
57 57
     {
58
-        if (! is_string($wstring) && ! is_int($wstring)) {
58
+        if (!is_string($wstring) && !is_int($wstring)) {
59 59
             trigger_error("w for WriteConcern must be a string or integer", E_WARNING);
60 60
             return false;
61 61
         }
Please login to merge, or discard this patch.
lib/Mongo/MongoCollection.php 2 patches
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
      * @throws MongoException if the inserted document is empty or if it contains zero-length keys. Attempting to insert an object with protected and private properties will cause a zero-length key error.
273 273
      * @throws MongoCursorException if the "w" option is set and the write fails.
274 274
      * @throws MongoCursorTimeoutException if the "w" option is set to a value greater than one and the operation takes longer than MongoCursor::$timeout milliseconds to complete. This does not kill the operation on the server, it is a client-side timeout. The operation in MongoCollection::$wtimeout is milliseconds.
275
-     * @return bool|array Returns an array containing the status of the insertion if the "w" option is set.
275
+     * @return MongoDB\InsertOneResult Returns an array containing the status of the insertion if the "w" option is set.
276 276
      */
277 277
     public function insert($a, array $options = array())
278 278
     {
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
      * @param array $a An array of arrays.
286 286
      * @param array $options Options for the inserts.
287 287
      * @throws MongoCursorException
288
-     * @return mixed f "safe" is set, returns an associative array with the status of the inserts ("ok") and any error that may have occured ("err"). Otherwise, returns TRUE if the batch insert was successfully sent, FALSE otherwise.
288
+     * @return MongoDB\InsertManyResult f "safe" is set, returns an associative array with the status of the inserts ("ok") and any error that may have occured ("err"). Otherwise, returns TRUE if the batch insert was successfully sent, FALSE otherwise.
289 289
      */
290 290
     public function batchInsert(array $a, array $options = array())
291 291
     {
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
      * @link http://www.php.net/manual/en/mongocollection.createindex.php
467 467
      * @param array $keys Field or fields to use as index.
468 468
      * @param array $options [optional] This parameter is an associative array of the form array("optionname" => <boolean>, ...).
469
-     * @return array Returns the database response.
469
+     * @return string|false Returns the database response.
470 470
      */
471 471
     public function createIndex(array $keys, array $options = array())
472 472
     {
@@ -559,7 +559,7 @@  discard block
 block discarded – undo
559 559
      * @throws MongoException if the inserted document is empty or if it contains zero-length keys. Attempting to insert an object with protected and private properties will cause a zero-length key error.
560 560
      * @throws MongoCursorException if the "w" option is set and the write fails.
561 561
      * @throws MongoCursorTimeoutException if the "w" option is set to a value greater than one and the operation takes longer than MongoCursor::$timeout milliseconds to complete. This does not kill the operation on the server, it is a client-side timeout. The operation in MongoCollection::$wtimeout is milliseconds.
562
-     * @return array|boolean If w was set, returns an array containing the status of the save.
562
+     * @return MongoDB\UpdateResult If w was set, returns an array containing the status of the save.
563 563
      * Otherwise, returns a boolean representing if the array was not empty (an empty array will not be inserted).
564 564
      */
565 565
     public function save($a, array $options = array())
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -125,14 +125,14 @@  discard block
 block discarded – undo
125 125
      */
126 126
     public function aggregate(array $pipeline, array $op = [])
127 127
     {
128
-        if (! TypeConverter::isNumericArray($pipeline)) {
128
+        if (!TypeConverter::isNumericArray($pipeline)) {
129 129
             $pipeline = [];
130 130
             $options = [];
131 131
 
132 132
             $i = 0;
133 133
             foreach (func_get_args() as $operator) {
134 134
                 $i++;
135
-                if (! is_array($operator)) {
135
+                if (!is_array($operator)) {
136 136
                     trigger_error("Argument $i is not an array", E_WARNING);
137 137
                     return;
138 138
                 }
@@ -170,14 +170,14 @@  discard block
 block discarded – undo
170 170
         ];
171 171
 
172 172
         // Convert cursor option
173
-        if (! isset($options['cursor']) || $options['cursor'] === true || $options['cursor'] === []) {
173
+        if (!isset($options['cursor']) || $options['cursor'] === true || $options['cursor'] === []) {
174 174
             // Cursor option needs to be an object convert bools and empty arrays since those won't be handled by TypeConverter
175 175
             $options['cursor'] = new \stdClass;
176 176
         }
177 177
 
178 178
         $command += $options;
179 179
 
180
-        $cursor = new MongoCommandCursor($this->db->getConnection(), (string)$this, $command);
180
+        $cursor = new MongoCommandCursor($this->db->getConnection(), (string) $this, $command);
181 181
         $cursor->setReadPreference($this->getReadPreference());
182 182
 
183 183
         return $cursor;
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
      * @throws MongoCursorException
285 285
      * @return boolean
286 286
      */
287
-    public function update(array $criteria , array $newobj, array $options = [])
287
+    public function update(array $criteria, array $newobj, array $options = [])
288 288
     {
289 289
         $multiple = ($options['multiple']) ? $options['multiple'] : false;
290 290
         $method = $multiple ? 'updateMany' : 'updateOne';
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
      */
322 322
     public function find(array $query = [], array $fields = [])
323 323
     {
324
-        $cursor = new MongoCursor($this->db->getConnection(), (string)$this, $query, $fields);
324
+        $cursor = new MongoCursor($this->db->getConnection(), (string) $this, $query, $fields);
325 325
         $cursor->setReadPreference($this->getReadPreference());
326 326
 
327 327
         return $cursor;
@@ -504,9 +504,9 @@  discard block
 block discarded – undo
504 504
     public function save($a, array $options = [])
505 505
     {
506 506
         if (is_object($a)) {
507
-            $a = (array)$a;
507
+            $a = (array) $a;
508 508
         }
509
-        if ( ! array_key_exists('_id', $a)) {
509
+        if (!array_key_exists('_id', $a)) {
510 510
             $id = new \MongoId();
511 511
         } else {
512 512
             $id = $a['_id'];
@@ -571,20 +571,20 @@  discard block
 block discarded – undo
571 571
         if (is_string($reduce)) {
572 572
             $reduce = new MongoCode($reduce);
573 573
         }
574
-        if ( ! $reduce instanceof MongoCode) {
574
+        if (!$reduce instanceof MongoCode) {
575 575
             throw new \InvalidArgumentExcption('reduce parameter should be a string or MongoCode instance.');
576 576
         }
577 577
         $command = [
578 578
             'group' => [
579 579
                 'ns' => $this->name,
580
-                '$reduce' => (string)$reduce,
580
+                '$reduce' => (string) $reduce,
581 581
                 'initial' => $initial,
582 582
                 'cond' => $condition,
583 583
             ],
584 584
         ];
585 585
 
586 586
         if ($keys instanceof MongoCode) {
587
-            $command['group']['$keyf'] = (string)$keys;
587
+            $command['group']['$keyf'] = (string) $keys;
588 588
         } else {
589 589
             $command['group']['key'] = $keys;
590 590
         }
@@ -593,7 +593,7 @@  discard block
 block discarded – undo
593 593
         }
594 594
         if (array_key_exists('finalize', $condition)) {
595 595
             if ($condition['finalize'] instanceof MongoCode) {
596
-                $condition['finalize'] = (string)$condition['finalize'];
596
+                $condition['finalize'] = (string) $condition['finalize'];
597 597
             }
598 598
             $command['group']['finalize'] = $condition['finalize'];
599 599
         }
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/MongoDB.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -130,11 +130,11 @@  discard block
 block discarded – undo
130 130
 
131 131
         $collections = $this->db->listCollections($options);
132 132
 
133
-        $getCollectionName = function (CollectionInfo $collectionInfo) {
133
+        $getCollectionName = function(CollectionInfo $collectionInfo) {
134 134
             return $collectionInfo->getName();
135 135
         };
136 136
 
137
-        return array_map($getCollectionName, (array)$collections);
137
+        return array_map($getCollectionName, (array) $collections);
138 138
     }
139 139
 
140 140
     /**
@@ -279,13 +279,13 @@  discard block
 block discarded – undo
279 279
         if ($document_or_id instanceof \MongoId) {
280 280
             $id = $document_or_id;
281 281
         } elseif (is_object($document_or_id)) {
282
-            if (! isset($document_or_id->_id)) {
282
+            if (!isset($document_or_id->_id)) {
283 283
                 return null;
284 284
             }
285 285
 
286 286
             $id = $document_or_id->_id;
287 287
         } elseif (is_array($document_or_id)) {
288
-            if (! isset($document_or_id['_id'])) {
288
+            if (!isset($document_or_id['_id'])) {
289 289
                 return null;
290 290
             }
291 291
 
Please login to merge, or discard this patch.