Skip to content

Commit f94fe44

Browse files
committed
Add basic documentation for internal classes
1 parent 836b503 commit f94fe44

9 files changed

Lines changed: 74 additions & 12 deletions

src/Io/ChunkedDecoder.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@
88
use React\Stream\WritableStreamInterface;
99
use Exception;
1010

11-
/** @internal */
11+
/**
12+
* [Internal] Decodes "Transfer-Encoding: chunked" from given stream and returns only payload data.
13+
*
14+
* This is used internally to decode incoming requests with this encoding.
15+
*
16+
* @internal
17+
*/
1218
class ChunkedDecoder extends EventEmitter implements ReadableStreamInterface
1319
{
1420
const CRLF = "\r\n";

src/Io/ChunkedEncoder.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@
77
use React\Stream\Util;
88
use React\Stream\WritableStreamInterface;
99

10-
/** @internal */
10+
/**
11+
* [Internal] Encodes given payload stream with "Transfer-Encoding: chunked" and emits encoded data
12+
*
13+
* This is used internally to encode outgoing requests with this encoding.
14+
*
15+
* @internal
16+
*/
1117
class ChunkedEncoder extends EventEmitter implements ReadableStreamInterface
1218
{
1319
private $input;

src/Io/CloseProtectionStream.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@
88
use React\Stream\WritableStreamInterface;
99

1010
/**
11+
* [Internal] Protects a given stream from actually closing and only pauses it instead.
12+
*
13+
* This is used internally to prevent the underlying connection from closing, so
14+
* that we can still send back a response over the same stream.
15+
*
1116
* @internal
12-
* This stream is used to protect the passed stream against closing.
1317
* */
1418
class CloseProtectionStream extends EventEmitter implements ReadableStreamInterface
1519
{

src/Io/HttpBodyStream.php

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,20 @@
99
use React\Stream\WritableStreamInterface;
1010

1111
/**
12+
* [Internal] Bridge between StreamInterface from PSR-7 and ReadableStreamInterface from ReactPHP
13+
*
14+
* This class is used in the server to stream the body of an incoming response
15+
* from the client. This allows us to stream big amounts of data without having
16+
* to buffer this data. Similarly, this used to stream the body of an outgoing
17+
* request body to the client. The data will be sent directly to the client.
18+
*
19+
* Note that this is an internal class only and nothing you should usually care
20+
* about. See the `StreamInterface` and `ReadableStreamInterface` for more
21+
* details.
22+
*
23+
* @see StreamInterface
24+
* @see ReadableStreamInterface
1225
* @internal
13-
* Uses a StreamInterface from PSR-7 and a ReadableStreamInterface from ReactPHP
14-
* to use PSR-7 objects and use ReactPHP streams
15-
* This is class is used in `HttpServer` to stream the body of a response
16-
* to the client. Because of this you can stream big amount of data without
17-
* necessity of buffering this data. The data will be send directly to the client.
1826
*/
1927
class HttpBodyStream extends EventEmitter implements StreamInterface, ReadableStreamInterface
2028
{
@@ -23,8 +31,8 @@ class HttpBodyStream extends EventEmitter implements StreamInterface, ReadableSt
2331
private $size;
2432

2533
/**
26-
* @param ReadableStreamInterface $input - Stream data from $stream as a body of a PSR-7 object4
27-
* @param int|null $size - size of the data body
34+
* @param ReadableStreamInterface $input Stream data from $stream as a body of a PSR-7 object4
35+
* @param int|null $size size of the data body
2836
*/
2937
public function __construct(ReadableStreamInterface $input, $size)
3038
{

src/Io/LengthLimitedStream.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@
77
use React\Stream\Util;
88
use React\Stream\WritableStreamInterface;
99

10-
/** @internal */
10+
/**
11+
* [Internal] Limits the amount of data the given stream can emit
12+
*
13+
* This is used internally to limit the size of the underlying connection stream
14+
* to the size defined by the "Content-Length" header of the incoming request.
15+
*
16+
* @internal
17+
*/
1118
class LengthLimitedStream extends EventEmitter implements ReadableStreamInterface
1219
{
1320
private $stream;

src/Io/MultipartParser.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
use RingCentral\Psr7;
77

88
/**
9+
* [Internal] Parses a string body with "Content-Type: multipart/form-data" into structured data
10+
*
11+
* This is use internally to parse incoming request bodies into structured data
12+
* that resembles PHP's `$_POST` and `$_FILES` superglobals.
13+
*
914
* @internal
1015
*/
1116
final class MultipartParser

src/Io/RequestHeaderParser.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
use Exception;
88

99
/**
10+
* [Internal] Parses an incoming request header from an input stream
11+
*
12+
* This is used internally to parse the request header from the connection and
13+
* then process the remaining connection as the request body.
14+
*
1015
* @event headers
1116
* @event error
1217
*

src/Io/ServerRequest.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,20 @@
55
use Psr\Http\Message\ServerRequestInterface;
66
use RingCentral\Psr7\Request;
77

8-
/** @internal */
8+
/**
9+
* [Internal] Implementation of the PSR-7 `ServerRequestInterface`
10+
*
11+
* This is used internally to represent each incoming request message.
12+
*
13+
* This implementation builds on top of an existing outgoing request message and
14+
* only adds required server methods.
15+
*
16+
* Note that this is an internal class only and nothing you should usually care
17+
* about. See the `ServerRequestInterface` for more details.
18+
*
19+
* @see ServerRequestInterface
20+
* @internal
21+
*/
922
class ServerRequest extends Request implements ServerRequestInterface
1023
{
1124
private $attributes = array();

src/Io/UploadedFile.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@
88
use RuntimeException;
99

1010
/**
11+
* [Internal] Implementation of the PSR-7 `UploadedFileInterface`
12+
*
13+
* This is used internally to represent each incoming file upload.
14+
*
15+
* Note that this is an internal class only and nothing you should usually care
16+
* about. See the `UploadedFileInterface` for more details.
17+
*
18+
* @see UploadedFileInterface
1119
* @internal
1220
*/
1321
final class UploadedFile implements UploadedFileInterface

0 commit comments

Comments
 (0)