addPeriodicTimer(0.2, fn() => print('.')); $stream = new StreamAdapter(new WillThrowExceptionAfter4Seconds(), $loop); $stream->on('data', fn() => print('Data received.' . PHP_EOL)); $stream->on('error', fn(Throwable $t) => print('Error: ' . $t->getMessage() . PHP_EOL)); $stream->on('close', fn() => print('Stream closed.' . PHP_EOL)); print(<<run();