@@ -178,6 +178,28 @@ public function stream_read(int $count)
178
178
return '' ;
179
179
}
180
180
181
+ public function stream_set_option (int $ option , int $ arg1 , ?int $ arg2 ): bool
182
+ {
183
+ if (null === $ this ->handle || 'stream ' !== get_resource_type ($ this ->handle )) {
184
+ trigger_error (sprintf ('The "$handle" property of "%s" need to be a stream. ' , __CLASS__ ), E_USER_WARNING );
185
+
186
+ return false ;
187
+ }
188
+
189
+ switch ($ option ) {
190
+ case STREAM_OPTION_BLOCKING :
191
+
10000
return $ this ->stream_set_blocking ($ this ->handle , $ arg1 );
192
+ case STREAM_OPTION_READ_TIMEOUT :
193
+ return $ this ->stream_set_timeout ($ this ->handle , $ arg1 , $ arg2 );
194
+ case STREAM_OPTION_WRITE_BUFFER :
195
+ return $ this ->stream_set_write_buffer ($ this ->handle , $ arg1 );
196
+ default :
197
+ trigger_error (sprintf ('The option "%s" is unknown for "stream_set_option" method ' , $ option ), E_ERROR );
198
+
199
+ return false ;
200
+ }
201
+ }
202
+
181
203
public function stream_tell (): int
182
204
{
183
205
return $ this ->offset ;
@@ -270,6 +292,31 @@ public function stream_stat(): array
270
292
];
271
293
}
272
294
295
+ private function stream_set_blocking ($ stream , bool $ mode ): bool
296
+ {
297
+ if (true === $ mode ) {
298
+ trigger_error (sprintf ('Blocking mode is not supported yet with "%s" class. ' , __CLASS__ ), E_USER_WARNING );
299
+
300
+ return false ;
301
+ }
302
+
303
+ return true ;
304
+ }
305
+
306
+ private function stream_set_write_buffer ($ stream , int $ buffer ): int
307
+ {
308
+ trigger_error (sprintf ('Writting with "%s" class, is not supported yet. ' , __CLASS__ ), E_USER_WARNING );
309
+
310
+ return false ;
311
+ }
312
+
313
+ private function stream_set_timeout ($ stream , int $ seconds , int $ microseconds = 0 ): bool
314
+ {
315
+ trigger_error (sprintf ('Set timeout with "%s" class, is not supported yet. ' , __CLASS__ ), E_USER_WARNING );
316
+
317
+ return false ;
318
+ }
319
+
273
320
private function __construct ()
274
321
{
275
322
}
0 commit comments