1 | <?php |
||
22 | class File_stream { |
||
23 | /** |
||
24 | * @var resource |
||
25 | */ |
||
26 | protected $stream; |
||
27 | |||
28 | 2 | function stream_open ($path, $mode) { |
|
29 | 2 | if ($mode != 'r' && $mode != 'rb') { |
|
30 | return false; |
||
31 | } |
||
32 | 2 | $files = Request::instance()->files; |
|
33 | 2 | foreach (explode('/', explode(':///', $path)[1]) as $file_path) { |
|
34 | 2 | if (!isset($files[$file_path])) { |
|
35 | return false; |
||
36 | } |
||
37 | 2 | $files = $files[$file_path]; |
|
38 | } |
||
39 | 2 | $this->stream = $files['stream']; |
|
40 | 2 | return true; |
|
41 | } |
||
42 | /** |
||
43 | * @param int $length |
||
44 | * |
||
45 | * @return false|string |
||
|
|||
46 | */ |
||
47 | 2 | function stream_read ($length) { |
|
48 | 2 | return fread($this->stream, $length); |
|
49 | } |
||
50 | /** |
||
51 | * @return false|int |
||
52 | */ |
||
53 | function stream_tell () { |
||
56 | /** |
||
57 | * @return bool |
||
58 | */ |
||
59 | 2 | function stream_eof () { |
|
60 | 2 | return feof($this->stream); |
|
61 | } |
||
62 | /** |
||
63 | * @param int $offset |
||
64 | * @param int $whence |
||
65 | * |
||
66 | * @return int |
||
67 | */ |
||
68 | function stream_seek ($offset, $whence = SEEK_SET) { |
||
71 | /** |
||
72 | * @return array |
||
73 | */ |
||
74 | 2 | function stream_stat () { |
|
77 | } |
||
78 |
This check looks for the generic type
array
as a return type and suggests a more specific type. This type is inferred from the actual code.