5
5
/**
6
6
* Describes a stream instance.
7
7
*/
8
- interface StreamInterface
8
+ interface StreamableInterface
9
9
{
10
10
/**
11
11
* Reads all data from the stream into a string, from the beginning to end.
@@ -31,10 +31,25 @@ public function close();
31
31
*
32
32
* After the stream has been detached, the stream is in an unusable state.
33
33
*
34
- * @return void
34
+ * @return resource|null Underlying PHP stream, if any
35
35
*/
36
36
public function detach ();
37
37
38
+ /**
39
+ * Replaces the underlying stream resource with the provided stream.
40
+ *
41
+ * Use this method to replace the underlying stream with another; as an
42
+ * example, in server-side code, if you decide to return a file, you
43
+ * would replace the original content-oriented stream with the file
44
+ * stream.
45
+ *
46
+ * Any internal state such as caching of cursor position should be reset
47
+ * when attach() is called, as the stream has changed.
48
+ *
49
+ * @return void
50
+ */
51
+ public function attach ($ stream );
52
+
38
53
/**
39
54
* Get the size of the stream if known
40
55
*
@@ -115,11 +130,25 @@ public function isReadable();
115
130
public function read ($ length );
116
131
117
132
/**
118
- * Returns the remaining contents in a string, up to maxlength bytes.
133
+ * Returns the remaining contents in a string
119
134
*
120
- * @param int $maxLength The maximum bytes to read. Defaults to -1 (read
121
- * all the remaining buffer).
122
135
* @return string
123
136
*/
124
- public function getContents ($ maxLength = -1 );
137
+ public function getContents ();
138
+
139
+ /**
140
+ * Get stream metadata as an associative array or retrieve a specific key.
141
+ *
142
+ * The keys returned are identical to the keys returned from PHP's
143
+ * stream_get_meta_data() function.
144
+ *
145
+ * @param string $key Specific metadata to retrieve.
146
+ *
147
+ * @return array|mixed|null Returns an associative array if no key is
148
+ * provided. Returns a specific key value if a key
149
+ * is provided and the value is found, or null if
150
+ * the key is not found.
151
+ * @see http://php.net/manual/en/function.stream-get-meta-data.php
152
+ */
153
+ public function getMetadata ($ key = null );
125
154
}
0 commit comments