1 | <?php |
||
12 | final class ResourceStream implements StreamInterface |
||
13 | { |
||
14 | |||
15 | /** |
||
16 | * @var resource |
||
17 | */ |
||
18 | private $resource; |
||
19 | |||
20 | /** |
||
21 | * ResourceStream constructor. |
||
22 | * @param $resource |
||
23 | */ |
||
24 | 57 | public function __construct($resource) |
|
33 | |||
34 | /** |
||
35 | * @return string |
||
36 | */ |
||
37 | 15 | public function __toString(): string |
|
42 | |||
43 | /** |
||
44 | * |
||
45 | */ |
||
46 | public function close(): void |
||
50 | |||
51 | /** |
||
52 | * @return mixed |
||
53 | */ |
||
54 | 51 | public function detach() |
|
58 | |||
59 | /** |
||
60 | * @return int|null |
||
61 | */ |
||
62 | 4 | public function getSize(): ?int |
|
66 | |||
67 | /** |
||
68 | * @return int |
||
69 | * @throws \RuntimeException |
||
70 | */ |
||
71 | 3 | public function tell(): int |
|
75 | |||
76 | /** |
||
77 | * @return bool |
||
78 | */ |
||
79 | 5 | public function eof(): bool |
|
83 | |||
84 | /** |
||
85 | * @return bool |
||
86 | */ |
||
87 | public function isSeekable(): bool |
||
96 | |||
97 | /** |
||
98 | * @param int $offset |
||
99 | * @param int $whence |
||
100 | * @return int |
||
101 | */ |
||
102 | 1 | public function seek(int $offset, int $whence = SEEK_SET): int |
|
106 | |||
107 | /** |
||
108 | * @return bool |
||
109 | */ |
||
110 | 3 | public function rewind(): bool |
|
114 | |||
115 | /** |
||
116 | * @return bool |
||
117 | */ |
||
118 | 1 | public function isWritable(): bool |
|
127 | |||
128 | /** |
||
129 | * @param $string |
||
130 | * @return int |
||
131 | */ |
||
132 | 1 | public function write($string): int |
|
136 | |||
137 | /** |
||
138 | * @return bool |
||
139 | */ |
||
140 | public function isReadable(): bool |
||
144 | |||
145 | /** |
||
146 | * @param int $length |
||
147 | * @return string |
||
148 | */ |
||
149 | 9 | public function read(int $length): string |
|
153 | |||
154 | /** |
||
155 | * @return string |
||
156 | */ |
||
157 | 8 | public function getContents(): string |
|
161 | |||
162 | /** |
||
163 | * @param array $keys |
||
164 | * @return array |
||
165 | */ |
||
166 | 11 | public function getMetadata(array $keys = []): array |
|
183 | } |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)
or! empty(...)
instead.