Эх сурвалжийг харах

Do not use magic methods to serialize the command buffer: rename Predis\Command::__invoke() to Predis\Command::serialize().

Daniele Alessandri 15 жил өмнө
parent
commit
fbd5059fb2

+ 2 - 2
lib/Predis.php

@@ -504,7 +504,7 @@ abstract class Command {
         return $data;
     }
 
-    public final function __invoke() {
+    public final function serialize() {
         return $this->serializeRequest($this->getCommandId(), $this->getArguments());
     }
 }
@@ -1328,7 +1328,7 @@ class TcpConnection implements IConnectionSingle {
     }
 
     public function writeCommand(Command $command) {
-        $this->writeBytes($command());
+        $this->writeBytes($command->serialize());
     }
 
     public function readResponse(Command $command) {

+ 4 - 4
test/PredisClientFeatures.php

@@ -94,7 +94,7 @@ class PredisClientFeaturesTestSuite extends PHPUnit_Framework_TestCase {
         $this->assertFalse($cmd->closesConnection());
         $this->assertFalse($cmd->canBeHashed());
         $this->assertNull($cmd->getHash(new \Predis\Distribution\HashRing()));
-        $this->assertEquals("PING\r\n", $cmd());
+        $this->assertEquals("PING\r\n", $cmd->serialize());
     }
 
     function testCommand_InlineWithArguments() {
@@ -106,7 +106,7 @@ class PredisClientFeaturesTestSuite extends PHPUnit_Framework_TestCase {
         $this->assertFalse($cmd->closesConnection());
         $this->assertTrue($cmd->canBeHashed());
         $this->assertNotNull($cmd->getHash(new \Predis\Distribution\HashRing()));
-        $this->assertEquals("GET key\r\n", $cmd());
+        $this->assertEquals("GET key\r\n", $cmd->serialize());
     }
 
     function testCommand_BulkWithArguments() {
@@ -118,7 +118,7 @@ class PredisClientFeaturesTestSuite extends PHPUnit_Framework_TestCase {
         $this->assertFalse($cmd->closesConnection());
         $this->assertTrue($cmd->canBeHashed());
         $this->assertNotNull($cmd->getHash(new \Predis\Distribution\HashRing()));
-        $this->assertEquals("SET key 5\r\nvalue\r\n", $cmd());
+        $this->assertEquals("SET key 5\r\nvalue\r\n", $cmd->serialize());
     }
 
     function testCommand_MultiBulkWithArguments() {
@@ -130,7 +130,7 @@ class PredisClientFeaturesTestSuite extends PHPUnit_Framework_TestCase {
         $this->assertFalse($cmd->closesConnection());
         $this->assertFalse($cmd->canBeHashed());
         $this->assertNotNull($cmd->getHash(new \Predis\Distribution\HashRing()));
-        $this->assertEquals("*5\r\n$4\r\nMSET\r\n$4\r\nkey1\r\n$6\r\nvalue1\r\n$4\r\nkey2\r\n$6\r\nvalue2\r\n", $cmd());
+        $this->assertEquals("*5\r\n$4\r\nMSET\r\n$4\r\nkey1\r\n$6\r\nvalue1\r\n$4\r\nkey2\r\n$6\r\nvalue2\r\n", $cmd->serialize());
     }
 
     function testCommand_ParseResponse() {