use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerInterface;
+use Psr\Log\NullLogger;
/**
* Helper class to manage Redis connections.
__CLASS__ . ' requires a Redis client library. ' .
'See https://www.mediawiki.org/wiki/Redis#Setup' );
}
- $this->logger = $options['logger'] ?? new \Psr\Log\NullLogger();
+ $this->logger = $options['logger'] ?? new NullLogger();
$this->connectTimeout = $options['connectTimeout'];
$this->readTimeout = $options['readTimeout'];
$this->persistent = $options['persistent'];
$this->id = $id;
}
- /**
- * @param LoggerInterface $logger
- * @return null
- */
public function setLogger( LoggerInterface $logger ) {
$this->logger = $logger;
}
* @param string $server A hostname/port combination or the absolute path of a UNIX socket.
* If a hostname is specified but no port, port 6379 will be used.
* @param LoggerInterface|null $logger PSR-3 logger intance. [optional]
- * @return RedisConnRef|bool Returns false on failure
+ * @return RedisConnRef|Redis|bool Returns false on failure
* @throws MWException
*/
public function getConnection( $server, LoggerInterface $logger = null ) {
+ // The above @return also documents 'Redis' for convenience with IDEs.
+ // RedisConnRef uses PHP magic methods, which wouldn't be recognised.
+
$logger = $logger ?: $this->logger;
// Check the listing "dead" servers which have had a connection errors.
// Servers are marked dead for a limited period of time, to