fix: Adjust console formatter code to match with Symfony type hints

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>
This commit is contained in:
Ferdinand Thiessen 2023-02-08 17:47:49 +01:00 committed by Ferdinand Thiessen
parent 698332e81d
commit dc9d8c42bb
5 changed files with 13 additions and 4 deletions

View 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, '']);

View 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);

View 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')

View 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())

View 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);