@@ -44,7 +44,7 @@ final class DuplexResourceStream extends EventEmitter implements DuplexStreamInt
44
44
* @param ?int $readChunkSize
45
45
* @param ?WritableStreamInterface $buffer
46
46
*/
47
- public function __construct ($ stream , ?LoopInterface $ loop = null , $ readChunkSize = null , ?WritableStreamInterface $ buffer = null )
47
+ public function __construct ($ stream , ?LoopInterface $ loop = null , ? int $ readChunkSize = null , ?WritableStreamInterface $ buffer = null )
48
48
{
49
49
if (!\is_resource ($ stream ) || \get_resource_type ($ stream ) !== "stream " ) {
50
50
throw new InvalidArgumentException ('First parameter must be a valid stream resource ' );
@@ -75,7 +75,7 @@ public function __construct($stream, ?LoopInterface $loop = null, $readChunkSize
75
75
76
76
$ this ->stream = $ stream ;
77
77
$ this ->loop = $ loop ?: Loop::get ();
78
- $ this ->bufferSize = ( $ readChunkSize === null ) ? 65536 : ( int ) $ readChunkSize ;
78
+ $ this ->bufferSize = $ readChunkSize ?? 65536 ;
79
79
$ this ->buffer = $ buffer ;
80
80
81
81
$ this ->buffer ->on ('error ' , function ($ error ) {
@@ -91,33 +91,33 @@ public function __construct($stream, ?LoopInterface $loop = null, $readChunkSize
91
91
$ this ->resume ();
92
92
}
93
93
94
- public function isReadable ()
94
+ public function isReadable (): bool
95
95
{
96
96
return $ this ->readable ;
97
97
}
98
98
99
- public function isWritable ()
99
+ public function isWritable (): bool
100
100
{
101
101
return $ this ->writable ;
102
102
}
103
103
104
- public function pause ()
104
+ public function pause (): void
105
105
{
106
106
if ($ this ->listening ) {
107
107
$ this ->loop ->removeReadStream ($ this ->stream );
108
108
$ this ->listening = false ;
109
109
}
110
110
}
111
111
112
- public function resume ()
112
+ public function resume (): void
113
113
{
114
114
if (!$ this ->listening && $ this ->readable ) {
115
115
$ this ->loop ->addReadStream ($ this ->stream , [$ this , 'handleData ' ]);
116
116
$ this ->listening = true ;
117
117
}
118
118
}
119
119
120
- public function write ($ data )
120
+ public function write ($ data ): bool
121
121
{
122
122
if (!$ this ->writable ) {
123
123
return false ;
@@ -126,7 +126,7 @@ public function write($data)
126
126
return $ this ->buffer ->write ($ data );
127
127
}
128
128
129
- public function close ()
129
+ public function close (): void
130
130
{
131
131
if (!$ this ->writable && !$ this ->closing ) {
132
132
return ;
@@ -147,7 +147,7 @@ public function close()
147
147
}
148
148
}
149
149
150
- public function end ($ data = null )
150
+ public function end ($ data = null ): void
151
151
{
152
152
if (!$ this ->writable ) {
153
153
return ;
@@ -162,7 +162,7 @@ public function end($data = null)
162
162
$ this ->buffer ->end ($ data );
163
163
}
164
164
165
- public function pipe (WritableStreamInterface $ dest , array $ options = [])
165
+ public function pipe (WritableStreamInterface $ dest , array $ options = []): WritableStreamInterface
166
166
{
167
167
return Util::pipe ($ this , $ dest , $ options );
168
168
}
0 commit comments