Skip to content

Commit

Permalink
[Console] Fix OutputStream for PHP 7.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Guillaume Pédelagrabe authored and fabpot committed Mar 27, 2020
1 parent a29ee7c commit b375f93
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
6 changes: 1 addition & 5 deletions src/Symfony/Component/Console/Output/StreamOutput.php
Expand Up @@ -12,7 +12,6 @@
namespace Symfony\Component\Console\Output;

use Symfony\Component\Console\Exception\InvalidArgumentException;
use Symfony\Component\Console\Exception\RuntimeException;
use Symfony\Component\Console\Formatter\OutputFormatterInterface;

/**
Expand Down Expand Up @@ -74,10 +73,7 @@ protected function doWrite($message, $newline)
$message .= PHP_EOL;
}

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

fflush($this->stream);
}
Expand Down
Empty file.
Expand Up @@ -56,4 +56,12 @@ public function testDoWrite()
rewind($output->getStream());
$this->assertEquals('foo'.PHP_EOL, stream_get_contents($output->getStream()), '->doWrite() writes to the stream');
}

public function testDoWriteOnFailure()
{
$resource = fopen(__DIR__.'/../Fixtures/stream_output_file.txt', 'r', false);
$output = new StreamOutput($resource);
rewind($output->getStream());
$this->assertEquals('', stream_get_contents($output->getStream()));
}
}

0 comments on commit b375f93

Please sign in to comment.