@@ -72,16 +72,14 @@ public function __construct($stream, LoopInterface $loop = null, $readChunkSize
72
72
$ this ->bufferSize = ($ readChunkSize === null ) ? 65536 : (int )$ readChunkSize ;
73
73
$ this ->buffer = $ buffer ;
74
74
75
- $ that = $ this ;
76
-
77
- $ this ->buffer ->on ('error ' , function ($ error ) use ($ that ) {
78
- $ that ->emit ('error ' , array ($ error ));
75
+ $ this ->buffer ->on ('error ' , function ($ error ) {
76
+ $ this ->emit ('error ' , [$ error ]);
79
77
});
80
78
81
- $ this ->buffer ->on ('close ' , array ( $ this , 'close ' ) );
79
+ $ this ->buffer ->on ('close ' , [ $ this , 'close ' ] );
82
80
83
- $ this ->buffer ->on ('drain ' , function () use ( $ that ) {
84
- $ that ->emit ('drain ' );
81
+ $ this ->buffer ->on ('drain ' , function () {
82
+ $ this ->emit ('drain ' );
85
83
});
86
84
87
85
$ this ->resume ();
@@ -108,7 +106,7 @@ public function pause()
108
106
public function resume ()
109
107
{
110
108
if (!$ this ->listening && $ this ->readable ) {
111
- $ this ->loop ->addReadStream ($ this ->stream , array ( $ this , 'handleData ' ) );
109
+ $ this ->loop ->addReadStream ($ this ->stream , [ $ this , 'handleData ' ] );
112
110
$ this ->listening = true ;
113
111
}
114
112
}
@@ -158,7 +156,7 @@ public function end($data = null)
158
156
$ this ->buffer ->end ($ data );
159
157
}
160
158
161
- public function pipe (WritableStreamInterface $ dest , array $ options = array () )
159
+ public function pipe (WritableStreamInterface $ dest , array $ options = [] )
162
160
{
163
161
return Util::pipe ($ this , $ dest , $ options );
164
162
}
@@ -182,13 +180,13 @@ public function handleData($stream)
182
180
\restore_error_handler ();
183
181
184
182
if ($ error !== null ) {
185
- $ this ->emit ('error ' , array ( new \RuntimeException ('Unable to read from stream: ' . $ error ->getMessage (), 0 , $ error )) );
183
+ $ this ->emit ('error ' , [ new \RuntimeException ('Unable to read from stream: ' . $ error ->getMessage (), 0 , $ error )] );
186
184
$ this ->close ();
187
185
return ;
188
186
}
189
187
190
188
if ($ data !== '' ) {
191
- $ this ->emit ('data ' , array ( $ data) );
189
+ $ this ->emit ('data ' , [ $ data] );
192
190
} elseif (\feof ($ this ->stream )) {
193
191
// no data read => we reached the end and close the stream
194
192
$ this ->emit ('end ' );
0 commit comments