-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor lib/private #39249
Refactor lib/private #39249
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -33,23 +33,23 @@ class RedisFactory { | |||||
public const REDIS_EXTRA_PARAMETERS_MINIMAL_VERSION = '5.3.0'; | ||||||
|
||||||
/** @var \Redis|\RedisCluster */ | ||||||
private $instance; | ||||||
|
||||||
private SystemConfig $config; | ||||||
|
||||||
private IEventLogger $eventLogger; | ||||||
private \Redis|\RedisCluster $instance; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This cannot work because the property is not instanciated in constructor.
Suggested change
And then the class should be adapted so that psalm is happy. The |
||||||
|
||||||
/** | ||||||
* RedisFactory constructor. | ||||||
* | ||||||
* @param SystemConfig $config | ||||||
*/ | ||||||
public function __construct(SystemConfig $config, IEventLogger $eventLogger) { | ||||||
$this->config = $config; | ||||||
$this->eventLogger = $eventLogger; | ||||||
public function __construct( | ||||||
private SystemConfig $config, | ||||||
private IEventLogger $eventLogger, | ||||||
) { | ||||||
} | ||||||
|
||||||
private function create() { | ||||||
/** | ||||||
* @throws \Exception | ||||||
*/ | ||||||
private function create(): void { | ||||||
$isCluster = in_array('redis.cluster', $this->config->getKeys(), true); | ||||||
$config = $isCluster | ||||||
? $this->config->getValue('redis.cluster', []) | ||||||
|
@@ -137,7 +137,7 @@ private function create() { | |||||
* @return array|null | ||||||
* @throws \UnexpectedValueException | ||||||
*/ | ||||||
private function getSslContext($config) { | ||||||
private function getSslContext(array $config): ?array { | ||||||
if (isset($config['ssl_context'])) { | ||||||
if (!$this->isConnectionParametersSupported()) { | ||||||
throw new \UnexpectedValueException(\sprintf( | ||||||
|
@@ -150,7 +150,10 @@ private function getSslContext($config) { | |||||
return null; | ||||||
} | ||||||
|
||||||
public function getInstance() { | ||||||
/** | ||||||
* @throws \Exception | ||||||
*/ | ||||||
public function getInstance(): \RedisCluster|\Redis { | ||||||
if (!$this->isAvailable()) { | ||||||
throw new \Exception('Redis support is not available'); | ||||||
} | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not see where it returns
null
?Docblock
@return
should be reverted toarray
as well or removed.