@@ -72,16 +72,14 @@ public function __construct($stream, LoopInterface $loop = null, $readChunkSize
7272 $ this ->bufferSize = ($ readChunkSize === null ) ? 65536 : (int )$ readChunkSize ;
7373 $ this ->buffer = $ buffer ;
7474
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 ]);
7977 });
8078
81- $ this ->buffer ->on ('close ' , array ( $ this , 'close ' ) );
79+ $ this ->buffer ->on ('close ' , [ $ this , 'close ' ] );
8280
83- $ this ->buffer ->on ('drain ' , function () use ( $ that ) {
84- $ that ->emit ('drain ' );
81+ $ this ->buffer ->on ('drain ' , function () {
82+ $ this ->emit ('drain ' );
8583 });
8684
8785 $ this ->resume ();
@@ -108,7 +106,7 @@ public function pause()
108106 public function resume ()
109107 {
110108 if (!$ this ->listening && $ this ->readable ) {
111- $ this ->loop ->addReadStream ($ this ->stream , array ( $ this , 'handleData ' ) );
109+ $ this ->loop ->addReadStream ($ this ->stream , [ $ this , 'handleData ' ] );
112110 $ this ->listening = true ;
113111 }
114112 }
@@ -158,7 +156,7 @@ public function end($data = null)
158156 $ this ->buffer ->end ($ data );
159157 }
160158
161- public function pipe (WritableStreamInterface $ dest , array $ options = array () )
159+ public function pipe (WritableStreamInterface $ dest , array $ options = [] )
162160 {
163161 return Util::pipe ($ this , $ dest , $ options );
164162 }
@@ -182,13 +180,13 @@ public function handleData($stream)
182180 \restore_error_handler ();
183181
184182 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 )] );
186184 $ this ->close ();
187185 return ;
188186 }
189187
190188 if ($ data !== '' ) {
191- $ this ->emit ('data ' , array ( $ data) );
189+ $ this ->emit ('data ' , [ $ data] );
192190 } elseif (\feof ($ this ->stream )) {
193191 // no data read => we reached the end and close the stream
194192 $ this ->emit ('end ' );
0 commit comments