@@ -111,7 +111,7 @@ from this source stream.
111
111
The event receives a single mixed argument for incoming data.
112
112
113
113
``` php
114
- $stream->on('data', function ($data) {
114
+ $stream->on('data', function (mixed $data): void {
115
115
echo $data;
116
116
});
117
117
```
@@ -142,7 +142,7 @@ The `end` event will be emitted once the source stream has successfully
142
142
reached the end of the stream (EOF).
143
143
144
144
``` php
145
- $stream->on('end', function () {
145
+ $stream->on('end', function (): void {
146
146
echo 'END';
147
147
});
148
148
```
@@ -180,7 +180,7 @@ trying to read from this stream.
180
180
The event receives a single ` Exception ` argument for the error instance.
181
181
182
182
``` php
183
- $server->on('error', function (Exception $e) {
183
+ $server->on('error', function (Exception $e): void {
184
184
echo 'Error: ' . $e->getMessage() . PHP_EOL;
185
185
});
186
186
```
@@ -213,7 +213,7 @@ stream which should result in the same error processing.
213
213
The ` close ` event will be emitted once the stream closes (terminates).
214
214
215
215
``` php
216
- $stream->on('close', function () {
216
+ $stream->on('close', function (): void {
217
217
echo 'CLOSED';
218
218
});
219
219
```
@@ -312,7 +312,7 @@ Re-attach the data source after a previous `pause()`.
312
312
``` php
313
313
$stream->pause();
314
314
315
- Loop::addTimer(1.0, function () use ($stream) {
315
+ Loop::addTimer(1.0, function () use ($stream): void {
316
316
$stream->resume();
317
317
});
318
318
```
@@ -362,7 +362,7 @@ you'll have to manually close the destination stream:
362
362
363
363
``` php
364
364
$source->pipe($dest);
365
- $source->on('close', function () use ($dest) {
365
+ $source->on('close', function () use ($dest): void {
366
366
$dest->end('BYE!');
367
367
});
368
368
```
@@ -456,7 +456,7 @@ The `drain` event will be emitted whenever the write buffer became full
456
456
previously and is now ready to accept more data.
457
457
458
458
``` php
459
- $stream->on('drain', function () use ($stream) {
459
+ $stream->on('drain', function () use ($stream): void {
460
460
echo 'Stream is now ready to accept more data';
461
461
});
462
462
```
@@ -478,11 +478,11 @@ The event receives a single `ReadableStreamInterface` argument for the
478
478
source stream.
479
479
480
480
``` php
481
- $stream->on('pipe', function (ReadableStreamInterface $source) use ($stream) {
481
+ $stream->on('pipe', function (ReadableStreamInterface $source) use ($stream): void {
482
482
echo 'Now receiving piped data';
483
483
484
484
// explicitly close target if source emits an error
485
- $source->on('error', function () use ($stream) {
485
+ $source->on('error', function () use ($stream): void {
486
486
$stream->close();
487
487
});
488
488
});
@@ -536,7 +536,7 @@ stream which should result in the same error processing.
536
536
The ` close ` event will be emitted once the stream closes (terminates).
537
537
538
538
``` php
539
- $stream->on('close', function () {
539
+ $stream->on('close', function (): void {
540
540
echo 'CLOSED';
541
541
});
542
542
```
@@ -746,7 +746,7 @@ stream in order to stop waiting for the stream to flush its final data.
746
746
747
747
``` php
748
748
$stream->end();
749
- Loop::addTimer(1.0, function () use ($stream) {
749
+ Loop::addTimer(1.0, function () use ($stream): void {
750
750
$stream->close();
751
751
});
752
752
```
@@ -831,10 +831,10 @@ readable mode or a stream such as `STDIN`:
831
831
832
832
``` php
833
833
$stream = new ReadableResourceStream(STDIN);
834
- $stream->on('data', function ($chunk) {
834
+ $stream->on('data', function (string $chunk): void {
835
835
echo $chunk;
836
836
});
837
- $stream->on('end', function () {
837
+ $stream->on('end', function (): void {
838
838
echo 'END';
839
839
});
840
840
```
@@ -1133,7 +1133,7 @@ The callback function is allowed to throw an `Exception`. In this case,
1133
1133
the stream will emit an ` error ` event and then [ ` close() ` ] ( #close-1 ) the stream.
1134
1134
1135
1135
``` php
1136
- $through = new ThroughStream(function ($data) {
1136
+ $through = new ThroughStream(function (mixed $data): string {
1137
1137
if (!is_string($data)) {
1138
1138
throw new \UnexpectedValueException('Only strings allowed');
1139
1139
}
@@ -1164,7 +1164,7 @@ $stdout = new WritableResourceStream(STDOUT);
1164
1164
1165
1165
$stdio = new CompositeStream($stdin, $stdout);
1166
1166
1167
- $stdio->on('data', function ($chunk) use ($stdio) {
1167
+ $stdio->on('data', function (string $chunk) use ($stdio): void {
1168
1168
$stdio->write('You said: ' . $chunk);
1169
1169
});
1170
1170
```
@@ -1243,7 +1243,7 @@ If you do not want to run these, they can simply be skipped like this:
1243
1243
vendor/bin/phpunit --exclude-group internet
1244
1244
```
1245
1245
1246
- On top of this, we use PHPStan on level 5 to ensure type safety across the project:
1246
+ On top of this, we use PHPStan on max level to ensure type safety across the project:
1247
1247
1248
1248
``` bash
1249
1249
vendor/bin/phpstan
0 commit comments