Skip to content

Commit 786846b

Browse files
committed
Documentation for stream resources
1 parent 3a7ad74 commit 786846b

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,13 @@ See also [example #3](examples).
296296
The `addReadStream(resource $stream, callable $callback): void` method can be used to
297297
register a listener to be notified when a stream is ready to read.
298298

299+
The first parameter MUST be a valid stream resource that supports
300+
checking whether it is ready to read by this loop implementation.
301+
A single stream resource MUST NOT be added more than once.
302+
Instead, either call [`removeReadStream()`](#removereadstream) first or
303+
react to this event with a single listener and then dispatch from this
304+
listener.
305+
299306
The listener callback function MUST be able to accept a single parameter,
300307
the stream resource added by this method or you MAY use a function which
301308
has no parameters at all.
@@ -327,6 +334,13 @@ the same time is not guaranteed.
327334
The `addWriteStream(resource $stream, callable $callback): void` method can be used to
328335
register a listener to be notified when a stream is ready to write.
329336

337+
The first parameter MUST be a valid stream resource that supports
338+
checking whether it is ready to write by this loop implementation.
339+
A single stream resource MUST NOT be added more than once.
340+
Instead, either call [`removeWriteStream()`](#removewritestream) first or
341+
react to this event with a single listener and then dispatch from this
342+
listener.
343+
330344
The listener callback function MUST be able to accept a single parameter,
331345
the stream resource added by this method or you MAY use a function which
332346
has no parameters at all.

src/LoopInterface.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ interface LoopInterface
99
/**
1010
* Register a listener to be notified when a stream is ready to read.
1111
*
12+
* The first parameter MUST be a valid stream resource that supports
13+
* checking whether it is ready to read by this loop implementation.
14+
* A single stream resource MUST NOT be added more than once.
15+
* Instead, either call [`removeReadStream()`](#removereadstream) first or
16+
* react to this event with a single listener and then dispatch from this
17+
* listener.
18+
*
1219
* The listener callback function MUST be able to accept a single parameter,
1320
* the stream resource added by this method or you MAY use a function which
1421
* has no parameters at all.
@@ -37,12 +44,20 @@ interface LoopInterface
3744
*
3845
* @param resource $stream The PHP stream resource to check.
3946
* @param callable $listener Invoked when the stream is ready.
47+
* @see self::removeReadStream()
4048
*/
4149
public function addReadStream($stream, callable $listener);
4250

4351
/**
4452
* Register a listener to be notified when a stream is ready to write.
4553
*
54+
* The first parameter MUST be a valid stream resource that supports
55+
* checking whether it is ready to write by this loop implementation.
56+
* A single stream resource MUST NOT be added more than once.
57+
* Instead, either call [`removeWriteStream()`](#removewritestream) first or
58+
* react to this event with a single listener and then dispatch from this
59+
* listener.
60+
*
4661
* The listener callback function MUST be able to accept a single parameter,
4762
* the stream resource added by this method or you MAY use a function which
4863
* has no parameters at all.
@@ -71,6 +86,7 @@ public function addReadStream($stream, callable $listener);
7186
*
7287
* @param resource $stream The PHP stream resource to check.
7388
* @param callable $listener Invoked when the stream is ready.
89+
* @see self::removeWriteStream()
7490
*/
7591
public function addWriteStream($stream, callable $listener);
7692

0 commit comments

Comments
 (0)