From d75f5e62df880b7f0b68e0b27f7f9de76a0a3dbe Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Thu, 5 Aug 2021 01:56:17 +0200 Subject: [PATCH] Add return type to OutputFormatterInterface::format() Signed-off-by: Alexander M. Turek --- .../Component/Console/Formatter/NullOutputFormatter.php | 4 ++-- .../Component/Console/Formatter/OutputFormatterInterface.php | 2 ++ .../Console/Tests/Formatter/NullOutputFormatterTest.php | 5 +---- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Component/Console/Formatter/NullOutputFormatter.php b/src/Symfony/Component/Console/Formatter/NullOutputFormatter.php index 0aa0a5c252327..d52d48da19303 100644 --- a/src/Symfony/Component/Console/Formatter/NullOutputFormatter.php +++ b/src/Symfony/Component/Console/Formatter/NullOutputFormatter.php @@ -21,9 +21,9 @@ final class NullOutputFormatter implements OutputFormatterInterface /** * {@inheritdoc} */ - public function format(?string $message): void + public function format(?string $message): ?string { - // do nothing + return null; } /** diff --git a/src/Symfony/Component/Console/Formatter/OutputFormatterInterface.php b/src/Symfony/Component/Console/Formatter/OutputFormatterInterface.php index 8c50d41964d76..41474eacd162c 100644 --- a/src/Symfony/Component/Console/Formatter/OutputFormatterInterface.php +++ b/src/Symfony/Component/Console/Formatter/OutputFormatterInterface.php @@ -53,6 +53,8 @@ public function getStyle(string $name); /** * Formats a message according to the given styles. + * + * @return string|null */ public function format(?string $message); } diff --git a/src/Symfony/Component/Console/Tests/Formatter/NullOutputFormatterTest.php b/src/Symfony/Component/Console/Tests/Formatter/NullOutputFormatterTest.php index 78dab00ca73f1..3a9f5c93432cf 100644 --- a/src/Symfony/Component/Console/Tests/Formatter/NullOutputFormatterTest.php +++ b/src/Symfony/Component/Console/Tests/Formatter/NullOutputFormatterTest.php @@ -25,10 +25,7 @@ public function testFormat() { $formatter = new NullOutputFormatter(); - $message = 'this message will not be changed'; - $formatter->format($message); - - $this->assertSame('this message will not be changed', $message); + $this->assertNull($formatter->format('this message will be destroyed')); } public function testGetStyle()