Skip to content

Commit 939a14f

Browse files
committed
[fixed bug] BUG说明:Connection类继承了Redis类,重了open方法,open方法和Redis类中的open方法参数不一致,error_reporting开启严格模式以后,会产生一条警告:Declaration of dcb9\redis\Connection::open() should be compatible with Redis::open($host, $port = NULL, $timeout = NULL, $retry_interval = NULL)。
1 parent 626e76d commit 939a14f

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

Connection.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,28 @@ public static function className()
7777
* Establishes a DB connection.
7878
* It does nothing if a DB connection has already been established.
7979
* @throws RedisException if connection fails
80+
* @see connect()
81+
* @param string $host
82+
* @param int $port
83+
* @param float $timeout
84+
* @param int $retry_interval
85+
* @return bool
8086
*/
81-
public function open()
87+
public function open( $host = null, $port = null, $timeout = null, $retry_interval = 0 )
8288
{
8389
if ($this->unixSocket !== null) {
8490
$isConnected = $this->connect($this->unixSocket);
8591
} else {
86-
$isConnected = $this->connect($this->hostname, $this->port, $this->connectionTimeout);
92+
if(is_null($host)){
93+
$host = $this->hostname;
94+
}
95+
if(is_null($port)){
96+
$port = $this->port;
97+
}
98+
if(is_null($timeout)){
99+
$timeout = $this->connectionTimeout;
100+
}
101+
$isConnected = $this->connect($host, $port, $timeout, null, $retry_interval);
87102
}
88103

89104
if ($isConnected === false) {

0 commit comments

Comments
 (0)