Andreas Braun пре 8 година
родитељ
комит
63f8ed6116

+ 9 - 9
lib/Mongo/MongoClient.php

@@ -32,13 +32,13 @@ class MongoClient
     use Helper\WriteConcern;
 
     const VERSION = '1.6.12';
-    const DEFAULT_HOST = "localhost" ;
-    const DEFAULT_PORT = 27017 ;
-    const RP_PRIMARY = "primary" ;
-    const RP_PRIMARY_PREFERRED = "primaryPreferred" ;
-    const RP_SECONDARY = "secondary" ;
-    const RP_SECONDARY_PREFERRED = "secondaryPreferred" ;
-    const RP_NEAREST = "nearest" ;
+    const DEFAULT_HOST = "localhost";
+    const DEFAULT_PORT = 27017;
+    const RP_PRIMARY = "primary";
+    const RP_PRIMARY_PREFERRED = "primaryPreferred";
+    const RP_SECONDARY = "secondary";
+    const RP_SECONDARY_PREFERRED = "secondaryPreferred";
+    const RP_NEAREST = "nearest";
 
     /**
      * @var bool
@@ -94,7 +94,7 @@ class MongoClient
 
         $this->server = $server;
         if (false === strpos($this->server, 'mongodb://')) {
-            $this->server = 'mongodb://'.$this->server;
+            $this->server = 'mongodb://' . $this->server;
         }
         $this->client = new Client($this->server, $options, $driverOptions);
         $info = $this->client->__debugInfo();
@@ -352,7 +352,7 @@ class MongoClient
     /**
      * @return array
      */
-    function __sleep()
+    public function __sleep()
     {
         return [
             'connected', 'status', 'server', 'persistent'

+ 3 - 3
lib/Mongo/MongoCollection.php

@@ -888,14 +888,14 @@ class MongoCollection
         $command = [
             'group' => [
                 'ns' => $this->name,
-                '$reduce' => (string)$reduce,
+                '$reduce' => (string) $reduce,
                 'initial' => $initial,
                 'cond' => $condition,
             ],
         ];
 
         if ($keys instanceof MongoCode) {
-            $command['group']['$keyf'] = (string)$keys;
+            $command['group']['$keyf'] = (string) $keys;
         } else {
             $command['group']['key'] = $keys;
         }
@@ -904,7 +904,7 @@ class MongoCollection
         }
         if (array_key_exists('finalize', $condition)) {
             if ($condition['finalize'] instanceof MongoCode) {
-                $condition['finalize'] = (string)$condition['finalize'];
+                $condition['finalize'] = (string) $condition['finalize'];
             }
             $command['group']['finalize'] = $condition['finalize'];
         }

+ 3 - 1
lib/Mongo/MongoDB.php

@@ -154,7 +154,9 @@ class MongoDB
                     'info' => isset($info['info']) ? (array) $info['info'] : null,
                     'idIndex' => isset($info['idIndex']) ? (array) $info['idIndex'] : null,
                 ],
-                function ($item) { return $item !== null; }
+                function ($item) {
+                    return $item !== null;
+                }
             );
         };
 

+ 1 - 1
lib/Mongo/MongoGridFS.php

@@ -207,7 +207,7 @@ class MongoGridFS extends MongoCollection
         try {
             $file = $this->insertFile($record, $options);
         } catch (MongoException $e) {
-            throw new MongoGridFSException('Could not store file: '. $e->getMessage(), $e->getCode(), $e);
+            throw new MongoGridFSException('Could not store file: ' . $e->getMessage(), $e->getCode(), $e);
         }
 
         try {

+ 1 - 1
lib/Mongo/MongoGridFSCursor.php

@@ -68,6 +68,6 @@ class MongoGridFSCursor extends MongoCursor
     public function key()
     {
         $file = $this->current();
-        return ($file !== null) ? (string)$file->file['_id'] : null;
+        return ($file !== null) ? (string) $file->file['_id'] : null;
     }
 }

+ 1 - 1
lib/Mongo/MongoWriteBatch.php

@@ -83,7 +83,7 @@ class MongoWriteBatch
     public function add($item)
     {
         if (is_object($item)) {
-            $item = (array)$item;
+            $item = (array) $item;
         }
 
         $this->validate($item);

+ 1 - 1
tests/Alcaeus/MongoDbAdapter/Mongo/MongoBinDataTest.php

@@ -18,7 +18,7 @@ class MongoBinDataTest extends TestCase
         $this->assertAttributeSame(self::GUID, 'bin', $bin);
         $this->assertAttributeSame(\MongoBinData::FUNC, 'type', $bin);
 
-        $this->assertSame('<Mongo Binary Data>', (string)$bin);
+        $this->assertSame('<Mongo Binary Data>', (string) $bin);
 
         return $bin;
     }

+ 1 - 1
tests/Alcaeus/MongoDbAdapter/Mongo/MongoCodeTest.php

@@ -16,7 +16,7 @@ class MongoCodeTest extends TestCase
         $this->assertAttributeSame('code', 'code', $code);
         $this->assertAttributeSame(['scope' => 'bleh'], 'scope', $code);
 
-        $this->assertSame('code', (string)$code);
+        $this->assertSame('code', (string) $code);
 
         return $code;
     }

+ 2 - 1
tests/Alcaeus/MongoDbAdapter/Mongo/MongoCollectionTest.php

@@ -1061,7 +1061,8 @@ class MongoCollectionTest extends TestCase
         $this->assertAttributeSame('foo', 'foo', $object);
     }
 
-    public function testSavingShouldReplaceTheWholeDocument() {
+    public function testSavingShouldReplaceTheWholeDocument()
+    {
         $id = '54203e08d51d4a1f868b456e';
         $collection = $this->getCollection();
 

+ 6 - 3
tests/Alcaeus/MongoDbAdapter/Mongo/MongoCursorTest.php

@@ -200,7 +200,8 @@ class MongoCursorTest extends TestCase
 
     public static function getCursorOptions()
     {
-        function getMissingOptionCallback($optionName) {
+        function getMissingOptionCallback($optionName)
+        {
             return function ($value) use ($optionName) {
                 return
                     is_array($value) &&
@@ -208,7 +209,8 @@ class MongoCursorTest extends TestCase
             };
         }
 
-        function getBasicCheckCallback($expected, $optionName) {
+        function getBasicCheckCallback($expected, $optionName)
+        {
             return function ($value) use ($expected, $optionName) {
                 return
                     is_array($value) &&
@@ -217,7 +219,8 @@ class MongoCursorTest extends TestCase
             };
         }
 
-        function getModifierCheckCallback($expected, $modifierName) {
+        function getModifierCheckCallback($expected, $modifierName)
+        {
             return function ($value) use ($expected, $modifierName) {
                 return
                     is_array($value) &&

+ 0 - 1
tests/Alcaeus/MongoDbAdapter/Mongo/MongoDBTest.php

@@ -180,7 +180,6 @@ class MongoDBTest extends TestCase
 
         $this->assertSame(ReadPreference::RP_SECONDARY, $readPreference->getMode());
         $this->assertSame([['a' => 'b']], $readPreference->getTagSets());
-
     }
 
     public function testReadPreferenceIsInherited()

+ 2 - 1
tests/Alcaeus/MongoDbAdapter/Mongo/MongoDateTest.php

@@ -17,7 +17,8 @@ class MongoDateTest extends TestCase
         ini_set("date.timezone", "UTC");
 
         // Today at 8h 8m 8s
-        $timestamp = mktime (8, 8, 8); $date = new \MongoDate($timestamp);
+        $timestamp = mktime(8, 8, 8);
+        $date = new \MongoDate($timestamp);
 
         $this->assertSame('08:08:08', $date->toDateTime()->format("H:i:s"));
 

+ 1 - 1
tests/Alcaeus/MongoDbAdapter/Mongo/MongoGridFSCursorTest.php

@@ -25,7 +25,7 @@ class MongoGridFSCursorTest extends TestCase
         $cursor = $gridfs->find(['filename' => 'foo.txt']);
         $this->assertCount(1, $cursor);
         foreach ($cursor as $key => $value) {
-            $this->assertSame((string)$id, $key);
+            $this->assertSame((string) $id, $key);
             $this->assertInstanceOf('MongoGridFSFile', $value);
             $this->assertSame('foo', $value->getBytes());
 

+ 4 - 4
tests/Alcaeus/MongoDbAdapter/Mongo/MongoGridFSTest.php

@@ -177,7 +177,7 @@ class MongoGridFSTest extends TestCase
         $this->assertObjectHasAttribute('filename', $record);
         $this->assertAttributeSame($filename, 'filename', $record);
 
-        $numberOfChunks = (int)ceil($size / 100);
+        $numberOfChunks = (int) ceil($size / 100);
         $this->assertSame($numberOfChunks, $newChunksCollection->count());
         $expectedContent = substr(file_get_contents(__FILE__), 0, 100);
 
@@ -222,7 +222,7 @@ class MongoGridFSTest extends TestCase
         $this->assertObjectHasAttribute('filename', $record);
         $this->assertAttributeSame('test.php', 'filename', $record);
 
-        $numberOfChunks = (int)ceil($size / 100);
+        $numberOfChunks = (int) ceil($size / 100);
         $this->assertSame($numberOfChunks, $newChunksCollection->count());
         $expectedContent = substr(file_get_contents(__FILE__), 0, 100);
 
@@ -273,7 +273,7 @@ class MongoGridFSTest extends TestCase
         $this->assertObjectHasAttribute('filename', $record);
         $this->assertAttributeSame('test.php', 'filename', $record);
 
-        $numberOfChunks = (int)ceil($size / 100);
+        $numberOfChunks = (int) ceil($size / 100);
         $this->assertSame($numberOfChunks, $newChunksCollection->count());
     }
 
@@ -332,7 +332,7 @@ class MongoGridFSTest extends TestCase
         $this->assertSame(1, $newCollection->count());
 
         $size = filesize(__FILE__);
-        $numberOfChunks = (int)ceil($size / 100);
+        $numberOfChunks = (int) ceil($size / 100);
         $this->assertSame($numberOfChunks, $newChunksCollection->count());
     }
 

+ 2 - 1
tests/Alcaeus/MongoDbAdapter/Mongo/MongoLogTest.php

@@ -8,7 +8,8 @@ class MongoLogTest extends Testcase
 {
     public function testSetCallback()
     {
-        $foo = function() {};
+        $foo = function () {
+        };
         $this->assertTrue(\MongoLog::setCallback($foo));
         $this->assertSame($foo, \MongoLog::getCallback());
     }

+ 1 - 1
tests/Alcaeus/MongoDbAdapter/Mongo/MongoTimestampTest.php

@@ -63,6 +63,6 @@ class MongoTimestampTest extends TestCase
         $bsonTimestamp = new \MongoDB\BSON\Timestamp(12345, 67890);
         $timestamp = new \MongoTimestamp(67890, 12345);
 
-        $this->assertSame((string) $bsonTimestamp, (string)$timestamp->toBSONType());
+        $this->assertSame((string) $bsonTimestamp, (string) $timestamp->toBSONType());
     }
 }

+ 1 - 1
tests/Alcaeus/MongoDbAdapter/TestCase.php

@@ -139,7 +139,7 @@ abstract class TestCase extends BaseTestCase
             /* command not found */
             if ($e->getCode() == 59) {
                 $this->markTestSkipped(
-                  'This test require the mongo daemon to be started with the test flag: --setParameter enableTestCommands=1'
+                    'This test require the mongo daemon to be started with the test flag: --setParameter enableTestCommands=1'
                 );
             }
         }