1 | <?php |
||
13 | class PumpStream implements StreamInterface |
||
14 | { |
||
15 | /** |
||
16 | * @var callable |
||
17 | */ |
||
18 | private $source; |
||
19 | |||
20 | /** |
||
21 | * @var int |
||
22 | */ |
||
23 | private $size; |
||
24 | |||
25 | /** |
||
26 | * @var int |
||
27 | */ |
||
28 | private $tellPos; |
||
29 | |||
30 | /** |
||
31 | * @var array |
||
32 | */ |
||
33 | private $metadata; |
||
34 | |||
35 | /** |
||
36 | * @var BufferStream |
||
37 | */ |
||
38 | private $buffer; |
||
39 | |||
40 | /** |
||
41 | * @param callable $source Source of the stream data. The callable MAY |
||
42 | * accept an integer argument used to control the |
||
43 | * amount of data to return. The callable MUST |
||
44 | * return a string when called, or false on error |
||
45 | * or EOF. |
||
46 | * @param array $options Stream options: |
||
47 | * - metadata: Hash of metadata to use with stream. |
||
48 | * - size: Size of the stream, if known. |
||
49 | */ |
||
50 | 5 | public function __construct(callable $source, array $options = []) |
|
58 | |||
59 | 1 | public function __toString() |
|
67 | |||
68 | 1 | public function close() |
|
72 | |||
73 | 1 | public function detach() |
|
78 | |||
79 | 2 | public function getSize() |
|
83 | |||
84 | 2 | public function tell() |
|
88 | |||
89 | 2 | public function eof() : bool |
|
93 | |||
94 | 2 | public function isSeekable() : bool |
|
98 | |||
99 | public function rewind() |
||
103 | |||
104 | public function seek($offset, $whence = SEEK_SET) |
||
108 | |||
109 | 1 | public function isWritable() : bool |
|
113 | |||
114 | 1 | public function write($string) |
|
118 | |||
119 | 1 | public function isReadable() : bool |
|
123 | |||
124 | 4 | public function read($length) |
|
139 | |||
140 | 1 | public function getContents() |
|
149 | |||
150 | 1 | public function getMetadata($key = null) |
|
158 | |||
159 | 4 | private function pump($length) |
|
173 | } |
||
174 |
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.