[Console] Fix OutputStream for PHP 7.4
This commit is contained in:
parent
a29ee7c220
commit
b375f93ed7
@ -12,7 +12,6 @@
|
|||||||
namespace Symfony\Component\Console\Output;
|
namespace Symfony\Component\Console\Output;
|
||||||
|
|
||||||
use Symfony\Component\Console\Exception\InvalidArgumentException;
|
use Symfony\Component\Console\Exception\InvalidArgumentException;
|
||||||
use Symfony\Component\Console\Exception\RuntimeException;
|
|
||||||
use Symfony\Component\Console\Formatter\OutputFormatterInterface;
|
use Symfony\Component\Console\Formatter\OutputFormatterInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -74,10 +73,7 @@ class StreamOutput extends Output
|
|||||||
$message .= PHP_EOL;
|
$message .= PHP_EOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (false === @fwrite($this->stream, $message)) {
|
@fwrite($this->stream, $message);
|
||||||
// should never happen
|
|
||||||
throw new RuntimeException('Unable to write output.');
|
|
||||||
}
|
|
||||||
|
|
||||||
fflush($this->stream);
|
fflush($this->stream);
|
||||||
}
|
}
|
||||||
|
@ -56,4 +56,12 @@ class StreamOutputTest extends TestCase
|
|||||||
rewind($output->getStream());
|
rewind($output->getStream());
|
||||||
$this->assertEquals('foo'.PHP_EOL, stream_get_contents($output->getStream()), '->doWrite() writes to the stream');
|
$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()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user