Skip to content

Commit bf60d5e

Browse files
Guillaume Pédelagrabefabpot
authored andcommitted
[Console] Fix OutputStream for PHP 7.4
1 parent a92b9a3 commit bf60d5e

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

Output/StreamOutput.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\Component\Console\Output;
1313

1414
use Symfony\Component\Console\Exception\InvalidArgumentException;
15-
use Symfony\Component\Console\Exception\RuntimeException;
1615
use Symfony\Component\Console\Formatter\OutputFormatterInterface;
1716

1817
/**
@@ -74,10 +73,7 @@ protected function doWrite($message, $newline)
7473
$message .= PHP_EOL;
7574
}
7675

77-
if (false === @fwrite($this->stream, $message)) {
78-
// should never happen
79-
throw new RuntimeException('Unable to write output.');
80-
}
76+
@fwrite($this->stream, $message);
8177

8278
fflush($this->stream);
8379
}

Tests/Fixtures/stream_output_file.txt

Whitespace-only changes.

Tests/Output/StreamOutputTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,12 @@ public function testDoWrite()
5656
rewind($output->getStream());
5757
$this->assertEquals('foo'.PHP_EOL, stream_get_contents($output->getStream()), '->doWrite() writes to the stream');
5858
}
59+
60+
public function testDoWriteOnFailure()
61+
{
62+
$resource = fopen(__DIR__.'/../Fixtures/stream_output_file.txt', 'r', false);
63+
$output = new StreamOutput($resource);
64+
rewind($output->getStream());
65+
$this->assertEquals('', stream_get_contents($output->getStream()));
66+
}
5967
}

0 commit comments

Comments
 (0)