Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Console] Fix OutputStream for PHP 7.4 #36222

Merged
merged 1 commit into from Mar 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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()));
}
}