From bce2f8850de2016bafdda4bb085516c7ad4ccd59 Mon Sep 17 00:00:00 2001 From: Lucas Werkmeister Date: Tue, 28 Jan 2025 13:06:48 +0100 Subject: [PATCH] logger: Make log() methods return void MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit psr/log 3.0.0 adds this return type. For this specific case the fix is very simple, fully compatible with the older version of psr/log, and something we’ll have to do sooner or later anyway. Bug: T356451 Change-Id: I49562ac7f1a71e82cab79fe44296feea573e26d4 (cherry picked from commit 9244d4b2623b9d789e7dea28e65b5ca6f9651aaf) --- includes/debug/logger/ConsoleLogger.php | 2 +- includes/debug/logger/LegacyLogger.php | 2 +- includes/debug/logger/LogCapturingSpi.php | 2 +- tests/phpunit/mocks/TestLogger.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/includes/debug/logger/ConsoleLogger.php b/includes/debug/logger/ConsoleLogger.php index ec225a3c071..bd3783f3a91 100644 --- a/includes/debug/logger/ConsoleLogger.php +++ b/includes/debug/logger/ConsoleLogger.php @@ -56,7 +56,7 @@ class ConsoleLogger extends AbstractLogger { /** * @inheritDoc */ - public function log( $level, $message, array $context = [] ) { + public function log( $level, $message, array $context = [] ): void { if ( !$this->minLevel || self::LEVELS[$level] >= self::LEVELS[$this->minLevel] ) { fwrite( STDERR, "[$level] " . LegacyLogger::format( $this->channel, $message, $context ) ); diff --git a/includes/debug/logger/LegacyLogger.php b/includes/debug/logger/LegacyLogger.php index 38bdafe189f..0ef8e5c2675 100644 --- a/includes/debug/logger/LegacyLogger.php +++ b/includes/debug/logger/LegacyLogger.php @@ -156,7 +156,7 @@ class LegacyLogger extends AbstractLogger { * @param string $message * @param array $context */ - public function log( $level, $message, array $context = [] ) { + public function log( $level, $message, array $context = [] ): void { if ( is_string( $level ) ) { $level = self::$levelMapping[$level]; } diff --git a/includes/debug/logger/LogCapturingSpi.php b/includes/debug/logger/LogCapturingSpi.php index 4a7c41521e4..7095010263c 100644 --- a/includes/debug/logger/LogCapturingSpi.php +++ b/includes/debug/logger/LogCapturingSpi.php @@ -71,7 +71,7 @@ class LogCapturingSpi implements Spi { $this->parent = $parent; } - public function log( $level, $message, array $context = [] ) { + public function log( $level, $message, array $context = [] ): void { $this->parent->capture( [ 'channel' => $this->channel, 'level' => $level, diff --git a/tests/phpunit/mocks/TestLogger.php b/tests/phpunit/mocks/TestLogger.php index 0b3a6aa2453..9960ed33a20 100644 --- a/tests/phpunit/mocks/TestLogger.php +++ b/tests/phpunit/mocks/TestLogger.php @@ -87,7 +87,7 @@ class TestLogger extends \Psr\Log\AbstractLogger { $this->buffer = []; } - public function log( $level, $message, array $context = [] ) { + public function log( $level, $message, array $context = [] ): void { $message = trim( $message ); if ( $this->filter ) {