Passed
Push — master ( a81e56...f8f96d )
by wen
07:57 queued 06:20
created
src/Connection.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -573,9 +573,9 @@  discard block
 block discarded – undo
573 573
         if ($this->_socket !== false) {
574 574
             return;
575 575
         }
576
-        $connection = ($this->unixSocket ?: $this->hostname . ':' . $this->port) . ', database=' . $this->database;
576
+        $connection = ($this->unixSocket ?: $this->hostname.':'.$this->port).', database='.$this->database;
577 577
         $this->_socket = @stream_socket_client(
578
-            $this->unixSocket ? 'unix://' . $this->unixSocket : 'tcp://' . $this->hostname . ':' . $this->port,
578
+            $this->unixSocket ? 'unix://'.$this->unixSocket : 'tcp://'.$this->hostname.':'.$this->port,
579 579
             $errorNumber,
580 580
             $errorDescription,
581 581
             $this->connectionTimeout ? $this->connectionTimeout : ini_get('default_socket_timeout'),
@@ -605,7 +605,7 @@  discard block
 block discarded – undo
605 605
     public function close()
606 606
     {
607 607
         if ($this->_socket !== false) {
608
-            $connection = ($this->unixSocket ?: $this->hostname . ':' . $this->port) . ', database=' . $this->database;
608
+            $connection = ($this->unixSocket ?: $this->hostname.':'.$this->port).', database='.$this->database;
609 609
             try {
610 610
                 $this->executeCommand('QUIT');
611 611
             } catch (SocketRedisException $e) {
@@ -717,9 +717,9 @@  discard block
 block discarded – undo
717 717
         $this->open();
718 718
 
719 719
         $params = array_merge(explode(' ', $name), $params);
720
-        $command = '*' . count($params) . "\r\n";
720
+        $command = '*'.count($params)."\r\n";
721 721
         foreach ($params as $arg) {
722
-            $command .= '$' . mb_strlen($arg, '8bit') . "\r\n" . $arg . "\r\n";
722
+            $command .= '$'.mb_strlen($arg, '8bit')."\r\n".$arg."\r\n";
723 723
         }
724 724
 
725 725
         if ($this->retries > 0) {
@@ -749,10 +749,10 @@  discard block
 block discarded – undo
749 749
     {
750 750
         $written = @fwrite($this->_socket, $command);
751 751
         if ($written === false) {
752
-            throw new SocketRedisException("Failed to write to socket.\nRedis command was: " . $command);
752
+            throw new SocketRedisException("Failed to write to socket.\nRedis command was: ".$command);
753 753
         }
754 754
         if ($written !== ($len = mb_strlen($command, '8bit'))) {
755
-            throw new SocketRedisException("Failed to write to socket. $written of $len bytes written.\nRedis command was: " . $command);
755
+            throw new SocketRedisException("Failed to write to socket. $written of $len bytes written.\nRedis command was: ".$command);
756 756
         }
757 757
         return $this->parseResponse(implode(' ', $params));
758 758
     }
@@ -770,7 +770,7 @@  discard block
 block discarded – undo
770 770
     private function parseResponse($command)
771 771
     {
772 772
         if (($line = fgets($this->_socket)) === false) {
773
-            throw new SocketRedisException("Failed to read from socket.\nRedis command was: " . $command);
773
+            throw new SocketRedisException("Failed to read from socket.\nRedis command was: ".$command);
774 774
         }
775 775
         $type = $line[0];
776 776
         $line = mb_substr($line, 1, -2, '8bit');
@@ -782,7 +782,7 @@  discard block
 block discarded – undo
782 782
                     return $line;
783 783
                 }
784 784
             case '-': // Error reply
785
-                throw new RedisException("Redis error: " . $line . "\nRedis command was: " . $command);
785
+                throw new RedisException("Redis error: ".$line."\nRedis command was: ".$command);
786 786
             case ':': // Integer reply
787 787
                 // no cast to int as it is in the range of a signed 64 bit integer
788 788
                 return $line;
@@ -790,11 +790,11 @@  discard block
 block discarded – undo
790 790
                 if ($line == '-1') {
791 791
                     return null;
792 792
                 }
793
-                $length = (int)$line + 2;
793
+                $length = (int) $line + 2;
794 794
                 $data = '';
795 795
                 while ($length > 0) {
796 796
                     if (($block = fread($this->_socket, $length)) === false) {
797
-                        throw new SocketRedisException("Failed to read from socket.\nRedis command was: " . $command);
797
+                        throw new SocketRedisException("Failed to read from socket.\nRedis command was: ".$command);
798 798
                     }
799 799
                     $data .= $block;
800 800
                     $length -= mb_strlen($block, '8bit');
@@ -810,7 +810,7 @@  discard block
 block discarded – undo
810 810
 
811 811
                 return $data;
812 812
             default:
813
-                throw new RedisException('Received illegal data from redis: ' . $line . "\nRedis command was: " . $command);
813
+                throw new RedisException('Received illegal data from redis: '.$line."\nRedis command was: ".$command);
814 814
         }
815 815
     }
816 816
 }
Please login to merge, or discard this patch.
src/Lock.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
      */
25 25
     public function acquireLock(string $lockName, $acquireTimeout = 10, $lockTimeout = 10)
26 26
     {
27
-        $lockName = 'lock:' . $lockName;
27
+        $lockName = 'lock:'.$lockName;
28 28
         $identifier = $this->getIdentifier();
29 29
         $end = time() + $acquireTimeout;
30 30
         while (time() < $end) {
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
      */
48 48
     public function releaseLock(string $lockName, string $identifier)
49 49
     {
50
-        $lockName = 'lock:' . $lockName;
50
+        $lockName = 'lock:'.$lockName;
51 51
         while (true) {
52 52
             $this->redis->watch($lockName);
53 53
             if ($this->redis->get($lockName) == $identifier) {
@@ -76,8 +76,8 @@  discard block
 block discarded – undo
76 76
     {
77 77
         $identifier = $this->getIdentifier();
78 78
         $microTime = $this->microTimeFloat();
79
-        $ownerZset = $semname . ':owner';
80
-        $counterStr = $semname . ':counter';
79
+        $ownerZset = $semname.':owner';
80
+        $counterStr = $semname.':counter';
81 81
 
82 82
         // 清理过期的信号量持有者
83 83
         $this->redis->zremrangebyscore($semname, '-inf', $microTime + $timeout);
@@ -109,8 +109,8 @@  discard block
 block discarded – undo
109 109
     public function releaseFairSemaphore($semname, $identifier)
110 110
     {
111 111
         $this->redis->zrem($semname, $identifier);
112
-        $ownerZset = $semname . ':owner';
113
-        return (bool)$this->redis->zrem($ownerZset, $identifier);
112
+        $ownerZset = $semname.':owner';
113
+        return (bool) $this->redis->zrem($ownerZset, $identifier);
114 114
     }
115 115
 
116 116
     /**
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
     protected function microTimeFloat()
156 156
     {
157 157
         list($usec, $sec) = explode(' ', microtime());
158
-        return ((float)$usec + (float)$sec);
158
+        return ((float) $usec + (float) $sec);
159 159
     }
160 160
 
161 161
     protected function getIdentifier()
Please login to merge, or discard this patch.