2018-10-17 21:52:26 +02:00
|
|
|
<?php
|
|
|
|
declare(strict_types = 1);
|
2018-11-06 03:57:36 +01:00
|
|
|
namespace Psalm\Internal\LanguageServer;
|
2018-10-17 21:52:26 +02:00
|
|
|
|
2019-02-06 02:00:13 +01:00
|
|
|
use Amp\ByteStream\ResourceOutputStream;
|
|
|
|
use Amp\Promise;
|
2018-10-17 21:52:26 +02:00
|
|
|
|
2018-12-02 00:37:49 +01:00
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
*/
|
2018-10-17 21:52:26 +02:00
|
|
|
class ProtocolStreamWriter implements ProtocolWriter
|
|
|
|
{
|
|
|
|
/**
|
2019-02-06 02:00:13 +01:00
|
|
|
* @var \Amp\ByteStream\ResourceOutputStream
|
2018-10-17 21:52:26 +02:00
|
|
|
*/
|
|
|
|
private $output;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param resource $output
|
|
|
|
*/
|
|
|
|
public function __construct($output)
|
|
|
|
{
|
2019-02-06 02:00:13 +01:00
|
|
|
$this->output = new ResourceOutputStream($output);
|
2018-10-17 21:52:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritdoc}
|
|
|
|
*/
|
|
|
|
public function write(Message $msg): Promise
|
|
|
|
{
|
2019-02-06 02:00:13 +01:00
|
|
|
return $this->output->write((string)$msg);
|
2018-10-17 21:52:26 +02:00
|
|
|
}
|
|
|
|
}
|