@@ -37,19 +37,19 @@ final class DuplexResourceStream extends EventEmitter implements DuplexStreamInt
3737
3838 public function __construct ($ stream , LoopInterface $ loop , $ readChunkSize = null , WritableStreamInterface $ buffer = null )
3939 {
40- if (!is_resource ($ stream ) || get_resource_type ($ stream ) !== "stream " ) {
40+ if (!\ is_resource ($ stream ) || \ get_resource_type ($ stream ) !== "stream " ) {
4141 throw new InvalidArgumentException ('First parameter must be a valid stream resource ' );
4242 }
4343
4444 // ensure resource is opened for reading and wrting (fopen mode must contain "+")
45- $ meta = stream_get_meta_data ($ stream );
46- if (isset ($ meta ['mode ' ]) && $ meta ['mode ' ] !== '' && strpos ($ meta ['mode ' ], '+ ' ) === false ) {
45+ $ meta = \ stream_get_meta_data ($ stream );
46+ if (isset ($ meta ['mode ' ]) && $ meta ['mode ' ] !== '' && \ strpos ($ meta ['mode ' ], '+ ' ) === false ) {
4747 throw new InvalidArgumentException ('Given stream resource is not opened in read and write mode ' );
4848 }
4949
5050 // this class relies on non-blocking I/O in order to not interrupt the event loop
5151 // e.g. pipes on Windows do not support this: https://bugs.php.net/bug.php?id=47918
52- if (stream_set_blocking ($ stream , 0 ) !== true ) {
52+ if (\ stream_set_blocking ($ stream , 0 ) !== true ) {
5353 throw new \RuntimeException ('Unable to set stream resource to non-blocking mode ' );
5454 }
5555
@@ -61,8 +61,8 @@ public function __construct($stream, LoopInterface $loop, $readChunkSize = null,
6161 // triggered), so we can ignore platforms not supporting this (HHVM).
6262 // Pipe streams (such as STDIN) do not seem to require this and legacy
6363 // PHP versions cause SEGFAULTs on unbuffered pipe streams, so skip this.
64- if (function_exists ('stream_set_read_buffer ' ) && !$ this ->isLegacyPipe ($ stream )) {
65- stream_set_read_buffer ($ stream , 0 );
64+ if (\ function_exists ('stream_set_read_buffer ' ) && !$ this ->isLegacyPipe ($ stream )) {
65+ \ stream_set_read_buffer ($ stream , 0 );
6666 }
6767
6868 if ($ buffer === null ) {
@@ -140,8 +140,8 @@ public function close()
140140 $ this ->buffer ->close ();
141141 $ this ->removeAllListeners ();
142142
143- if (is_resource ($ this ->stream )) {
144- fclose ($ this ->stream );
143+ if (\ is_resource ($ this ->stream )) {
144+ \ fclose ($ this ->stream );
145145 }
146146 }
147147
@@ -169,7 +169,7 @@ public function pipe(WritableStreamInterface $dest, array $options = array())
169169 public function handleData ($ stream )
170170 {
171171 $ error = null ;
172- set_error_handler (function ($ errno , $ errstr , $ errfile , $ errline ) use (&$ error ) {
172+ \ set_error_handler (function ($ errno , $ errstr , $ errfile , $ errline ) use (&$ error ) {
173173 $ error = new \ErrorException (
174174 $ errstr ,
175175 0 ,
@@ -179,9 +179,9 @@ public function handleData($stream)
179179 );
180180 });
181181
182- $ data = stream_get_contents ($ stream , $ this ->bufferSize );
182+ $ data = \ stream_get_contents ($ stream , $ this ->bufferSize );
183183
184- restore_error_handler ();
184+ \ restore_error_handler ();
185185
186186 if ($ error !== null ) {
187187 $ this ->emit ('error ' , array (new \RuntimeException ('Unable to read from stream: ' . $ error ->getMessage (), 0 , $ error )));
@@ -212,8 +212,8 @@ public function handleData($stream)
212212 */
213213 private function isLegacyPipe ($ resource )
214214 {
215- if (PHP_VERSION_ID < 50428 || (PHP_VERSION_ID >= 50500 && PHP_VERSION_ID < 50512 )) {
216- $ meta = stream_get_meta_data ($ resource );
215+ if (\ PHP_VERSION_ID < 50428 || (\ PHP_VERSION_ID >= 50500 && \ PHP_VERSION_ID < 50512 )) {
216+ $ meta = \ stream_get_meta_data ($ resource );
217217
218218 if (isset ($ meta ['stream_type ' ]) && $ meta ['stream_type ' ] === 'STDIO ' ) {
219219 return true ;
0 commit comments