]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix: Adjust console formatter code to match with Symfony type hints 36617/head
authorFerdinand Thiessen <rpm@fthiessen.de>
Wed, 8 Feb 2023 16:47:49 +0000 (17:47 +0100)
committerFerdinand Thiessen <opensource@fthiessen.de>
Mon, 17 Apr 2023 16:35:10 +0000 (18:35 +0200)
Symfony has added type hints on the `OutputFormatterInterface`,
so we must adjust our type hints to match with Symfony.

Signed-off-by: Ferdinand Thiessen <rpm@fthiessen.de>
apps/encryption/tests/Crypto/EncryptAllTest.php
lib/private/Console/TimestampFormatter.php
tests/Core/Command/Encryption/ChangeKeyStorageRootTest.php
tests/Core/Command/Preview/RepairTest.php
tests/lib/Encryption/DecryptAllTest.php

index b99e9144be868c25e7ee1bb19c4c4ddc1937546f..459f680a374caa5cbcfab937299ef7083caa1566 100644 (file)
@@ -121,6 +121,7 @@ class EncryptAllTest extends TestCase {
 
                /* We need format method to return a string */
                $outputFormatter = $this->createMock(OutputFormatterInterface::class);
+               $outputFormatter->method('isDecorated')->willReturn(false);
                $outputFormatter->method('format')->willReturnArgument(0);
 
                $this->outputInterface->expects($this->any())->method('getFormatter')
@@ -346,9 +347,11 @@ class EncryptAllTest extends TestCase {
                                ['/user1/files/foo/subfile'],
                        );
 
+               $outputFormatter = $this->createMock(OutputFormatterInterface::class);
+               $outputFormatter->method('isDecorated')->willReturn(false);
                $this->outputInterface->expects($this->any())
                        ->method('getFormatter')
-                       ->willReturn($this->createMock(OutputFormatterInterface::class));
+                       ->willReturn($outputFormatter);
                $progressBar = new ProgressBar($this->outputInterface);
 
                $this->invokePrivate($encryptAll, 'encryptUsersFiles', ['user1', $progressBar, '']);
index c25ed578805afef16c652e55140b18550eecfab3..8d74c28e94f81724359d33b76731766b2bdf6036 100644 (file)
@@ -94,11 +94,11 @@ class TimestampFormatter implements OutputFormatterInterface {
        /**
         * Formats a message according to the given styles.
         *
-        * @param string $message The message to style
-        * @return string The styled message, prepended with a timestamp using the
+        * @param string|null $message The message to style
+        * @return string|null The styled message, prepended with a timestamp using the
         * log timezone and dateformat, e.g. "2015-06-23T17:24:37+02:00"
         */
-       public function format($message) {
+       public function format(?string $message): ?string {
                if (!$this->formatter->isDecorated()) {
                        // Don't add anything to the output when we shouldn't
                        return $this->formatter->format($message);
index 1d5e2ac420d3715474b58351669619a1de924e95..ecb3faaa25df5d676af8a642e88896189c067af2 100644 (file)
@@ -75,6 +75,7 @@ class ChangeKeyStorageRootTest extends TestCase {
 
                /* We need format method to return a string */
                $outputFormatter = $this->createMock(OutputFormatterInterface::class);
+               $outputFormatter->method('isDecorated')->willReturn(false);
                $outputFormatter->method('format')->willReturnArgument(0);
 
                $this->outputInterface->expects($this->any())->method('getFormatter')
index d235c0d0aea7fb3db17d648311f36d68b6b32cd5..090e9cc0bd00fab99cf69e81a3748d5e25e3528d 100644 (file)
@@ -71,6 +71,7 @@ class RepairTest extends TestCase {
 
                /* We need format method to return a string */
                $outputFormatter = $this->createMock(OutputFormatterInterface::class);
+               $outputFormatter->method('isDecorated')->willReturn(false);
                $outputFormatter->method('format')->willReturnArgument(0);
 
                $this->output->expects($this->any())
index f33f88eb21459c2903f9f363acfdb07fe3f5444d..69f78f435cfcb2f14a52c33516518c39d6e03acc 100644 (file)
@@ -77,12 +77,15 @@ class DecryptAllTest extends TestCase {
                        ->disableOriginalConstructor()->getMock();
                $this->outputInterface = $this->getMockBuilder(OutputInterface::class)
                        ->disableOriginalConstructor()->getMock();
+               $this->outputInterface->expects($this->any())->method('isDecorated')
+                       ->willReturn(false);
                $this->userInterface = $this->getMockBuilder(UserInterface::class)
                        ->disableOriginalConstructor()->getMock();
 
                /* We need format method to return a string */
                $outputFormatter = $this->createMock(OutputFormatterInterface::class);
                $outputFormatter->method('format')->willReturn('foo');
+               $outputFormatter->method('isDecorated')->willReturn(false);
 
                $this->outputInterface->expects($this->any())->method('getFormatter')
                        ->willReturn($outputFormatter);
@@ -304,6 +307,7 @@ class DecryptAllTest extends TestCase {
 
                /* We need format method to return a string */
                $outputFormatter = $this->createMock(OutputFormatterInterface::class);
+               $outputFormatter->method('isDecorated')->willReturn(false);
                $outputFormatter->method('format')->willReturn('foo');
 
                $output = $this->createMock(OutputInterface::class);