Stream::bucketNew()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 2
1
<?php
2
3
namespace PHP\Wrappers;
4
5
/**
6
 * Class Stream
7
 *
8
 * @package PHP\Wrappers
9
 * @author  Aurimas Niekis <[email protected]>
10
 */
11
class Stream
12
{
13
    /**
14
     * Append bucket to brigade
15
     *
16
     * @param resource $brigade
17
     * @param object   $bucket
18
     *
19
     * @return void
20
     */
21
    public function bucketAppend($brigade, $bucket)
22
    {
23
        stream_bucket_append($brigade, $bucket);
24
    }
25
26
    /**
27
     * Return a bucket object from the brigade for operating on
28
     *
29
     * @param resource $brigade
30
     *
31
     * @return object
32
     */
33
    public function bucketMakeWriteable($brigade)
34
    {
35
        return stream_bucket_make_writeable($brigade);
36
    }
37
38
    /**
39
     * Create a new bucket for use on the current stream
40
     *
41
     * @param resource $stream
42
     * @param string   $buffer
43
     *
44
     * @return object
45
     */
46
    public function bucketNew($stream, string $buffer)
47
    {
48
        return stream_bucket_new($stream, $buffer);
49
    }
50
51
    /**
52
     * Prepend bucket to brigade
53
     *
54
     * @param resource $brigade
55
     * @param object   $bucket
56
     *
57
     * @return void
58
     */
59
    public function bucketPrepend($brigade, $bucket)
60
    {
61
        stream_bucket_prepend($brigade, $bucket);
62
    }
63
64
    /**
65
     * Creates a stream context
66
     *
67
     * @param array $options Must be an associative array of associative arrays in the format
68
     *                       $arr['wrapper']['option'] = $value.
69
     * @param array $params  Must be an associative array in the format
70
     *                       $arr['parameter'] = $value.
71
     *                       Refer to context parameters for
72
     *                       a listing of standard stream parameters.
73
     *
74
     * @return resource
75
     */
76
    public function contextCreate(array $options = null, array $params = null)
0 ignored issues
show
Unused Code introduced by
The parameter $options is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $params is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
77
    {
78
        return call_user_func_array('stream_context_create', func_get_args());
79
    }
80
81
    /**
82
     * Retrieve the default stream context
83
     *
84
     * @param array $options
85
     *
86
     * @return resource
87
     */
88
    public function contextGetDefault(array $options = null)
0 ignored issues
show
Unused Code introduced by
The parameter $options is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
89
    {
90
        return call_user_func_array('stream_context_get_default', func_get_args());
91
    }
92
93
    /**
94
     * Retrieve options for a stream/wrapper/context
95
     *
96
     * @param resource $streamOrContext The stream or context to get options from
97
     *
98
     * @return array
99
     */
100
    public function contextGetOptions($streamOrContext) : array
101
    {
102
        return stream_context_get_options($streamOrContext);
103
    }
104
105
    /**
106
     * Retrieves parameters from a context
107
     *
108
     * @param resource $streamOrContext A stream resource or a
109
     *                                  context resource
110
     *
111
     * @return array
112
     */
113
    public function contextGetParams($streamOrContext) : array
114
    {
115
        return stream_context_get_params($streamOrContext);
116
    }
117
118
    /**
119
     * Set the default stream context
120
     *
121
     * @param array $options The options to set for the default context.
122
     *
123
     * @return resource
124
     */
125
    public function contextSetDefault(array $options)
126
    {
127
        return stream_context_set_default($options);
128
    }
129
130
    /**
131
     * Sets an option for a stream/wrapper/context
132
     *
133
     * @param resource $streamOrContext The stream or context resource to apply the options to.
134
     * @param string   $wrapper         The options to set for the default context.
135
     * @param string   $option
136
     * @param mixed    $value
137
     *
138
     * @return bool
139
     */
140
    public function contextSetOption($streamOrContext, string $wrapper, string $option, $value) : bool
141
    {
142
        return stream_context_set_option($streamOrContext, $wrapper, $option, $value);
143
    }
144
145
    /**
146
     * Sets an option for a stream/wrapper/context
147
     *
148
     * @param resource $streamOrContext The stream or context resource to apply the options to.
149
     * @param array    $options         The options to set for the default context.
150
     *
151
     * @return bool
152
     */
153
    public function contextSetOptions($streamOrContext, array $options) : bool
154
    {
155
        return stream_context_set_option($streamOrContext, $options);
156
    }
157
158
    /**
159
     * Set parameters for a stream/wrapper/context
160
     *
161
     * @param resource $streamOrContext The stream or context to apply the parameters too.
162
     * @param array    $params          An array of parameters to set.
163
     *
164
     * @return bool
165
     */
166
    public function contextSetParams($streamOrContext, array $params) : bool
167
    {
168
        return stream_context_set_params($streamOrContext, $params);
169
    }
170
171
    /**
172
     * Copies data from one stream to another
173
     *
174
     * @param resource $source    The source stream
175
     * @param resource $dest      The destination stream
176
     * @param int      $maxlength Maximum bytes to copy
177
     * @param int      $offset    The offset where to start to copy data
178
     *
179
     * @return int
180
     */
181
    public function copyToStream($source, $dest, int $maxlength = null, int $offset = null) : int
0 ignored issues
show
Unused Code introduced by
The parameter $source is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $dest is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $maxlength is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $offset is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
182
    {
183
        return call_user_func_array('stream_copy_to_stream', func_get_args());
184
    }
185
186
    /**
187
     * Set character set for stream encoding
188
     *
189
     * @param resource $stream
190
     * @param string   $encoding
191
     *
192
     * @return bool
193
     */
194
    public function encoding($stream, string $encoding = null) : bool
0 ignored issues
show
Unused Code introduced by
The parameter $stream is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $encoding is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
195
    {
196
        return call_user_func_array('stream_encoding', func_get_args());
197
    }
198
199
    /**
200
     * Attach a filter to a stream
201
     *
202
     * @param resource $stream     The target stream.
203
     * @param string   $filtername The filter name.
204
     * @param int      $readWrite  By default, stream_filter_append will
205
     *                             attach the filter to the read filter chain
206
     *                             if the file was opened for reading (i.e. File Mode:
207
     *                             r, and/or +).  The filter
208
     *                             will also be attached to the write filter chain
209
     *                             if the file was opened for writing (i.e. File Mode:
210
     *                             w, a, and/or +).
211
     *                             STREAM_FILTER_READ,
212
     *                             STREAM_FILTER_WRITE, and/or
213
     *                             STREAM_FILTER_ALL can also be passed to the
214
     *                             read_write parameter to override this behavior.
215
     * @param mixed    $params     This filter will be added with the specified
216
     *                             params to the end of
217
     *                             the list and will therefore be called last during stream operations.
218
     *                             To add a filter to the beginning of the list, use
219
     *                             stream_filter_prepend.
220
     *
221
     * @return resource
222
     */
223
    public function filterAppend($stream, string $filtername, int $readWrite = null, $params = null)
0 ignored issues
show
Unused Code introduced by
The parameter $stream is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $filtername is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $readWrite is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $params is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
224
    {
225
        return call_user_func_array('stream_filter_append', func_get_args());
226
    }
227
228
    /**
229
     * Attach a filter to a stream
230
     *
231
     * @param resource $stream     The target stream.
232
     * @param string   $filtername The filter name.
233
     * @param int      $readWrite  By default, stream_filter_prepend will
234
     *                             attach the filter to the read filter chain
235
     *                             if the file was opened for reading (i.e. File Mode:
236
     *                             r, and/or +).  The filter
237
     *                             will also be attached to the write filter chain
238
     *                             if the file was opened for writing (i.e. File Mode:
239
     *                             w, a, and/or +).
240
     *                             STREAM_FILTER_READ,
241
     *                             STREAM_FILTER_WRITE, and/or
242
     *                             STREAM_FILTER_ALL can also be passed to the
243
     *                             read_write parameter to override this behavior.
244
     *                             See stream_filter_append for an example of
245
     *                             using this parameter.
246
     * @param mixed    $params     This filter will be added with the specified params
247
     *                             to the beginning of the list and will therefore be
248
     *                             called first during stream operations.  To add a filter to the end of the
249
     *                             list, use stream_filter_append.
250
     *
251
     * @return resource
252
     */
253
    public function filterPrepend($stream, string $filtername, int $readWrite = null, $params = null)
0 ignored issues
show
Unused Code introduced by
The parameter $stream is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $filtername is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $readWrite is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $params is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
254
    {
255
        return call_user_func_array('stream_filter_prepend', func_get_args());
256
    }
257
258
    /**
259
     * Register a user defined stream filter
260
     *
261
     * @param string $filtername The filter name to be registered.
262
     * @param string $classname  To implement a filter, you need to define a class as an extension of
263
     *                           php_user_filter with a number of member
264
     *                           functions. When performing read/write operations on the stream
265
     *                           to which your filter is attached, PHP will pass the data through your
266
     *                           filter (and any other filters attached to that stream) so that the
267
     *                           data may be modified as desired. You must implement the methods
268
     *                           exactly as described in php_user_filter - doing
269
     *                           otherwise will lead to undefined behaviour.
270
     *
271
     * @return bool
272
     */
273
    public function filterRegister(string $filtername, string $classname) : bool
274
    {
275
        return stream_filter_register($filtername, $classname);
276
    }
277
278
    /**
279
     * Remove a filter from a stream
280
     *
281
     * @param resource $streamFilter The stream filter to be removed.
282
     *
283
     * @return bool
284
     */
285
    public function filterRemove($streamFilter) : bool
286
    {
287
        return stream_filter_remove($streamFilter);
288
    }
289
290
    /**
291
     * Reads remainder of a stream into a string
292
     *
293
     * @param resource $handle    A stream resource (e.g. returned from fopen)
294
     * @param int      $maxlength The maximum bytes to read. Defaults to -1 (read all the remaining
295
     *                            buffer).
296
     * @param int      $offset    Seek to the specified offset before reading. If this number is negative,
297
     *                            no seeking will occur and reading will start from the current position.
298
     *
299
     * @return string
300
     */
301
    public function getContents($handle, int $maxlength = null, int $offset = null) : string
0 ignored issues
show
Unused Code introduced by
The parameter $handle is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $maxlength is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $offset is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
302
    {
303
        return call_user_func_array('stream_get_contents', func_get_args());
304
    }
305
306
    /**
307
     * Retrieve list of registered filters
308
     *
309
     * @return array
310
     */
311
    public function getFilters() : array
312
    {
313
        return stream_get_filters();
314
    }
315
316
    /**
317
     * Gets line from stream resource up to a given delimiter
318
     *
319
     * @param resource $handle A valid file handle.
320
     * @param int      $length The number of bytes to read from the handle.
321
     * @param string   $ending An optional string delimiter.
322
     *
323
     * @return string
324
     */
325
    public function getLine($handle, int $length, string $ending = null) : string
0 ignored issues
show
Unused Code introduced by
The parameter $handle is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $length is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $ending is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
326
    {
327
        return call_user_func_array('stream_get_line', func_get_args());
328
    }
329
330
    /**
331
     * Retrieves header/meta data from streams/file pointers
332
     *
333
     * @param resource $stream The stream can be any stream created by fopen,
334
     *                         fsockopen and pfsockopen.
335
     *
336
     * @return array
337
     */
338
    public function getMetaData($stream) : array
339
    {
340
        return stream_get_meta_data($stream);
341
    }
342
343
    /**
344
     * Retrieve list of registered socket transports
345
     *
346
     * @return array
347
     */
348
    public function getTransports() : array
349
    {
350
        return stream_get_transports();
351
    }
352
353
    /**
354
     * Retrieve list of registered streams
355
     *
356
     * @return array
357
     */
358
    public function getWrappers() : array
359
    {
360
        return stream_get_wrappers();
361
    }
362
363
    /**
364
     * Checks if a stream is a local stream
365
     *
366
     * @param mixed $streamOrUrl The stream resource or URL to check.
367
     *
368
     * @return bool
369
     */
370
    public function isLocal($streamOrUrl) : bool
371
    {
372
        return stream_is_local($streamOrUrl);
373
    }
374
375
    /**
376
     * A callback function for the notification context parameter
377
     *
378
     * @param int    $notificationCode One of the STREAM_NOTIFY_* notification constants.
379
     * @param int    $severity         One of the STREAM_NOTIFY_SEVERITY_* notification constants.
380
     * @param string $message          Passed if a descriptive message is available for the event.
381
     * @param int    $messageCode      Passed if a descriptive message code is available for the event.
382
     * @param int    $bytesTransferred If applicable, the bytes_transferred will be
383
     *                                 populated.
384
     * @param int    $bytesMax         If applicable, the bytes_max will be
385
     *                                 populated.
386
     *
387
     * @return void
388
     */
389
    public function notificationCallback(
390
        int $notificationCode,
391
        int $severity,
392
        string $message,
393
        int $messageCode,
394
        int $bytesTransferred,
395
        int $bytesMax
396
    ) {
397
        stream_notification_callback($notificationCode, $severity, $message, $messageCode, $bytesTransferred,
398
            $bytesMax);
399
    }
400
401
    /**
402
     * Resolve filename against the include path
403
     *
404
     * @param string $filename The filename to resolve.
405
     *
406
     * @return string
407
     */
408
    public function resolveIncludePath(string $filename) : string
409
    {
410
        return stream_resolve_include_path($filename);
411
    }
412
413
    /**
414
     * Runs the equivalent of the select() system call on the given
415
     * arrays of streams with a timeout specified by tv_sec and tv_usec
416
     *
417
     * @param array $read   The streams listed in the read array will be watched to
418
     *                      see if characters become available for reading (more precisely, to see if
419
     *                      a read will not block - in particular, a stream resource is also ready on
420
     *                      end-of-file, in which case an fread will return
421
     *                      a zero length string).
422
     * @param array $write  The streams listed in the write array will be
423
     *                      watched to see if a write will not block.
424
     * @param array $except The streams listed in the except array will be
425
     *                      watched for high priority exceptional ("out-of-band") data arriving.
426
     * @param int   $tvSec  The tv_sec and tv_usec
427
     *                      together form the timeout parameter,
428
     *                      tv_sec specifies the number of seconds while
429
     *                      tv_usec the number of microseconds.
430
     *                      The timeout is an upper bound on the amount of time
431
     *                      that stream_select will wait before it returns.
432
     *                      If tv_sec and tv_usec are
433
     *                      both set to 0, stream_select will
434
     *                      not wait for data - instead it will return immediately, indicating the
435
     *                      current status of the streams.
436
     * @param int   $tvUsec See tv_sec description.
437
     *
438
     * @return int
439
     */
440
    public function select(array &$read, array &$write, array &$except, int $tvSec, int $tvUsec = null) : int
0 ignored issues
show
Unused Code introduced by
The parameter $read is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $write is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $except is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $tvSec is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $tvUsec is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
441
    {
442
        return call_user_func_array('stream_select', func_get_args());
443
    }
444
445
    /**
446
     * Set the stream chunk size
447
     *
448
     * @param resource $fp
449
     * @param int      $chunkSize
450
     *
451
     * @return int
452
     */
453
    public function setChunkSize($fp, int $chunkSize) : int
454
    {
455
        return stream_set_chunk_size($fp, $chunkSize);
456
    }
457
458
    /**
459
     * Set read file buffering on the given stream
460
     *
461
     * @param resource $stream
462
     * @param int      $buffer
463
     *
464
     * @return int
465
     */
466
    public function setReadBuffer($stream, int $buffer) : int
467
    {
468
        return stream_set_read_buffer($stream, $buffer);
469
    }
470
471
    /**
472
     * Sets write file buffering on the given stream
473
     *
474
     * @param resource $stream The file pointer.
475
     * @param int      $buffer The number of bytes to buffer. If buffer
476
     *                         is 0 then write operations are unbuffered.  This ensures that all writes
477
     *                         with fwrite are completed before other processes are
478
     *                         allowed to write to that output stream.
479
     *
480
     * @return int
481
     */
482
    public function setWriteBuffer($stream, int $buffer) : int
483
    {
484
        return stream_set_write_buffer($stream, $buffer);
485
    }
486
487
    /**
488
     * Accept a connection on a socket created by stream_socket_server
489
     *
490
     * @param resource $serverSocket The server socket to accept a connection from.
491
     * @param float    $timeout      Override the default socket accept timeout. Time should be given in
492
     *                               seconds.
493
     * @param string   $peername     Will be set to the name (address) of the client which connected, if
494
     *                               included and available from the selected transport.
495
     *
496
     * @return resource
497
     */
498
    public function socketAccept($serverSocket, float $timeout = null, string &$peername = null)
0 ignored issues
show
Unused Code introduced by
The parameter $serverSocket is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $timeout is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $peername is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
499
    {
500
        return call_user_func_array('stream_socket_accept', func_get_args());
501
    }
502
503
    /**
504
     * Open Internet or Unix domain socket connection
505
     *
506
     * @param string   $remoteSocket Address to the socket to connect to.
507
     * @param int      $errno        Will be set to the system level error number if connection fails.
508
     * @param string   $errstr       Will be set to the system level error message if the connection fails.
509
     * @param float    $timeout      Number of seconds until the connect() system call
510
     *                               should timeout.
511
     *
512
     *
513
     * This parameter only applies when not making asynchronous
514
     * connection attempts.
515
     *
516
     *
517
     *
518
     *
519
     * To set a timeout for reading/writing data over the socket, use the
520
     * stream_set_timeout, as the
521
     * timeout only applies while making connecting
522
     * the socket.
523
     * @param int      $flags        Bitmask field which may be set to any combination of connection flags.
524
     *                               Currently the select of connection flags is limited to
525
     *                               STREAM_CLIENT_CONNECT (default),
526
     *                               STREAM_CLIENT_ASYNC_CONNECT and
527
     *                               STREAM_CLIENT_PERSISTENT.
528
     * @param resource $context      A valid context resource created with stream_context_create.
529
     *
530
     * @return resource
531
     */
532
    public function socketClient(
533
        string $remoteSocket,
0 ignored issues
show
Unused Code introduced by
The parameter $remoteSocket is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
534
        int &$errno = null,
0 ignored issues
show
Unused Code introduced by
The parameter $errno is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
535
        string &$errstr = null,
0 ignored issues
show
Unused Code introduced by
The parameter $errstr is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
536
        float $timeout = null,
0 ignored issues
show
Unused Code introduced by
The parameter $timeout is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
537
        int $flags = null,
0 ignored issues
show
Unused Code introduced by
The parameter $flags is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
538
        $context = null
0 ignored issues
show
Unused Code introduced by
The parameter $context is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
539
    ) {
540
        return call_user_func_array('stream_socket_client', func_get_args());
541
    }
542
543
    /**
544
     * Turns encryption on/off on an already connected socket
545
     *
546
     * @param resource $stream        The stream resource.
547
     * @param bool     $enable        Enable/disable cryptography on the stream.
548
     * @param int      $cryptoType    Setup encryption on the stream.
549
     *                                Valid methods are
550
     *
551
     * STREAM_CRYPTO_METHOD_SSLv2_CLIENT
552
     * STREAM_CRYPTO_METHOD_SSLv3_CLIENT
553
     * STREAM_CRYPTO_METHOD_SSLv23_CLIENT
554
     * STREAM_CRYPTO_METHOD_TLS_CLIENT
555
     * STREAM_CRYPTO_METHOD_SSLv2_SERVER
556
     * STREAM_CRYPTO_METHOD_SSLv3_SERVER
557
     * STREAM_CRYPTO_METHOD_SSLv23_SERVER
558
     * STREAM_CRYPTO_METHOD_TLS_SERVER
559
     * @param resource $sessionStream Seed the stream with settings from session_stream.
560
     *
561
     * @return mixed
562
     */
563
    public function socketEnableCrypto($stream, bool $enable, int $cryptoType = null, $sessionStream = null)
0 ignored issues
show
Unused Code introduced by
The parameter $stream is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $enable is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $cryptoType is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $sessionStream is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
564
    {
565
        return call_user_func_array('stream_socket_enable_crypto', func_get_args());
566
    }
567
568
    /**
569
     * Retrieve the name of the local or remote sockets
570
     *
571
     * @param resource $handle   The socket to get the name of.
572
     * @param bool     $wantPeer If set to  the remote socket name will be returned, if set
573
     *                           to  the local socket name will be returned.
574
     *
575
     * @return string
576
     */
577
    public function socketGetName($handle, bool $wantPeer) : string
578
    {
579
        return stream_socket_get_name($handle, $wantPeer);
580
    }
581
582
    /**
583
     * Creates a pair of connected, indistinguishable socket streams
584
     *
585
     * @param int $domain   The protocol family to be used: STREAM_PF_INET,
586
     *                      STREAM_PF_INET6 or
587
     *                      STREAM_PF_UNIX
588
     * @param int $type     The type of communication to be used:
589
     *                      STREAM_SOCK_DGRAM,
590
     *                      STREAM_SOCK_RAW,
591
     *                      STREAM_SOCK_RDM,
592
     *                      STREAM_SOCK_SEQPACKET or
593
     *                      STREAM_SOCK_STREAM
594
     * @param int $protocol The protocol to be used: STREAM_IPPROTO_ICMP,
595
     *                      STREAM_IPPROTO_IP,
596
     *                      STREAM_IPPROTO_RAW,
597
     *                      STREAM_IPPROTO_TCP or
598
     *                      STREAM_IPPROTO_UDP
599
     *
600
     * @return array
601
     */
602
    public function socketPair(int $domain, int $type, int $protocol) : array
603
    {
604
        return stream_socket_pair($domain, $type, $protocol);
605
    }
606
607
    /**
608
     * Receives data from a socket, connected or not
609
     *
610
     * @param resource $socket  The remote socket.
611
     * @param int      $length  The number of bytes to receive from the socket.
612
     * @param int      $flags   The value of flags can be any combination
613
     *                          of the following:
614
     *
615
     * Possible values for flags
616
     *
617
     *
618
     *
619
     * STREAM_OOB
620
     *
621
     * Process OOB (out-of-band) data.
622
     *
623
     *
624
     *
625
     * STREAM_PEEK
626
     *
627
     * Retrieve data from the socket, but do not consume the buffer.
628
     * Subsequent calls to fread or
629
     * stream_socket_recvfrom will see
630
     * the same data.
631
     * @param string   $address If address is provided it will be populated with
632
     *                          the address of the remote socket.
633
     *
634
     * @return string
635
     */
636
    public function socketRecvfrom($socket, int $length, int $flags = null, string &$address = null) : string
0 ignored issues
show
Unused Code introduced by
The parameter $socket is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $length is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $flags is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $address is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
637
    {
638
        return call_user_func_array('stream_socket_recvfrom', func_get_args());
639
    }
640
641
    /**
642
     * Sends a message to a socket, whether it is connected or not
643
     *
644
     * @param resource $socket  The socket to send data to.
645
     * @param string   $data    The data to be sent.
646
     * @param int      $flags   The value of flags can be any combination
647
     *                          of the following:
648
     *
649
     * possible values for flags
650
     *
651
     *
652
     *
653
     * STREAM_OOB
654
     *
655
     * Process OOB (out-of-band) data.
656
     * @param string   $address The address specified when the socket stream was created will be used
657
     *                          unless an alternate address is specified in address.
658
     *
659
     * @return int
660
     */
661
    public function socketSendto($socket, string $data, int $flags = null, string $address = null) : int
0 ignored issues
show
Unused Code introduced by
The parameter $socket is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $data is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $flags is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $address is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
662
    {
663
        return call_user_func_array('stream_socket_sendto', func_get_args());
664
    }
665
666
    /**
667
     * Create an Internet or Unix domain server socket
668
     *
669
     * @param string   $localSocket The type of socket created is determined by the transport specified
670
     *                              using standard URL formatting: transport://target.
671
     * @param int      $errno       If the optional errno and errstr
672
     *                              arguments are present they will be set to indicate the actual system
673
     *                              level error that occurred in the system-level socket(),
674
     *                              bind(), and listen() calls. If
675
     *                              the value returned in errno is
676
     *                              0 and the function returned , it is an
677
     *                              indication that the error occurred before the bind()
678
     *                              call. This is most likely due to a problem initializing the socket.
679
     *                              Note that the errno and
680
     *                              errstr arguments will always be passed by reference.
681
     * @param string   $errstr      See errno description.
682
     * @param int      $flags       A bitmask field which may be set to any combination of socket creation
683
     *                              flags.
684
     * @param resource $context
685
     *
686
     * @return resource
687
     */
688
    public function socketServer(
689
        string $localSocket,
0 ignored issues
show
Unused Code introduced by
The parameter $localSocket is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
690
        int &$errno = null,
0 ignored issues
show
Unused Code introduced by
The parameter $errno is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
691
        string &$errstr = null,
0 ignored issues
show
Unused Code introduced by
The parameter $errstr is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
692
        int $flags = null,
0 ignored issues
show
Unused Code introduced by
The parameter $flags is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
693
        $context = null
0 ignored issues
show
Unused Code introduced by
The parameter $context is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
694
    ) {
695
        return call_user_func_array('stream_socket_server', func_get_args());
696
    }
697
698
    /**
699
     * Shutdown a full-duplex connection
700
     *
701
     * @param resource $stream An open stream (opened with stream_socket_client,
702
     *                         for example)
703
     * @param int      $how    One of the following constants: STREAM_SHUT_RD
704
     *                         (disable further receptions), STREAM_SHUT_WR
705
     *                         (disable further transmissions) or
706
     *                         STREAM_SHUT_RDWR (disable further receptions and
707
     *                         transmissions).
708
     *
709
     * @return bool
710
     */
711
    public function socketShutdown($stream, int $how) : bool
712
    {
713
        return stream_socket_shutdown($stream, $how);
714
    }
715
716
    /**
717
     * Tells whether the stream supports locking.
718
     *
719
     * @param resource $stream The stream to check.
720
     *
721
     * @return bool
722
     */
723
    public function supportsLock($stream) : bool
724
    {
725
        return stream_supports_lock($stream);
726
    }
727
728
    /**
729
     * Register a URL wrapper implemented as a PHP class
730
     *
731
     * @param string $protocol  The wrapper name to be registered.
732
     * @param string $classname The classname which implements the protocol.
733
     * @param int    $flags     Should be set to STREAM_IS_URL if
734
     *                          protocol is a URL protocol. Default is 0, local
735
     *                          stream.
736
     *
737
     * @return bool
738
     */
739
    public function wrapperRegister(string $protocol, string $classname, int $flags = null) : bool
0 ignored issues
show
Unused Code introduced by
The parameter $protocol is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $classname is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $flags is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
740
    {
741
        return call_user_func_array('stream_wrapper_register', func_get_args());
742
    }
743
744
    /**
745
     * Restores a previously unregistered built-in wrapper
746
     *
747
     * @param string $protocol
748
     *
749
     * @return bool
750
     */
751
    public function wrapperRestore(string $protocol) : bool
752
    {
753
        return stream_wrapper_restore($protocol);
754
    }
755
756
    /**
757
     * Unregister a URL wrapper
758
     *
759
     * @param string $protocol
760
     *
761
     * @return bool
762
     */
763
    public function wrapperUnregister(string $protocol) : bool
764
    {
765
        return stream_wrapper_unregister($protocol);
766
    }
767
768
}
769
770