Skip to content

Commit

Permalink
Fix incorrect type hints, and ensure port's nullability is respected (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Xon authored Jun 20, 2022
1 parent b63f772 commit 85df015
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ class Credis_Client {

/**
* Scheme of the Redis server (tcp, tls, tlsv1.2, unix)
* @var string
* @var string|null
*/
protected $scheme;

Expand All @@ -207,19 +207,19 @@ class Credis_Client {

/**
* Port on which the Redis server is running
* @var integer|null
* @var int|null
*/
protected $port;

/**
* Timeout for connecting to Redis server
* @var float
* @var float|null
*/
protected $timeout;

/**
* Timeout for reading response from Redis server
* @var float
* @var float|null
*/
protected $readTimeout;

Expand Down Expand Up @@ -280,12 +280,12 @@ class Credis_Client {
protected $isWatching = FALSE;

/**
* @var string
* @var string|null
*/
protected $authUsername;

/**
* @var string
* @var string|null
*/
protected $authPassword;

Expand All @@ -301,7 +301,7 @@ class Credis_Client {
protected $wrapperMethods = array('delete' => 'del', 'getkeys' => 'keys', 'sremove' => 'srem');

/**
* @var array
* @var array<string,string>|callable|null
*/
protected $renamedCommands;

Expand Down Expand Up @@ -342,18 +342,20 @@ public function getSslMeta()
* $host may also be a path to a unix socket or a string in the form of tcp://[hostname]:[port] or unix://[path]
*
* @param string $host The hostname of the Redis server
* @param integer $port The port number of the Redis server
* @param float $timeout Timeout period in seconds
* @param int|null $port The port number of the Redis server
* @param float|null $timeout Timeout period in seconds
* @param string $persistent Flag to establish persistent connection
* @param int $db The selected datbase of the Redis server
* @param string $password The authentication password of the Redis server
* @param string $username The authentication username of the Redis server
* @param int $db The selected database of the Redis server
* @param string|null $password The authentication password of the Redis server
* @param string|null $username The authentication username of the Redis server
* @param array|null $tlsOptions The TLS/SSL context options. See https://www.php.net/manual/en/context.ssl.php for details
*/
public function __construct($host = '127.0.0.1', $port = 6379, $timeout = null, $persistent = '', $db = 0, $password = null, $username = null, array $tlsOptions = null)
{
$this->host = (string) $host;
$this->port = (int) $port;
if ($port !== null) {
$this->port = (int) $port;
}
$this->scheme = null;
$this->timeout = $timeout;
$this->persistent = (string) $persistent;
Expand Down Expand Up @@ -622,7 +624,7 @@ public function isConnected()
* Set the read timeout for the connection. Use 0 to disable timeouts entirely (or use a very long timeout
* if not supported).
*
* @param int $timeout 0 (or -1) for no timeout, otherwise number of seconds
* @param float $timeout 0 (or -1) for no timeout, otherwise number of seconds
* @throws CredisException
* @return Credis_Client
*/
Expand Down

0 comments on commit 85df015

Please sign in to comment.