1 | <?php |
||||||
2 | |||||||
3 | namespace Cerbero\JsonObjects; |
||||||
4 | |||||||
5 | use Psr\Http\Message\StreamInterface; |
||||||
6 | |||||||
7 | /** |
||||||
8 | * The stream wrapper. |
||||||
9 | * |
||||||
10 | * @phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
||||||
11 | */ |
||||||
12 | class StreamWrapper |
||||||
13 | { |
||||||
14 | /** |
||||||
15 | * The name of the stream wrapper. |
||||||
16 | * |
||||||
17 | * @var string |
||||||
18 | */ |
||||||
19 | public const NAME = 'cerbero-json-objects'; |
||||||
20 | |||||||
21 | /** |
||||||
22 | * The stream context. |
||||||
23 | * |
||||||
24 | * @var resource |
||||||
25 | */ |
||||||
26 | public $context; |
||||||
27 | |||||||
28 | /** |
||||||
29 | * The stream. |
||||||
30 | * |
||||||
31 | * @var \Psr\Http\Message\StreamInterface |
||||||
32 | */ |
||||||
33 | protected $stream; |
||||||
34 | |||||||
35 | /** |
||||||
36 | * Open the stream |
||||||
37 | * |
||||||
38 | * @param string $path |
||||||
39 | * @param string $mode |
||||||
40 | * @param int $options |
||||||
41 | * @param mixed $opened_path |
||||||
42 | * @return bool |
||||||
43 | */ |
||||||
44 | 8 | public function stream_open(string $path, string $mode, int $options, &$opened_path): bool |
|||||
0 ignored issues
–
show
The parameter
$path is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. ![]() The parameter
$opened_path is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. ![]() |
|||||||
45 | { |
||||||
46 | 8 | $options = stream_context_get_options($this->context); |
|||||
47 | 8 | $stream = $options[static::NAME]['stream'] ?? null; |
|||||
48 | |||||||
49 | 8 | if (!$stream instanceof StreamInterface || !$stream->isReadable()) { |
|||||
50 | 3 | return false; |
|||||
51 | } |
||||||
52 | |||||||
53 | 5 | $this->stream = $stream; |
|||||
54 | |||||||
55 | 5 | return true; |
|||||
56 | } |
||||||
57 | |||||||
58 | /** |
||||||
59 | * Determine whether the pointer is at the end of the stream |
||||||
60 | * |
||||||
61 | * @return bool |
||||||
62 | */ |
||||||
63 | 2 | public function stream_eof(): bool |
|||||
64 | { |
||||||
65 | 2 | return $this->stream->eof(); |
|||||
66 | } |
||||||
67 | |||||||
68 | /** |
||||||
69 | * Read from the stream |
||||||
70 | * |
||||||
71 | * @param int $count |
||||||
72 | * @return string |
||||||
73 | */ |
||||||
74 | 1 | public function stream_read(int $count): string |
|||||
75 | { |
||||||
76 | 1 | return $this->stream->read($count); |
|||||
77 | } |
||||||
78 | } |
||||||
79 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.