Completed
Pull Request — master (#12)
by
unknown
02:42
created
lib/Mongo/MongoClient.php 1 patch
Spacing   +9 added lines, -9 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
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
             $results[$key] = [
196 196
                 'host'     => $server->getHost(),
197 197
                 'port'     => $server->getPort(),
198
-                'health'   => (int)$info['ok'], // Not totally sure about this
198
+                'health'   => (int) $info['ok'], // Not totally sure about this
199 199
                 'state'    => $server->getType(),
200 200
                 'ping'     => $server->getLatency(),
201 201
                 'lastPing' => null,
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
      * {@link http://www.php.net/manual/en/class.mongoint64.php MongoInt64} class. The latter is necessary on 32
236 236
      * bit platforms (and Windows).
237 237
      */
238
-    public function killCursor($server_hash , $id)
238
+    public function killCursor($server_hash, $id)
239 239
     {
240 240
         throw new \Exception('Not implemented');
241 241
     }
Please login to merge, or discard this patch.
lib/Mongo/MongoCursor.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\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/Mongo/MongoDB.php 2 patches
Doc Comments   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -292,7 +292,6 @@  discard block
 block discarded – undo
292 292
      * (PECL mongo &gt;= 0.9.0)<br/>
293 293
      * Get a list of collections in this database
294 294
      * @link http://www.php.net/manual/en/mongodb.listcollections.php
295
-     * @param bool $includeSystemCollections [optional] <p>Include system collections.</p>
296 295
      * @return array Returns a list of MongoCollections.
297 296
      */
298 297
     public function listCollections(array $options = [])
@@ -433,7 +432,7 @@  discard block
 block discarded – undo
433 432
      * (PECL mongo &gt;= 0.9.5)<br/>
434 433
      * Creates a database error
435 434
      * @link http://www.php.net/manual/en/mongodb.forceerror.php
436
-     * @return boolean Returns the database response.
435
+     * @return boolean|null Returns the database response.
437 436
      */
438 437
     public function forceError()
439 438
     {
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 
130 130
         $collections = $this->db->listCollections($options);
131 131
 
132
-        $getCollectionName = function (CollectionInfo $collectionInfo) {
132
+        $getCollectionName = function(CollectionInfo $collectionInfo) {
133 133
             return $collectionInfo->getName();
134 134
         };
135 135
 
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
             $id = isset($document_or_id->_id) ? $document_or_id->_id : null;
316 316
 //            $id = $document_or_id->_id ?? null;
317 317
         } elseif (is_array($document_or_id)) {
318
-            if (! isset($document_or_id['_id'])) {
318
+            if (!isset($document_or_id['_id'])) {
319 319
                 return null;
320 320
             }
321 321
 
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   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -121,14 +121,14 @@  discard block
 block discarded – undo
121 121
      */
122 122
     public function aggregate(array $pipeline, array $op = [])
123 123
     {
124
-        if (! TypeConverter::isNumericArray($pipeline)) {
124
+        if (!TypeConverter::isNumericArray($pipeline)) {
125 125
             $pipeline = [];
126 126
             $options = [];
127 127
 
128 128
             $i = 0;
129 129
             foreach (func_get_args() as $operator) {
130 130
                 $i++;
131
-                if (! is_array($operator)) {
131
+                if (!is_array($operator)) {
132 132
                     trigger_error("Argument $i is not an array", E_WARNING);
133 133
                     return;
134 134
                 }
@@ -164,14 +164,14 @@  discard block
 block discarded – undo
164 164
         ];
165 165
 
166 166
         // Convert cursor option
167
-        if (! isset($options['cursor']) || $options['cursor'] === true || $options['cursor'] === []) {
167
+        if (!isset($options['cursor']) || $options['cursor'] === true || $options['cursor'] === []) {
168 168
             // Cursor option needs to be an object convert bools and empty arrays since those won't be handled by TypeConverter
169 169
             $options['cursor'] = new \stdClass;
170 170
         }
171 171
 
172 172
         $command += $options;
173 173
 
174
-        $cursor = new MongoCommandCursor($this->db->getConnection(), (string)$this, $command);
174
+        $cursor = new MongoCommandCursor($this->db->getConnection(), (string) $this, $command);
175 175
         $cursor->setReadPreference($this->getReadPreference());
176 176
 
177 177
         return $cursor;
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
      * @throws MongoCursorException
322 322
      * @return boolean
323 323
      */
324
-    public function update(array $criteria , array $newobj, array $options = array())
324
+    public function update(array $criteria, array $newobj, array $options = array())
325 325
     {
326 326
         $multiple = ($options['multiple']) ? $options['multiple'] : false;
327 327
 //        $multiple = $options['multiple'] ?? false;
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
      */
390 390
     public function find(array $query = array(), array $fields = array())
391 391
     {
392
-        $cursor = new MongoCursor($this->db->getConnection(), (string)$this, $query, $fields);
392
+        $cursor = new MongoCursor($this->db->getConnection(), (string) $this, $query, $fields);
393 393
         $cursor->setReadPreference($this->getReadPreference());
394 394
 
395 395
         return $cursor;
@@ -565,9 +565,9 @@  discard block
 block discarded – undo
565 565
     public function save($a, array $options = array())
566 566
     {
567 567
         if (is_object($a)) {
568
-            $a = (array)$a;
568
+            $a = (array) $a;
569 569
         }
570
-        if ( ! array_key_exists('_id', $a)) {
570
+        if (!array_key_exists('_id', $a)) {
571 571
             $id = new \MongoId();
572 572
         } else {
573 573
             $id = $a['_id'];
@@ -629,20 +629,20 @@  discard block
 block discarded – undo
629 629
         if (is_string($reduce)) {
630 630
             $reduce = new MongoCode($reduce);
631 631
         }
632
-        if ( ! $reduce instanceof MongoCode) {
632
+        if (!$reduce instanceof MongoCode) {
633 633
             throw new \InvalidArgumentExcption('reduce parameter should be a string or MongoCode instance.');
634 634
         }
635 635
         $command = [
636 636
             'group' => [
637 637
                 'ns'      => $this->name,
638
-                '$reduce' => (string)$reduce,
638
+                '$reduce' => (string) $reduce,
639 639
                 'initial' => $initial,
640 640
                 'cond'    => $condition,
641 641
             ],
642 642
         ];
643 643
 
644 644
         if ($keys instanceof MongoCode) {
645
-            $command['group']['$keyf'] = (string)$keys;
645
+            $command['group']['$keyf'] = (string) $keys;
646 646
         } else {
647 647
             $command['group']['key'] = $keys;
648 648
         }
@@ -651,14 +651,14 @@  discard block
 block discarded – undo
651 651
         }
652 652
         if (array_key_exists('finalize', $condition)) {
653 653
             if ($condition['finalize'] instanceof MongoCode) {
654
-                $condition['finalize'] = (string)$condition['finalize'];
654
+                $condition['finalize'] = (string) $condition['finalize'];
655 655
             }
656 656
             $command['group']['finalize'] = $condition['finalize'];
657 657
         }
658 658
 
659 659
         $result = $this->db->command($command, [], $hash);
660 660
         unset($result['waitedMS']);
661
-        $result['ok'] = (int)$result['ok'];
661
+        $result['ok'] = (int) $result['ok'];
662 662
         if (count($result['retval'])) {
663 663
             $result['retval'] = current($result['retval']);
664 664
         }
Please login to merge, or discard this patch.
lib/Mongo/Mongo.php 1 patch
Doc Comments   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
      * @deprecated Pass a string of the form "mongodb://server1,server2" to the constructor instead of using this method.
42 42
      * @link http://www.php.net/manual/en/mongo.pairconnect.php
43 43
      * @throws MongoConnectionException
44
-     * @return boolean
44
+     * @return boolean|null
45 45
      */
46 46
     public function pairConnect() {}
47 47
 
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
      * Set the size for future connection pools.
92 92
      * @link http://php.net/manual/en/mongo.setpoolsize.php
93 93
      * @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>
94
-     * @return bool Returns the former value of pool size.
94
+     * @return boolean|null Returns the former value of pool size.
95 95
      */
96 96
     public function setPoolSize($size) {}
97 97
     /**
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
      * @param string $username A username used to identify the connection.
102 102
      * @param string $password A password used to identify the connection.
103 103
      * @throws MongoConnectionException
104
-     * @return boolean If the connection was successful.
104
+     * @return boolean|null If the connection was successful.
105 105
      */
106 106
     public function persistConnect($username = "", $password = "") {}
107 107
 
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
      * @param string $username A username used to identify the connection.
113 113
      * @param string $password A password used to identify the connection.
114 114
      * @throws MongoConnectionException
115
-     * @return boolean If the connection was successful.
115
+     * @return boolean|null If the connection was successful.
116 116
      */
117 117
     public function pairPersistConnect($username = "", $password = "") {}
118 118
 
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
      *
122 122
      * @link http://www.php.net/manual/en/mongo.connectutil.php
123 123
      * @throws MongoConnectionException
124
-     * @return boolean If the connection was successful.
124
+     * @return boolean|null If the connection was successful.
125 125
      */
126 126
     protected function connectUtil() {}
127 127
 
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
      * Creates a database error on the database.
154 154
      * @deprecated Use MongoDB::forceError() instead.
155 155
      * @link http://www.php.net/manual/en/mongo.forceerror.php
156
-     * @return boolean The database response.
156
+     * @return boolean|null The database response.
157 157
      */
158 158
     public function forceError() {}
159 159
 }
Please login to merge, or discard this patch.
lib/Alcaeus/MongoDbAdapter/Helper/Slave.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -29,10 +29,10 @@  discard block
 block discarded – undo
29 29
     abstract public function setSlaveOkay($ok = true);
30 30
 
31 31
 
32
-	/**
33
-     * @link http://www.php.net/manual/en/mongocollection.getslaveokay.php
34
-     * @return bool
35
-     */
32
+ /**
33
+  * @link http://www.php.net/manual/en/mongocollection.getslaveokay.php
34
+  * @return bool
35
+  */
36 36
     public function getSlaveOkay()
37 37
     {
38 38
         return $this->readPreference->getMode() != \MongoDB\Driver\ReadPreference::RP_PRIMARY;
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 
41 41
     private function setSlaveOkayFromParameter($ok = true)
42 42
     {
43
-    	$result = $this->getSlaveOkay();
43
+     $result = $this->getSlaveOkay();
44 44
         $this->readPreference = new \MongoDB\Driver\ReadPreference(
45 45
             $ok ? \MongoDB\Driver\ReadPreference::RP_SECONDARY_PREFERRED : \MongoDB\Driver\ReadPreference::RP_PRIMARY,
46 46
             $this->readPreference->getTagSets()
Please login to merge, or discard this patch.