From 5640e8a8809e57696c5dddc4b66e8f142e698e06 Mon Sep 17 00:00:00 2001 From: Athos Ribeiro Date: Mon, 25 Apr 2022 10:41:55 -0300 Subject: [PATCH 1/2] Comply with psr/log 3 Signed-off-by: Athos Ribeiro --- classes/mutex/RedisMutex.php | 3 ++- composer.json | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/classes/mutex/RedisMutex.php b/classes/mutex/RedisMutex.php index 6732ce54..92da76b6 100644 --- a/classes/mutex/RedisMutex.php +++ b/classes/mutex/RedisMutex.php @@ -62,8 +62,9 @@ public function __construct(array $redisAPIs, string $name, int $timeout = 3) * be logged as warnings. * * @param LoggerInterface $logger The logger. + * @return void. */ - public function setLogger(LoggerInterface $logger) + public function setLogger(LoggerInterface $logger): void { $this->logger = $logger; } diff --git a/composer.json b/composer.json index 73d571a8..ab8f3b8d 100644 --- a/composer.json +++ b/composer.json @@ -43,7 +43,7 @@ }, "require": { "php": "^7.2 || ^8.0", - "psr/log": "^1" + "psr/log": "^3" }, "require-dev": { "ext-memcached": "*", From e344556d42698c901c687887cf1c3e12af2cdc93 Mon Sep 17 00:00:00 2001 From: Willem Stuursma Date: Tue, 26 Apr 2022 11:07:31 +0200 Subject: [PATCH 2/2] Allow newer versions of psr/log --- classes/mutex/RedisMutex.php | 25 +++---------------------- composer.json | 2 +- 2 files changed, 4 insertions(+), 23 deletions(-) diff --git a/classes/mutex/RedisMutex.php b/classes/mutex/RedisMutex.php index 92da76b6..90af55d4 100644 --- a/classes/mutex/RedisMutex.php +++ b/classes/mutex/RedisMutex.php @@ -7,7 +7,7 @@ use malkusch\lock\exception\LockAcquireException; use malkusch\lock\exception\LockReleaseException; use Psr\Log\LoggerAwareInterface; -use Psr\Log\LoggerInterface; +use Psr\Log\LoggerAwareTrait; use Psr\Log\NullLogger; /** @@ -21,6 +21,8 @@ */ abstract class RedisMutex extends SpinlockMutex implements LoggerAwareInterface { + use LoggerAwareTrait; + /** * @var string The random value token for key identification. */ @@ -31,11 +33,6 @@ abstract class RedisMutex extends SpinlockMutex implements LoggerAwareInterface */ private $redisAPIs; - /** - * @var LoggerInterface The logger. - */ - private $logger; - /** * Sets the Redis APIs. * @@ -53,22 +50,6 @@ public function __construct(array $redisAPIs, string $name, int $timeout = 3) $this->logger = new NullLogger(); } - /** - * Sets a logger instance on the object - * - * RedLock is a fault tolerant lock algorithm. I.e. it does tolerate - * failing redis connections without breaking. If you want to get notified - * about such events you'll have to provide a logger. Those events will - * be logged as warnings. - * - * @param LoggerInterface $logger The logger. - * @return void. - */ - public function setLogger(LoggerInterface $logger): void - { - $this->logger = $logger; - } - protected function acquire(string $key, int $expire): bool { // 1. This differs from the specification to avoid an overflow on 32-Bit systems. diff --git a/composer.json b/composer.json index ab8f3b8d..22977325 100644 --- a/composer.json +++ b/composer.json @@ -43,7 +43,7 @@ }, "require": { "php": "^7.2 || ^8.0", - "psr/log": "^3" + "psr/log": "^1|^2|^3" }, "require-dev": { "ext-memcached": "*",