Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b375f93

Browse filesBrowse files
Guillaume Pédelagrabefabpot
Guillaume Pédelagrabe
authored andcommitted
[Console] Fix OutputStream for PHP 7.4
1 parent a29ee7c commit b375f93
Copy full SHA for b375f93

File tree

3 files changed

+9
-5
lines changed
Filter options

3 files changed

+9
-5
lines changed

‎src/Symfony/Component/Console/Output/StreamOutput.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Output/StreamOutput.php
+1-5Lines 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
}

‎src/Symfony/Component/Console/Tests/Fixtures/stream_output_file.txt

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Tests/Fixtures/stream_output_file.txt
Whitespace-only changes.

‎src/Symfony/Component/Console/Tests/Output/StreamOutputTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Tests/Output/StreamOutputTest.php
+8Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.