mirror of
https://github.com/danog/psalm.git
synced 2024-12-02 17:52:45 +01:00
32 lines
793 B
PHP
32 lines
793 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Psalm\Tests\LanguageServer;
|
|
|
|
use Psalm\Internal\LanguageServer\EmitterInterface;
|
|
use Psalm\Internal\LanguageServer\EmitterTrait;
|
|
use Psalm\Internal\LanguageServer\Message;
|
|
use Psalm\Internal\LanguageServer\ProtocolReader;
|
|
use Psalm\Internal\LanguageServer\ProtocolWriter;
|
|
use Revolt\EventLoop;
|
|
|
|
/**
|
|
* A fake duplex protocol stream
|
|
*/
|
|
class MockProtocolStream implements ProtocolReader, ProtocolWriter, EmitterInterface
|
|
{
|
|
use EmitterTrait;
|
|
/**
|
|
* Sends a Message to the client
|
|
*
|
|
* @psalm-suppress PossiblyUnusedReturnValue
|
|
*/
|
|
public function write(Message $msg): void
|
|
{
|
|
EventLoop::queue(function () use ($msg): void {
|
|
$this->emit('message', [Message::parse((string)$msg)]);
|
|
});
|
|
}
|
|
}
|